Skip to content
Snippets Groups Projects
Commit 378b347a authored by Bhatu's avatar Bhatu
Browse files

Add support for ":0" indexing of nodes in graphdef

Sometimes the generated graph defs specify the 0'th output explicitly.
Example:
node {
  name: "abc"
  input: "Placeholder_1:0"
}
node {
  name: "Placeholder_1"
  op: "Placeholder"
}
Node abc specifies that it wants the 0th output of the Placeholder_1 node.
However in single output nodes, the tensor name is same as node name. So
Placeholder_1:0 tensor cannot be found. The same is also true for the 0th output
of multiple output nodes (output tensor names will be node_name,node_name:1,..)

So while parsing the graph def we strip away any ":0" from the input names.
parent 97fb6ce3
No related branches found
No related tags found
No related merge requests found
......@@ -579,7 +579,12 @@ class Node:
self.__op = tokens[1][1:-1]
elif (curToken == "input:"):
if (errIfTokensNotMinLen(tokens, 2, cnt, "node")): return (False, cnt)
self.__inputs.append(tokens[1][1:-1])
input_name = tokens[1][1:-1]
# Sometimes graph defs generated specify 0'th output explicitly whereas the node names do not
# contain that. So we strip it
if input_name.endswith(":0"):
input_name = input_name[:-2]
self.__inputs.append(input_name)
elif (curToken == "attr"):
(noParseError, cnt) = self.readAttrFromFilePointer(fileP, cnt)
if (not(noParseError)):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment