[FRONTEND] Fix expand_dims and tl.full to handle scalar tensors#2275
Merged
ptillet merged 4 commits intotriton-lang:mainfrom Sep 12, 2023
Merged
[FRONTEND] Fix expand_dims and tl.full to handle scalar tensors#2275ptillet merged 4 commits intotriton-lang:mainfrom
ptillet merged 4 commits intotriton-lang:mainfrom
Conversation
Currently `tl.full([], 0, tl.int32)` fails with:
```
TypeError('0d block_type is forbidden')
```
This fixes it to create a tensor with scalar type.
Currently calling:
```
tl.sum(x)[None]
```
results in
```
TypeError("'constexpr' object is not iterable")
```
Further if we fix that, it still fails in `semantic.expand_dims` with
```
AttributeError("'dtype' object has no attribute 'shape'")
```
peterbell10
commented
Sep 11, 2023
| # test broadcast | ||
| # --------------- | ||
| @pytest.mark.parametrize("dtype", dtypes_with_bfloat16) | ||
| def test_broadcast(dtype, device): |
Contributor
Author
There was a problem hiding this comment.
Unrelated change, but this test overwrites the test above and looks like it might have been a bad merge conflict resolution. I've removed the shadowed test that is identical other than hard coding device="cuda".
Jokeren
approved these changes
Sep 11, 2023
Contributor
Author
|
Looks like |
Contributor
Author
|
Actually, there is special handling of |
alexander-zinoviev
pushed a commit
to alexander-zinoviev/triton
that referenced
this pull request
Sep 21, 2023
…on-lang#2275) This fixes a few bugs related to scalar tensors: - `tl.full([], fill_value, dtype)` fails with `TypeError('0d block_type is forbidden')` - `scalar[None]` fails with `TypeError("'constexpr' object is not iterable")` - `scalar[None, None]` fails with `AttributeError("'dtype' object has no attribute 'shape'")` - `scalar.shape` returns `[1]` instead of 0-dim `[]` - Also related, `tl.zeros_like(scalar)` returns a 1d tensor instead of another scalar
pingzhuu
pushed a commit
to siliconflow/triton
that referenced
this pull request
Apr 2, 2024
…on-lang#2275) This fixes a few bugs related to scalar tensors: - `tl.full([], fill_value, dtype)` fails with `TypeError('0d block_type is forbidden')` - `scalar[None]` fails with `TypeError("'constexpr' object is not iterable")` - `scalar[None, None]` fails with `AttributeError("'dtype' object has no attribute 'shape'")` - `scalar.shape` returns `[1]` instead of 0-dim `[]` - Also related, `tl.zeros_like(scalar)` returns a 1d tensor instead of another scalar
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This fixes a few bugs related to scalar tensors:
tl.full([], fill_value, dtype)fails withTypeError('0d block_type is forbidden')scalar[None]fails withTypeError("'constexpr' object is not iterable")scalar[None, None]fails withAttributeError("'dtype' object has no attribute 'shape'")scalar.shapereturns[1]instead of 0-dim[]tl.zeros_like(scalar)returns a 1d tensor instead of another scalar