tt-metal: [Bug Report] Multiply and divide has different broadcasting rules
Describe the bug
I can’t use ttnn.divide same way as ttnn.multiply. Multiply works as expected, divide crashes.
To Reproduce
import ttnn
import torch
import numpy as np
with ttnn.manage_device(device_id=0) as device:
x = torch.ones((1, 2, 3, 4), dtype=torch.bfloat16)
y = torch.ones((1, 1, 1, 1), dtype=torch.bfloat16) * 0.5
x_tt = ttnn.from_torch(x, dtype=ttnn.bfloat16, layout=ttnn.TILE_LAYOUT, device=device)
y_tt = ttnn.from_torch(y, dtype=ttnn.bfloat16, layout=ttnn.TILE_LAYOUT, device=device)
x_y_mult_tt = ttnn.multiply(x_tt, y_tt)
print(ttnn.to_torch(x_y_mult_tt))
x_y_divide_tt = ttnn.divide(x_tt, y_tt)
print(ttnn.to_torch(x_y_divide_tt))
Expected behavior Divide should have same broadcasting rules to multiply.
Please complete the following environment information:
- OS: Ubuntu 20.04
- Version of software (eg. commit): 12fdb68d525ebc73c5e9e19db9a953e3640c5359
About this issue
- Original URL
- State: open
- Created 2 years ago
- Comments: 32 (21 by maintainers)
Commits related to this issue
- #12798: Fix for div op broadcast — committed to tenstorrent/tt-metal by umadevimcw 2 years ago
@sdjordjevicTT At the high level
The existing implementation doesn’t support broadcasting directly for dimensions other than H, W, and HW. To achieve broadcasting for other dimensions, we previously used the repeat operation, which slowed down the process. However, in the experimental version, broadcasting is supported for up to 4D.
Experimental binary ops are available in
ttnn/cpp/ttnn/operations/eltwise/binary_ng.