Tensorflow frontend issue


#1

With latest master version, running tutorials compile tensorflow case, python from_tensorflow.py lead to TypeError: ‘TensorShapeProto’ object is not iterable


#2

This issue is related to commit https://github.com/dmlc/tvm/commit/c8245e9a21d18e6bb980a6c603808b6fd732ff93


#3

z@codes-2:~/tvm/tutorials/nnvm$ python from_tensorflow.py
/usr/local/lib/python2.7/dist-packages/h5py/init.py:34: FutureWarning: Conversion of the second argument of issubdtype from float to np.floating is deprecated. In future, it will be treated as np.float64 == np.dtype(float).type.
from ._conv import register_converters as _register_converters
2018-11-12 10:35:18.659235: I tensorflow/core/platform/cpu_feature_guard.cc:140] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2 AVX AVX2 FMA
Converted 0 variables to const ops.
DecodeJpeg: It’s a pass through, please handle preprocessing before input
Traceback (most recent call last):
File “from_tensorflow.py”, line 118, in
sym, params = nnvm.frontend.from_tensorflow(graph_def, layout=layout)
File “/home/z/tvm/nnvm/python/nnvm/frontend/tensorflow.py”, line 1399, in from_tensorflow
sym, params = g.from_tensorflow(graph, layout, shape)
File “/home/z/tvm/nnvm/python/nnvm/frontend/tensorflow.py”, line 1174, in from_tensorflow
shape_dict.update(shape)
TypeError: ‘TensorShapeProto’ object is not iterable


#4

Can you show me the args to nnvm.frontend.from_tensorflow call in your code ?


#5

The code used is from_tensorflow.py in the tutorials/nnvm folder, so the args to nnvm.frontend.from_tensorflow:
1, graph_def
with tf.gfile.FastGFile(os.path.join("./", model_name), ‘rb’) as f:
graph_def = tf.GraphDef()
graph_def.ParseFromString(f.read())
graph = tf.import_graph_def(graph_def, name=’’)
# Call the utility to import the graph definition into default graph.
graph_def = nnvm.testing.tf.ProcessGraphDefParam(graph_def)
# Add shapes to the graph.
with tf.Session() as sess:
graph_def = nnvm.testing.tf.AddShapesToGraphDef(sess, ‘softmax’)
2, layout =None


#6

repo_base = ‘https://github.com/dmlc/web-data/raw/master/tensorflow/models/InceptionV1/
model_name = ‘classify_image_graph_def-with_shapes.pb’
model_url = os.path.join(repo_base, model_name)


#7

I have similar error as @heqing.
Is this issue still open or is there already a solution?
Thanks


#9

would you mind to send a PR to fix?


#10

I was not sure about my fix method, got a new error after.
Go to frontend tensorflow.py ‘class GraghProto’: find the loop ‘for node in graph.node’:
elif ‘_output_shapes’ in attr:
self._output_shapes[node.name] =
[tensor_util.TensorShapeProtoToList(shape_o)
for shape_o in attr[’_output_shapes’]]


#11

This issue is due to variable scope of shape is not changed during “for”


so the fixing:
elif ‘_output_shapes’ in attr:
self._output_shapes[node.name] =
[tensor_util.TensorShapeProtoToList(shape)
for shape in attr[’_output_shapes’]]
==>
elif ‘_output_shapes’ in attr:
self._output_shapes[node.name] =
[tensor_util.TensorShapeProtoToList(shape_local)
for shape_local in attr[’_output_shapes’]]