tt-metal: [Bug Report] ttnn.max wrong results

Describe the bug ttnn.max returns unexpected results

To Reproduce

with ttnn.manage_device(device_id=0) as device:
    x = -torch.ones((1, 2, 3, 4), dtype=torch.float32)
    x_tt = ttnn.from_torch(x, dtype=ttnn.bfloat16, layout=ttnn.TILE_LAYOUT, device=device)
    y_tt = ttnn.max(x_tt, dim=-1)
    print(ttnn.to_torch(x_tt))
    print(ttnn.to_torch(y_tt))

Output:

TorchTensor([[[[-1., -1., -1., -1.],
               [-1., -1., -1., -1.],
               [-1., -1., -1., -1.]],

              [[-1., -1., -1., -1.],
               [-1., -1., -1., -1.],
               [-1., -1., -1., -1.]]]], dtype=torch.bfloat16)
TorchTensor([[[[0.],
               [0.],
               [0.]],

              [[0.],
               [0.],
               [0.]]]], dtype=torch.bfloat16)

Expected behavior Resulting value should be -1.

Please complete the following environment information:

  • OS: Ubuntu 20.04
  • Version of software: a7d9204fc9cdf579e0a512e3c26fb291b398c75b

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 23 (21 by maintainers)

Commits related to this issue

Most upvoted comments

I changed the shape to (1, 2, 32, 32) and it looks like -1 values are returned. Next steps: I will need to look at how the padding is set up.

@caixunshiren Does it fail on the main branch too now ? We put a workaround for the issue in #9370 which fixes it, but we have not closed the issue since it is a temporary workaround.

No it doesn’t! We haven’t observed ndpcc so far