-
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.
#4225: Add YAML and unit tests for identity
- Loading branch information
1 parent
bed7516
commit 708fd75
Showing
4 changed files
with
230 additions
and
0 deletions.
There are no files selected for viewing
76 changes: 76 additions & 0 deletions
76
tests/tt_eager/python_api_testing/non_working_unit_tests/grayskull/test_identity.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,76 @@ | ||
# SPDX-FileCopyrightText: © 2023 Tenstorrent Inc. | ||
|
||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
from loguru import logger | ||
import pytest | ||
import torch | ||
|
||
import tt_lib as ttl | ||
|
||
from tests.tt_eager.python_api_testing.sweep_tests.comparison_funcs import comp_pcc | ||
|
||
from tests.tt_eager.python_api_testing.sweep_tests.pytorch_ops import eltwise_identity as pt_identity | ||
from tests.tt_eager.python_api_testing.sweep_tests.tt_lib_ops import eltwise_identity as tt_identity | ||
from tests.tt_eager.python_api_testing.sweep_tests.generation_funcs import gen_rand_complex | ||
from tests.tt_eager.python_api_testing.sweep_tests.common import set_slow_dispatch_mode | ||
|
||
|
||
def run_identity_tests(input_shape, dtype, dlayout, in_mem_config, out_mem_config, data_seed, dispatch_mode, device): | ||
torch.manual_seed(data_seed) | ||
prev_dispatch_mode = set_slow_dispatch_mode(dispatch_mode) | ||
|
||
if in_mem_config == "SYSTEM_MEMORY": | ||
in_mem_config = None | ||
|
||
x = torch.Tensor(size=input_shape).uniform_(-100, 100) | ||
x_ref = x.detach().clone() | ||
|
||
# get ref result | ||
ref_value = pt_identity(x_ref) | ||
|
||
tt_result = tt_identity( | ||
x=x, | ||
device=device, | ||
dtype=[dtype], | ||
layout=[dlayout], | ||
input_mem_config=[in_mem_config], | ||
output_mem_config=out_mem_config, | ||
) | ||
|
||
# compare tt and golden outputs | ||
success, pcc_value = comp_pcc(ref_value, tt_result) | ||
logger.debug(pcc_value) | ||
|
||
set_slow_dispatch_mode(prev_dispatch_mode) | ||
assert success | ||
|
||
|
||
test_sweep_args = [ | ||
( | ||
(6, 12, 40, 208), | ||
ttl.tensor.DataType.BFLOAT16, | ||
ttl.tensor.Layout.ROW_MAJOR, | ||
(ttl.tensor.MemoryConfig(ttl.tensor.TensorMemoryLayout.INTERLEAVED, ttl.tensor.BufferType.L1)), | ||
(ttl.tensor.MemoryConfig(ttl.tensor.TensorMemoryLayout.INTERLEAVED, ttl.tensor.BufferType.DRAM)), | ||
13795575, | ||
"1", | ||
), | ||
( | ||
(5, 8, 100, 118), | ||
ttl.tensor.DataType.BFLOAT16, | ||
ttl.tensor.Layout.ROW_MAJOR, | ||
(ttl.tensor.MemoryConfig(ttl.tensor.TensorMemoryLayout.INTERLEAVED, ttl.tensor.BufferType.L1)), | ||
(ttl.tensor.MemoryConfig(ttl.tensor.TensorMemoryLayout.INTERLEAVED, ttl.tensor.BufferType.DRAM)), | ||
3405120, | ||
"1", | ||
), | ||
] | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"input_shape, dtype, dlayout, in_mem_config, out_mem_config, data_seed, dispatch_mode", | ||
(test_sweep_args), | ||
) | ||
def test_identity_test(input_shape, dtype, dlayout, in_mem_config, out_mem_config, data_seed, dispatch_mode, device): | ||
run_identity_tests(input_shape, dtype, dlayout, in_mem_config, out_mem_config, data_seed, dispatch_mode, device) |
54 changes: 54 additions & 0 deletions
54
...eep_tests/test_configs/ci_sweep_tests/broken_grayskull/pytorch_eltwise_identity_test.yaml
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,54 @@ | ||
--- | ||
test-list: | ||
- eltwise-identity: | ||
shape: | ||
start-shape: [1, 1, 32, 32] | ||
end-shape: [6, 12, 256, 256] | ||
interval: [1, 1, 32, 32] | ||
num-shapes: 1 | ||
num-samples: 64 | ||
args-sampling-strategy: "all" | ||
env: | ||
TT_METAL_SLOW_DISPATCH_MODE: ["", "1"] | ||
# TT_PCI_DMA_BUF_SIZE: "1048576" | ||
datagen: | ||
function: gen_rand | ||
dtype: bfloat16 | ||
args: | ||
low: -100 | ||
high: 100 | ||
comparison: | ||
function: comp_pcc | ||
args-gen: gen_dtype_layout_device | ||
output-file: eltwise_identity_sweep.csv | ||
args: | ||
data-layout: ["TILE"] | ||
data-type: ["BFLOAT16"] | ||
buffer-type: ["DRAM", "L1", "SYSTEM_MEMORY"] | ||
out-buffer-type: ["DRAM"] | ||
- eltwise-identity: | ||
shape: | ||
start-shape: [1, 1, 2, 2] | ||
end-shape: [6, 12, 256, 256] | ||
interval: [1, 1, 2, 2] | ||
num-shapes: 1 | ||
num-samples: 64 | ||
args-sampling-strategy: "all" | ||
env: | ||
TT_METAL_SLOW_DISPATCH_MODE: ["", "1"] | ||
# TT_PCI_DMA_BUF_SIZE: "1048576" | ||
datagen: | ||
function: gen_rand | ||
dtype: bfloat16 | ||
args: | ||
low: -100 | ||
high: 100 | ||
comparison: | ||
function: comp_pcc | ||
args-gen: gen_dtype_layout_device | ||
output-file: eltwise_identity_sweep.csv | ||
args: | ||
data-layout: ["ROW_MAJOR"] | ||
data-type: ["BFLOAT16"] | ||
buffer-type: ["DRAM", "L1", "SYSTEM_MEMORY"] | ||
out-buffer-type: ["DRAM"] |
54 changes: 54 additions & 0 deletions
54
...weep_tests/test_configs/ci_sweep_tests/broken_wormhole/pytorch_eltwise_identity_test.yaml
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,54 @@ | ||
--- | ||
test-list: | ||
- eltwise-identity: | ||
shape: | ||
start-shape: [1, 1, 32, 32] | ||
end-shape: [6, 12, 256, 256] | ||
interval: [1, 1, 32, 32] | ||
num-shapes: 1 | ||
num-samples: 64 | ||
args-sampling-strategy: "all" | ||
env: | ||
TT_METAL_SLOW_DISPATCH_MODE: ["", "1"] | ||
# TT_PCI_DMA_BUF_SIZE: "1048576" | ||
datagen: | ||
function: gen_rand | ||
dtype: bfloat16 | ||
args: | ||
low: -100 | ||
high: 100 | ||
comparison: | ||
function: comp_pcc | ||
args-gen: gen_dtype_layout_device | ||
output-file: eltwise_identity_sweep.csv | ||
args: | ||
data-layout: ["TILE"] | ||
data-type: ["BFLOAT16"] | ||
buffer-type: ["DRAM", "L1", "SYSTEM_MEMORY"] | ||
out-buffer-type: ["DRAM"] | ||
- eltwise-identity: | ||
shape: | ||
start-shape: [1, 1, 2, 2] | ||
end-shape: [6, 12, 256, 256] | ||
interval: [1, 1, 2, 2] | ||
num-shapes: 1 | ||
num-samples: 64 | ||
args-sampling-strategy: "all" | ||
env: | ||
TT_METAL_SLOW_DISPATCH_MODE: ["", "1"] | ||
# TT_PCI_DMA_BUF_SIZE: "1048576" | ||
datagen: | ||
function: gen_rand | ||
dtype: bfloat16 | ||
args: | ||
low: -100 | ||
high: 100 | ||
comparison: | ||
function: comp_pcc | ||
args-gen: gen_dtype_layout_device | ||
output-file: eltwise_identity_sweep.csv | ||
args: | ||
data-layout: ["ROW_MAJOR"] | ||
data-type: ["BFLOAT16"] | ||
buffer-type: ["DRAM", "L1", "SYSTEM_MEMORY"] | ||
out-buffer-type: ["DRAM"] |
46 changes: 46 additions & 0 deletions
46
...on_api_testing/sweep_tests/test_configs/ci_sweep_tests/pytorch_eltwise_identity_test.yaml
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 @@ | ||
--- | ||
test-list: | ||
- eltwise-identity: | ||
shape: | ||
start-shape: [1, 1, 32, 32] | ||
end-shape: [12, 24, 512, 512] | ||
interval: [1, 1, 32, 32] | ||
num-shapes: 1 | ||
num-samples: 64 | ||
args-sampling-strategy: "all" | ||
datagen: | ||
function: gen_rand | ||
args: | ||
low: -100 | ||
high: 100 | ||
comparison: | ||
function: comp_pcc | ||
args-gen: gen_dtype_layout_device | ||
output-file: eltwise_identity_sweep.csv | ||
args: | ||
data-layout: ["TILE"] | ||
data-type: ["BFLOAT16", "BFLOAT8_B"] | ||
buffer-type: ["DRAM", "L1", "SYSTEM_MEMORY"] | ||
out-buffer-type: ["DRAM"] | ||
- eltwise-identity: | ||
shape: | ||
start-shape: [1, 1, 2, 2] | ||
end-shape: [12, 24, 512, 512] | ||
interval: [1, 1, 2, 2] | ||
num-shapes: 1 | ||
num-samples: 64 | ||
args-sampling-strategy: "all" | ||
datagen: | ||
function: gen_rand | ||
args: | ||
low: -100 | ||
high: 100 | ||
comparison: | ||
function: comp_pcc | ||
args-gen: gen_dtype_layout_device | ||
output-file: eltwise_identity_sweep.csv | ||
args: | ||
data-layout: ["ROW_MAJOR"] | ||
data-type: ["BFLOAT16"] | ||
buffer-type: ["DRAM", "L1", "SYSTEM_MEMORY"] | ||
out-buffer-type: ["DRAM"] |