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
006d530c
Commit
006d530c
authored
Jan 06, 2026
by
PanZezhong
Browse files
issue/810 static compute graph infra
parent
caa61e9e
Changes
23
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
100 additions
and
0 deletions
+100
-0
src/infinicore/utils.hpp
src/infinicore/utils.hpp
+11
-0
test/infinicore/graph/graph.py
test/infinicore/graph/graph.py
+85
-0
xmake.lua
xmake.lua
+4
-0
No files found.
src/infinicore/utils.hpp
View file @
006d530c
...
@@ -47,3 +47,14 @@ inline struct SpdlogInitializer {
...
@@ -47,3 +47,14 @@ inline struct SpdlogInitializer {
} \
} \
} \
} \
} while (0)
} while (0)
#define INFINICORE_ASSERT(CONDITION__) \
do { \
if (!(CONDITION__)) { \
SPDLOG_ERROR( \
"Assertion `{}` failed from {} at {}:{}", \
#CONDITION__, __func__, __FILE__, __LINE__); \
throw std::runtime_error( \
std::string("Assertion `") + #CONDITION__ + "` failed from " + __func__ + " at " + __FILE__ + ":" + std::to_string(__LINE__)); \
} \
} while (0)
test/infinicore/graph/graph.py
0 → 100644
View file @
006d530c
import
sys
import
os
sys
.
path
.
insert
(
0
,
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
".."
))
import
torch
import
infinicore
from
framework
import
BaseOperatorTest
,
TensorSpec
,
TestCase
,
GenericTestRunner
# Test cases format: (in_shape, proj_w_shape)
_TEST_CASES_DATA
=
[
((
32
,
4096
),
(
4096
,
4096
)),
]
_TOLERANCE_MAP
=
{
infinicore
.
float16
:
{
"atol"
:
0
,
"rtol"
:
1e-2
},
infinicore
.
float32
:
{
"atol"
:
1e-4
,
"rtol"
:
1e-3
},
infinicore
.
bfloat16
:
{
"atol"
:
0
,
"rtol"
:
5e-2
},
}
_TENSOR_DTYPES
=
[
infinicore
.
float16
,
infinicore
.
float32
,
infinicore
.
bfloat16
]
def
parse_test_cases
():
cases
=
[]
for
in_shape
,
proj_w_shape
in
_TEST_CASES_DATA
:
for
dtype
in
_TENSOR_DTYPES
:
tol
=
_TOLERANCE_MAP
[
dtype
]
in_spec
=
TensorSpec
.
from_tensor
(
in_shape
,
dtype
=
dtype
)
proj_w_spec
=
TensorSpec
.
from_tensor
(
proj_w_shape
,
dtype
=
dtype
)
temp_spec
=
TensorSpec
.
from_tensor
(
in_shape
,
dtype
=
dtype
)
# Out-of-place
cases
.
append
(
TestCase
(
inputs
=
[
in_spec
,
proj_w_spec
,
temp_spec
],
kwargs
=
{},
output_spec
=
None
,
comparison_target
=
None
,
tolerance
=
tol
,
description
=
"Graph"
,
)
)
return
cases
class
OpTest
(
BaseOperatorTest
):
"""Test Operator Graph"""
def
__init__
(
self
):
super
().
__init__
(
"Graph"
)
def
get_test_cases
(
self
):
return
parse_test_cases
()
def
torch_operator
(
self
,
*
args
,
**
kwargs
):
a
=
args
[
0
]
b
=
args
[
1
]
return
torch
.
matmul
(
a
,
b
)
def
infinicore_operator
(
self
,
*
args
,
**
kwargs
):
"""Record graph and run"""
a
=
args
[
0
]
b
=
args
[
1
]
temp_a
=
args
[
2
]
infinicore
.
start_graph_recording
()
c
=
infinicore
.
matmul
(
temp_a
,
b
)
op_graph
=
infinicore
.
stop_graph_recording
()
temp_a
.
copy_
(
a
)
op_graph
.
run
()
return
c
def
main
():
"""Main entry point"""
runner
=
GenericTestRunner
(
OpTest
)
runner
.
run_and_exit
()
if
__name__
==
"__main__"
:
main
()
xmake.lua
View file @
006d530c
...
@@ -390,6 +390,7 @@ target("infinicore_cpp_api")
...
@@ -390,6 +390,7 @@ target("infinicore_cpp_api")
add_files
(
"src/infinicore/context/*.cc"
)
add_files
(
"src/infinicore/context/*.cc"
)
add_files
(
"src/infinicore/context/*/*.cc"
)
add_files
(
"src/infinicore/context/*/*.cc"
)
add_files
(
"src/infinicore/tensor/*.cc"
)
add_files
(
"src/infinicore/tensor/*.cc"
)
add_files
(
"src/infinicore/graph/*.cc"
)
add_files
(
"src/infinicore/nn/*.cc"
)
add_files
(
"src/infinicore/nn/*.cc"
)
add_files
(
"src/infinicore/ops/*/*.cc"
)
add_files
(
"src/infinicore/ops/*/*.cc"
)
add_files
(
"src/utils/*.cc"
)
add_files
(
"src/utils/*.cc"
)
...
@@ -418,6 +419,8 @@ target("_infinicore")
...
@@ -418,6 +419,8 @@ target("_infinicore")
add_packages
(
"pybind11"
)
add_packages
(
"pybind11"
)
set_languages
(
"cxx17"
)
set_languages
(
"cxx17"
)
add_deps
(
"infinicore_cpp_api"
)
set_kind
(
"shared"
)
set_kind
(
"shared"
)
local
INFINI_ROOT
=
os.getenv
(
"INFINI_ROOT"
)
or
(
os.getenv
(
is_host
(
"windows"
)
and
"HOMEPATH"
or
"HOME"
)
..
"/.infini"
)
local
INFINI_ROOT
=
os.getenv
(
"INFINI_ROOT"
)
or
(
os.getenv
(
is_host
(
"windows"
)
and
"HOMEPATH"
or
"HOME"
)
..
"/.infini"
)
add_includedirs
(
INFINI_ROOT
..
"/include"
,
{
public
=
true
})
add_includedirs
(
INFINI_ROOT
..
"/include"
,
{
public
=
true
})
...
@@ -429,6 +432,7 @@ target("_infinicore")
...
@@ -429,6 +432,7 @@ target("_infinicore")
add_files
(
"src/infinicore/context/*.cc"
)
add_files
(
"src/infinicore/context/*.cc"
)
add_files
(
"src/infinicore/context/*/*.cc"
)
add_files
(
"src/infinicore/context/*/*.cc"
)
add_files
(
"src/infinicore/tensor/*.cc"
)
add_files
(
"src/infinicore/tensor/*.cc"
)
add_files
(
"src/infinicore/graph/*.cc"
)
add_files
(
"src/infinicore/nn/*.cc"
)
add_files
(
"src/infinicore/nn/*.cc"
)
add_files
(
"src/infinicore/ops/*/*.cc"
)
add_files
(
"src/infinicore/ops/*/*.cc"
)
add_files
(
"src/infinicore/pybind11/**.cc"
)
add_files
(
"src/infinicore/pybind11/**.cc"
)
...
...
Prev
1
2
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