TRT5.0: Error when creating UFF graph with DepthwiseConv2dNative


When converting a .pb graph to .uff using convert-to-uff, I get the following error which appears to be linked to a depth-wise convolution layer:

Converting to UFF graph
Traceback (most recent call last):
  File "/opt/tools/anaconda2/bin/convert-to-uff", line 11, in <module>
  File "/opt/tools/anaconda2/lib/python2.7/site-packages/uff/bin/", line 79, in main
  File "/opt/tools/anaconda2/lib/python2.7/site-packages/uff/converters/tensorflow/", line 159, in from_tensorflow_frozen_model
    return from_tensorflow(graphdef, output_nodes, preprocessor, **kwargs)
  File "/opt/tools/anaconda2/lib/python2.7/site-packages/uff/converters/tensorflow/", line 132, in from_tensorflow
  File "/opt/tools/anaconda2/lib/python2.7/site-packages/uff/converters/tensorflow/", line 77, in convert_tf2uff_graph
    uff_graph, input_replacements)
  File "/opt/tools/anaconda2/lib/python2.7/site-packages/uff/converters/tensorflow/", line 64, in convert_tf2uff_node
    op, name, tf_node, inputs, uff_graph, tf_nodes=tf_nodes)
  File "/opt/tools/anaconda2/lib/python2.7/site-packages/uff/converters/tensorflow/", line 43, in convert_layer
    return cls.registry_[op](name, tf_node, inputs, uff_graph, **kwargs)
  File "/opt/tools/anaconda2/lib/python2.7/site-packages/uff/converters/tensorflow/", line 276, in convert_depthwise_conv2d_native
    return _conv2d_helper(name, tf_node, inputs, uff_graph, func="depthwise", **kwargs)
  File "/opt/tools/anaconda2/lib/python2.7/site-packages/uff/converters/tensorflow/", line 301, in _conv2d_helper
    number_groups = int(wt.attr['value'].tensor.tensor_shape.dim[2].size)
IndexError: list index out of range

Note that I am using python 2.7, tensorflow 1.11 (to create the .pb file) and TensorRT (which comes with uff 0.5.1) on a p100 GPU.

I can provide the .pb file if needed, it is quite small (900kb)

Any help would be very much appreciated.


It’d help us debug if you can please provide a small repro package that contains the source, model/pb/uff that exhibit this symptom.

you can DM me if you don’t want to post on the forum.

NVIDIA Enterprise Support


Thanks for your interest.

After some digging, I think I found (part of) the problem.

When using tf.nn.depthwise_conv2d, it appears that tensorflow authorizes using a filter argument of shape [filter_height, filter_width, in_channels] if the channel_multiplier is 1. (see

But this is incompatible with uff, which expects weights of dimension 4, hence the crash.

HOWEVER, even after correcting this, retraining a model… and successfully building an uff graph and then an engine, I am NOT able to get the same results using TRT and tensorflow. Still digging…

Got it working by provding input in NCHW format and converting output back to NHWC format.

It’s a bit confusing though, I thought specifying the format in the parser.register_input was enough.

@blancpaques can you explain more how did you change input in NCHW format and converting output back to NHWC format? In which file and where? Do you also use the following config file: