tt-metal: [Bug Report] ttnn.sum resulting shape is wrong

Describe the bug Wrong output shape.

To Reproduce

import torch
import ttnn

torch.set_printoptions(precision=10)

with ttnn.manage_device(device_id=0) as device:
    x_torch = torch.ones((1, 1, 9, 9), dtype=torch.float32)
    x = ttnn.from_torch(x_torch, dtype=ttnn.bfloat16, layout=ttnn.TILE_LAYOUT, device=device)

    y = ttnn.sum(x)
    y0 = ttnn.sum(x, dim=0)
    y1 = ttnn.sum(x, dim=1)
    y2 = ttnn.sum(x, dim=2)
    y3 = ttnn.sum(x, dim=3)

    print('y:', y.shape)
    print('y0:', y0.shape)
    print('y1:', y1.shape)
    print('y2:', y2.shape)
    print('y3:', y3.shape)

current output:

y: ttnn.Shape([1, 1, 1[32], 1[32]])
y0: ttnn.Shape([1, 1, 32, 32])
y1: ttnn.Shape([1, 1, 32, 32])
y2: ttnn.Shape([1, 1, 1[32], 9[32]])
y3: ttnn.Shape([1, 1, 9[32], 1[32]])

Expected behavior

y: ttnn.Shape([1, 1, 1[32], 1[32]])
y0: ttnn.Shape([1, 1, 9[32], 9[32]])
y1: ttnn.Shape([1, 1, 9[32], 9[32]])
y2: ttnn.Shape([1, 1, 1[32], 9[32]])
y3: ttnn.Shape([1, 1, 9[32], 1[32]])

Please complete the following environment information:

  • OS: Ubuntu 20.04
  • Version of software: latest main

About this issue

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

Commits related to this issue

Most upvoted comments

Output when running the test with latest main:

y: ttnn.Shape([1, 1, 1[32], 1[32]])
y0: ttnn.Shape([1, 1, 9[32], 9[32]])
y1: ttnn.Shape([1, 1, 9[32], 9[32]])
y2: ttnn.Shape([1, 1, 1[32], 9[32]])
y3: ttnn.Shape([1, 1, 9[32], 1[32]])

Closing.