-
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.
: fix and update test for typecast to compare after round : add test for clone and typecast for multiple input and output data types : Add output dtype for typecast : Add input and output dtype for torch and device : update tests
- Loading branch information
1 parent
343e002
commit 2d0acb6
Showing
11 changed files
with
217 additions
and
18 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
96 changes: 96 additions & 0 deletions
96
tests/tt_eager/python_api_testing/sweep_tests/pytests/tt_dnn/test_typecast.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,96 @@ | ||
# SPDX-FileCopyrightText: © 2023-24 Tenstorrent Inc. | ||
|
||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
import pytest | ||
import torch | ||
from functools import partial | ||
import tt_lib as ttl | ||
|
||
|
||
from tests.tt_eager.python_api_testing.sweep_tests import ( | ||
comparison_funcs, | ||
generation_funcs, | ||
) | ||
from tests.tt_eager.python_api_testing.sweep_tests.run_pytorch_ci_tests import ( | ||
run_single_pytorch_test, | ||
) | ||
|
||
mem_configs = [ | ||
ttl.tensor.MemoryConfig(ttl.tensor.TensorMemoryLayout.INTERLEAVED, ttl.tensor.BufferType.DRAM), | ||
ttl.tensor.MemoryConfig(ttl.tensor.TensorMemoryLayout.INTERLEAVED, ttl.tensor.BufferType.L1), | ||
] | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"pt_input_dtype, tt_input_dtype", | ||
( | ||
(torch.float16, ttl.tensor.DataType.FLOAT32), | ||
(torch.float32, ttl.tensor.DataType.BFLOAT8_B), | ||
(torch.bfloat16, ttl.tensor.DataType.BFLOAT16), | ||
(torch.int, ttl.tensor.DataType.UINT32), | ||
), | ||
) | ||
@pytest.mark.parametrize( | ||
"pt_output_dtype, tt_output_dtype", | ||
( | ||
(torch.bfloat16, ttl.tensor.DataType.BFLOAT16), | ||
(torch.float32, ttl.tensor.DataType.BFLOAT8_B), | ||
), | ||
) | ||
@pytest.mark.parametrize( | ||
"input_shapes", | ||
[ | ||
[[1, 1, 32, 32]], # Single core | ||
[[1, 1, 320, 320]], # multi core | ||
[[1, 3, 320, 320]], # multi core | ||
[[1, 1, 32, 32]], # Single core | ||
[[1, 1, 320, 384]], # Multi core | ||
[[1, 3, 320, 384]], # Multi core | ||
], | ||
) | ||
@pytest.mark.parametrize( | ||
"input_mem_config", | ||
mem_configs, | ||
) | ||
@pytest.mark.parametrize( | ||
"dst_mem_config", | ||
mem_configs, | ||
) | ||
class TestTypecast: | ||
def test_run_typecast_op( | ||
self, | ||
pt_output_dtype, | ||
tt_output_dtype, | ||
pt_input_dtype, | ||
tt_input_dtype, | ||
input_shapes, | ||
input_mem_config, | ||
dst_mem_config, | ||
device, | ||
function_level_defaults, | ||
): | ||
if tt_input_dtype in [ttl.tensor.DataType.FLOAT32, ttl.tensor.DataType.UINT32]: | ||
pytest.skip(f"{tt_input_dtype} cannot be converted yet. Skip") | ||
if tt_input_dtype == tt_output_dtype: | ||
pytest.skip("Same I/O data types. Skip.") | ||
datagen_func = [ | ||
generation_funcs.gen_func_with_cast(partial(generation_funcs.gen_rand, low=0, high=10), pt_input_dtype) | ||
] | ||
test_args = generation_funcs.gen_default_dtype_layout_device(input_shapes)[0] | ||
test_args["pt_input_dtype"] = [pt_input_dtype] | ||
test_args["tt_input_dtype"] = [tt_input_dtype] | ||
test_args["pt_output_dtype"] = [pt_output_dtype] | ||
test_args["tt_output_dtype"] = [tt_output_dtype] | ||
test_args["input_mem_config"] = [input_mem_config] | ||
test_args.update({"output_mem_config": dst_mem_config}) | ||
comparison_func = comparison_funcs.comp_pcc | ||
|
||
run_single_pytorch_test( | ||
"typecast", | ||
input_shapes, | ||
datagen_func, | ||
comparison_func, | ||
device, | ||
test_args, | ||
) |
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