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

TTNN to_torch fails on HC transpose output tensor #14251

Open
esmalTT opened this issue Oct 24, 2024 · 1 comment
Open

TTNN to_torch fails on HC transpose output tensor #14251

esmalTT opened this issue Oct 24, 2024 · 1 comment
Labels

Comments

@esmalTT
Copy link
Contributor

esmalTT commented Oct 24, 2024

Summary

The following code crashes when trying to convert the output of transpose to a torch tensor:

import pytest
import ttnn
import torch


def test_untilize_hc_transpose(device, use_program_cache):
    B, C, H, W = 1, 32, 1, 32
    input_tensor = torch.range(0, B * C * H * C - 1).reshape([B, C, H, W])
    memory_config = ttnn.create_sharded_memory_config(
        [B, C, nearest_32(H), nearest_32(W)],
        ttnn.CoreGrid(x=1, y=1),
        ttnn.ShardStrategy.HEIGHT,
    )
    x = ttnn.from_torch(
        input_tensor,
        dtype=ttnn.bfloat16,
        layout=ttnn.TILE_LAYOUT,
        device=device,
    )
    x = ttnn.to_memory_config(x, memory_config)
    x = ttnn.untilize(x)  # [1, 32, 1[32], 32]
    x = ttnn.transpose(x, 1, 2)  # [ 1, 1, 32, 32]
    actual = ttnn.to_torch(x) # ERROR: RuntimeError: shape '[1, 1, 32, 32]' is invalid for input of size 32768
    expected = torch.transpose(input_tensor, 1, 2)
    assert_with_pcc(expected, actual, 0.99999)

The error reported is:

RuntimeError: shape '[1, 1, 32, 32]' is invalid for input of size 32768
@esmalTT esmalTT added bug Something isn't working P1 op_cat: TM Unet-Shallow P0 and removed P1 labels Oct 24, 2024
@esmalTT
Copy link
Contributor Author

esmalTT commented Oct 25, 2024

Update: if running in debug mode, we get the same error but in the transpose call.

@esmalTT esmalTT added P1 and removed P0 labels Oct 25, 2024
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

1 participant