Hello, I am trying to convert ResNet18 preprocessing from TensorFlow to TensorRT (version 3.0.1-1+cuda8.0 running on Ubuntu 16.04 on an x86-64 machine):
#!/usr/bin/env python
import tensorflow as tf
with tf.Graph().as_default(), tf.Session() as session:
inputs = tf.placeholder(shape=(None, 256, 256, 3), dtype=tf.float32, name='images')
output = (inputs / 255.0 - [0.485, 0.456, 0.406]) / [0.229, 0.224, 0.225]
output_node_names = [output.name[:-len(':0')]]
graph_def = session.graph.as_graph_def()
graph_def = tf.graph_util.convert_variables_to_constants(session, graph_def, output_node_names)
import uff
uff_model = uff.from_tensorflow(graph_def, output_node_names)
This fails with:
2018-01-11 13:41:10.015188: I tensorflow/core/platform/cpu_feature_guard.cc:137] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX AVX2 FMA
2018-01-11 13:41:10.463045: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1030] Found device 0 with properties:
name: GeForce GTX 1080 Ti major: 6 minor: 1 memoryClockRate(GHz): 1.582
pciBusID: 0000:83:00.0
totalMemory: 10.91GiB freeMemory: 10.75GiB
2018-01-11 13:41:10.463116: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1120] Creating TensorFlow device (/device:GPU:0) -> (device: 0, name: GeForce GTX 1080 Ti, pci bus id: 0000:83:00.0, compute capability: 6.1)
Converted 0 variables to const ops.
Using output node div_1
Converting to UFF graph
Warning: No conversion function registered for layer: RealDiv yet.
Converting as custom op RealDiv div_1
name: "div_1"
op: "RealDiv"
input: "sub"
input: "div_1/y"
attr {
key: "T"
value {
type: DT_FLOAT
}
}
Traceback (most recent call last):
File "./minimal_example.py", line 13, in <module>
uff_model = uff.from_tensorflow(graph_def, output_node_names)
File "/usr/lib/python2.7/dist-packages/uff/converters/tensorflow/conversion_helpers.py", line 75, in from_tensorflow
name="main")
File "/usr/lib/python2.7/dist-packages/uff/converters/tensorflow/converter.py", line 64, in convert_tf2uff_graph
uff_graph, input_replacements)
File "/usr/lib/python2.7/dist-packages/uff/converters/tensorflow/converter.py", line 51, in convert_tf2uff_node
op, name, tf_node, inputs, uff_graph, tf_nodes=tf_nodes)
File "/usr/lib/python2.7/dist-packages/uff/converters/tensorflow/converter.py", line 28, in convert_layer
fields = cls.parse_tf_attrs(tf_node.attr)
File "/usr/lib/python2.7/dist-packages/uff/converters/tensorflow/converter.py", line 177, in parse_tf_attrs
for key, val in attrs.items()}
File "/usr/lib/python2.7/dist-packages/uff/converters/tensorflow/converter.py", line 177, in <dictcomp>
for key, val in attrs.items()}
File "/usr/lib/python2.7/dist-packages/uff/converters/tensorflow/converter.py", line 172, in parse_tf_attr_value
return cls.convert_tf2uff_field(code, val)
File "/usr/lib/python2.7/dist-packages/uff/converters/tensorflow/converter.py", line 146, in convert_tf2uff_field
return TensorFlowToUFFConverter.convert_tf2numpy_dtype(val)
File "/usr/lib/python2.7/dist-packages/uff/converters/tensorflow/converter.py", line 74, in convert_tf2numpy_dtype
return np.dtype(dt[dtype])
TypeError: list indices must be integers, not AttrValue
Do I understand correctly that division operation for floats is not supported by the converter?
Do I understand correctly that this operation is actually supported by TensorRT (the developer’s manual mentions division: http://docs.nvidia.com/deeplearning/sdk/tensorrt-developer-guide/index.html#tfops), and the problem is only in the TensorFlow to UFF converter?