Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jerrrrry
infinicore
Commits
61a7dc0e
Commit
61a7dc0e
authored
Nov 24, 2025
by
wooway777
Browse files
issue/666 - Standardized test imports
parent
406c9668
Changes
268
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
124 additions
and
81 deletions
+124
-81
test/infinicore/ops/split.py
test/infinicore/ops/split.py
+1
-2
test/infinicore/ops/sqrt.py
test/infinicore/ops/sqrt.py
+7
-3
test/infinicore/ops/square.py
test/infinicore/ops/square.py
+7
-3
test/infinicore/ops/stack.py
test/infinicore/ops/stack.py
+26
-29
test/infinicore/ops/std.py
test/infinicore/ops/std.py
+7
-3
test/infinicore/ops/std_mean.py
test/infinicore/ops/std_mean.py
+7
-3
test/infinicore/ops/sum.py
test/infinicore/ops/sum.py
+7
-3
test/infinicore/ops/svd.py
test/infinicore/ops/svd.py
+1
-2
test/infinicore/ops/swiglu.py
test/infinicore/ops/swiglu.py
+8
-4
test/infinicore/ops/take.py
test/infinicore/ops/take.py
+1
-2
test/infinicore/ops/tan.py
test/infinicore/ops/tan.py
+7
-3
test/infinicore/ops/tanhshrink.py
test/infinicore/ops/tanhshrink.py
+7
-3
test/infinicore/ops/threshold.py
test/infinicore/ops/threshold.py
+7
-3
test/infinicore/ops/topk.py
test/infinicore/ops/topk.py
+7
-3
test/infinicore/ops/transpose.py
test/infinicore/ops/transpose.py
+7
-3
test/infinicore/ops/triplet_margin_loss.py
test/infinicore/ops/triplet_margin_loss.py
+1
-2
test/infinicore/ops/triplet_margin_with_distance_loss.py
test/infinicore/ops/triplet_margin_with_distance_loss.py
+1
-2
test/infinicore/ops/trunc.py
test/infinicore/ops/trunc.py
+7
-3
test/infinicore/ops/unfold.py
test/infinicore/ops/unfold.py
+1
-2
test/infinicore/ops/unique.py
test/infinicore/ops/unique.py
+7
-3
No files found.
test/infinicore/ops/split.py
View file @
61a7dc0e
...
...
@@ -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)
...
...
test/infinicore/ops/sqrt.py
View file @
61a7dc0e
...
...
@@ -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)
...
...
test/infinicore/ops/square.py
View file @
61a7dc0e
...
...
@@ -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)
...
...
test/infinicore/ops/stack.py
View file @
61a7dc0e
...
...
@@ -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
,
...
...
test/infinicore/ops/std.py
View file @
61a7dc0e
...
...
@@ -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:
...
...
test/infinicore/ops/std_mean.py
View file @
61a7dc0e
...
...
@@ -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
...
...
test/infinicore/ops/sum.py
View file @
61a7dc0e
...
...
@@ -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
...
...
test/infinicore/ops/svd.py
View file @
61a7dc0e
...
...
@@ -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
...
...
test/infinicore/ops/swiglu.py
View file @
61a7dc0e
...
...
@@ -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
)
...
...
test/infinicore/ops/take.py
View file @
61a7dc0e
...
...
@@ -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
=
[
...
...
test/infinicore/ops/tan.py
View file @
61a7dc0e
...
...
@@ -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)
...
...
test/infinicore/ops/tanhshrink.py
View file @
61a7dc0e
...
...
@@ -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)
...
...
test/infinicore/ops/threshold.py
View file @
61a7dc0e
...
...
@@ -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)
...
...
test/infinicore/ops/topk.py
View file @
61a7dc0e
...
...
@@ -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
=
[
...
...
test/infinicore/ops/transpose.py
View file @
61a7dc0e
...
...
@@ -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)
...
...
test/infinicore/ops/triplet_margin_loss.py
View file @
61a7dc0e
...
...
@@ -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')
...
...
test/infinicore/ops/triplet_margin_with_distance_loss.py
View file @
61a7dc0e
...
...
@@ -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')
...
...
test/infinicore/ops/trunc.py
View file @
61a7dc0e
...
...
@@ -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
=
[
...
...
test/infinicore/ops/unfold.py
View file @
61a7dc0e
...
...
@@ -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.
...
...
test/infinicore/ops/unique.py
View file @
61a7dc0e
...
...
@@ -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
...
...
Prev
1
…
9
10
11
12
13
14
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment