tensorflow-onnx icon indicating copy to clipboard operation
tensorflow-onnx copied to clipboard

input with dynamic dimensions for depthwise_conv2d

Open tdsuper opened this issue 3 years ago • 2 comments

I am trying to convert a tensorflow model with depthwise_conv2d operation to onnx.

However, if the input has dynamic dimensions such as tf.placeholder(tf.float32, [1, None, None, 3], name='input'), tf2onnx will report error input channel must be positive.

I have also tried to specify the width and height of input, tf2onnx can succefully convert the model. It seems like that k_input_channels corresponds to the channels dimension of input. But I do not know why k_input_channels would be -1 for the input with dynamic dimensions.

I do not know whether the depthwise convolution does not support dynamic input currently or I have missed something.

tdsuper avatar Jun 09 '22 04:06 tdsuper

Yes, DepthwiseConv2d op can support the height and width dimensions as dynamic. It only checks if the input channel dimension >=1. In the exmaple tf.placeholder(tf.float32, [1, None, None, 3], name='input'), the channel size == 3 so tf2onnx shouldn't throw this error. Could you shard the reproduction code then we can help you to take a look at what's happened?

hwangdeyu avatar Jun 10 '22 07:06 hwangdeyu

Hi, the model I tried to convert is from the checkpoints of SingleHDR, which calls tf.image.sobel_edges. From the source of tensorflow, I found the implementation of tf.image.sobel_edges contains depthwise_conv2d operation.

tdsuper avatar Jun 15 '22 01:06 tdsuper