I have modified the script tensorrt.py (which implements integrated TensorFlow-TensorRT) to accelerate the inference of my model (trained with TensorFlow and exported the inference graph as a SavedModel). The script runs fine for the inference mode FP32, but throws errors for native mode> Some tips or suggestions about the root cause?
Source code / logs
Inference mode: native
INFO:tensorflow:Restoring parameters from b'/home/saved_model/1538691479/variables/variables'
INFO:tensorflow:Froze 251 variables.
Converted 251 variables to const ops.
graph_name frozen_graph.pb:
Running native graph
native_frozen_graph.pb
INFO:tensorflow:Starting execution
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/importer.py", line 489, in import_graph_def
graph._c_graph, serialized, options) # pylint: disable=protected-access
tensorflow.python.framework.errors_impl.InvalidArgumentError:
Negative dimension size caused by subtracting 8 from 7 for 'import/resnet_model/average_pooling2d/AvgPool' (op: 'AvgPool') with input shapes: [32,7,7,2048].
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "tensorrt_v2.py", line 635, in <module>
main(argv=sys.argv)
File "tensorrt_v2.py", line 480, in main
g_name, frozen_graph_def, data, log_buffer, flags)
File "tensorrt_v2.py", line 376, in time_and_log_graph
graph_def, data, flags.input_node, flags.output_node, flags.num_loops)
File "tensorrt_v2.py", line 314, in time_graph
return_elements=[output_node]
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/util/deprecation.py", line 432, in new_func
return func(*args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/importer.py", line 493, in import_graph_def
raise ValueError(str(e))