-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#7516: Remove reshape on to_memory_config, make it a composit, and pr…
…ovide support for automatically using launch_op
- Loading branch information
Showing
20 changed files
with
594 additions
and
145 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# SPDX-FileCopyrightText: © 2023 Tenstorrent Inc. | ||
|
||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
import pytest | ||
|
||
import torch | ||
|
||
import ttnn | ||
|
||
from tests.ttnn.utils_for_testing import assert_with_pcc | ||
|
||
|
||
@pytest.mark.parametrize("scalar", [3]) | ||
@pytest.mark.parametrize("size", [64]) | ||
def test_add_1D_tensor_and_scalar(device, scalar, size): | ||
device.enable_async(True) | ||
|
||
torch.manual_seed(0) | ||
|
||
torch_input_tensor = torch.rand((size,), dtype=torch.bfloat16) | ||
torch_output_tensor = torch_input_tensor + scalar | ||
|
||
input_tensor = ttnn.from_torch(torch_input_tensor, layout=ttnn.TILE_LAYOUT, device=device) | ||
output_tensor = input_tensor + scalar | ||
output_tensor = ttnn.to_torch(output_tensor, torch_rank=1) | ||
|
||
assert ttnn.pearson_correlation_coefficient(torch_output_tensor, output_tensor) >= 0.99988 | ||
assert output_tensor.shape == (size,) | ||
|
||
|
||
@pytest.mark.parametrize("h", [32]) | ||
@pytest.mark.parametrize("w", [64]) | ||
def test_add_2D_tensors(device, h, w): | ||
device.enable_async(True) | ||
|
||
torch_input_tensor_a = torch.rand((h, w), dtype=torch.bfloat16) | ||
torch_input_tensor_b = torch.rand((h, w), dtype=torch.bfloat16) | ||
torch_output_tensor = torch.add(torch_input_tensor_a, torch_input_tensor_b) | ||
|
||
input_tensor_a = ttnn.from_torch(torch_input_tensor_a, layout=ttnn.TILE_LAYOUT, device=device) | ||
input_tensor_b = ttnn.from_torch(torch_input_tensor_b, layout=ttnn.TILE_LAYOUT, device=device) | ||
output = ttnn.add(input_tensor_a, input_tensor_b) | ||
output = ttnn.to_torch(output) | ||
|
||
assert_with_pcc(torch_output_tensor, output, 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.