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
77869913
Commit
77869913
authored
Nov 21, 2018
by
Ashutosh Parkhi
Committed by
Tianqi Chen
Nov 21, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tensorflow frontend supports user given outputs (#1913)
parent
2c231b5a
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
91 additions
and
46 deletions
+91
-46
nnvm/python/nnvm/frontend/tensorflow.py
+11
-6
nnvm/tests/python/frontend/tensorflow/test_forward.py
+80
-40
No files found.
nnvm/python/nnvm/frontend/tensorflow.py
View file @
77869913
...
...
@@ -1039,7 +1039,7 @@ class GraphProto(object):
self
.
_num_param
=
0
self
.
_num_rnn_layer
=
False
def
from_tensorflow
(
self
,
graph
,
layout
=
"NHWC"
,
shape
=
None
):
def
from_tensorflow
(
self
,
graph
,
layout
=
"NHWC"
,
shape
=
None
,
outputs
=
None
):
"""Construct nnvm nodes from tensorflow graph definition - GraphDef.
Follow the tensorflow graph definition to parse and convert it to NNVM.
...
...
@@ -1086,6 +1086,7 @@ class GraphProto(object):
raise
NotImplementedError
(
\
"The following operators are not implemented: {}"
.
format
(
missing_operators
))
final_op
=
None
# Parse the nodes to re-create TF graph using Symbol API of NNVM
for
node
in
graph
.
node
:
# Tensorflow doesn't have seperate list for params extraction.
...
...
@@ -1165,6 +1166,7 @@ class GraphProto(object):
# Assuming only one output.
self
.
_nodes
[
node
.
name
]
=
op
final_op
=
op
# Infer shapes if passed explicitely
node_output
=
self
.
_nodes
[
node
.
name
]
...
...
@@ -1175,13 +1177,16 @@ class GraphProto(object):
_
,
out_shapes
=
graph_util
.
infer_shape
(
g
,
**
shape_dict
)
self
.
_output_shapes
[
node
.
name
]
=
out_shapes
# Assume the final node is the output node
out
=
node_output
out
=
[]
if
outputs
is
None
:
out
.
append
(
final_op
)
else
:
out
=
[
self
.
_nodes
[
out_name
]
for
out_name
in
outputs
]
#Add the RNN outputs also with 'head' nodes of the nnvm graph
if
self
.
_num_rnn_layer
:
out_rnn
=
_sym
.
concatenate
(
*
self
.
_out_rnn
,
axis
=
0
)
out
=
[
out
,
out_rnn
]
out
.
append
(
out_rnn
)
if
isinstance
(
out
,
list
):
out
=
_sym
.
Group
(
out
)
...
...
@@ -1378,7 +1383,7 @@ class GraphProto(object):
return
inputs
def
from_tensorflow
(
graph
,
layout
=
"NHWC"
,
shape
=
None
):
def
from_tensorflow
(
graph
,
layout
=
"NHWC"
,
shape
=
None
,
outputs
=
None
):
""" Load tensorflow graph which is a python tensorflow graph object into nnvm graph.
The companion parameters will be handled automatically.
...
...
@@ -1396,5 +1401,5 @@ def from_tensorflow(graph, layout="NHWC", shape=None):
Dict of converted parameters stored in tvm.ndarray format
"""
g
=
GraphProto
()
sym
,
params
=
g
.
from_tensorflow
(
graph
,
layout
,
shape
)
sym
,
params
=
g
.
from_tensorflow
(
graph
,
layout
,
shape
,
outputs
)
return
sym
,
params
nnvm/tests/python/frontend/tensorflow/test_forward.py
View file @
77869913
This diff is collapsed.
Click to expand it.
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