Skip to content

Commit

Permalink
[NNVM] TF, Prefer Placeholders to Consts when processing inputs
Browse files Browse the repository at this point in the history
This patch disable setting first Const as input if there are some
Placeholders in Graph. It allows to parse some real-world models
generated by e.g. `tf.simple_save` in cases when Placeholders were
inserted _after_ Constants.
  • Loading branch information
Sergey Mironov committed Aug 2, 2018
1 parent 5077367 commit d50bf27
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions nnvm/python/nnvm/frontend/tensorflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -888,10 +888,11 @@ def _parse_import_prerequisites(graph):
b. Set of operator names which don't have their mapping in TVM, i.e.
which are not supported
"""
placeholders = []
missing_operators = set()
for node in graph.node:
if node.op == "Placeholder":
pass
placeholders.append(node)
elif node.op == "Const":
pass
else:
Expand All @@ -900,7 +901,7 @@ def _parse_import_prerequisites(graph):
else:
missing_operators.add(node.op)

return missing_operators
return (placeholders,missing_operators)


class GraphProto(object):
Expand Down Expand Up @@ -955,7 +956,7 @@ def from_tensorflow(self, graph):
raise ImportError(
"Unable to import tensorflow which is required {}".format(e))

missing_operators = _parse_import_prerequisites(graph)
placeholders,missing_operators = _parse_import_prerequisites(graph)

if missing_operators:
raise NotImplementedError( \
Expand All @@ -981,7 +982,7 @@ def from_tensorflow(self, graph):
raise NotImplementedError( \
"Please freeze the graph with add_shapes=True")
elif node.op == "Const":
if self._input_node == '':
if self._input_node == '' and not placeholders:
self._input_node = node.name
self._num_input += 1
self._nodes[node.name] = _sym.Variable(name=node.name)
Expand Down

0 comments on commit d50bf27

Please sign in to comment.