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
32bd2f82
Commit
32bd2f82
authored
Dec 23, 2025
by
baominghelly
Browse files
Issue/787 - class/method rename && move structs code to results file
parent
515b92fb
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
87 additions
and
92 deletions
+87
-92
test/infinicore/framework/__init__.py
test/infinicore/framework/__init__.py
+3
-4
test/infinicore/framework/base.py
test/infinicore/framework/base.py
+1
-1
test/infinicore/framework/executor.py
test/infinicore/framework/executor.py
+3
-5
test/infinicore/framework/results.py
test/infinicore/framework/results.py
+61
-3
test/infinicore/framework/runner.py
test/infinicore/framework/runner.py
+1
-1
test/infinicore/framework/structs.py
test/infinicore/framework/structs.py
+0
-62
test/infinicore/framework/utils/json_utils.py
test/infinicore/framework/utils/json_utils.py
+8
-8
test/infinicore/ops/adaptive_max_pool2d.py
test/infinicore/ops/adaptive_max_pool2d.py
+1
-0
test/infinicore/ops/embedding.py
test/infinicore/ops/embedding.py
+1
-1
test/infinicore/ops/random_sample.py
test/infinicore/ops/random_sample.py
+2
-2
test/infinicore/ops/sort.py
test/infinicore/ops/sort.py
+1
-0
test/infinicore/ops/std.py
test/infinicore/ops/std.py
+1
-0
test/infinicore/run.py
test/infinicore/run.py
+4
-5
No files found.
test/infinicore/framework/__init__.py
View file @
32bd2f82
...
...
@@ -9,11 +9,10 @@ from .config import (
)
from
.datatypes
import
to_torch_dtype
,
to_infinicore_dtype
from
.devices
import
InfiniDeviceEnum
,
InfiniDeviceNames
,
torch_device_map
from
.results
import
TestTiming
,
OperatorResult
,
CaseResult
,
TestSummary
from
.runner
import
GenericTestRunner
from
.tensor
import
TensorSpec
,
TensorInitializer
from
.structs
import
TestTiming
,
OperatorResult
,
CaseResult
from
.summary
import
TestSummary
from
.driver
import
TestDriver
from
.executor
import
TestExecutor
from
.utils.compare_utils
import
(
compare_results
,
create_test_comparator
,
...
...
@@ -44,7 +43,7 @@ __all__ = [
"TensorSpec"
,
"TestCase"
,
"TestConfig"
,
"Test
Drive
r"
,
"Test
Executo
r"
,
"TestSummary"
,
"TestRunner"
,
"TestTiming"
,
...
...
test/infinicore/framework/base.py
View file @
32bd2f82
...
...
@@ -8,7 +8,7 @@ import infinicore
import
traceback
from
abc
import
ABC
,
abstractmethod
from
.
struc
ts
import
CaseResult
from
.
resul
ts
import
CaseResult
from
.datatypes
import
to_torch_dtype
,
to_infinicore_dtype
from
.devices
import
InfiniDeviceNames
,
torch_device_map
from
.tensor
import
TensorSpec
,
TensorInitializer
...
...
test/infinicore/framework/
drive
r.py
→
test/infinicore/framework/
executo
r.py
View file @
32bd2f82
...
...
@@ -2,8 +2,7 @@ import sys
import
importlib.util
from
io
import
StringIO
from
contextlib
import
contextmanager
from
.structs
import
OperatorResult
from
.summary
import
TestSummary
from
.results
import
OperatorResult
,
TestSummary
@
contextmanager
...
...
@@ -18,8 +17,8 @@ def capture_output():
sys
.
stdout
,
sys
.
stderr
=
old_out
,
old_err
class
Test
Drive
r
:
def
driv
e
(
self
,
file_path
)
->
OperatorResult
:
class
Test
Executo
r
:
def
execut
e
(
self
,
file_path
)
->
OperatorResult
:
result
=
OperatorResult
(
name
=
file_path
.
stem
)
try
:
...
...
@@ -53,7 +52,6 @@ class TestDriver:
test_summary
=
TestSummary
()
test_summary
.
process_operator_result
(
result
,
test_results
)
# test_summary._extract_timing(result, test_results)
except
Exception
as
e
:
result
.
success
=
False
...
...
test/infinicore/framework/
summary
.py
→
test/infinicore/framework/
results
.py
View file @
32bd2f82
from
typing
import
List
,
Dict
,
Any
from
dataclasses
import
is_dataclass
from
dataclasses
import
dataclass
,
is_dataclass
,
field
from
.devices
import
InfiniDeviceEnum
from
.
base
import
TensorSpec
from
.
tensor
import
TensorSpec
from
.utils.json_utils
import
save_json_report
@
dataclass
class
CaseResult
:
"""Test case result data structure"""
success
:
bool
return_code
:
int
# 0: success, -1: failure, -2: skipped, -3: partial
torch_host_time
:
float
=
0.0
torch_device_time
:
float
=
0.0
infini_host_time
:
float
=
0.0
infini_device_time
:
float
=
0.0
error_message
:
str
=
""
test_case
:
Any
=
None
device
:
Any
=
None
@
dataclass
class
TestTiming
:
"""Stores performance timing metrics."""
torch_host
:
float
=
0.0
torch_device
:
float
=
0.0
infini_host
:
float
=
0.0
infini_device
:
float
=
0.0
# Added field to support the logic in your print_summary
operators_tested
:
int
=
0
@
dataclass
class
OperatorResult
:
"""Stores the execution results of a single operator."""
name
:
str
success
:
bool
=
False
return_code
:
int
=
-
1
error_message
:
str
=
""
stdout
:
str
=
""
stderr
:
str
=
""
timing
:
TestTiming
=
field
(
default_factory
=
TestTiming
)
@
property
def
status_icon
(
self
):
if
self
.
return_code
==
0
:
return
"✅"
if
self
.
return_code
==
-
2
:
return
"⏭️"
if
self
.
return_code
==
-
3
:
return
"⚠️"
return
"❌"
@
property
def
status_text
(
self
):
if
self
.
return_code
==
0
:
return
"PASSED"
if
self
.
return_code
==
-
2
:
return
"SKIPPED"
if
self
.
return_code
==
-
3
:
return
"PARTIAL"
return
"FAILED"
class
TestSummary
:
"""
Test
s
ummary:
Test
S
ummary
class
:
1. Aggregates results (Timing & Status calculation).
2. Handles Console Output (Live & Summary).
3. Handles File Reporting (Data Preparation).
...
...
test/infinicore/framework/runner.py
View file @
32bd2f82
...
...
@@ -7,7 +7,7 @@ import os
import
inspect
import
re
from
.
import
TestConfig
,
TestRunner
,
get_args
,
get_test_devices
from
.
summary
import
TestSummary
from
.
results
import
TestSummary
class
GenericTestRunner
:
...
...
test/infinicore/framework/structs.py
deleted
100644 → 0
View file @
515b92fb
from
dataclasses
import
dataclass
,
field
from
typing
import
Any
@
dataclass
class
CaseResult
:
"""Test case result data structure"""
success
:
bool
return_code
:
int
# 0: success, -1: failure, -2: skipped, -3: partial
torch_host_time
:
float
=
0.0
torch_device_time
:
float
=
0.0
infini_host_time
:
float
=
0.0
infini_device_time
:
float
=
0.0
error_message
:
str
=
""
test_case
:
Any
=
None
device
:
Any
=
None
@
dataclass
class
TestTiming
:
"""Stores performance timing metrics."""
torch_host
:
float
=
0.0
torch_device
:
float
=
0.0
infini_host
:
float
=
0.0
infini_device
:
float
=
0.0
# Added field to support the logic in your print_summary
operators_tested
:
int
=
0
@
dataclass
class
OperatorResult
:
"""Stores the execution results of a single operator."""
name
:
str
success
:
bool
=
False
return_code
:
int
=
-
1
error_message
:
str
=
""
stdout
:
str
=
""
stderr
:
str
=
""
timing
:
TestTiming
=
field
(
default_factory
=
TestTiming
)
@
property
def
status_icon
(
self
):
if
self
.
return_code
==
0
:
return
"✅"
if
self
.
return_code
==
-
2
:
return
"⏭️"
if
self
.
return_code
==
-
3
:
return
"⚠️"
return
"❌"
@
property
def
status_text
(
self
):
if
self
.
return_code
==
0
:
return
"PASSED"
if
self
.
return_code
==
-
2
:
return
"SKIPPED"
if
self
.
return_code
==
-
3
:
return
"PARTIAL"
return
"FAILED"
test/infinicore/framework/utils/json_utils.py
View file @
32bd2f82
...
...
@@ -19,7 +19,7 @@ def save_json_report(save_path, total_results):
print
(
f
"💾 Saving to:
{
final_path
}
"
)
# Helper for JSON stringify to avoid repetition
def
_
j
(
obj
):
def
_
to_json
(
obj
):
return
json
.
dumps
(
obj
,
ensure_ascii
=
False
)
try
:
...
...
@@ -58,16 +58,16 @@ def save_json_report(save_path, total_results):
)
if
c_key
in
[
"kwargs"
,
"inputs"
]:
_write_
smart_
field
(
_write_field
(
f
,
c_key
,
c_val
,
I16
,
I20
,
close_comma
=
c_comma
)
else
:
f
.
write
(
f
'
{
I16
}
"
{
c_key
}
":
{
_
j
(
c_val
)
}{
c_comma
}
\n
'
)
f
.
write
(
f
'
{
I16
}
"
{
c_key
}
":
{
_
to_json
(
c_val
)
}{
c_comma
}
\n
'
)
# Handle trailing comparison/tolerance fields uniformly
if
"comparison_target"
in
case_item
:
cmp
=
_
j
(
case_item
.
get
(
"comparison_target"
))
tol
=
_
j
(
case_item
.
get
(
"tolerance"
))
cmp
=
_
to_json
(
case_item
.
get
(
"comparison_target"
))
tol
=
_
to_json
(
case_item
.
get
(
"tolerance"
))
f
.
write
(
f
'
{
I16
}
"comparison_target":
{
cmp
}
, "tolerance":
{
tol
}
\n
'
)
...
...
@@ -77,7 +77,7 @@ def save_json_report(save_path, total_results):
f
.
write
(
f
"
{
I8
}
]
{
comma
}
\n
"
)
else
:
# Standard top-level fields
f
.
write
(
f
"
{
I8
}{
_
j
(
key
)
}
:
{
_
j
(
val
)
}{
comma
}
\n
"
)
f
.
write
(
f
"
{
I8
}{
_
to_json
(
key
)
}
:
{
_
to_json
(
val
)
}{
comma
}
\n
"
)
close_entry
=
"},"
if
i
<
len
(
total_results
)
-
1
else
"}"
f
.
write
(
f
"
{
I4
}{
close_entry
}
\n
"
)
...
...
@@ -90,9 +90,9 @@ def save_json_report(save_path, total_results):
print
(
f
" ❌ Save failed:
{
e
}
"
)
def
_write_
smart_
field
(
f
,
key
,
value
,
indent
,
sub_indent
,
close_comma
=
""
):
def
_write_field
(
f
,
key
,
value
,
indent
,
sub_indent
,
close_comma
=
""
):
"""
Internal Helper: Write a JSON field with
smart
wrapping.
Internal Helper: Write a JSON field with wrapping.
"""
# 1. Try Compact Mode
compact_json
=
json
.
dumps
(
value
,
ensure_ascii
=
False
)
...
...
test/infinicore/ops/adaptive_max_pool2d.py
View file @
32bd2f82
...
...
@@ -7,6 +7,7 @@ import torch
import
infinicore
from
framework
import
(
BaseOperatorTest
,
CaseResult
,
TensorSpec
,
TestCase
,
GenericTestRunner
,
...
...
test/infinicore/ops/embedding.py
View file @
32bd2f82
...
...
@@ -6,7 +6,7 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
import
torch
from
framework
import
BaseOperatorTest
,
TensorSpec
,
TestCase
,
GenericTestRunner
from
framework.tensor
import
TensorInitializer
from
framework.utils
import
(
from
framework.utils
.tensor_utils
import
(
convert_infinicore_to_torch
,
infinicore_tensor_from_torch
,
to_torch_dtype
,
...
...
test/infinicore/ops/random_sample.py
View file @
32bd2f82
...
...
@@ -222,8 +222,8 @@ class OpTest(BaseOperatorTest):
# Re-run operations with the same logits to get results for comparison
# prepare_pytorch_inputs_and_kwargs will reuse self._current_logits if it exists
from
framework.
base
import
CaseResult
from
framework.utils
import
(
from
framework.
results
import
CaseResult
from
framework.utils
.tensor_utils
import
(
convert_infinicore_to_torch
,
infinicore_tensor_from_torch
,
)
...
...
test/infinicore/ops/sort.py
View file @
32bd2f82
...
...
@@ -7,6 +7,7 @@ import torch
import
infinicore
from
framework
import
(
BaseOperatorTest
,
CaseResult
,
TensorSpec
,
TestCase
,
GenericTestRunner
,
...
...
test/infinicore/ops/std.py
View file @
32bd2f82
...
...
@@ -7,6 +7,7 @@ import torch
import
infinicore
from
framework
import
(
BaseOperatorTest
,
CaseResult
,
TensorSpec
,
TestCase
,
GenericTestRunner
,
...
...
test/infinicore/run.py
View file @
32bd2f82
...
...
@@ -3,9 +3,8 @@ import argparse
from
pathlib
import
Path
# Import components from the unified framework package
from
framework.driver
import
TestDriver
from
framework.summary
import
TestSummary
from
framework.structs
import
TestTiming
from
framework.executor
import
TestExecutor
from
framework.results
import
TestSummary
,
TestTiming
from
framework
import
get_hardware_args_group
,
add_common_test_args
...
...
@@ -235,7 +234,7 @@ def main():
sys
.
exit
(
0
)
# 2. Preparation
drive
r
=
Test
Drive
r
()
executo
r
=
Test
Executo
r
()
cumulative_timing
=
TestTiming
()
test_summary
=
TestSummary
(
args
.
verbose
,
args
.
bench
)
results
=
[]
...
...
@@ -244,7 +243,7 @@ def main():
# 3. Execution Loop
for
f
in
test_files
:
result
=
driver
.
driv
e
(
f
)
result
=
executor
.
execut
e
(
f
)
results
.
append
(
result
)
# Real-time reporting and printing of stdout
...
...
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