TensorRT stridedslice: wrong output order

Hi NV,

environment:
cuda10 tensorRT:7
tensorflow 1.13.2

I am working on using uffparser to parser my uff file which is generated by frozen graph.
Here is the issue:
I tried to slice net tensor which is [1, 44, 152, 3] in tensorflow.
net_1 should be [1,44,152, 1] in tensorflow.
but during uffparser process,input node is model/decoder/Conv_19/BiasAdd -> [3,44,152]
net_1 order becomes [44, 152, 1]. I think net_1 order should be [1, 44, 152]. the order of net_1 is wrong. How to make it becomes [1, 44, 152] during uffparser?
The snippet code of tensorflow:
net_1 = tf.strided_slice(net, begin = [0, 0, 0, 0], end = [1, net.shape[1], net.shape[2], 1], strides = [1, 1, 1, 1])
net_2 = tf.strided_slice(net, begin = [0, 0, 0, 1], end = [1, net.shape[1], net.shape[2], 2], strides = [1, 1, 1, 1])
net_3 = tf.strided_slice(net, begin = [0, 0, 0, 2], end = [1, net.shape[1], net.shape[2], 3], strides = [1, 1, 1, 1])
theta = tf.nn.sigmoid(net_1) * 3.1415926535 / 6
phi = tf.nn.sigmoid(net_2) * 3.1415926535 * 2
dist = tf.nn.sigmoid(net_3) * self.max_depth
n1 = tf.multiply(tf.math.sin(theta), tf.math.cos(phi))
n2 = tf.multiply(tf.math.sin(theta), tf.math.sin(phi))
n3 = tf.math.cos(theta)
net = tf.concat([n1, n2, n3, dist], axis=3)
the verbose of ussparser:
[TensorRT] VERBOSE: UFFParser: model/decoder/Conv_19/BiasAdd -> [3,44,152]
[TensorRT] VERBOSE: UFFParser: Applying order forwarding to: model/decoder/Conv_19/BiasAdd
[TensorRT] VERBOSE: UFFParser: Parsing model/decoder/StridedSlice/begin[Op: Const].
[TensorRT] VERBOSE: UFFParser: model/decoder/StridedSlice/begin -> [4]
[TensorRT] VERBOSE: UFFParser: Applying order forwarding to: model/decoder/StridedSlice/begin
[TensorRT] VERBOSE: UFFParser: Parsing model/decoder/StridedSlice/end[Op: Const].
[TensorRT] VERBOSE: UFFParser: model/decoder/StridedSlice/end -> [4]
[TensorRT] VERBOSE: UFFParser: Applying order forwarding to: model/decoder/StridedSlice/end
[TensorRT] VERBOSE: UFFParser: Parsing model/decoder/StridedSlice/strides[Op: Const].
[TensorRT] VERBOSE: UFFParser: model/decoder/StridedSlice/strides -> [4]
[TensorRT] VERBOSE: UFFParser: Applying order forwarding to: model/decoder/StridedSlice/strides
[TensorRT] VERBOSE: UFFParser: Parsing model/decoder/StridedSlice[Op: StridedSlice]. Inputs: model/decoder/Conv_19/BiasAdd, model/decoder/StridedSlice/begin, model/decoder/StridedSlice/end, model/decoder/StridedSlice/strides
[TensorRT] VERBOSE: UFFParser: model/decoder/StridedSlice -> [44,152,1]

Hi @derekwong6666,

Similar to your other post here: TensorRT strideslice: StridedSlice does not support axis shrinking unless with Constant input node for now, I recommend trying the ONNX parser instead.

However, to answer your question, you could try playing with the UFF parser’s input order argument here to see if that gives you the results you expect: https://docs.nvidia.com/deeplearning/sdk/tensorrt-api/python_api/parsers/Uff/pyUff.html#tensorrt.UffParser.register_input

Example:

parser.register_input(input_name, input_shape, trt.UffInputOrder.NHWC)
# or
parser.register_input(input_name, input_shape, trt.UffInputOrder.NCHW)

Either way, TensorRT adds in transpose ops to make the network run in NCHW order for performance reasons.