Commit 61a7dc0e authored by wooway777's avatar wooway777
Browse files

issue/666 - Standardized test imports

parent 406c9668
...@@ -5,8 +5,7 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..")) ...@@ -5,8 +5,7 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
import torch import torch
import infinicore import infinicore
from framework.base import BaseOperatorTest, TensorSpec, TestCase from framework import BaseOperatorTest, TensorSpec, TestCase, GenericTestRunner
from framework.runner import GenericTestRunner
# Test cases format: (matrix_shape, strides_or_None) # Test cases format: (matrix_shape, strides_or_None)
# logdet(input) — returns (sign, logabsdet) in PyTorch # logdet(input) — returns (sign, logabsdet) in PyTorch
......
...@@ -5,9 +5,13 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..")) ...@@ -5,9 +5,13 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
import torch import torch
import infinicore import infinicore
from framework.base import BaseOperatorTest, TensorSpec, TestCase from framework import (
from framework.runner import GenericTestRunner BaseOperatorTest,
from framework.utils import is_broadcast TensorSpec,
TestCase,
GenericTestRunner,
is_broadcast,
)
# Test cases format: (shape, a_strides_or_None, b_strides_or_None, out_strides_or_None) # Test cases format: (shape, a_strides_or_None, b_strides_or_None, out_strides_or_None)
# logical_and performs element-wise boolean AND; inputs may be bool or integer # logical_and performs element-wise boolean AND; inputs may be bool or integer
......
...@@ -5,9 +5,13 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..")) ...@@ -5,9 +5,13 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
import torch import torch
import infinicore import infinicore
from framework.base import BaseOperatorTest, TensorSpec, TestCase from framework import (
from framework.runner import GenericTestRunner BaseOperatorTest,
from framework.utils import is_broadcast TensorSpec,
TestCase,
GenericTestRunner,
is_broadcast,
)
# Test cases format: (shape, input_strides_or_None, out_strides_or_None) # Test cases format: (shape, input_strides_or_None, out_strides_or_None)
# logical_not negates boolean values # logical_not negates boolean values
......
...@@ -5,9 +5,13 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..")) ...@@ -5,9 +5,13 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
import torch import torch
import infinicore import infinicore
from framework.base import BaseOperatorTest, TensorSpec, TestCase from framework import (
from framework.runner import GenericTestRunner BaseOperatorTest,
from framework.utils import is_broadcast TensorSpec,
TestCase,
GenericTestRunner,
is_broadcast,
)
# Test cases format: (shape, a_strides_or_None, b_strides_or_None, out_strides_or_None) # Test cases format: (shape, a_strides_or_None, b_strides_or_None, out_strides_or_None)
# logical_or performs element-wise boolean OR # logical_or performs element-wise boolean OR
......
...@@ -5,9 +5,13 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..")) ...@@ -5,9 +5,13 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
import torch import torch
import infinicore import infinicore
from framework.base import BaseOperatorTest, TensorSpec, TestCase from framework import (
from framework.runner import GenericTestRunner BaseOperatorTest,
from framework.utils import is_broadcast TensorSpec,
TestCase,
GenericTestRunner,
is_broadcast,
)
# Test cases format: (shape, a_strides_or_None, b_strides_or_None, out_strides_or_None) # Test cases format: (shape, a_strides_or_None, b_strides_or_None, out_strides_or_None)
# logical_xor performs element-wise boolean XOR # logical_xor performs element-wise boolean XOR
......
...@@ -5,9 +5,13 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..")) ...@@ -5,9 +5,13 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
import torch import torch
import infinicore import infinicore
from framework.base import BaseOperatorTest, TensorSpec, TestCase from framework import (
from framework.runner import GenericTestRunner BaseOperatorTest,
from framework.utils import is_broadcast TensorSpec,
TestCase,
GenericTestRunner,
is_broadcast,
)
# Test cases format: (in_shape, in_strides_or_None) # Test cases format: (in_shape, in_strides_or_None)
......
...@@ -5,9 +5,13 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..")) ...@@ -5,9 +5,13 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
import torch import torch
import infinicore import infinicore
from framework.base import BaseOperatorTest, TensorSpec, TestCase from framework import (
from framework.runner import GenericTestRunner BaseOperatorTest,
from framework.utils import is_broadcast TensorSpec,
TestCase,
GenericTestRunner,
is_broadcast,
)
# Test cases format: (in_shape, in_strides_or_None, dim, keepdim_or_None, out_strides_or_None) # Test cases format: (in_shape, in_strides_or_None, dim, keepdim_or_None, out_strides_or_None)
# logsumexp computes log(sum(exp(input), dim=dim)) with numerical stability # logsumexp computes log(sum(exp(input), dim=dim)) with numerical stability
......
...@@ -5,8 +5,7 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..")) ...@@ -5,8 +5,7 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
import torch import torch
import infinicore import infinicore
from framework.base import BaseOperatorTest, TensorSpec, TestCase from framework import BaseOperatorTest, TensorSpec, TestCase, GenericTestRunner
from framework.runner import GenericTestRunner
# Test cases format: (in_shape, in_strides_or_None, norm_type, kernel_size, stride_or_None, ceil_mode) # Test cases format: (in_shape, in_strides_or_None, norm_type, kernel_size, stride_or_None, ceil_mode)
......
...@@ -5,8 +5,7 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..")) ...@@ -5,8 +5,7 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
import torch import torch
import infinicore import infinicore
from framework.base import BaseOperatorTest, TensorSpec, TestCase from framework import BaseOperatorTest, TensorSpec, TestCase, GenericTestRunner
from framework.runner import GenericTestRunner
# Test cases format: (in_shape, in_strides_or_None, norm_type, kernel_size, stride_or_None, ceil_mode) # Test cases format: (in_shape, in_strides_or_None, norm_type, kernel_size, stride_or_None, ceil_mode)
......
...@@ -5,8 +5,7 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..")) ...@@ -5,8 +5,7 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
import torch import torch
import infinicore import infinicore
from framework.base import BaseOperatorTest, TensorSpec, TestCase from framework import BaseOperatorTest, TensorSpec, TestCase, GenericTestRunner
from framework.runner import GenericTestRunner
# Test cases format: (in_shape, in_strides_or_None, norm_type, kernel_size, stride_or_None, ceil_mode) # Test cases format: (in_shape, in_strides_or_None, norm_type, kernel_size, stride_or_None, ceil_mode)
......
...@@ -5,8 +5,7 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..")) ...@@ -5,8 +5,7 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
import torch import torch
import infinicore import infinicore
from framework.base import BaseOperatorTest, TensorSpec, TestCase from framework import BaseOperatorTest, TensorSpec, TestCase, GenericTestRunner
from framework.runner import GenericTestRunner
# Test cases format: (input1_shape, input2_shape, target_shape, input1_strides_or_None, input2_strides_or_None, target_strides_or_None, margin_or_None, p_or_None) # Test cases format: (input1_shape, input2_shape, target_shape, input1_strides_or_None, input2_strides_or_None, target_strides_or_None, margin_or_None, p_or_None)
# infinicore.nn.functional.margin_ranking_loss(input1, input2, target, margin=0, p=1, reduction='mean') # infinicore.nn.functional.margin_ranking_loss(input1, input2, target, margin=0, p=1, reduction='mean')
......
...@@ -5,8 +5,7 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..")) ...@@ -5,8 +5,7 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
import torch import torch
import infinicore import infinicore
from framework.base import BaseOperatorTest, TensorSpec, TestCase from framework import BaseOperatorTest, TensorSpec, TestCase, GenericTestRunner
from framework.runner import GenericTestRunner
# Test cases format: (input_shape, input_strides_or_None, mask_shape) # Test cases format: (input_shape, input_strides_or_None, mask_shape)
_TEST_CASES_DATA = [ _TEST_CASES_DATA = [
......
...@@ -5,9 +5,13 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..")) ...@@ -5,9 +5,13 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
import torch import torch
import infinicore import infinicore
from framework.base import BaseOperatorTest, TensorSpec, TestCase from framework import (
from framework.runner import GenericTestRunner BaseOperatorTest,
from framework.utils import is_broadcast TensorSpec,
TestCase,
GenericTestRunner,
is_broadcast,
)
# ============================================================================== # ==============================================================================
# Operator-specific configuration # Operator-specific configuration
......
...@@ -5,8 +5,7 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..")) ...@@ -5,8 +5,7 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
import torch import torch
import infinicore import infinicore
from framework.base import BaseOperatorTest, TensorSpec, TestCase from framework import BaseOperatorTest, TensorSpec, TestCase, GenericTestRunner
from framework.runner import GenericTestRunner
# Test cases format: (matrix_shape, strides_or_None) # Test cases format: (matrix_shape, strides_or_None)
# infinicore.matrix_exp(input) # infinicore.matrix_exp(input)
......
...@@ -5,8 +5,7 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..")) ...@@ -5,8 +5,7 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
import torch import torch
import infinicore import infinicore
from framework.base import BaseOperatorTest, TensorSpec, TestCase from framework import BaseOperatorTest, TensorSpec, TestCase, GenericTestRunner
from framework.runner import GenericTestRunner
# Test cases format: (matrix_shape, strides_or_None, n_or_None) # Test cases format: (matrix_shape, strides_or_None, n_or_None)
# infinicore.matrix_power(input, n) # infinicore.matrix_power(input, n)
......
...@@ -5,9 +5,13 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..")) ...@@ -5,9 +5,13 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
import torch import torch
import infinicore import infinicore
from framework.base import BaseOperatorTest, TensorSpec, TestCase from framework import (
from framework.runner import GenericTestRunner BaseOperatorTest,
from framework.utils import is_broadcast TensorSpec,
TestCase,
GenericTestRunner,
is_broadcast,
)
# Test cases format: (in_shape, in_strides_or_None, dim_or_None, keepdim_or_None, out_strides_or_None) # Test cases format: (in_shape, in_strides_or_None, dim_or_None, keepdim_or_None, out_strides_or_None)
# max reduces by taking maximum along dim(s) or overall # max reduces by taking maximum along dim(s) or overall
......
...@@ -5,8 +5,7 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..")) ...@@ -5,8 +5,7 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
import torch import torch
import infinicore import infinicore
from framework.base import BaseOperatorTest, TensorSpec, TestCase from framework import BaseOperatorTest, TensorSpec, TestCase, GenericTestRunner
from framework.runner import GenericTestRunner
# Test cases format: (in_shape, in_strides_or_None, kernel_size, stride_or_None, padding, dilation, ceil_mode) # Test cases format: (in_shape, in_strides_or_None, kernel_size, stride_or_None, padding, dilation, ceil_mode)
......
...@@ -5,8 +5,7 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..")) ...@@ -5,8 +5,7 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
import torch import torch
import infinicore import infinicore
from framework.base import BaseOperatorTest, TensorSpec, TestCase from framework import BaseOperatorTest, TensorSpec, TestCase, GenericTestRunner
from framework.runner import GenericTestRunner
# Test cases format: (in_shape, in_strides_or_None, kernel_size, stride_or_None, padding, dilation, ceil_mode) # Test cases format: (in_shape, in_strides_or_None, kernel_size, stride_or_None, padding, dilation, ceil_mode)
......
...@@ -5,8 +5,7 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..")) ...@@ -5,8 +5,7 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
import torch import torch
import infinicore import infinicore
from framework.base import BaseOperatorTest, TensorSpec, TestCase from framework import BaseOperatorTest, TensorSpec, TestCase, GenericTestRunner
from framework.runner import GenericTestRunner
# Test cases format: (in_shape, in_strides_or_None, kernel_size, stride_or_None, padding, dilation, ceil_mode) # Test cases format: (in_shape, in_strides_or_None, kernel_size, stride_or_None, padding, dilation, ceil_mode)
......
...@@ -5,8 +5,7 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..")) ...@@ -5,8 +5,7 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
import torch import torch
import infinicore import infinicore
from framework.base import BaseOperatorTest, TensorSpec, TestCase from framework import BaseOperatorTest, TensorSpec, TestCase, GenericTestRunner
from framework.runner import GenericTestRunner
from framework.tensor import TensorInitializer from framework.tensor import TensorInitializer
# Test cases format: # Test cases format:
...@@ -27,36 +26,34 @@ from framework.tensor import TensorInitializer ...@@ -27,36 +26,34 @@ from framework.tensor import TensorInitializer
_TEST_CASES_DATA = [ _TEST_CASES_DATA = [
# ========== Basic cases ========== # ========== Basic cases ==========
# small sizes and various stride/padding combinations # small sizes and various stride/padding combinations
((1, 1, 4), 2, 2, 0, False, None), ((1, 1, 4), 2, 2, 0, False, None),
((2, 3, 8), 2, 2, 0, False, None), ((2, 3, 8), 2, 2, 0, False, None),
((2, 3, 8), 3, 2, 1, False, None), ((2, 3, 8), 3, 2, 1, False, None),
((1, 4, 6), 2, None, 0, False, None), # default stride ((1, 4, 6), 2, None, 0, False, None), # default stride
((4, 8, 16), 2, 2, 0, True, 32), # L_in = (16-1)*2 - 0 + 2 = 32 ((4, 8, 16), 2, 2, 0, True, 32), # L_in = (16-1)*2 - 0 + 2 = 32
((4, 8, 16), 3, 2, 1, True, 31), # L_in = (16-1)*2 - 2 + 3 = 31 ((4, 8, 16), 3, 2, 1, True, 31), # L_in = (16-1)*2 - 2 + 3 = 31
((2, 1, 10), 3, 1, 1, True, 10), # L_in = (10-1)*1 - 2 + 3 = 10 ((2, 1, 10), 3, 1, 1, True, 10), # L_in = (10-1)*1 - 2 + 3 = 10
((2, 1, 5), 2, None, 1, True, 8), # L_in = (5-1)*2 - 2 + 2 = 8 ((2, 1, 5), 2, None, 1, True, 8), # L_in = (5-1)*2 - 2 + 2 = 8
# ========== Large-scale performance test cases ========== # ========== Large-scale performance test cases ==========
# medium to large sizes for performance and stability # medium to large sizes for performance and stability
((8, 64, 128), 2, 2, 0, False, None), ((8, 64, 128), 2, 2, 0, False, None),
((8, 64, 256), 3, 2, 1, False, None), ((8, 64, 256), 3, 2, 1, False, None),
((4, 128, 512), 2, 2, 0, False, None), ((4, 128, 512), 2, 2, 0, False, None),
((4, 128, 512), 3, 2, 1, False, None), ((4, 128, 512), 3, 2, 1, False, None),
((16, 32, 256), 4, 4, 0, False, None), ((16, 32, 256), 4, 4, 0, False, None),
((16, 32, 256), 3, 1, 1, False, None), ((16, 32, 256), 3, 1, 1, False, None),
((32, 16, 1024), 2, 2, 0, True, 2048), # L_in = (1024-1)*2 + 2 = 2048 ((32, 16, 1024), 2, 2, 0, True, 2048), # L_in = (1024-1)*2 + 2 = 2048
((32, 16, 512), 3, 2, 1, True, 1023), # L_in = (512-1)*2 - 2 + 3 = 1023 ((32, 16, 512), 3, 2, 1, True, 1023), # L_in = (512-1)*2 - 2 + 3 = 1023
((2, 256, 2048), 2, 2, 0, True, 4096), # L_in = (2048-1)*2 + 2 = 4096 ((2, 256, 2048), 2, 2, 0, True, 4096), # L_in = (2048-1)*2 + 2 = 4096
((2, 256, 2048), 3, 2, 1, True, 4095), # L_in = (2048-1)*2 - 2 + 3 = 4095 ((2, 256, 2048), 3, 2, 1, True, 4095), # L_in = (2048-1)*2 - 2 + 3 = 4095
((1, 64, 16384), 2, 2, 0, False, None), ((1, 64, 16384), 2, 2, 0, False, None),
((1, 64, 8192), 3, 2, 1, False, None), ((1, 64, 8192), 3, 2, 1, False, None),
# ========== Edge cases ========== # ========== Edge cases ==========
# extreme small / boundary sizes # extreme small / boundary sizes
((1, 1, 1), 1, 1, 0, False, None), ((1, 1, 1), 1, 1, 0, False, None),
((1, 4, 2), 2, 2, 0, True, 4), # L_in = (2-1)*2 + 2 = 4 ((1, 4, 2), 2, 2, 0, True, 4), # L_in = (2-1)*2 + 2 = 4
((2, 1, 64), 3, 2, 1, False, None), ((2, 1, 64), 3, 2, 1, False, None),
((1, 1, 3), 2, 2, 1, True, 4), # L_in = (3-1)*2 - 2 + 2 = 4 ((1, 1, 3), 2, 2, 1, True, 4), # L_in = (3-1)*2 - 2 + 2 = 4
] ]
_TOLERANCE_MAP = { _TOLERANCE_MAP = {
...@@ -79,8 +76,14 @@ def parse_test_cases(): ...@@ -79,8 +76,14 @@ def parse_test_cases():
""" """
test_cases = [] test_cases = []
for (input_shape, kernel_size, stride, padding, for (
use_output_size, output_length) in _TEST_CASES_DATA: input_shape,
kernel_size,
stride,
padding,
use_output_size,
output_length,
) in _TEST_CASES_DATA:
for dtype in _TENSOR_DTYPES: for dtype in _TENSOR_DTYPES:
tol = _TOLERANCE_MAP.get(dtype, {"atol": 1e-5, "rtol": 1e-4}) tol = _TOLERANCE_MAP.get(dtype, {"atol": 1e-5, "rtol": 1e-4})
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment