Tensorflow's dilated convolutions with UFF parser not supported

Hello,

I am trying to use the UFF parser with the Python API to convert a Tensorflow model to a UFF file, such that it can be read and optimized by TensorRT 3.0

Unfortunately, a key layer in my network is dilated convolutions. I have tried Keras (using Conv2D layer with a dilation of (2,2) or more) as well as tf.nn.atrous_conv2d and neither of them works. This is disappointing as in the TensorRT 3.0 developer PDF it specifically says dilated convolutions are one of the supported layers.

I get the following error below. Any help would be greatly appreciated!

Using output node softmax
Converting to UFF graph
Warning: No conversion function registered for layer: BatchToSpaceND yet.
Converting as custom op BatchToSpaceND ctx_conv7_1/convolution/BatchToSpaceND
name: "ctx_conv7_1/convolution/BatchToSpaceND"
op: "BatchToSpaceND"
input: "ctx_conv7_1/convolution"
input: "ctx_conv7_1/convolution/BatchToSpaceND/block_shape"
input: "ctx_conv7_1/convolution/BatchToSpaceND/crops"
attr {
  key: "T"
  value {
    type: DT_FLOAT
  }
}
attr {
  key: "Tblock_shape"
  value {
    type: DT_INT32
  }
}
attr {
  key: "Tcrops"
  value {
    type: DT_INT32
  }
}

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-7-4d9dd3552b08> in <module>()
      1 import uff
----> 2 uff_model = uff.from_tensorflow(tf_model, ['softmax'])

/usr/lib/python3.5/dist-packages/uff/converters/tensorflow/conversion_helpers.py in from_tensorflow(graphdef, output_nodes, **kwargs)
     73         output_nodes=output_nodes,
     74         input_replacements=input_replacements,
---> 75         name="main")
     76 
     77     uff_metagraph_proto = uff_metagraph.to_uff()

/usr/lib/python3.5/dist-packages/uff/converters/tensorflow/converter.py in convert_tf2uff_graph(cls, tf_graphdef, uff_metagraph, output_nodes, input_replacements, name)
     62         while len(nodes_to_convert):
     63             nodes_to_convert += cls.convert_tf2uff_node(nodes_to_convert.pop(), tf_nodes,
---> 64                                                         uff_graph, input_replacements)
     65         for output in output_nodes:
     66             uff_graph.mark_output(output)

/usr/lib/python3.5/dist-packages/uff/converters/tensorflow/converter.py in convert_tf2uff_node(cls, name, tf_nodes, uff_graph, input_replacements)
     49         op = tf_node.op
     50         uff_node = cls.convert_layer(
---> 51             op, name, tf_node, inputs, uff_graph, tf_nodes=tf_nodes)
     52         return uff_node
     53 

/usr/lib/python3.5/dist-packages/uff/converters/tensorflow/converter.py in convert_layer(cls, op, name, tf_node, inputs, uff_graph, **kwargs)
     26             print("Converting as custom op", op, name)
     27             print(tf_node)
---> 28             fields = cls.parse_tf_attrs(tf_node.attr)
     29             uff_graph.custom_node(op, inputs, name, fields)
     30             return [cls.split_node_name_and_output(inp)[0] for inp in inputs]

/usr/lib/python3.5/dist-packages/uff/converters/tensorflow/converter.py in parse_tf_attrs(cls, attrs)
    175     def parse_tf_attrs(cls, attrs):
    176         return {key: cls.parse_tf_attr_value(val)
--> 177                 for key, val in attrs.items()}
    178 
    179     @classmethod

/usr/lib/python3.5/dist-packages/uff/converters/tensorflow/converter.py in <dictcomp>(.0)
    175     def parse_tf_attrs(cls, attrs):
    176         return {key: cls.parse_tf_attr_value(val)
--> 177                 for key, val in attrs.items()}
    178 
    179     @classmethod

/usr/lib/python3.5/dist-packages/uff/converters/tensorflow/converter.py in parse_tf_attr_value(cls, val)
    170     def parse_tf_attr_value(cls, val):
    171         code = val.WhichOneof('value')
--> 172         return cls.convert_tf2uff_field(code, val)
    173 
    174     @classmethod

/usr/lib/python3.5/dist-packages/uff/converters/tensorflow/converter.py in convert_tf2uff_field(cls, code, val)
    144             return bool(val)
    145         elif code == 'type':
--> 146             return TensorFlowToUFFConverter.convert_tf2numpy_dtype(val)
    147         elif code == 'list':
    148             fields = val.ListFields()

/usr/lib/python3.5/dist-packages/uff/converters/tensorflow/converter.py in convert_tf2numpy_dtype(cls, dtype)
     72               'c8', 'i8', 'b', 'qi1', 'qu1', 'qi4', 'bf2',
     73               'qi2', 'qu2', 'u2', 'c16', 'f2', 'r']
---> 74         return np.dtype(dt[dtype])
     75 
     76     @classmethod

TypeError: list indices must be integers or slices, not AttrValue

​

Hi,

From your error log, there is a non-supported layer called BatchToSpaceND.

TensorRT doesn’t support dilated convolutions yet.
You can find relevant information in the following section of document:

2.3.1.3. NvCaffeParser
2.3.2.2.4. Supported TensorFlow Operations

Thanks.