Skip to content

Commit

Permalink
Added testing for signbit negative zero in bfloat16
Browse files Browse the repository at this point in the history
  • Loading branch information
atatuzunerTT committed Feb 28, 2025
1 parent dca2bb5 commit 9dd8c02
Showing 1 changed file with 80 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# SPDX-FileCopyrightText: © 2023-24 Tenstorrent Inc.

# SPDX-License-Identifier: Apache-2.0

import pytest
import torch
import random
from functools import partial
import ttnn


from tests.tt_eager.python_api_testing.sweep_tests import (
comparison_funcs,
generation_funcs,
)
from tests.tt_eager.python_api_testing.sweep_tests.run_pytorch_ci_tests import (
run_single_pytorch_test,
)
from models.utility_functions import skip_for_blackhole

mem_configs = [
ttnn.MemoryConfig(ttnn.TensorMemoryLayout.INTERLEAVED, ttnn.BufferType.DRAM),
ttnn.MemoryConfig(ttnn.TensorMemoryLayout.INTERLEAVED, ttnn.BufferType.L1),
]


@pytest.mark.parametrize(
"input_shapes",
[
[[1, 1, 32, 32]],
],
)
@pytest.mark.parametrize(
"dst_mem_config",
mem_configs,
)
class TestSignbit:
def test_run_signbit_negative_zero(
self,
input_shapes,
dst_mem_config,
device,
):
datagen_func = [
generation_funcs.gen_func_with_cast(partial(generation_funcs.gen_rand, low=-100, high=100), torch.bfloat16)
]
test_args = generation_funcs.gen_default_dtype_layout_device(input_shapes)[0]
test_args.update({"output_mem_config": dst_mem_config})
comparison_func = comparison_funcs.comp_equal

run_single_pytorch_test(
"eltwise-signbit",
input_shapes,
datagen_func,
comparison_func,
device,
test_args,
)

def test_run_signbit_op(
self,
input_shapes,
dst_mem_config,
device,
):
datagen_func = [
generation_funcs.gen_func_with_cast(partial(generation_funcs.gen_constant, constant=-0.0), torch.bfloat16)
]
test_args = generation_funcs.gen_default_dtype_layout_device(input_shapes)[0]
test_args.update({"output_mem_config": dst_mem_config})
comparison_func = comparison_funcs.comp_equal

run_single_pytorch_test(
"eltwise-signbit",
input_shapes,
datagen_func,
comparison_func,
device,
test_args,
)

0 comments on commit 9dd8c02

Please sign in to comment.