Description
I convert my purely CNN TensorFlow model to UFF. Since UFF doesn’t support tf.nn.space_to_depth and tf.nn.depth_to_space, I implement them on my own via tf.reshape and tf.transfrom. When building a TensorRT engine, I get a parser error:
[TensorRT] ERROR: UffParser: Parser error: autoencoder/denoiser/layers/scale1/pixelshuffledown/Reshape: Reshape: Volume mismatch. Note: Initial Volume = 9331200, New Volume = 207360
My testing shape of input is 1x720x1296x10, while the training shape is 32x144x144x10. I notice that 9331200 equals 720x1296x10 and 207360 equals 144x144x10. How can I address this problem?
Environment
TensorRT Version: 7.0.0.11
GPU Type: RTX 2080ti
Nvidia Driver Version: 460.73.01
CUDA Version: 10.0
CUDNN Version: 7.6.4
Operating System + Version: Ubuntu 16.04
Python Version: 3.6.13
TensorFlow Version: 1.15
Relevant Files
My UFF model can be downloaded here.
Steps To Reproduce
My implementation of tf.reshape and tf.transfrom:
def pixelshuffledown(self, x, block_size=2):
with tf.variable_scope('pixelshuffledown'):
batch=-1
_, height, width, depth = x.get_shape()
reduced_height = height // block_size
reduced_width = width // block_size
out=tf.reshape(x, [batch, reduced_height, block_size, reduced_width, block_size, depth])
out=tf.transpose(out, (0,1,3,2,4,5))
out=tf.reshape(out, [batch, reduced_height, reduced_width, depth*block_size*block_size])
return out
def pixelshuffleup(self, x, block_size=2):
with tf.variable_scope('pixelshuffleup'):
batch=-1
_, height, width, depth = x.get_shape()
reduced_depth = depth // (block_size * block_size)
out = tf.reshape(x, [batch, height, width, block_size, block_size, reduced_depth] )
out = tf.transpose(out, (0, 1, 3, 2, 4, 5))
out = tf.reshape(out, [batch, height * block_size, width * block_size, reduced_depth])
return out
How I convert UFF model:
convert-to-uff .../model.pb -I "source,source,float32,1,720,1296,10" -O autoencoder/denoiser/final_stage/relu/relu
No warning raised by the converter.