From a8df27d7abd7d0fb43ad0672f2ebdde28608c442 Mon Sep 17 00:00:00 2001 From: umadevimcw Date: Fri, 12 Apr 2024 06:12:46 +0000 Subject: [PATCH] #6991: Update ttnn unit test files for non-nan --- tests/ttnn/unit_tests/operations/test_mean.py | 3 --- tests/ttnn/unit_tests/operations/test_min.py | 4 ---- .../unit_tests/operations/test_reduction.py | 4 ---- tests/ttnn/unit_tests/operations/test_sum.py | 4 ---- .../ttnn/unit_tests/operations/test_unary.py | 21 ++++++++++++++----- 5 files changed, 16 insertions(+), 20 deletions(-) diff --git a/tests/ttnn/unit_tests/operations/test_mean.py b/tests/ttnn/unit_tests/operations/test_mean.py index 9556a0357860..e6055cb14299 100644 --- a/tests/ttnn/unit_tests/operations/test_mean.py +++ b/tests/ttnn/unit_tests/operations/test_mean.py @@ -18,9 +18,6 @@ def test_mean(device, batch_size, h, w, dim): torch.manual_seed(0) - if is_wormhole_b0() and dim == -2: - pytest.skip("Issue #6991: Wormhole B0: mean operation fails for dim=-2") - torch_input_tensor = torch_random((batch_size, h, w), -1, 1, dtype=torch.bfloat16) torch_output_tensor = torch.mean(torch_input_tensor, dim=dim, keepdim=True, dtype=torch.bfloat16) diff --git a/tests/ttnn/unit_tests/operations/test_min.py b/tests/ttnn/unit_tests/operations/test_min.py index e38ee7082dc6..21814ba00bfc 100644 --- a/tests/ttnn/unit_tests/operations/test_min.py +++ b/tests/ttnn/unit_tests/operations/test_min.py @@ -16,8 +16,6 @@ @pytest.mark.parametrize("w", [32, 64]) @pytest.mark.parametrize("dim", [-1, -2]) def test_min(device, batch_size, h, w, dim): - if is_wormhole_b0() and dim == -2: - pytest.skip("Issue #6991: PCC mismatch for dim=-2") torch.manual_seed(0) torch_input_tensor = torch_random((batch_size, h, w), -100, 100, dtype=torch.bfloat16) @@ -37,8 +35,6 @@ def test_min(device, batch_size, h, w, dim): @pytest.mark.parametrize("h", [32, 64]) @pytest.mark.parametrize("w", [32, 64]) def test_min_global(device, batch_size, h, w): - if is_wormhole_b0(): - pytest.skip("Issue #6991: PCC mismatch") torch.manual_seed(0) torch_input_tensor = torch_random((batch_size, h, w), -100, 100, dtype=torch.bfloat16) diff --git a/tests/ttnn/unit_tests/operations/test_reduction.py b/tests/ttnn/unit_tests/operations/test_reduction.py index f410dd508f99..12843436ea17 100644 --- a/tests/ttnn/unit_tests/operations/test_reduction.py +++ b/tests/ttnn/unit_tests/operations/test_reduction.py @@ -17,8 +17,6 @@ @pytest.mark.parametrize("dim", [-1, -2]) def test_std(device, batch_size, h, w, dim): torch.manual_seed(0) - if is_wormhole_b0() and dim == -2: - pytest.skip("Issue #6991: PCC mismatch for dim=-2") torch_input_tensor = torch.randn((batch_size, h, w), dtype=torch.bfloat16) torch_output_tensor = torch.std(torch_input_tensor, dim=dim, keepdim=True) @@ -39,8 +37,6 @@ def test_std(device, batch_size, h, w, dim): @pytest.mark.parametrize("dim", [-1, -2]) def test_var(device, batch_size, h, w, dim): torch.manual_seed(0) - if is_wormhole_b0() and dim == -2: - pytest.skip("Issue #6991: PCC mismatch for dim=-2") torch_input_tensor = torch.randn((batch_size, h, w), dtype=torch.bfloat16) torch_output_tensor = torch.var(torch_input_tensor, dim=dim, keepdim=True) diff --git a/tests/ttnn/unit_tests/operations/test_sum.py b/tests/ttnn/unit_tests/operations/test_sum.py index a099991e426c..42088988cc05 100644 --- a/tests/ttnn/unit_tests/operations/test_sum.py +++ b/tests/ttnn/unit_tests/operations/test_sum.py @@ -17,8 +17,6 @@ @pytest.mark.parametrize("dim", [-1, -2, (2, 1)]) def test_sum(device, batch_size, h, w, dim): torch.manual_seed(0) - if is_wormhole_b0(): - pytest.skip("Issue #6991: PCC mismatch") torch_input_tensor = torch_random((batch_size, h, w), -100, 100, dtype=torch.bfloat16) torch_output_tensor = torch.sum(torch_input_tensor, dim=dim, keepdim=True) @@ -38,8 +36,6 @@ def test_sum(device, batch_size, h, w, dim): @pytest.mark.parametrize("w", [32, 64]) def test_sum_global(device, batch_size, h, w): torch.manual_seed(0) - if is_wormhole_b0(): - pytest.skip("Issue #6991: PCC mismatch") torch_input_tensor = torch_random((batch_size, h, w), -100, 100, dtype=torch.bfloat16) torch_output_tensor = torch.sum(torch_input_tensor) diff --git a/tests/ttnn/unit_tests/operations/test_unary.py b/tests/ttnn/unit_tests/operations/test_unary.py index 91e24659d6e7..c493d81f880d 100644 --- a/tests/ttnn/unit_tests/operations/test_unary.py +++ b/tests/ttnn/unit_tests/operations/test_unary.py @@ -157,9 +157,8 @@ def test_cosh(device, h, w): @pytest.mark.parametrize("h", [64]) @pytest.mark.parametrize("w", [128]) -@skip_for_wormhole_b0("Issue #6991: Failing on wormhole_b0 PCC issue") def test_acosh(device, h, w): - run_unary_test(device, h, w, ttnn.acosh, torch.acosh) + run_unary_test_with_range(device, h, w, 1, 100, ttnn.acosh, torch.acosh) @pytest.mark.parametrize("h", [64]) @@ -212,9 +211,21 @@ def run_unary_test_with_float(device, h, w, scalar, ttnn_function, torch_functio assert_with_pcc(torch_output_tensor, output_tensor, pcc) -@pytest.mark.parametrize("scalar", [1, 2]) +def run_unary_test_with_range(device, h, w, scalar, low, high, ttnn_function, torch_function, pcc=0.9999): + torch_input_tensor = torch.rand((h, w), dtype=torch.bfloat16) * (high - low) + low + torch_output_tensor = torch_function(torch_input_tensor, scalar) + + input_tensor = ttnn.from_torch(torch_input_tensor, layout=ttnn.TILE_LAYOUT, device=device) + output_tensor = ttnn_function(input_tensor, scalar) + output_tensor = ttnn.to_layout(output_tensor, ttnn.ROW_MAJOR_LAYOUT) + output_tensor = ttnn.from_device(output_tensor) + output_tensor = ttnn.to_torch(output_tensor) + + assert_with_pcc(torch_output_tensor, output_tensor, pcc) + + +@pytest.mark.parametrize("scalar", [1, 1e-6]) @pytest.mark.parametrize("h", [64]) @pytest.mark.parametrize("w", [128]) -@skip_for_wormhole_b0("Issue #6991: Failing on wormhole_b0 PCC issue") def test_logit(device, h, w, scalar): - run_unary_test_with_float(device, h, w, scalar, ttnn.logit, torch.logit) + run_unary_test_with_range(device, h, w, scalar, ttnn.logit, torch.logit)