Skip to content

Commit

Permalink
#8635: Add test and sweep to demonstrate ttnn.empty failing with last…
Browse files Browse the repository at this point in the history
… odd dimension
  • Loading branch information
nemanjagrujic committed May 20, 2024
1 parent 61a30c6 commit e5ead49
Show file tree
Hide file tree
Showing 5 changed files with 117 additions and 24 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# SPDX-FileCopyrightText: © 2023 Tenstorrent Inc.

# SPDX-License-Identifier: Apache-2.0

from loguru import logger
import random
import pytest
import torch
import ttnn

from tests.ttnn.utils_for_testing import assert_with_pcc
from tests.ttnn.python_api_testing.sweep_tests import ttnn_ops


def run_empty_tests(input_shape, dtype, dlayout, in_mem_config, output_mem_config, data_seed, device):
torch.manual_seed(data_seed)

x = torch.Tensor(size=input_shape[0]).uniform_(-100, 100).to(torch.bfloat16)

try:
# get ref result
ref_value = torch.empty(x.shape)

tt_result = ttnn_ops.empty(
x,
device=device,
dtype=dtype,
layout=dlayout,
input_mem_config=in_mem_config,
output_mem_config=output_mem_config,
)

except Exception as e:
logger.warning(f"Operation execution crashed")
raise e

assert len(tt_result.shape) == len(ref_value.shape)


test_sweep_args = [
(
[(4, 7, 21, 133)],
[ttnn.bfloat16],
[ttnn.TILE_LAYOUT],
[ttnn.DRAM_MEMORY_CONFIG],
(ttnn.DRAM_MEMORY_CONFIG),
4171614,
),
(
[(5, 3, 145, 71)],
[ttnn.bfloat16],
[ttnn.TILE_LAYOUT],
[ttnn.DRAM_MEMORY_CONFIG],
(ttnn.DRAM_MEMORY_CONFIG),
4171614,
),
(
[(5, 3, 145, 72)],
[ttnn.bfloat16],
[ttnn.TILE_LAYOUT],
[ttnn.DRAM_MEMORY_CONFIG],
(ttnn.DRAM_MEMORY_CONFIG),
4171614,
),
(
[(4, 9, 52, 181)],
[ttnn.bfloat16],
[ttnn.TILE_LAYOUT],
[ttnn.DRAM_MEMORY_CONFIG],
(ttnn.DRAM_MEMORY_CONFIG),
4171614,
),
(
[(6, 6, 98, 125)],
[ttnn.bfloat16],
[ttnn.TILE_LAYOUT],
[ttnn.DRAM_MEMORY_CONFIG],
(ttnn.DRAM_MEMORY_CONFIG),
4171614,
),
]


