In conversion to TensorRT from Tensorflow, there is issue at Depthwise_con2d.
The implementation is as in the picture.
Tensorflow code is as follow.
def gauss_kernel(self, kernlen=21, nsig=3, channels=1): interval = (2*nsig+1.)/(kernlen) x = np.linspace(-nsig-interval/2., nsig+interval/2., kernlen+1) kern1d = np.diff(st.norm.cdf(x)) kernel_raw = np.sqrt(np.outer(kern1d, kern1d)) kernel = kernel_raw/kernel_raw.sum() out_filter = np.array(kernel, dtype = np.float32) out_filter = out_filter.reshape((kernlen, kernlen, 1, 1)) out_filter = np.repeat(out_filter, channels, axis = 2) return out_filter def make_gauss_var(self, name, size, sigma, c_i): # with tf.device("/cpu:0"): kernel = self.gauss_kernel(size, sigma, c_i) var = tf.Variable(tf.convert_to_tensor(kernel), name=name) return var @layer def smoother(self, input, name='gaussian_heatMat'): # Get the number of channels in the input c_i = input.get_shape().as_list() # Convolution for a given input and kernel convolve = lambda i, k: tf.nn.depthwise_conv2d(i, k, [1, 1, 1, 1], padding='SAME') with tf.variable_scope(name) as scope: kernel = self.make_gauss_var('gauss_weight', 25, 3.0, c_i)#filter_size=25,sigma=3.0 output = convolve(input, kernel) return output
I have errors in parsing to network from uff as
[TensorRT] ERROR: gaussian_heatMat/depthwise: kernel weights has count 11875 but 7796358 was expected [TensorRT] ERROR: gaussian_heatMat/depthwise: count of 11875 weights in kernel, but kernel dimensions (25, 25) with 1459200 input channels, 19 output channels and 19 groups were specified. [TensorRT] ERROR: UffParser: Parser error: MarkOutput_0: Order size is not matching the number dimensions of TensorRT
11875 = 252519 so that is kernel. Why 7796358 was expected? Don’t under the other errors as well.