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
0017fa0b
Commit
0017fa0b
authored
Dec 17, 2025
by
wooway777
Browse files
issue/792 - add moore threads device sync to tests
parent
726eacf8
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
6 deletions
+32
-6
test/infinicore/framework/utils.py
test/infinicore/framework/utils.py
+2
-0
test/infiniop/libinfiniop/utils.py
test/infiniop/libinfiniop/utils.py
+30
-6
No files found.
test/infinicore/framework/utils.py
View file @
0017fa0b
...
...
@@ -13,6 +13,8 @@ def synchronize_device(torch_device):
torch
.
npu
.
synchronize
()
elif
torch_device
==
"mlu"
:
torch
.
mlu
.
synchronize
()
elif
torch_device
==
"musa"
:
torch
.
musa
.
synchronize
()
def
debug
(
actual
,
desired
,
atol
=
0
,
rtol
=
1e-2
,
equal_nan
=
False
,
verbose
=
True
):
...
...
test/infiniop/libinfiniop/utils.py
View file @
0017fa0b
...
...
@@ -71,17 +71,32 @@ class TestTensor(CTensor):
torch_shape
.
append
(
shape
[
i
])
if
mode
==
"random"
:
# For integer types, use randint instead of rand
if
dt
in
[
InfiniDtype
.
I8
,
InfiniDtype
.
I16
,
InfiniDtype
.
I32
,
InfiniDtype
.
I64
,
InfiniDtype
.
U8
,
InfiniDtype
.
U16
,
InfiniDtype
.
U32
,
InfiniDtype
.
U64
,
InfiniDtype
.
BYTE
,
InfiniDtype
.
BOOL
]:
if
dt
in
[
InfiniDtype
.
I8
,
InfiniDtype
.
I16
,
InfiniDtype
.
I32
,
InfiniDtype
.
I64
,
InfiniDtype
.
U8
,
InfiniDtype
.
U16
,
InfiniDtype
.
U32
,
InfiniDtype
.
U64
,
InfiniDtype
.
BYTE
,
InfiniDtype
.
BOOL
,
]:
randint_low
=
-
2000000000
if
randint_low
is
None
else
randint_low
randint_high
=
2000000000
if
randint_high
is
None
else
randint_high
self
.
_torch_tensor
=
torch
.
randint
(
randint_low
,
randint_high
,
torch_shape
,
dtype
=
to_torch_dtype
(
dt
),
device
=
torch_device_map
[
device
]
randint_low
,
randint_high
,
torch_shape
,
dtype
=
to_torch_dtype
(
dt
),
device
=
torch_device_map
[
device
],
)
else
:
self
.
_torch_tensor
=
torch
.
rand
(
torch_shape
,
dtype
=
to_torch_dtype
(
dt
),
device
=
torch_device_map
[
device
]
torch_shape
,
dtype
=
to_torch_dtype
(
dt
),
device
=
torch_device_map
[
device
],
)
elif
mode
==
"zeros"
:
self
.
_torch_tensor
=
torch
.
zeros
(
...
...
@@ -431,6 +446,8 @@ def synchronize_device(torch_device):
torch
.
npu
.
synchronize
()
elif
torch_device
==
"mlu"
:
torch
.
mlu
.
synchronize
()
elif
torch_device
==
"musa"
:
torch
.
musa
.
synchronize
()
def
debug
(
actual
,
desired
,
atol
=
0
,
rtol
=
1e-2
,
equal_nan
=
False
,
verbose
=
True
):
...
...
@@ -463,7 +480,14 @@ def debug(actual, desired, atol=0, rtol=1e-2, equal_nan=False, verbose=True):
def
filter_tensor_dtypes_by_device
(
device
,
tensor_dtypes
):
if
device
in
(
InfiniDeviceEnum
.
CPU
,
InfiniDeviceEnum
.
NVIDIA
,
InfiniDeviceEnum
.
METAX
,
InfiniDeviceEnum
.
ASCEND
,
InfiniDeviceEnum
.
ILUVATAR
,
InfiniDeviceEnum
.
CAMBRICON
):
if
device
in
(
InfiniDeviceEnum
.
CPU
,
InfiniDeviceEnum
.
NVIDIA
,
InfiniDeviceEnum
.
METAX
,
InfiniDeviceEnum
.
ASCEND
,
InfiniDeviceEnum
.
ILUVATAR
,
InfiniDeviceEnum
.
CAMBRICON
,
):
return
tensor_dtypes
else
:
# 过滤掉 torch.bfloat16
...
...
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