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

Tensor mismatch on transpose 2x4 using bfloat16 data format #1403

Open
dgolubovicTT opened this issue Nov 25, 2024 · 0 comments
Open

Tensor mismatch on transpose 2x4 using bfloat16 data format #1403

dgolubovicTT opened this issue Nov 25, 2024 · 0 comments
Assignees

Comments

@dgolubovicTT
Copy link
Contributor

Running single op transpose test for tensor of dimensions 2x4 and bfloat16 data format(transpose dims: dim0=-1 , dim1=-2) causes tensor mismatch.
However, this can't be reproed on ttnn transpose test.
Here is the ttnn IR of transpose case causing tensor mismatch: test_transpose_2x4_mismatch_ttnn.txt

Here is the ttnn repro test that passes:

@pytest.mark.parametrize("b", [1])
@pytest.mark.parametrize("h", [2])
@pytest.mark.parametrize("w", [4])
@pytest.mark.parametrize("dim0", [-1])
@pytest.mark.parametrize("dim1", [-2])
def test_transpose(device, b, h, w, dim0, dim1):
    torch.manual_seed(1234)

    torch_input_tensor = torch_random((1, b, h, w), -0.1, 0.1, dtype=torch.bfloat16)
    torch_output_tensor = torch_input_tensor.transpose(dim0, dim1)

    input_tensor = ttnn.to_device(ttnn.from_torch(torch_input_tensor), device, memory_config=ttnn.DRAM_MEMORY_CONFIG)
    input_tensor = ttnn.to_layout(input_tensor, layout=ttnn.TILE_LAYOUT)
    output_tensor = ttnn.transpose(input_tensor, dim0, dim1, memory_config=ttnn.DRAM_MEMORY_CONFIG)
    output_tensor = ttnn.from_device(output_tensor)
    output_tensor = ttnn.to_layout(output_tensor, layout=ttnn.ROW_MAJOR_LAYOUT)
    output_tensor = ttnn.to_torch(output_tensor)
    print("torch_input_tensor: ")
    print(torch_input_tensor)
    print("output_tensor: ")
    print(output_tensor)
    print("torch_output_tensor: ")
    print(torch_output_tensor)

    assert_with_pcc(torch_output_tensor, output_tensor)

Comparing ttnn test and ttnn IR I can't find what is the difference that could cause ttnn test to pass and ttnn IR to fail.
Need help from someone on mlir side @sdjordjevicTT.

If you need anything else feel free to ask.

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

No branches or pull requests

2 participants