-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Linking tensor.reshape to ttnn.reshape (#16377)
### Ticket Link to Github Issue #13745 ### Problem description tensor.reshape is used as a view reshape; the behaviour should be similar to ttnn.reshape ### What's changed Linking tensor.reshape to ttnn.reshape and adding tensor.reshape as an experimental operation named view. Same PR as #15669, but it was reverted ### Checklist - [x] Post commit CI passes https://github.com/tenstorrent/tt-metal/actions/runs/12635237980 - [x] T3K unit tests https://github.com/tenstorrent/tt-metal/actions/runs/12635247860 - [x] Nightly model and ttnn tests https://github.com/tenstorrent/tt-metal/actions/runs/12635313084 - [x] Single card demo tests https://github.com/tenstorrent/tt-metal/actions/runs/12653046344 - [ ] Blackhole Post commit (if applicable) - [ ] Model regression CI testing passes (if applicable) - [ ] Device performance regression CI testing passes (if applicable) - [ ] **(For models and ops writers)** Full [new models](https://github.com/tenstorrent/tt-metal/actions/workflows/full-new-models-suite.yaml) tests passes - [ ] New/Existing tests provide coverage for changes
- Loading branch information
Showing
25 changed files
with
399 additions
and
176 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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,33 @@ | ||
# SPDX-FileCopyrightText: © 2025 Tenstorrent Inc. | ||
|
||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
import torch | ||
import ttnn | ||
from tests.ttnn.utils_for_testing import assert_with_pcc | ||
|
||
|
||
def test_transpose_with_reshape(device): | ||
# Create input tensor | ||
torch_input = torch.rand((1, 1, 2048, 512), dtype=torch.bfloat16) | ||
|
||
# TT operations | ||
tt_input = ttnn.from_torch( | ||
torch_input, | ||
dtype=ttnn.DataType.BFLOAT16, | ||
layout=ttnn.ROW_MAJOR_LAYOUT, | ||
device=device, | ||
memory_config=ttnn.L1_MEMORY_CONFIG, | ||
) | ||
tt_input = tt_input.reshape(1, 2048, 4, 128) | ||
tt_output = ttnn.transpose(tt_input, 1, 2) | ||
|
||
# Convert back to PyTorch for comparison | ||
tt_result = ttnn.to_torch(tt_output) | ||
|
||
# PyTorch reference operations | ||
torch_ref = torch_input.view(1, 2048, 4, 128) | ||
torch_ref = torch_ref.transpose(1, 2) | ||
|
||
# Compare results | ||
assert_with_pcc(torch_ref, tt_result, 0.9999) |
This file contains 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 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 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 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 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 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
Oops, something went wrong.