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
101e3e08
Commit
101e3e08
authored
Oct 22, 2019
by
Jon Soifer
Committed by
Zhi
Oct 22, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Relay][Frontend][TF] Fix Size operator (#4175)
* [Relay][Frontend][TF] Fix Size operator * Uncomment tests
parent
ecb0a7ea
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
7 deletions
+17
-7
python/tvm/relay/frontend/common.py
+1
-1
python/tvm/relay/frontend/tensorflow.py
+8
-1
tests/python/frontend/tensorflow/test_forward.py
+8
-5
No files found.
python/tvm/relay/frontend/common.py
View file @
101e3e08
...
...
@@ -259,7 +259,7 @@ def get_relay_op(op_name):
op
=
None
else
:
# try search op in various modules
for
candidate
in
(
_op
,
_op
.
nn
,
_op
.
image
,
_op
.
vision
):
for
candidate
in
(
_op
,
_op
.
nn
,
_op
.
image
,
_op
.
vision
,
_op
.
contrib
):
op
=
getattr
(
candidate
,
op_name
,
None
)
if
op
is
not
None
:
break
...
...
python/tvm/relay/frontend/tensorflow.py
View file @
101e3e08
...
...
@@ -1305,6 +1305,13 @@ def _squared_difference():
return
_op
.
multiply
(
difference
,
difference
)
return
_impl
def
_size
():
def
_impl
(
inputs
,
attr
,
params
):
new_attr
=
attr
new_attr
[
'out_type'
]
=
attr
[
'out_type'
]
.
name
return
AttrCvt
(
'ndarray_size'
,
transforms
=
{
'out_type'
:
'dtype'
})(
inputs
,
new_attr
)
return
_impl
# compatible operators that do NOT require any conversion.
_identity_list
=
[]
...
...
@@ -1410,7 +1417,7 @@ _convert_map = {
'Shape'
:
_shape
(),
'Sigmoid'
:
AttrCvt
(
'sigmoid'
),
'Sign'
:
AttrCvt
(
'sign'
),
'Size'
:
AttrCvt
(
'ndarray_size'
),
'Size'
:
_size
(
),
'Slice'
:
_slice
(),
'Softmax'
:
_softmax
(),
'Softplus'
:
_softplus
(),
...
...
tests/python/frontend/tensorflow/test_forward.py
View file @
101e3e08
...
...
@@ -2184,15 +2184,18 @@ def test_forward_mean():
def
test_forward_size
():
def
check_size
(
ishape
):
np_input
=
np
.
random
.
uniform
(
size
=
ishape
)
.
astype
(
np
.
float32
)
# if all dimensions are constant, TF will optimize away size operator into constant
tf_input_shape
=
list
(
np_input
.
shape
)
tf_input_shape
[
0
]
=
None
with
tf
.
Graph
()
.
as_default
():
input
=
tf
.
placeholder
(
shape
=
np_input
.
shape
,
dtype
=
np_input
.
dtype
,
name
=
'input'
)
input
=
tf
.
placeholder
(
shape
=
tf_input_
shape
,
dtype
=
np_input
.
dtype
,
name
=
'input'
)
tf
.
size
(
input
,
name
=
'size'
)
compare_tf_with_tvm
([
np_input
],
[
'input:0'
],
'size:0'
)
if
tf
.
__version__
<
LooseVersion
(
'1.1'
):
check_size
((
10
,
8
,
16
,
32
))
check_size
((
10
,))
check_size
(())
check_size
((
10
,
8
,
16
,
32
))
check_size
((
10
,))
#######################################################################
# All, Max, Min
...
...
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