tenstorrent / tt-metal

:metal: TT-NN operator library, and TT-Metalium low level kernel programming model.
https://docs.tenstorrent.com/ttnn/latest/index.html
Apache License 2.0
484 stars 79 forks source link

Need broadcast support for ttnn.div #15216

Open punithsekar opened 1 week ago

punithsekar commented 1 week ago

Describe the bug Need broadcast support for ttnn.div.

To Reproduce Steps to reproduce the behavior:

  1. Run the following code snippet
  2. 
    import torch 
    import ttnn
    import pytest

@pytest.mark.parametrize("device_params", [{"l1_small_size": 24576}], indirect=True) def test_div(device): a=torch.randn(3,1) a_ttnn=ttnn.from_torch(a,layout=ttnn.TILE_LAYOUT,device=device) b=torch.randn(1,2) torch_output=a/b # output_shape = [3,2] b_ttnn=ttnn.from_torch(b,layout=ttnn.TILE_LAYOUT,device=device) ttnn_output=ttnn.div(a_ttnn,b_ttnn)


**Expected behavior**
To run without any error

**Screenshots**

def call(self, *function_args, **function_kwargs):

  return self.function(*function_args, **function_kwargs)

E RuntimeError: TT_THROW @ ../ttnn/cpp/ttnn/operations/eltwise/binary/device/broadcast_height_multi_core_program_factory.cpp:25: tt::exception E info: E BinaryOpType cannot be mapped to BcastOpMath E backtrace: E --- /home/ubuntu/punith/tt-metal/ttnn/ttnn/_ttnn.so(+0x5d7a09) [0x7f5dc8676a09] E --- ttnn::operations::binary::BinaryDeviceOperation::BroadcastHeightMultiCore::create(ttnn::operations::binary::BinaryDeviceOperation::operation_attributes_t const&, ttnn::operations::binary::BinaryDeviceOperation::tensor_args_t const&, tt::tt_metal::Tensor&)

Please complete the following environment information:

Additional context Used in PETR model, in pos2posemb3d method.

punithsekar commented 1 week ago

fyi @saichandax

punithsekar commented 6 days ago

Planned to preprocess this method(pos2posemb3d), So, Currently, this feature is not required now. Will reopen if needed. Thanks

punithsekar commented 6 days ago

Reopening this as similar issue in SinePositionalEncoding3D class of petr model