-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
2b908fb
commit fbf58c9
Showing
41 changed files
with
351 additions
and
131 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
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
52 changes: 52 additions & 0 deletions
52
tests/ttnn/unit_tests/operations/complex/test_complex_conj.py
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,52 @@ | ||
# SPDX-FileCopyrightText: © 2024 Tenstorrent Inc. | ||
|
||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
import torch | ||
|
||
import tt_lib as ttl | ||
import pytest | ||
import ttnn | ||
from loguru import logger | ||
from tests.ttnn.unit_tests.operations.backward.utility_funcs import data_gen_with_range | ||
from tests.tt_eager.python_api_testing.sweep_tests.comparison_funcs import comp_pcc, comp_equal, comp_allclose | ||
|
||
from models.utility_functions import is_wormhole_b0, skip_for_grayskull | ||
from tests.ttnn.unit_tests.operations.complex.utility_funcs import ( | ||
convert_complex_to_torch_tensor, | ||
random_complex_tensor, | ||
) | ||
|
||
|
||
@skip_for_grayskull() | ||
@pytest.mark.parametrize( | ||
"memcfg", | ||
( | ||
ttl.tensor.MemoryConfig(ttl.tensor.TensorMemoryLayout.INTERLEAVED, ttl.tensor.BufferType.DRAM), | ||
ttl.tensor.MemoryConfig(ttl.tensor.TensorMemoryLayout.INTERLEAVED, ttl.tensor.BufferType.L1), | ||
), | ||
ids=["out_DRAM", "out_L1"], | ||
) | ||
@pytest.mark.parametrize("dtype", ((ttl.tensor.DataType.FLOAT32,))) | ||
@pytest.mark.parametrize("bs", ((1, 1),)) | ||
@pytest.mark.parametrize("hw", ((32, 32),)) | ||
def test_conj(bs, hw, memcfg, dtype, device, function_level_defaults): | ||
input_shape = torch.Size([bs[0], bs[1], hw[0], hw[1]]) | ||
|
||
in_data = random_complex_tensor(input_shape, (-90, 90), (-70, 70)) | ||
|
||
input_tensor = ttnn.complex_tensor( | ||
ttl.tensor.Tensor(in_data.real, dtype).to(ttl.tensor.Layout.TILE).to(device, memcfg), | ||
ttl.tensor.Tensor(in_data.imag, dtype).to(ttl.tensor.Layout.TILE).to(device, memcfg), | ||
) | ||
|
||
tt_dev = ttnn.conj(input_tensor, memory_config=memcfg) | ||
|
||
tt_to_torch = convert_complex_to_torch_tensor(tt_dev) | ||
|
||
golden_function = ttnn.get_golden_function(ttnn.conj) | ||
golden_tensor = golden_function(in_data) | ||
|
||
passing, output = comp_pcc(golden_tensor, tt_to_torch) | ||
logger.info(output) | ||
assert passing |
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,21 @@ | ||
# SPDX-FileCopyrightText: © 2023 Tenstorrent Inc. | ||
|
||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
import torch | ||
|
||
import tt_lib as ttl | ||
|
||
|
||
def random_complex_tensor(shape, real_range=(-100, 100), imag_range=(-100, 100)): | ||
torch.manual_seed(213919) | ||
real_part = (real_range[1] - real_range[0]) * torch.rand(shape) + real_range[0] | ||
imag_part = (imag_range[1] - imag_range[0]) * torch.rand(shape) + imag_range[0] | ||
return torch.complex(real_part, imag_part) | ||
|
||
|
||
def convert_complex_to_torch_tensor(tt_dev): | ||
tt_dev_r = tt_dev.real.cpu().to(ttl.tensor.Layout.ROW_MAJOR).to_torch() | ||
tt_dev_i = tt_dev.imag.cpu().to(ttl.tensor.Layout.ROW_MAJOR).to_torch() | ||
tt_to_torch = torch.complex(tt_dev_r, tt_dev_i) | ||
return tt_to_torch |
Oops, something went wrong.