Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tic
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wenyuanbo
tic
Commits
07606e4c
Commit
07606e4c
authored
Oct 26, 2019
by
Jon Soifer
Committed by
Jared Roesch
Oct 26, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Relay][Frontend][ONNX] Add support for op Where (#4184)
* Add support for op Where * Update impl version
parent
9cc78741
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
1 deletions
+36
-1
python/tvm/relay/frontend/onnx.py
+9
-1
tests/python/frontend/onnx/test_forward.py
+27
-0
No files found.
python/tvm/relay/frontend/onnx.py
View file @
07606e4c
...
...
@@ -922,6 +922,13 @@ class Erf(OnnxOpConverter):
def
_impl_v1
(
cls
,
inputs
,
attr
,
params
):
return
_op
.
erf
(
inputs
[
0
])
class
Where
(
OnnxOpConverter
):
"""Operator converter for Where
"""
@classmethod
def
_impl_v9
(
cls
,
inputs
,
attr
,
params
):
return
_op
.
where
(
inputs
[
0
],
inputs
[
1
],
inputs
[
2
])
# compatible operators that do NOT require any conversion.
_identity_list
=
[]
...
...
@@ -1042,7 +1049,8 @@ def _get_convert_map(opset):
'Not'
:
Not
.
get_converter
(
opset
),
'And'
:
And
.
get_converter
(
opset
),
'Tile'
:
Tile
.
get_converter
(
opset
),
'Erf'
:
Erf
.
get_converter
(
opset
)
'Erf'
:
Erf
.
get_converter
(
opset
),
'Where'
:
Where
.
get_converter
(
opset
)
}
...
...
tests/python/frontend/onnx/test_forward.py
View file @
07606e4c
...
...
@@ -1299,6 +1299,32 @@ def test_erf():
z
=
scipy
.
special
.
erf
(
x
)
verify_erf
(
x
,
z
)
def
verify_where
(
condition
,
x
,
y
,
dtype
,
outdata
):
node
=
helper
.
make_node
(
'Where'
,
inputs
=
[
'condition'
,
'x'
,
'y'
],
outputs
=
[
'out'
])
graph
=
helper
.
make_graph
([
node
],
'where_test'
,
inputs
=
[
helper
.
make_tensor_value_info
(
'condition'
,
TensorProto
.
BOOL
,
list
(
condition
.
shape
)),
helper
.
make_tensor_value_info
(
'x'
,
dtype
,
list
(
x
.
shape
)),
helper
.
make_tensor_value_info
(
'y'
,
dtype
,
list
(
y
.
shape
))],
outputs
=
[
helper
.
make_tensor_value_info
(
'out'
,
dtype
,
list
(
outdata
.
shape
))])
model
=
helper
.
make_model
(
graph
,
producer_name
=
'where_test'
)
for
target
,
ctx
in
ctx_list
():
tvm_out
=
get_tvm_output
(
model
,
[
condition
,
x
,
y
],
target
,
ctx
,
outdata
.
shape
)
tvm
.
testing
.
assert_allclose
(
outdata
,
tvm_out
)
def
test_where
():
condition
=
np
.
array
([[
1
,
0
],
[
1
,
1
]],
dtype
=
np
.
bool
)
x
=
np
.
array
([[
1
,
2
],
[
3
,
4
]],
dtype
=
np
.
int64
)
y
=
np
.
array
([[
9
,
8
],
[
7
,
6
]],
dtype
=
np
.
int64
)
outdata
=
np
.
where
(
condition
,
x
,
y
)
verify_where
(
condition
,
x
,
y
,
TensorProto
.
INT64
,
outdata
)
x
=
np
.
array
([[
1
,
2
],
[
3
,
4
]],
dtype
=
np
.
float32
)
y
=
np
.
array
([[
9
,
8
],
[
7
,
6
]],
dtype
=
np
.
float32
)
outdata
=
np
.
where
(
condition
,
x
,
y
)
verify_where
(
condition
,
x
,
y
,
TensorProto
.
FLOAT
,
outdata
)
if
__name__
==
'__main__'
:
test_flatten
()
...
...
@@ -1347,3 +1373,4 @@ if __name__ == '__main__':
test_and
()
test_tile
()
test_erf
()
test_where
()
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