Repository navigation
fix slice return type on coord_tensor #707
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
8133aad
fix slice return type on coordtensor
tingqli b9bf1b5
add test case
tingqli 8e39dce
fix python style
tingqli 720ae96
Merge branch 'main' into fixslice-coordt
coderfeli 5ecd81d
fix unit test
tingqli ff825a4
fix coding style
tingqli 6a5418d
Merge branch 'main' into fixslice-coordt
coderfeli File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| import torch | ||
|
|
||
| import flydsl.compiler as flyc | ||
| import flydsl.expr as fx | ||
|
|
||
|
|
||
| def test_coord_tensor_slicing(): | ||
| @flyc.jit | ||
| def test(i: fx.Int32, output: fx.Tensor): | ||
| row_base = fx.make_int_tuple(0) | ||
| row_layout = fx.make_layout((128, 64), (1, 0)) | ||
| coord_tensor = fx.Tensor(fx.make_view(row_base, row_layout)) | ||
| ct0 = coord_tensor[6, None] | ||
| ct1 = coord_tensor[i, None] | ||
| assert ct0[0].get_static_leaf_int == 6, f"expected static slice to be 6, got {ct0[0].get_static_leaf_int}" | ||
| output[0] = fx.get_scalar(ct0[0]) | ||
| output[1] = fx.get_scalar(ct1[0]) | ||
|
|
||
| output = torch.zeros(2, dtype=torch.int32, device="cpu", requires_grad=False) | ||
| test(6, output) | ||
| assert output[0].item() == 6, f"expected 6 for static slice, got {output[0].item()}" | ||
| assert output[1].item() == 6, f"expected 6 for dynamic slice, got {output[1].item()}" | ||
|
tingqli marked this conversation as resolved.
Resolved
|
||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.