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
gaoqiong
MIGraphX
Commits
031ccf5f
Commit
031ccf5f
authored
May 24, 2023
by
Alan Turner
Browse files
Formatting
parent
baac1dab
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
2 deletions
+19
-2
src/api/migraphx.py
src/api/migraphx.py
+1
-0
test/py/onnx_backend_test.py
test/py/onnx_backend_test.py
+1
-0
tools/api.py
tools/api.py
+17
-2
No files found.
src/api/migraphx.py
View file @
031ccf5f
...
...
@@ -46,6 +46,7 @@ def shape_type_wrap(p):
def
auto_handle
(
*
args
,
**
kwargs
):
def
with_handle
(
f
):
return
api
.
handle
(
'migraphx_'
+
f
.
__name__
,
'migraphx::'
+
f
.
__name__
,
*
args
,
**
kwargs
)(
f
)
...
...
test/py/onnx_backend_test.py
View file @
031ccf5f
...
...
@@ -38,6 +38,7 @@ pytest_plugins = 'onnx.backend.test.report',
class
MIGraphXBackendTest
(
onnx
.
backend
.
test
.
BackendTest
):
def
__init__
(
self
,
backend
,
parent_module
=
None
):
super
(
MIGraphXBackendTest
,
self
).
__init__
(
backend
,
parent_module
)
...
...
tools/api.py
View file @
031ccf5f
...
...
@@ -50,6 +50,7 @@ class Template(string.Template):
class
Type
:
def
__init__
(
self
,
name
:
str
)
->
None
:
self
.
name
=
name
.
strip
()
...
...
@@ -144,6 +145,7 @@ extern "C" ${error_type} ${name}(${params})
class
CFunction
:
def
__init__
(
self
,
name
:
str
)
->
None
:
self
.
name
=
name
self
.
params
:
List
[
str
]
=
[]
...
...
@@ -188,12 +190,14 @@ class CFunction:
class
BadParam
:
def
__init__
(
self
,
cond
:
str
,
msg
:
str
)
->
None
:
self
.
cond
=
cond
self
.
msg
=
msg
class
Parameter
:
def
__init__
(
self
,
name
:
str
,
type
:
str
,
...
...
@@ -250,7 +254,8 @@ class Parameter:
size
=
self
.
size_name
,
result
=
result
or
''
)
def
add_param
(
self
,
t
:
Union
[
str
,
Type
],
def
add_param
(
self
,
t
:
Union
[
str
,
Type
],
name
:
Optional
[
str
]
=
None
)
->
None
:
if
not
isinstance
(
t
,
str
):
t
=
t
.
str
()
...
...
@@ -409,6 +414,7 @@ def to_template_vars(params: List[Union[Any, Parameter]]) -> str:
class
Function
:
def
__init__
(
self
,
name
:
str
,
params
:
Optional
[
List
[
Parameter
]]
=
None
,
...
...
@@ -545,6 +551,7 @@ cpp_class_constructor_template = Template('''
class
CPPMember
:
def
__init__
(
self
,
name
:
str
,
function
:
Function
,
...
...
@@ -621,6 +628,7 @@ class CPPMember:
class
CPPClass
:
def
__init__
(
self
,
name
:
str
,
ctype
:
str
)
->
None
:
self
.
name
=
name
self
.
ctype
=
ctype
...
...
@@ -677,6 +685,7 @@ def add_function(name: str, *args, **kwargs) -> Function:
def
once
(
f
:
Callable
)
->
Any
:
@
wraps
(
f
)
def
decorated
(
*
args
,
**
kwargs
):
if
not
decorated
.
has_run
:
...
...
@@ -722,6 +731,7 @@ c_type_map: Dict[str, Type] = {}
def
cwrap
(
name
:
str
,
c_type
:
Optional
[
str
]
=
None
)
->
Callable
:
def
with_cwrap
(
f
):
type_map
[
name
]
=
f
if
c_type
:
...
...
@@ -1015,6 +1025,7 @@ def string_c_wrap(p: Parameter) -> None:
class
Handle
:
def
__init__
(
self
,
name
:
str
,
ctype
:
str
,
cpptype
:
str
,
**
kwargs
)
->
None
:
self
.
name
=
name
self
.
ctype
=
ctype
...
...
@@ -1140,6 +1151,7 @@ def generate_virtual_impl(f: Function, fname: str) -> str:
class
Interface
(
Handle
):
def
__init__
(
self
,
name
:
str
,
ctype
:
str
,
cpptype
:
str
)
->
None
:
super
().
__init__
(
name
,
ctype
,
cpptype
,
skip_def
=
True
)
self
.
ifunctions
:
List
[
Function
]
=
[]
...
...
@@ -1234,6 +1246,7 @@ def handle(ctype: str,
cpptype
:
str
,
name
:
Optional
[
str
]
=
None
,
ref
:
Optional
[
bool
]
=
None
)
->
Callable
:
def
with_handle
(
f
):
n
=
name
or
f
.
__name__
h
=
Handle
(
n
,
ctype
,
cpptype
,
ref
=
ref
)
...
...
@@ -1249,8 +1262,10 @@ def handle(ctype: str,
return
with_handle
def
interface
(
ctype
:
str
,
cpptype
:
str
,
def
interface
(
ctype
:
str
,
cpptype
:
str
,
name
:
Optional
[
str
]
=
None
)
->
Callable
:
def
with_interface
(
f
):
n
=
name
or
f
.
__name__
h
=
Interface
(
n
,
ctype
,
cpptype
)
...
...
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