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
c38f2f39
Unverified
Commit
c38f2f39
authored
Mar 30, 2020
by
lfengad
Committed by
GitHub
Mar 30, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for sharing params of operators in tensorflow frontend (#5042)
parent
3bab699d
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
1 deletions
+19
-1
python/tvm/relay/frontend/tensorflow.py
+1
-1
tests/python/frontend/tensorflow/test_forward.py
+18
-0
No files found.
python/tvm/relay/frontend/tensorflow.py
View file @
c38f2f39
...
...
@@ -81,7 +81,7 @@ def _dimension_constraint():
def
_get_param
(
params
,
input_node
):
if
isinstance
(
input_node
,
_expr
.
Constant
):
return
np
.
atleast_1d
(
input_node
.
data
.
asnumpy
())
return
params
.
pop
(
input_node
.
name_hint
)
.
asnumpy
()
return
params
[
input_node
.
name_hint
]
.
asnumpy
()
def
_get_num_param
(
params
,
input_node
):
return
_get_param
(
params
,
input_node
)
.
item
()
...
...
tests/python/frontend/tensorflow/test_forward.py
View file @
c38f2f39
...
...
@@ -3058,6 +3058,21 @@ def test_forward_add_n():
_test_forward_add_n
(
in4
)
_test_forward_add_n
(
in5
)
#######################################################################
# Sharing params case
# ----------------------
def
test_sharing_node
():
"""Test the sharing params case."""
np_data
=
np
.
random
.
uniform
(
size
=
(
2
,
2
,
2
))
.
astype
(
'float32'
)
with
tf
.
Graph
()
.
as_default
():
in_data
=
tf
.
placeholder
(
tf
.
float32
,
shape
=
(
2
,
2
,
2
),
name
=
'in_data'
)
axis
=
tf
.
constant
([
-
1
],
dtype
=
tf
.
int32
,
name
=
'axis'
)
mean0
=
tf
.
reduce_mean
(
in_data
,
axis
=
axis
,
keepdims
=
False
,
name
=
'mean0'
)
mean1
=
tf
.
reduce_mean
(
in_data
,
axis
=
axis
,
keepdims
=
False
,
name
=
'mean1'
)
out
=
tf
.
add
(
mean0
,
mean1
,
name
=
'out'
)
compare_tf_with_tvm
([
np_data
],
[
'in_data:0'
],
'out:0'
)
#######################################################################
# Unravel Index
...
...
@@ -3311,3 +3326,6 @@ if __name__ == '__main__':
# Internal misc. ops
test_read_variable_op
()
# Sharing params case using Mean ops
test_sharing_node
()
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