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

argmax returns incorrect shape #16720

Open
bbradelTT opened this issue Jan 14, 2025 · 0 comments
Open

argmax returns incorrect shape #16720

bbradelTT opened this issue Jan 14, 2025 · 0 comments
Assignees
Labels
bug Something isn't working op_cat: reduces P1

Comments

@bbradelTT
Copy link
Contributor

Run pytest

import pytest

import torch

import ttnn
from tests.ttnn.utils_for_testing import assert_with_pcc
from models.utility_functions import torch_random


@pytest.mark.parametrize("batch_size", [1, 32])
@pytest.mark.parametrize("h", [32])
@pytest.mark.parametrize("w", [64000])
@pytest.mark.parametrize("dim", [-1])
def test_argmax(device, batch_size, h, w, dim):

    torch.manual_seed(0)


    torch_input_tensor = torch.randn((1, 1, h, w), dtype=torch.bfloat16)
    torch_output_tensor = torch.argmax(torch_input_tensor, dim=3)
    input_tensor = ttnn.from_torch(torch_input_tensor, device=device)
    output_tensor = ttnn.argmax(input_tensor, dim=3, use_multicore=False if batch_size > 1 else True)
    output_tensor = ttnn.to_torch(output_tensor)
    assert_with_pcc(torch_output_tensor, output_tensor)

Expected:

  • Everything passes

Actual:

FAILED test_argmax.py::test_argmax[-1-64000-32-1] - AssertionError: list(expected_pytorch_result.shape)=[1, 1, 32] vs list(actual_pytorch_result.shape)=[1, 1, 1, 32]
FAILED test_argmax.py::test_argmax[-1-64000-32-32] - AssertionError: list(expected_pytorch_result.shape)=[1, 1, 32] vs list(actual_pytorch_result.shape)=[1, 1, 1, 32]

Adding in a reshape fixes the problem, but argmax should set the shapes properly by itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working op_cat: reduces P1
Projects
None yet
Development

No branches or pull requests

1 participant