-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#4003: split unary sweep into per op sweeps
- Loading branch information
Showing
5 changed files
with
234 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# SPDX-FileCopyrightText: © 2023 Tenstorrent Inc. | ||
|
||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
from typing import Optional, Tuple | ||
|
||
import torch | ||
|
||
import ttnn | ||
|
||
from tests.ttnn.utils_for_testing import check_with_pcc | ||
from models.utility_functions import torch_random | ||
|
||
|
||
parameters = { | ||
"batch_sizes": [(1,)], | ||
"height": [384, 1024], | ||
"width": [1024, 4096], | ||
"input_dtype": [ttnn.bfloat16], | ||
"input_memory_config": [ttnn.DRAM_MEMORY_CONFIG], | ||
"output_memory_config": [ttnn.DRAM_MEMORY_CONFIG], | ||
} | ||
|
||
|
||
def skip(**_) -> Tuple[bool, Optional[str]]: | ||
return False, None | ||
|
||
|
||
def is_expected_to_fail(**_) -> Tuple[bool, Optional[str]]: | ||
return False, None | ||
|
||
|
||
def run( | ||
batch_sizes, | ||
height, | ||
width, | ||
input_dtype, | ||
input_memory_config, | ||
output_memory_config, | ||
*, | ||
device, | ||
) -> Tuple[bool, Optional[str]]: | ||
input_shape = (*batch_sizes, height, width) | ||
|
||
low = -0.1 | ||
high = 0.1 | ||
|
||
torch_input_tensor = torch_random(input_shape, low, high, dtype=torch.float32) | ||
torch_output_tensor = torch.nn.functional.gelu(torch_input_tensor) | ||
|
||
input_tensor = ttnn.from_torch( | ||
torch_input_tensor, dtype=input_dtype, device=device, memory_config=input_memory_config | ||
) | ||
|
||
output_tensor = ttnn.gelu(input_tensor, memory_config=output_memory_config) | ||
output_tensor = ttnn.to_torch(output_tensor) | ||
|
||
return check_with_pcc(torch_output_tensor, output_tensor, 0.999) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# SPDX-FileCopyrightText: © 2023 Tenstorrent Inc. | ||
|
||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
from typing import Optional, Tuple | ||
|
||
import torch | ||
|
||
import ttnn | ||
|
||
from tests.ttnn.utils_for_testing import check_with_pcc | ||
from models.utility_functions import torch_random | ||
|
||
|
||
parameters = { | ||
"batch_sizes": [(1,)], | ||
"height": [384, 1024], | ||
"width": [1024, 4096], | ||
"input_dtype": [ttnn.bfloat16], | ||
"input_memory_config": [ttnn.DRAM_MEMORY_CONFIG], | ||
"output_memory_config": [ttnn.DRAM_MEMORY_CONFIG], | ||
} | ||
|
||
|
||
def skip(**_) -> Tuple[bool, Optional[str]]: | ||
return False, None | ||
|
||
|
||
def is_expected_to_fail(**_) -> Tuple[bool, Optional[str]]: | ||
return False, None | ||
|
||
|
||
def run( | ||
batch_sizes, | ||
height, | ||
width, | ||
input_dtype, | ||
input_memory_config, | ||
output_memory_config, | ||
*, | ||
device, | ||
) -> Tuple[bool, Optional[str]]: | ||
input_shape = (*batch_sizes, height, width) | ||
|
||
low = -0.1 | ||
high = 0.1 | ||
|
||
torch_input_tensor = torch_random(input_shape, low, high, dtype=torch.float32) | ||
torch_output_tensor = torch.relu(torch_input_tensor) | ||
|
||
input_tensor = ttnn.from_torch( | ||
torch_input_tensor, dtype=input_dtype, device=device, memory_config=input_memory_config | ||
) | ||
|
||
output_tensor = ttnn.relu(input_tensor, memory_config=output_memory_config) | ||
output_tensor = ttnn.to_torch(output_tensor) | ||
|
||
return check_with_pcc(torch_output_tensor, output_tensor, 0.999) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# SPDX-FileCopyrightText: © 2023 Tenstorrent Inc. | ||
|
||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
from typing import Optional, Tuple | ||
|
||
import torch | ||
|
||
import ttnn | ||
|
||
from tests.ttnn.utils_for_testing import check_with_pcc | ||
from models.utility_functions import torch_random | ||
|
||
|
||
parameters = { | ||
"batch_sizes": [(1,)], | ||
"height": [384, 1024], | ||
"width": [1024, 4096], | ||
"input_dtype": [ttnn.bfloat16], | ||
"input_memory_config": [ttnn.DRAM_MEMORY_CONFIG], | ||
"output_memory_config": [ttnn.DRAM_MEMORY_CONFIG], | ||
} | ||
|
||
|
||
def skip(**_) -> Tuple[bool, Optional[str]]: | ||
return False, None | ||
|
||
|
||
def is_expected_to_fail(**_) -> Tuple[bool, Optional[str]]: | ||
return False, None | ||
|
||
|
||
def run( | ||
batch_sizes, | ||
height, | ||
width, | ||
input_dtype, | ||
input_memory_config, | ||
output_memory_config, | ||
*, | ||
device, | ||
) -> Tuple[bool, Optional[str]]: | ||
input_shape = (*batch_sizes, height, width) | ||
|
||
low = 0 | ||
high = 0.1 | ||
|
||
torch_input_tensor = torch_random(input_shape, low, high, dtype=torch.float32) | ||
torch_output_tensor = torch.rsqrt(torch_input_tensor) | ||
|
||
input_tensor = ttnn.from_torch( | ||
torch_input_tensor, dtype=input_dtype, device=device, memory_config=input_memory_config | ||
) | ||
|
||
output_tensor = ttnn.rsqrt(input_tensor, memory_config=output_memory_config) | ||
output_tensor = ttnn.to_torch(output_tensor) | ||
|
||
return check_with_pcc(torch_output_tensor, output_tensor, 0.999) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# SPDX-FileCopyrightText: © 2023 Tenstorrent Inc. | ||
|
||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
from typing import Optional, Tuple | ||
|
||
import torch | ||
|
||
import ttnn | ||
|
||
from tests.ttnn.utils_for_testing import check_with_pcc | ||
from models.utility_functions import torch_random | ||
|
||
|
||
parameters = { | ||
"batch_sizes": [(1,)], | ||
"height": [384, 1024], | ||
"width": [1024, 4096], | ||
"input_dtype": [ttnn.bfloat16], | ||
"input_memory_config": [ttnn.DRAM_MEMORY_CONFIG], | ||
"output_memory_config": [ttnn.DRAM_MEMORY_CONFIG], | ||
} | ||
|
||
|
||
def skip(**_) -> Tuple[bool, Optional[str]]: | ||
return False, None | ||
|
||
|
||
def is_expected_to_fail(**_) -> Tuple[bool, Optional[str]]: | ||
return False, None | ||
|
||
|
||
def run( | ||
batch_sizes, | ||
height, | ||
width, | ||
input_dtype, | ||
input_memory_config, | ||
output_memory_config, | ||
*, | ||
device, | ||
) -> Tuple[bool, Optional[str]]: | ||
input_shape = (*batch_sizes, height, width) | ||
|
||
low = -0.1 | ||
high = 0.1 | ||
|
||
torch_input_tensor = torch_random(input_shape, low, high, dtype=torch.float32) | ||
torch_output_tensor = torch.tanh(torch_input_tensor) | ||
|
||
input_tensor = ttnn.from_torch( | ||
torch_input_tensor, dtype=input_dtype, device=device, memory_config=input_memory_config | ||
) | ||
|
||
output_tensor = ttnn.tanh(input_tensor, memory_config=output_memory_config) | ||
output_tensor = ttnn.to_torch(output_tensor) | ||
|
||
return check_with_pcc(torch_output_tensor, output_tensor, 0.999) |