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

Support for creating a 0-dim tensor when a single scalar value or shape [ ] is given #13803

Open KalaivaniMCW opened 1 month ago

KalaivaniMCW commented 1 month ago

Requirements from pytorch tracing sweeps https://github.com/tenstorrent/pytorch2.0_ttnn/blob/main/docs/operations/aten.add.Tensor.md

Case 1: when input parameters are such :

Tensor<[1, 1, 1024]> self = ?,
Tensor other = 1.0

The tensor other is expected to be created as a 0-dim tensor with value 1.0

Case 2: when input parameters are such :

Tensor<[]> self = ?,
Tensor other = 1

The tensor self is expected to be created as a 0-dim tensor The tensor other is expected to be created as a 0-dim tensor with value 1.0

image

Case:3 Empty Tensor or elements [0,1]

image
KalaivaniMCW commented 1 week ago

Adding some examples regarding [ ], below shapes are taken from ttnn.add sweep for pytorch2 When tested in torch , Torch: {'input_shape': {'self': [], 'other': [0, 1]}, Image

Torch: {'input_shape': {'self': [], 'other': [1, 1, 768]} Image

VirdhatchaniKN commented 1 week ago

Adding some examples regarding [ ], below shapes are taken from ttnn.divide sweep for pytorch2 : https://github.com/tenstorrent/tt-metal/issues/14733 When tested in torch ,

Image Image