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__), ".."))
import torch
import infinicore
from framework.base import BaseOperatorTest, TensorSpec, TestCase
from framework.runner import GenericTestRunner
from framework import BaseOperatorTest, TensorSpec, TestCase, GenericTestRunner
# Test cases format: (input_shape, input_strides_or_None, split_size_or_sections, dim_or_None)
# infinicore.split(tensor, split_size_or_sections, dim=0)
......
......@@ -5,9 +5,13 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
import torch
import infinicore
from framework.base import BaseOperatorTest, TensorSpec, TestCase
from framework.runner import GenericTestRunner
from framework.utils import is_broadcast
from framework import (
BaseOperatorTest,
TensorSpec,
TestCase,
GenericTestRunner,
is_broadcast,
)
# Test cases format: (in_shape, in_strides_or_None)
# infinicore.sqrt(input)
......
......@@ -5,9 +5,13 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
import torch
import infinicore
from framework.base import BaseOperatorTest, TensorSpec, TestCase
from framework.runner import GenericTestRunner
from framework.utils import is_broadcast
from framework import (
BaseOperatorTest,
TensorSpec,
TestCase,
GenericTestRunner,
is_broadcast,
)
# Test cases format: (in_shape, in_strides_or_None)
# infinicore.square(input)
......
......@@ -5,8 +5,7 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
import torch
import infinicore
from framework.base import BaseOperatorTest, TensorSpec, TestCase
from framework.runner import GenericTestRunner
from framework import BaseOperatorTest, TensorSpec, TestCase, GenericTestRunner
# ==============================================================================
# Operator-specific configuration for stack
......@@ -15,34 +14,32 @@ from framework.runner import GenericTestRunner
# Test cases format: (base_shape, num_tensors, dim)
_TEST_CASES_DATA = [
# ========== Basic cases ==========
((8,), 2, 0),
((8,), 4, 1), # stack 1D tensors along a new last dim
((2, 3), 3, 0),
((2, 3), 3, 1),
((2, 3), 3, 2),
((4, 5, 6), 2, -1),
((4, 5, 6), 4, 0),
((3, 4, 5, 6), 2, 2),
((8,), 2, 0),
((8,), 4, 1), # stack 1D tensors along a new last dim
((2, 3), 3, 0),
((2, 3), 3, 1),
((2, 3), 3, 2),
((4, 5, 6), 2, -1),
((4, 5, 6), 4, 0),
((3, 4, 5, 6), 2, 2),
# ========== Large-scale performance test cases ==========
((1024,), 8, 0),
((2048,), 16, 0),
((256, 256), 4, 0),
((256, 256), 8, 1),
((64, 128, 128), 4, 0),
((64, 128, 128), 8, 1),
((32, 64, 64, 64), 4, 0),
((32, 64, 64, 64), 4, 2),
((16, 32, 64, 128), 8, 1),
((16, 32, 64, 128), 8, -1),
((8, 16, 32, 64), 16, 0),
((8, 16, 32, 64), 16, 3),
((1024,), 8, 0),
((2048,), 16, 0),
((256, 256), 4, 0),
((256, 256), 8, 1),
((64, 128, 128), 4, 0),
((64, 128, 128), 8, 1),
((32, 64, 64, 64), 4, 0),
((32, 64, 64, 64), 4, 2),
((16, 32, 64, 128), 8, 1),
((16, 32, 64, 128), 8, -1),
((8, 16, 32, 64), 16, 0),
((8, 16, 32, 64), 16, 3),
# ========== Edge cases ==========
((1,), 2, 0), # single element
((0, 3), 3, 0), # zero-length dimension
((2, 0, 4), 4, 1), # zero in middle dimension
((1, 1, 1), 1, 0), # single tensor
((1,), 2, 0), # single element
((0, 3), 3, 0), # zero-length dimension
((2, 0, 4), 4, 1), # zero in middle dimension
((1, 1, 1), 1, 0), # single tensor
]
_TOLERANCE_MAP = {
......@@ -79,7 +76,7 @@ def parse_test_cases():
cases.append(
TestCase(
inputs=[tuple(input_specs)],
inputs=[tuple(input_specs)],
kwargs=kwargs,
output_spec=None,
comparison_target=None,
......
......@@ -5,9 +5,13 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
import torch
import infinicore
from framework.base import BaseOperatorTest, TensorSpec, TestCase, TestResult
from framework.runner import GenericTestRunner
from framework.utils import is_broadcast
from framework import (
BaseOperatorTest,
TensorSpec,
TestCase,
GenericTestRunner,
is_broadcast,
)
from framework.devices import InfiniDeviceEnum
# Test cases format:
......
......@@ -5,9 +5,13 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
import torch
import infinicore
from framework.base import BaseOperatorTest, TensorSpec, TestCase
from framework.runner import GenericTestRunner
from framework.utils import is_broadcast
from framework import (
BaseOperatorTest,
TensorSpec,
TestCase,
GenericTestRunner,
is_broadcast,
)
# Test cases format: (in_shape, in_strides_or_None, dim_or_None, unbiased_or_None, out_strides_or_None)
# std_mean returns (std, mean) along dim(s) or overall
......
......@@ -5,9 +5,13 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
import torch
import infinicore
from framework.base import BaseOperatorTest, TensorSpec, TestCase
from framework.runner import GenericTestRunner
from framework.utils import is_broadcast
from framework import (
BaseOperatorTest,
TensorSpec,
TestCase,
GenericTestRunner,
is_broadcast,
)
# Test cases format: (in_shape, in_strides_or_None, dim_or_None, keepdim_or_None, dtype_or_None)
# sum computes the sum along dim(s) or overall
......
......@@ -5,8 +5,7 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
import torch
import infinicore
from framework.base import BaseOperatorTest, TensorSpec, TestCase
from framework.runner import GenericTestRunner
from framework import BaseOperatorTest, TensorSpec, TestCase, GenericTestRunner
# Test cases format: (matrix_shape, strides_or_None, compute_uv_or_None)
# infinicore.svd(a, some=True, compute_uv=True) — different return shapes depending on flags
......
......@@ -5,9 +5,13 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
import torch
import infinicore
from framework.base import BaseOperatorTest, TensorSpec, TestCase
from framework.runner import GenericTestRunner
from framework.utils import is_broadcast
from framework import (
BaseOperatorTest,
TensorSpec,
TestCase,
GenericTestRunner,
is_broadcast,
)
# ==============================================================================
# Operator-specific configuration
......@@ -147,7 +151,7 @@ class OpTest(BaseOperatorTest):
def infinicore_operator(self, a, b, out=None, **kwargs):
"""InfiniCore SwiGLU implementation"""
import infinicore.nn.functional as F
return F.swiglu(a, b, out=out)
......
......@@ -5,9 +5,8 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
import torch
import infinicore
from framework.base import BaseOperatorTest, TensorSpec, TestCase
from framework import BaseOperatorTest, TensorSpec, TestCase, GenericTestRunner
from framework.tensor import TensorInitializer
from framework.runner import GenericTestRunner
# Test cases format: (input_shape, input_strides_or_None, indices_shape)
_TEST_CASES_DATA = [
......
......@@ -5,9 +5,13 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
import torch
import infinicore
from framework.base import BaseOperatorTest, TensorSpec, TestCase
from framework.runner import GenericTestRunner
from framework.utils import is_broadcast
from framework import (
BaseOperatorTest,
TensorSpec,
TestCase,
GenericTestRunner,
is_broadcast,
)
# =======================================================================
# Test cases format: (shape, input_strides_or_None)
......
......@@ -5,9 +5,13 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
import torch
import infinicore
from framework.base import BaseOperatorTest, TensorSpec, TestCase
from framework.runner import GenericTestRunner
from framework.utils import is_broadcast
from framework import (
BaseOperatorTest,
TensorSpec,
TestCase,
GenericTestRunner,
is_broadcast,
)
# Test cases format: (in_shape, in_strides_or_None)
......
......@@ -5,9 +5,13 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
import torch
import infinicore
from framework.base import BaseOperatorTest, TensorSpec, TestCase
from framework.runner import GenericTestRunner
from framework.utils import is_broadcast
from framework import (
BaseOperatorTest,
TensorSpec,
TestCase,
GenericTestRunner,
is_broadcast,
)
# Test cases format: (in_shape, in_strides_or_None, threshold, value)
......
......@@ -5,9 +5,13 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
import torch
import infinicore
from framework.base import BaseOperatorTest, TensorSpec, TestCase
from framework.runner import GenericTestRunner
from framework.utils import is_broadcast
from framework import (
BaseOperatorTest,
TensorSpec,
TestCase,
GenericTestRunner,
is_broadcast,
)
# Test cases format: (shape, input_strides, k, dim, largest, sorted)
_TEST_CASES_DATA = [
......
......@@ -5,9 +5,13 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
import torch
import infinicore
from framework.base import BaseOperatorTest, TensorSpec, TestCase
from framework.runner import GenericTestRunner
from framework.utils import is_broadcast
from framework import (
BaseOperatorTest,
TensorSpec,
TestCase,
GenericTestRunner,
is_broadcast,
)
# Test cases format: (shape, dim0, dim1, input_strides_or_None)
# infinicore.transpose(input, dim0, dim1)
......
......@@ -5,8 +5,7 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
import torch
import infinicore
from framework.base import BaseOperatorTest, TensorSpec, TestCase
from framework.runner import GenericTestRunner
from framework import BaseOperatorTest, TensorSpec, TestCase, GenericTestRunner
# Test cases format: (anchor_shape, positive_shape, negative_shape, strides_or_None, margin_or_None, p_or_None, eps_or_None, swap_or_None)
# infinicore.nn.functional.triplet_margin_loss(anchor, positive, negative, margin=1.0, p=2, eps=1e-6, swap=False, reduction='mean')
......
......@@ -5,8 +5,7 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
import torch
import infinicore
from framework.base import BaseOperatorTest, TensorSpec, TestCase
from framework.runner import GenericTestRunner
from framework import BaseOperatorTest, TensorSpec, TestCase, GenericTestRunner
# Test cases format: (anchor_shape, positive_shape, negative_shape, strides_or_None, margin_or_None, swap_or_None)
# infinicore.nn.functional.triplet_margin_with_distance_loss(anchor, positive, negative, distance_function=None, margin=1.0, swap=False, reduction='mean')
......
......@@ -5,9 +5,13 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
import torch
import infinicore
from framework.base import BaseOperatorTest, TensorSpec, TestCase
from framework.runner import GenericTestRunner
from framework.utils import is_broadcast
from framework import (
BaseOperatorTest,
TensorSpec,
TestCase,
GenericTestRunner,
is_broadcast,
)
# trunc(input)
_TEST_CASES_DATA = [
......
......@@ -5,8 +5,7 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
import torch
import infinicore
from framework.base import BaseOperatorTest, TensorSpec, TestCase
from framework.runner import GenericTestRunner
from framework import BaseOperatorTest, TensorSpec, TestCase, GenericTestRunner
# Test cases format: (in_shape, in_strides_or_None, kernel_size, dilation, padding, stride)
# Unfold extracts sliding local blocks from a batched input tensor.
......
......@@ -5,9 +5,13 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
import torch
import infinicore
from framework.base import BaseOperatorTest, TensorSpec, TestCase
from framework.runner import GenericTestRunner
from framework.utils import is_broadcast
from framework import (
BaseOperatorTest,
TensorSpec,
TestCase,
GenericTestRunner,
is_broadcast,
)
# Test cases format: (in_shape, in_strides_or_None, sorted_or_None, return_inverse_or_None, return_counts_or_None)
# unique returns unique values and optionally inverse indices and counts
......
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