Lyken17 edited a comment on issue #8182:
URL: https://github.com/apache/tvm/issues/8182#issuecomment-877677173


   happened to be here. It was surprising the issue was not solved after so 
long time. TranposedConv2d is an important operator in GAN related 
applications. For anyone who also had this trouble, you may refer following 
code to support `group` parameter in transposed convolution
   
   ```python
       out_c = simplify(out_c)
       out_channels = simplify(out_c * groups)
   
       out_h = simplify(in_h - filter_h + 1)
       out_w = simplify(in_w - filter_w + 1)
       dc = te.reduce_axis((0, in_c // groups), name="dc")
       dh = te.reduce_axis((0, filter_h), name="dh")
       dw = te.reduce_axis((0, filter_w), name="dw")
       
       # data: batch, in_channels, out_h, out_w
       # weight: out_channels // G, in_channels, out_h, out_w
       return te.compute(
           (batch, out_channels, out_h, out_w),
           lambda b, c, h, w: te.sum(
               data_pad[
                   b, 
                   c // (out_channels // groups) * (in_channels // groups) + 
dc, 
                   h + dh, 
                   w + dw
               ].astype(out_dtype)
               * kernel_transform[
                   c % (out_channels // groups), 
                   c // (out_channels // groups) * (in_channels // groups) + 
dc, 
                   dh, 
                   dw
               ].astype(out_dtype),
               axis=[dc, dh, dw],
           ),
           tag="conv2d_transpose_nchw",
       )
   ```


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to