tt-metal: ttnn pad is not working for some inputs and seems to ignore pad value
pad value seems to be ignored. Also, some shapes seem not to work.
Repro steps:
Run the following pytest.
import pytest
import torch
import ttnn
from tests.ttnn.utils_for_testing import assert_with_pcc
from models.utility_functions import torch_random
def test_pad(device):
input_shape = (1, 1, 12, 8)
a = torch.ones(input_shape)
b = ttnn.from_torch(a, dtype=ttnn.float32, layout=ttnn.TILE_LAYOUT, device=device)
c = ttnn.pad(b, [1, 1, 12, 64], [0, 0, 0, 0], 3)
print(c)
def test_pad2(device):
input_shape = (1, 2, 3, 4)
a = torch.ones(input_shape)
b = ttnn.from_torch(a, dtype=ttnn.float32, layout=ttnn.TILE_LAYOUT, device=device)
c = ttnn.pad(b, [1, 2, 32, 32], [0, 0, 0, 0], value=3)
print(c)
Expected: The printed tensors should be printed, be the right size, and have 3 padded.
Actual:
First test throws an error:
E RuntimeError: TT_FATAL @ ../ttnn/cpp/ttnn/operations/data_movement/pad/device/pad_op.cpp:26: input_tensor.get_legacy_shape()[2] + this->input_tensor_start[2] <= this->output_tensor_shape[2]
E info:
E Output size cannot fit input with offset
Second test prints
ttnn.Tensor([[[[ 1.00000, 1.00000, ..., 0.00000, 0.00000],
[ 1.00000, 1.00000, ..., 0.00000, 0.00000],
...,
[ 0.00000, 0.00000, ..., 0.00000, 0.00000],
[ 0.00000, 0.00000, ..., 0.00000, 0.00000]],
[[ 1.00000, 1.00000, ..., 0.00000, 0.00000],
[ 1.00000, 1.00000, ..., 0.00000, 0.00000],
...,
[ 0.00000, 0.00000, ..., 0.00000, 0.00000],
[ 0.00000, 0.00000, ..., 0.00000, 0.00000]]]], shape=Shape([1, 2, 32, 32]), dtype=DataType::FLOAT32, layout=Layout::TILE)
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 20 (19 by maintainers)
Hey @cmaryanTT @jaykru-tt has a PR addressing thr issue that he is going to merge after ppl approve.
https://github.com/tenstorrent/tt-metal/pull/15985
@jaykru-tt Hopefully. I’ll try to make it work. We need to have a general solution though.
This is a symptom of our pad/unpad ops not being treated as actual ops that returns you a new logical tensor. @ayerofieiev-tt