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
c87a2ef4
Commit
c87a2ef4
authored
Nov 22, 2025
by
zhuyue
Browse files
Issue/658: Skip non-contiguous tensor tests on Moore platform
parent
314d4a65
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
85 additions
and
3 deletions
+85
-3
test/infinicore/ops/adaptive_max_pool2d.py
test/infinicore/ops/adaptive_max_pool2d.py
+19
-1
test/infinicore/ops/sort.py
test/infinicore/ops/sort.py
+33
-1
test/infinicore/ops/std.py
test/infinicore/ops/std.py
+33
-1
No files found.
test/infinicore/ops/adaptive_max_pool2d.py
View file @
c87a2ef4
...
...
@@ -5,9 +5,10 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
import
torch
import
infinicore
from
framework.base
import
BaseOperatorTest
,
TensorSpec
,
TestCase
from
framework.base
import
BaseOperatorTest
,
TensorSpec
,
TestCase
,
TestResult
from
framework.runner
import
GenericTestRunner
from
framework.utils
import
is_broadcast
from
framework.devices
import
InfiniDeviceEnum
# Test cases format: (in_shape, in_strides_or_None, output_size_or_None)
...
...
@@ -63,6 +64,23 @@ class OpTest(BaseOperatorTest):
def
torch_operator
(
self
,
*
args
,
**
kwargs
):
return
torch
.
nn
.
functional
.
adaptive_max_pool2d
(
*
args
,
**
kwargs
)
def
run_test
(
self
,
device
,
test_case
,
config
):
"""Skip non-contiguous tensor tests on Moore platform (muDNN only supports contiguous tensors for pooling operations)."""
if
device
==
InfiniDeviceEnum
.
MOORE
:
if
(
test_case
.
inputs
and
isinstance
(
test_case
.
inputs
[
0
],
TensorSpec
)
and
test_case
.
inputs
[
0
].
strides
is
not
None
):
return
TestResult
(
success
=
False
,
return_code
=-
2
,
test_case
=
test_case
,
device
=
device
,
error_message
=
"muDNN only supports contiguous tensors for pooling operations"
,
)
return
super
().
run_test
(
device
,
test_case
,
config
)
# def infinicore_operator(self, *args, **kwargs):
# """InfiniCore implementation (operator not yet available)."""
# return infinicore.nn.functional.adaptive_max_pool2d(*args, **kwargs)
...
...
test/infinicore/ops/sort.py
View file @
c87a2ef4
...
...
@@ -5,9 +5,10 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
import
torch
import
infinicore
from
framework.base
import
BaseOperatorTest
,
TensorSpec
,
TestCase
from
framework.base
import
BaseOperatorTest
,
TensorSpec
,
TestCase
,
TestResult
from
framework.runner
import
GenericTestRunner
from
framework.utils
import
is_broadcast
from
framework.devices
import
InfiniDeviceEnum
# ==============================================================================
# Operator-specific configuration for sort
...
...
@@ -166,6 +167,37 @@ class OpTest(BaseOperatorTest):
# forward to torch.sort; stable kwarg included for compatibility
return
torch
.
sort
(
x
,
dim
=
dim
,
descending
=
descending
,
stable
=
stable
,
out
=
out
)
def
run_test
(
self
,
device
,
test_case
,
config
):
"""Skip non-contiguous tensor tests on Moore platform (muDNN Sort only supports contiguous tensors)."""
if
device
==
InfiniDeviceEnum
.
MOORE
:
# Check input tensor
if
(
test_case
.
inputs
and
isinstance
(
test_case
.
inputs
[
0
],
TensorSpec
)
and
test_case
.
inputs
[
0
].
strides
is
not
None
):
return
TestResult
(
success
=
False
,
return_code
=-
2
,
test_case
=
test_case
,
device
=
device
,
error_message
=
"muDNN Sort only supports contiguous tensors"
,
)
# Check output tensors (values and indices)
output_specs
=
getattr
(
test_case
,
"output_specs"
,
None
)
or
(
[
test_case
.
output_spec
]
if
test_case
.
output_spec
else
[]
)
for
spec
in
output_specs
:
if
isinstance
(
spec
,
TensorSpec
)
and
spec
.
strides
is
not
None
:
return
TestResult
(
success
=
False
,
return_code
=-
2
,
test_case
=
test_case
,
device
=
device
,
error_message
=
"muDNN Sort only supports contiguous tensors"
,
)
return
super
().
run_test
(
device
,
test_case
,
config
)
# def infinicore_operator(self, x, dim=-1, descending=False, stable=False, out=None, **kwargs):
# # assume infinicore provides a similar API
# return infinicore.sort(x, dim=dim, descending=descending, stable=stable, out=out)
...
...
test/infinicore/ops/std.py
View file @
c87a2ef4
...
...
@@ -5,9 +5,10 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
import
torch
import
infinicore
from
framework.base
import
BaseOperatorTest
,
TensorSpec
,
TestCase
from
framework.base
import
BaseOperatorTest
,
TensorSpec
,
TestCase
,
TestResult
from
framework.runner
import
GenericTestRunner
from
framework.utils
import
is_broadcast
from
framework.devices
import
InfiniDeviceEnum
# Test cases format:
# (in_shape, in_strides_or_None, dim_or_None, correction_or_None, keepdim_or_None, out_strides_or_None)
...
...
@@ -108,6 +109,37 @@ class OpTest(BaseOperatorTest):
def
torch_operator
(
self
,
*
args
,
**
kwargs
):
return
torch
.
std
(
*
args
,
**
kwargs
)
def
run_test
(
self
,
device
,
test_case
,
config
):
"""Skip non-contiguous tensor tests on Moore platform (muDNN VARIANCE & STD only support contiguous tensors)."""
if
device
==
InfiniDeviceEnum
.
MOORE
:
# Check input tensor
if
(
test_case
.
inputs
and
isinstance
(
test_case
.
inputs
[
0
],
TensorSpec
)
and
test_case
.
inputs
[
0
].
strides
is
not
None
):
return
TestResult
(
success
=
False
,
return_code
=-
2
,
test_case
=
test_case
,
device
=
device
,
error_message
=
"muDNN VARIANCE & STD only support contiguous tensors"
,
)
# Check output tensor
if
(
test_case
.
output_spec
and
isinstance
(
test_case
.
output_spec
,
TensorSpec
)
and
test_case
.
output_spec
.
strides
is
not
None
):
return
TestResult
(
success
=
False
,
return_code
=-
2
,
test_case
=
test_case
,
device
=
device
,
error_message
=
"muDNN VARIANCE & STD only support contiguous tensors"
,
)
return
super
().
run_test
(
device
,
test_case
,
config
)
# def infinicore_operator(self, *args, **kwargs):
# """InfiniCore implementation (operator not yet available)."""
# return infinicore.std(*args, **kwargs)
...
...
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