Skip to content

Commit

Permalink
#8142: Update sweep tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mouliraj-mcw committed Oct 18, 2024
1 parent 8af6470 commit 73c4723
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 10 deletions.
15 changes: 12 additions & 3 deletions tests/sweep_framework/sweeps/eltwise/unary/log10/log10.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,22 @@
+ gen_shapes([1, 32, 32], [12, 256, 256], [1, 32, 32], 16)
+ gen_shapes([32, 32], [256, 256], [32, 32], 32),
"input_a_dtype": [ttnn.bfloat16, ttnn.bfloat8_b],
"input_a_layout": [ttnn.TILE_LAYOUT],
"input_a_layout": [ttnn.TILE_LAYOUT, ttnn.ROW_MAJOR_LAYOUT],
"input_a_memory_config": [ttnn.DRAM_MEMORY_CONFIG, ttnn.L1_MEMORY_CONFIG],
"output_memory_config": [ttnn.DRAM_MEMORY_CONFIG, ttnn.L1_MEMORY_CONFIG],
},
}


# Invalidate vector is called during the generation phase where each vector will be passed in.
# If invalidated, the vector will still be stored but will be skipped.
# Returns False, None if the vector is valid, and True, str with a reason for invalidation if it is invalid.
def invalidate_vector(test_vector) -> Tuple[bool, Optional[str]]:
if test_vector["input_a_layout"] == ttnn.ROW_MAJOR_LAYOUT:
return True, "Row Major layout is not supported"
return False, None


# This is the run instructions for the test, defined by the developer.
# The run function must take the above-defined parameters as inputs.
# The runner will call this run function with each test vector, and the returned results from this function will be stored.
Expand All @@ -48,8 +57,8 @@ def run(
torch_input_tensor_a = gen_func_with_cast_tt(
partial(torch_random, low=1, high=100, dtype=torch.float32), input_a_dtype
)(input_shape)
torch_output_tensor = torch.log10(torch_input_tensor_a)

golden_function = ttnn.get_golden_function(ttnn.log10)
torch_output_tensor = golden_function(torch_input_tensor_a)
input_tensor_a = ttnn.from_torch(
torch_input_tensor_a,
dtype=input_a_dtype,
Expand Down
17 changes: 14 additions & 3 deletions tests/sweep_framework/sweeps/eltwise/unary/log1p/log1p.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,23 @@
"input_shape": gen_shapes([1, 1, 32, 32], [6, 12, 256, 256], [1, 1, 32, 32], 16)
+ gen_shapes([1, 32, 32], [12, 256, 256], [1, 32, 32], 16)
+ gen_shapes([32, 32], [256, 256], [32, 32], 32),
"input_a_dtype": [ttnn.bfloat16],
"input_a_layout": [ttnn.TILE_LAYOUT],
"input_a_dtype": [ttnn.bfloat16, ttnn.bfloat8_b],
"input_a_layout": [ttnn.TILE_LAYOUT, ttnn.ROW_MAJOR_LAYOUT],
"input_a_memory_config": [ttnn.DRAM_MEMORY_CONFIG, ttnn.L1_MEMORY_CONFIG],
"output_memory_config": [ttnn.DRAM_MEMORY_CONFIG, ttnn.L1_MEMORY_CONFIG],
},
}


# Invalidate vector is called during the generation phase where each vector will be passed in.
# If invalidated, the vector will still be stored but will be skipped.
# Returns False, None if the vector is valid, and True, str with a reason for invalidation if it is invalid.
def invalidate_vector(test_vector) -> Tuple[bool, Optional[str]]:
if test_vector["input_a_layout"] == ttnn.ROW_MAJOR_LAYOUT or test_vector["input_a_dtype"] == ttnn.bfloat8_b:
return True, "Row Major layout and bfloat8_b are not supported"
return False, None


# This is the run instructions for the test, defined by the developer.
# The run function must take the above-defined parameters as inputs.
# The runner will call this run function with each test vector, and the returned results from this function will be stored.
Expand All @@ -48,7 +57,9 @@ def run(
torch_input_tensor_a = gen_func_with_cast_tt(
partial(torch_random, low=1, high=100, dtype=torch.float32), input_a_dtype
)(input_shape)
torch_output_tensor = torch.log1p(torch_input_tensor_a)

golden_function = ttnn.get_golden_function(ttnn.log1p)
torch_output_tensor = golden_function(torch_input_tensor_a)

input_tensor_a = ttnn.from_torch(
torch_input_tensor_a,
Expand Down
14 changes: 12 additions & 2 deletions tests/sweep_framework/sweeps/eltwise/unary/log2/log2.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,22 @@
+ gen_shapes([1, 32, 32], [12, 256, 256], [1, 32, 32], 16)
+ gen_shapes([32, 32], [256, 256], [32, 32], 32),
"input_a_dtype": [ttnn.bfloat16, ttnn.bfloat8_b],
"input_a_layout": [ttnn.TILE_LAYOUT],
"input_a_layout": [ttnn.TILE_LAYOUT, ttnn.ROW_MAJOR_LAYOUT],
"input_a_memory_config": [ttnn.DRAM_MEMORY_CONFIG, ttnn.L1_MEMORY_CONFIG],
"output_memory_config": [ttnn.DRAM_MEMORY_CONFIG, ttnn.L1_MEMORY_CONFIG],
},
}


# Invalidate vector is called during the generation phase where each vector will be passed in.
# If invalidated, the vector will still be stored but will be skipped.
# Returns False, None if the vector is valid, and True, str with a reason for invalidation if it is invalid.
def invalidate_vector(test_vector) -> Tuple[bool, Optional[str]]:
if test_vector["input_a_layout"] == ttnn.ROW_MAJOR_LAYOUT:
return True, "Row Major layout is not supported"
return False, None


# This is the run instructions for the test, defined by the developer.
# The run function must take the above-defined parameters as inputs.
# The runner will call this run function with each test vector, and the returned results from this function will be stored.
Expand All @@ -48,7 +57,8 @@ def run(
torch_input_tensor_a = gen_func_with_cast_tt(
partial(torch_random, low=1, high=100, dtype=torch.float32), input_a_dtype
)(input_shape)
torch_output_tensor = torch.log2(torch_input_tensor_a)
golden_function = ttnn.get_golden_function(ttnn.log2)
torch_output_tensor = golden_function(torch_input_tensor_a)

input_tensor_a = ttnn.from_torch(
torch_input_tensor_a,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,22 @@
+ gen_shapes([1, 32, 32], [12, 256, 256], [1, 32, 32], 16)
+ gen_shapes([32, 32], [256, 256], [32, 32], 32),
"input_a_dtype": [ttnn.bfloat16, ttnn.bfloat8_b],
"input_a_layout": [ttnn.TILE_LAYOUT],
"input_a_layout": [ttnn.TILE_LAYOUT, ttnn.ROW_MAJOR_LAYOUT],
"input_a_memory_config": [ttnn.DRAM_MEMORY_CONFIG, ttnn.L1_MEMORY_CONFIG],
"output_memory_config": [ttnn.DRAM_MEMORY_CONFIG, ttnn.L1_MEMORY_CONFIG],
},
}


# Invalidate vector is called during the generation phase where each vector will be passed in.
# If invalidated, the vector will still be stored but will be skipped.
# Returns False, None if the vector is valid, and True, str with a reason for invalidation if it is invalid.
def invalidate_vector(test_vector) -> Tuple[bool, Optional[str]]:
if test_vector["input_a_layout"] == ttnn.ROW_MAJOR_LAYOUT:
return True, "Row Major layout is not supported"
return False, None


# This is the run instructions for the test, defined by the developer.
# The run function must take the above-defined parameters as inputs.
# The runner will call this run function with each test vector, and the returned results from this function will be stored.
Expand All @@ -48,7 +57,8 @@ def run(
torch_input_tensor_a = gen_func_with_cast_tt(
partial(torch_random, low=-4, high=10, dtype=torch.float32), input_a_dtype
)(input_shape)
torch_output_tensor = torch.nn.functional.logsigmoid(torch_input_tensor_a)
golden_function = ttnn.get_golden_function(ttnn.log_sigmoid)
torch_output_tensor = golden_function(torch_input_tensor_a)

input_tensor_a = ttnn.from_torch(
torch_input_tensor_a,
Expand Down

0 comments on commit 73c4723

Please sign in to comment.