@pytest.mark.parametrize(
"input_shape, dtype, dlayout, in_mem_config, output_mem_config, data_seed",
(test_sweep_args),
)
def test_eltwise_empty(input_shape, dtype, dlayout, in_mem_config, output_mem_config, data_seed, device):
run_empty_tests(input_shape, dtype, dlayout, in_mem_config, output_mem_config, data_seed, device)
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
test-list:
- ttnn-empty:
shape:
start-shape: [1, 1, 32, 32]
start-shape: [1, 1, 1, 1]
end-shape: [6, 12, 256, 256]
interval: [1, 1, 32, 32]
num-dims: [2,3,4]
interval: [1, 1, 1, 1]
num-dims: [2, 3, 4]
num-shapes: 1
num-samples: 128
num-samples: 64
args-sampling-strategy: "all"
env:
# TT_PCI_DMA_BUF_SIZE: "1048576"
Expand All @@ -19,22 +19,23 @@ test-list:
comparison:
function: comp_shape
args-gen: gen_dtype_layout_device
sanitize-args: False
args:
data-layout: ["TILE"]
data-type: ["BFLOAT16", "BFLOAT8_B"]
buffer-type: ["DRAM", "L1"]
out-buffer-type: ["DRAM", "L1", "SYSTEM_MEMORY"]
out-buffer-type: ["DRAM", "L1"]
output-file: empty_sweep.csv
- ttnn-empty:
shape:
start-shape: [1, 1, 2, 2]
end-shape: [6, 12, 256, 256]
interval: [1, 1, 1, 2]
num-shapes: 2
num-samples: 256
num-dims: [2, 3, 4]
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
Expand All @@ -44,9 +45,10 @@ test-list:
comparison:
function: comp_shape
args-gen: gen_dtype_layout_device
sanitize-args: False
args:
data-layout: ["ROW_MAJOR"]
data-type: ["BFLOAT16", "BFLOAT8_B"]
buffer-type: ["DRAM", "L1"]
out-buffer-type: ["DRAM", "L1", "SYSTEM_MEMORY"]
out-buffer-type: ["DRAM", "L1"]
output-file: empty_sweep.csv
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
test-list:
- ttnn-empty:
shape:
start-shape: [1, 1, 32, 32]
start-shape: [1, 1, 1, 1]
end-shape: [6, 12, 256, 256]
interval: [1, 1, 32, 32]
num-dims: [2,3,4]
interval: [1, 1, 1, 1]
num-dims: [2, 3, 4]
num-shapes: 1
num-samples: 128
num-samples: 64
args-sampling-strategy: "all"
env:
# TT_PCI_DMA_BUF_SIZE: "1048576"
Expand All @@ -19,22 +19,23 @@ test-list:
comparison:
function: comp_shape
args-gen: gen_dtype_layout_device
sanitize-args: False
args:
data-layout: ["TILE"]
data-type: ["BFLOAT16", "BFLOAT8_B"]
buffer-type: ["DRAM", "L1"]
out-buffer-type: ["DRAM", "L1", "SYSTEM_MEMORY"]
out-buffer-type: ["DRAM", "L1"]
output-file: empty_sweep.csv
- ttnn-empty:
shape:
start-shape: [1, 1, 2, 2]
end-shape: [6, 12, 256, 256]
interval: [1, 1, 1, 2]
num-shapes: 2
num-samples: 256
num-dims: [2, 3, 4]
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
Expand All @@ -44,9 +45,10 @@ test-list:
comparison:
function: comp_shape
args-gen: gen_dtype_layout_device
sanitize-args: False
args:
data-layout: ["ROW_MAJOR"]
data-type: ["BFLOAT16", "BFLOAT8_B"]
buffer-type: ["DRAM", "L1"]
out-buffer-type: ["DRAM", "L1", "SYSTEM_MEMORY"]
out-buffer-type: ["DRAM", "L1"]
output-file: empty_sweep.csv
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ test-list:
start-shape: [1, 1, 32, 32]
end-shape: [6, 12, 256, 256]
interval: [1, 1, 32, 32]
num-dims: [2,3,4]
num-dims: [2, 3, 4]
num-shapes: 1
num-samples: 64
args-sampling-strategy: "all"
Expand All @@ -31,11 +31,11 @@ test-list:
start-shape: [1, 1, 2, 2]
end-shape: [6, 12, 256, 256]
interval: [1, 1, 1, 2]
num-shapes: 2
num-dims: [2, 3, 4]
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ test-list:
start-shape: [1, 1, 32, 32]
end-shape: [6, 12, 256, 256]
interval: [1, 1, 32, 32]
num-dims: [2,3,4]
num-dims: [2, 3, 4]
num-shapes: 1
num-samples: 64
args-sampling-strategy: "all"
Expand All @@ -31,11 +31,11 @@ test-list:
start-shape: [1, 1, 2, 2]
end-shape: [6, 12, 256, 256]
interval: [1, 1, 1, 2]
num-shapes: 2
num-dims: [2, 3, 4]
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
Expand Down

0 comments on commit e5ead49

Please sign in to comment.