Skip to content

Commit

Permalink
#6722: Update golden function output to handle nan & inf - asin
Browse files Browse the repository at this point in the history
  • Loading branch information
umadevimcw committed Aug 30, 2024
1 parent 832661a commit b6eaafb
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/ttnn/unit_tests/operations/test_unary.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,23 @@ def run_unary_test(device, h, w, ttnn_function, pcc=0.9999):
assert_with_pcc(torch_output_tensor, output_tensor, pcc)


def run_unary_test_fixed(device, h, w, fill_value, ttnn_function, pcc=0.9999):
torch.manual_seed(0)

torch_input_tensor = torch.full((h, w), fill_value, dtype=torch.bfloat16)

golden_function = ttnn.get_golden_function(ttnn_function)
torch_output_tensor = golden_function(torch_input_tensor)

input_tensor = ttnn.from_torch(torch_input_tensor, layout=ttnn.TILE_LAYOUT, device=device)
output_tensor = ttnn_function(input_tensor)
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)


def run_identity_test(device, h, w, data_type, pcc=0.9999):
torch.manual_seed(0)
ttnn_function = ttnn.identity
Expand Down Expand Up @@ -377,3 +394,8 @@ def test_remainder(device, h, w, scalar):
@skip_for_grayskull("Op not supported for Grayskull, supported for wormhole_b0")
def test_fmod(device, h, w, scalar):
run_unary_test_with_float(device, h, w, scalar, ttnn.fmod)

@pytest.mark.parametrize("h", [64])
@pytest.mark.parametrize("w", [128])
def test_asin_fixed(device, h, w):
run_unary_test_fixed(device, h, w, 90, ttnn.asin, pcc=0.999)

0 comments on commit b6eaafb

Please sign in to comment.