TensorRT strideslice: StridedSlice does not support axis shrinking unless with Constant input node for now

Hi NV,

environment: tensorRT 7, cuda10.0, tensorflow 1.13.2

I tried to slice the channel out. But I got this error during uffparser. So how to solve this bug? Thanks!

The snippet code of tensorflow:
net_1 = net[:,:,:,0]
net_2 = net[:,:,:,1]
net_3 = net[:,:,:,2]
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_mul = tf.multiply(tf.math.sin(theta), tf.math.cos(phi))
n2_mul = tf.multiply(tf.math.sin(theta), tf.math.sin(phi))
n3_mul = tf.math.cos(theta)

[TensorRT] VERBOSE: UFFParser: Parsing model/decoder/Conv_19/BiasAdd[Op: Binary]. Inputs: model/decoder/Conv_19/Conv2D, model/decoder/Conv_19/biases
[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/strided_slice_4/stack[Op: Const].
[TensorRT] VERBOSE: UFFParser: model/decoder/strided_slice_4/stack -> [4]
[TensorRT] VERBOSE: UFFParser: Applying order forwarding to: model/decoder/strided_slice_4/stack
[TensorRT] VERBOSE: UFFParser: Parsing model/decoder/strided_slice_4/stack_1[Op: Const].
[TensorRT] VERBOSE: UFFParser: model/decoder/strided_slice_4/stack_1 -> [4]
[TensorRT] VERBOSE: UFFParser: Applying order forwarding to: model/decoder/strided_slice_4/stack_1
[TensorRT] VERBOSE: UFFParser: Parsing model/decoder/strided_slice_4/stack_2[Op: Const].
[TensorRT] VERBOSE: UFFParser: model/decoder/strided_slice_4/stack_2 -> [4]
[TensorRT] VERBOSE: UFFParser: Applying order forwarding to: model/decoder/strided_slice_4/stack_2
[TensorRT] VERBOSE: UFFParser: Parsing model/decoder/strided_slice_4[Op: StridedSlice]. Inputs: model/decoder/Conv_19/BiasAdd, model/decoder/strided_slice_4/stack, model/decoder/strided_slice_4/stack_1, model/decoder/strided_slice_4/stack_2
[TensorRT] ERROR: UffParser: Parser error: model/decoder/strided_slice_4: StridedSlice does not support axis shrinking unless with Constant input node for now

Hi @derekwong6666,

The UFF parser will be deprecated in the future and isn’t receiving much attention at the moment. The best supported path now is to use the ONNX parser.

Can you try to convert your model to onnx using tf2onnx: https://github.com/onnx/tensorflow-onnx?

Then you can try to parse it with something like:

trtexec --explicitBatch --onnx=model.onnx

One thing to note is that ONNX models in TensorRT 7 require that you create your network with the EXPLICIT_BATCH parameter.

There’s a pretty detailed post on some of the differences when migrating from implicit batch to explicit batch here: TensorRT 7 ONNX models with variable batch size