I tried to call relay.from_tensofrflow for mobilenet_v2 models.
The error is
mobilenet_v2_0.75_224_frozen.pb
{'input': (1, 224, 224, 3)}
Traceback (most recent call last):
File "./tune_relay_x86.py", line 247, in <module>
tune_and_evaluate(tuning_option)
File "./tune_relay_x86.py", line 214, in tune_and_evaluate
mod, params, data_shape, out_shape = get_network(model_name, batch_size)
File "./tune_relay_x86.py", line 96, in get_network
mod, params = relay.frontend.from_tensorflow(graph_def, shape={input_name: input_shape}, layout=target_layout)
File "/usr/local/lib/python3.6/dist-packages/tvm-0.6.dev0-py3.6-linux-x86_64.egg/tvm/relay/frontend/tensorflow.py", line 2423, in from_tensorflow
mod, params = g.from_tensorflow(graph, layout, shape, outputs)
File "/usr/local/lib/python3.6/dist-packages/tvm-0.6.dev0-py3.6-linux-x86_64.egg/tvm/relay/frontend/tensorflow.py", line 2067, in from_tensorflow
op = self._convert_operator(node.op, inputs, attr, graph)
File "/usr/local/lib/python3.6/dist-packages/tvm-0.6.dev0-py3.6-linux-x86_64.egg/tvm/relay/frontend/tensorflow.py", line 2386, in _convert_operator
sym = convert_map[op_name](inputs, attrs, self._params)
File "/usr/local/lib/python3.6/dist-packages/tvm-0.6.dev0-py3.6-linux-x86_64.egg/tvm/relay/frontend/tensorflow.py", line 807, in _impl
return _op.clip(inputs[0], a_min=0, a_max=6)
IndexError: list index out of range
Code:
import tensorflow as tf
name = "mobilenet_v2_0.75_224_frozen.pb"
input_name = "input"
input_shape = (1, 224, 224, 3)
target_layout='NCHW'
with tf.Session() as sess:
print("load graph")
with tf.gfile.GFile(name,'rb') as f:
graph_def = tf.GraphDef()
graph_def.ParseFromString(f.read())
print(name)
print({input_name: input_shape})
mod, params = relay.frontend.from_tensorflow(graph_def, shape={input_name: input_shape}, layout=target_layout)
Model .pb
file can be downloaded from https://storage.googleapis.com/mobilenet_v2/checkpoints/mobilenet_v2_0.75_224.tgz
# V2
summarize_graph --in_graph="mobilenet_v2_0.75_224_frozen.pb"
Found 1 possible inputs: (name=input, type=float(1), shape=None)
No variables spotted.
Found 1 possible outputs: (name=MobilenetV2/Predictions/Reshape_1, op=Reshape)
Found 2640731 (2.64M) const parameters, 0 (0) variable parameters, and 0 control_edges
Op types used: 158 Const, 36 BiasAdd, 36 Conv2D, 35 Relu6, 17 DepthwiseConv2dNative, 17 FusedBatchNorm, 10 Add, 2 Reshape, 1 AvgPool, 1 Placeholder, 1 Shape, 1 Softmax, 1 Squeeze
To use with tensorflow/tools/benchmark:benchmark_model try these arguments:
bazel run tensorflow/tools/benchmark:benchmark_model -- --graph=/home/dlc/workplace/autotune-test/mobilenet_v2_0.75_224_frozen.pb --show_flops --input_layer=input --input_layer_type=float --input_layer_shape= --output_layer=MobilenetV2/Predictions/Reshape_1
Strange thing is that input shape is None
instead of ?,224,224,3
# V1
$ summarize_graph --in_graph="mobilenet_v1_1.0_224_frozen.pb"
Found 1 possible inputs: (name=input, type=float(1), shape=[?,224,224,3])
No variables spotted.
Found 1 possible outputs: (name=MobilenetV1/Predictions/Reshape_1, op=Reshape)
Found 4254891 (4.25M) const parameters, 0 (0) variable parameters, and 0 control_edges
Op types used: 138 Const, 138 Identity, 27 FusedBatchNorm, 27 Relu6, 15 Conv2D, 13 DepthwiseConv2dNative, 2 Reshape, 1 AvgPool, 1 BiasAdd, 1 Placeholder, 1 Shape, 1 Softmax, 1 Squeeze
To use with tensorflow/tools/benchmark:benchmark_model try these arguments:
bazel run tensorflow/tools/benchmark:benchmark_model -- --graph=/home/dlc/workplace/autotune-test/mobilenet_v1_1.0_224_frozen.pb --show_flops --input_layer=input --input_layer_type=float --input_layer_shape=-1,224,224,3 --output_layer=MobilenetV1/Predictions/Reshape_1
Tensorboard:
V2 input screenshot