Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug Report] Operations that reduce broadcasted tensors give incorrect results #15965

Open
pglusacTT opened this issue Dec 12, 2024 · 2 comments
Assignees
Labels

Comments

@pglusacTT
Copy link

Describe the bug
Doing operations that reduce (sum, min, mean...) after having a broadcast gives incorrect results.
If the tensors match in shape the result is correct.

To Reproduce
Run the code below:

import torch
import ttnn

device_id = 0
device = ttnn.open_device(device_id=device_id)

arg1_pt = torch.ones((2, 1))
arg1 = ttnn.from_torch(arg1_pt, dtype=ttnn.float32, layout=ttnn.TILE_LAYOUT, device=device)
arg2_pt = torch.ones((2, 2))
arg2 = ttnn.from_torch(arg2_pt, dtype=ttnn.float32, layout=ttnn.TILE_LAYOUT, device=device)

addition = ttnn.add(arg1, arg2)
    
summ = ttnn.sum(addition)
output_tensor = ttnn.to_torch(summ)


torch_output_tensor = torch.sum(arg1_pt + arg2_pt)

print(output_tensor) # TorchTensor([[68.]])
print(torch_output_tensor) # tensor(8.)

assert torch.allclose(torch_output_tensor, output_tensor, rtol=1e-3), "Error: output_tensor and torch_output_tensor are not close"


ttnn.close_device(device)

Expected behavior
The result of the operations should not be incorrect after broadcasts.

Environment information:

  • OS: Ubuntu 22.04
  • Version of software: dde5614
@pglusacTT pglusacTT added the bug Something isn't working label Dec 12, 2024
@vladimirjovanovicTT vladimirjovanovicTT added P1 and removed P2 labels Dec 26, 2024
@smehtaTT
Copy link

@cmaryanTT to prioritize this with @bbradelTT

@bbradelTT
Copy link
Contributor

This may be related to other issues such as #12662
We'll look at this once that issue is unblocked and being worked on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants