-
Notifications
You must be signed in to change notification settings - Fork 81
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
#9109: Add q_id to binary EQ in ttlib and test int output
- Loading branch information
1 parent
792c2e4
commit 696dc36
Showing
5 changed files
with
221 additions
and
13 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
72 changes: 72 additions & 0 deletions
72
tests/tt_eager/python_api_testing/unit_testing/misc/test_binary_eq_int.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,72 @@ | ||
# SPDX-FileCopyrightText: © 2023 Tenstorrent Inc. | ||
|
||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
import torch | ||
import pytest | ||
import tt_lib | ||
from tests.tt_eager.python_api_testing.unit_testing.backward_ops.utility_funcs import data_gen_with_range, compare_pcc | ||
from models.utility_functions import is_grayskull | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"input_shapes", | ||
((torch.Size([1, 1, 32, 32])),), | ||
) | ||
@pytest.mark.parametrize( | ||
"mem_configs", | ||
( | ||
tt_lib.tensor.MemoryConfig(tt_lib.tensor.TensorMemoryLayout.INTERLEAVED, tt_lib.tensor.BufferType.DRAM), | ||
tt_lib.tensor.MemoryConfig(tt_lib.tensor.TensorMemoryLayout.INTERLEAVED, tt_lib.tensor.BufferType.L1), | ||
), | ||
) | ||
@pytest.mark.parametrize("out_dtype", (tt_lib.tensor.DataType.UINT32, tt_lib.tensor.DataType.UINT16)) | ||
def test_binary_eq(input_shapes, out_dtype, mem_configs, device): | ||
if is_grayskull(): | ||
pytest.skip("GS does not support fp32/uint32/uint16 data types") | ||
|
||
in_data, input_tensor = data_gen_with_range(input_shapes, -100, 100, device, True) | ||
other_data, other_tensor = data_gen_with_range(input_shapes, -90, 100, device, True) | ||
|
||
cq_id = 0 | ||
mem_cfg = mem_configs | ||
|
||
tt_output_tensor_on_device = tt_lib.tensor.eq( | ||
cq_id, input_tensor, other_tensor, output_mem_config=mem_cfg, output_dtype=out_dtype | ||
) | ||
|
||
golden_tensor = torch.eq(in_data, other_data) | ||
comp_pass = compare_pcc([tt_output_tensor_on_device], [golden_tensor]) | ||
assert comp_pass | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"input_shapes", | ||
((torch.Size([1, 1, 32, 32])),), | ||
) | ||
@pytest.mark.parametrize( | ||
"mem_configs", | ||
( | ||
tt_lib.tensor.MemoryConfig(tt_lib.tensor.TensorMemoryLayout.INTERLEAVED, tt_lib.tensor.BufferType.DRAM), | ||
tt_lib.tensor.MemoryConfig(tt_lib.tensor.TensorMemoryLayout.INTERLEAVED, tt_lib.tensor.BufferType.L1), | ||
), | ||
) | ||
@pytest.mark.parametrize("out_dtype", (tt_lib.tensor.DataType.UINT32, tt_lib.tensor.DataType.UINT16)) | ||
def test_bw_binary_eq_opt_output(input_shapes, device, mem_configs, out_dtype): | ||
if is_grayskull(): | ||
pytest.skip("GS does not support fp32/uint32/uint16 data types") | ||
|
||
in_data, input_tensor = data_gen_with_range(input_shapes, -100, 100, device, True) | ||
other_data, other_tensor = data_gen_with_range(input_shapes, -90, 100, device, True) | ||
_, out_tensor = data_gen_with_range(input_shapes, -70, 60, device, True) | ||
|
||
cq_id = 0 | ||
mem_cfg = mem_configs | ||
|
||
tt_lib.tensor.typecast(out_tensor, out_dtype, output_mem_config=mem_cfg) | ||
|
||
tt_lib.tensor.eq(cq_id, input_tensor, other_tensor, output_mem_config=mem_cfg, output_tensor=out_tensor) | ||
|
||
golden_tensor = torch.eq(in_data, other_data) | ||
comp_pass = compare_pcc([out_tensor], [golden_tensor]) | ||
assert comp_pass |
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