timprepscius edited a comment on issue #20639:
URL: 
https://github.com/apache/incubator-mxnet/issues/20639#issuecomment-934933419


   ```
   
   def deconv(attrs, inputs, proto_obj):
       """Computes transposed convolution of the input tensor."""
       new_attrs = translation_utils._fix_attribute_names(attrs, 
{'kernel_shape' : 'kernel',
                                                                  'strides' : 
'stride',
                                                                  'pads': 'pad',
                                                                  'dilations': 
'dilate',
                                                                  'group': 
'num_group'})
       new_attrs = translation_utils._add_extra_attributes(new_attrs, 
{'num_group' : 1})
       new_attrs = translation_utils._fix_bias('Deconvolution', new_attrs, 
len(inputs))
   
       new_attrs = translation_utils._fix_channels('Deconvolution', new_attrs, 
inputs, proto_obj)
       kernel = new_attrs['kernel']
       stride = new_attrs['stride'] if 'stride' in new_attrs else []
       padding = new_attrs['pad'] if 'pad' in new_attrs else []
       dilations = new_attrs['dilate'] if 'dilate' in new_attrs else []
       num_filter = new_attrs['num_filter']
       num_group = new_attrs['num_group']
       no_bias = new_attrs['no_bias'] if 'no_bias' in new_attrs else False
       bias = None if no_bias is True else inputs[2]
   
       # Unlike ONNX, MXNet's deconvolution operator does not support 
asymmetric padding, so we first
       # use 'Pad' operator, which supports asymmetric padding. Then use the 
deconvolution operator.
       pad_width = (0, 0, 0, 0) + translation_utils._pad_sequence_fix(padding, 
kernel_dim=len(kernel))
   
       def negate_pad(x):
           return tuple([-v for v in x])
   
       # this change in necessary for torch
       pad_width = negate_pad(pad_width)
       pad_op = symbol.pad(inputs[0], mode='constant', pad_width=pad_width)
   
       deconv_op = symbol.Deconvolution(pad_op, inputs[1], bias,
                                        kernel=kernel, stride=stride, 
dilate=dilations,
                                        num_filter=num_filter, 
num_group=num_group, no_bias=no_bias)
   
       return deconv_op, new_attrs, inputs
   
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@mxnet.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@mxnet.apache.org
For additional commands, e-mail: issues-h...@mxnet.apache.org

Reply via email to