tenstorrent / tt-metal

:metal: TT-NN operator library, and TT-Metalium low level kernel programming model.
Apache License 2.0
456 stars 67 forks source link

ttnn.pad fails with error "on device padding does not support front padding" #10987

Open vigneshkeerthivasanx opened 3 months ago

vigneshkeerthivasanx commented 3 months ago

Describe the bug ttnn.pad fails with error "on device padding does not support front padding" for the test cases provided below in the code snippet.

To Reproduce Steps to reproduce the behavior:

  1. Save the below snippet to a file
    
    import torch
    import pytest 
    import ttnn
    from tests.ttnn.utils_for_testing import assert_with_pcc

@pytest.mark.parametrize("h", [16, 128, 64, 32]) @pytest.mark.parametrize( "padding,torch_padding", [ (((1, 2), (1, 2)), (1, 2, 1, 2)), ], ) @pytest.mark.parametrize("value", [0]) def test_pad_blazepose(device, h, padding, torch_padding, value): torch.manual_seed(0) w = h torch_input_tensor = torch.rand((1, 128, h, w), dtype=torch.bfloat16) torch_output_tensor = torch.nn.functional.pad(torch_input_tensor, torch_padding, mode="constant", value=value)

input_tensor = ttnn.from_torch(torch_input_tensor, layout=ttnn.ROW_MAJOR_LAYOUT)
input_tensor = ttnn.from_device(input_tensor)
output_tensor = ttnn.pad(input_tensor, padding=padding, value=value)

output_tensor = ttnn.to_torch(output_tensor)
assert output_tensor.shape == torch_output_tensor.shape

assert_with_pcc(torch_output_tensor, output_tensor, 0.9999)
2.Run the script using pytest `<path/to/file>`
3.See error

**Screenshots**
The following error is faced when the above code is tested.

E RuntimeError: TT_FATAL @ ../ttnn/cpp/ttnn/operations/data_movement/pad/pad.cpp:92: front_padding_is_zero E info: E ttnn.pad: on device padding does not support front padding

vigneshkeerthivasanx commented 3 months ago

cc: @boris-drazic @saichandax

saichandax commented 3 months ago

Can we create a unit test and share the branch details here?

vigneshkeerthivasanx commented 3 months ago

unit test : commit