You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2021/06/15 05:40:01 UTC

[GitHub] [tvm] zotanika opened a new pull request #8260: [Caffe Frontend] supporting group > 1 cases for Deconv op

zotanika opened a new pull request #8260:
URL: https://github.com/apache/tvm/pull/8260


   - Handling group > 1 cases, assuming group == output channels
   - Simply decomposed into Relay split, conv2d_transposed, and multi-leveled concatenate ops
   - Added some test cases
   
   Signed-off-by: zotanika <zo...@gmail.com>
   
   Thanks for contributing to TVM!   Please refer to guideline https://tvm.apache.org/docs/contribute/ for useful information and tips. After the pull request is submitted, please request code reviews from [Reviewers](https://github.com/apache/incubator-tvm/blob/master/CONTRIBUTORS.md#reviewers) by @ them in the pull request thread.
   


-- 
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.

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



[GitHub] [tvm] masahi merged pull request #8260: [Caffe Frontend] supporting group > 1 cases for Deconv op

Posted by GitBox <gi...@apache.org>.
masahi merged pull request #8260:
URL: https://github.com/apache/tvm/pull/8260


   


-- 
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: commits-unsubscribe@tvm.apache.org

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



[GitHub] [tvm] lixiaoquan commented on a change in pull request #8260: [Caffe Frontend] supporting group > 1 cases for Deconv op

Posted by GitBox <gi...@apache.org>.
lixiaoquan commented on a change in pull request #8260:
URL: https://github.com/apache/tvm/pull/8260#discussion_r672042044



##########
File path: tests/python/frontend/caffe/test_forward.py
##########
@@ -452,6 +452,33 @@ def test_forward_Deconvolution():
             bias_filler=dict(type="xavier"),
         ),
     )
+    _test_deconvolution(
+        data,
+        convolution_param=dict(
+            num_output=16,
+            bias_term=False,
+            pad=0,
+            kernel_size=2,
+            stride=2,
+            dilation=1,
+            group=16,
+            weight_filler=dict(type="xavier"),
+            bias_filler=dict(type="xavier"),
+        ),
+    )
+    data = np.random.rand(1, 100, 32, 32).astype(np.float32)
+    _test_deconvolution(
+        data,
+        convolution_param=dict(
+            num_output=100,
+            bias_term=False,
+            pad=0,
+            kernel_size=2,
+            stride=2,
+            dilation=1,
+            group=100,

Review comment:
       ```suggestion
               group=100,
               weight_filler=dict(type="xavier"),
               bias_filler=dict(type="xavier"),
   ```




-- 
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: commits-unsubscribe@tvm.apache.org

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



[GitHub] [tvm] lixiaoquan commented on a change in pull request #8260: [Caffe Frontend] supporting group > 1 cases for Deconv op

Posted by GitBox <gi...@apache.org>.
lixiaoquan commented on a change in pull request #8260:
URL: https://github.com/apache/tvm/pull/8260#discussion_r672042044



##########
File path: tests/python/frontend/caffe/test_forward.py
##########
@@ -452,6 +452,33 @@ def test_forward_Deconvolution():
             bias_filler=dict(type="xavier"),
         ),
     )
+    _test_deconvolution(
+        data,
+        convolution_param=dict(
+            num_output=16,
+            bias_term=False,
+            pad=0,
+            kernel_size=2,
+            stride=2,
+            dilation=1,
+            group=16,
+            weight_filler=dict(type="xavier"),
+            bias_filler=dict(type="xavier"),
+        ),
+    )
+    data = np.random.rand(1, 100, 32, 32).astype(np.float32)
+    _test_deconvolution(
+        data,
+        convolution_param=dict(
+            num_output=100,
+            bias_term=False,
+            pad=0,
+            kernel_size=2,
+            stride=2,
+            dilation=1,
+            group=100,

Review comment:
       ```suggestion
               group=100,
               weight_filler=dict(type="xavier"),
               bias_filler=dict(type="xavier"),
   ```




-- 
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: commits-unsubscribe@tvm.apache.org

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



[GitHub] [tvm] lixiaoquan commented on a change in pull request #8260: [Caffe Frontend] supporting group > 1 cases for Deconv op

Posted by GitBox <gi...@apache.org>.
lixiaoquan commented on a change in pull request #8260:
URL: https://github.com/apache/tvm/pull/8260#discussion_r672042044



##########
File path: tests/python/frontend/caffe/test_forward.py
##########
@@ -452,6 +452,33 @@ def test_forward_Deconvolution():
             bias_filler=dict(type="xavier"),
         ),
     )
+    _test_deconvolution(
+        data,
+        convolution_param=dict(
+            num_output=16,
+            bias_term=False,
+            pad=0,
+            kernel_size=2,
+            stride=2,
+            dilation=1,
+            group=16,
+            weight_filler=dict(type="xavier"),
+            bias_filler=dict(type="xavier"),
+        ),
+    )
+    data = np.random.rand(1, 100, 32, 32).astype(np.float32)
+    _test_deconvolution(
+        data,
+        convolution_param=dict(
+            num_output=100,
+            bias_term=False,
+            pad=0,
+            kernel_size=2,
+            stride=2,
+            dilation=1,
+            group=100,

Review comment:
       ```suggestion
               group=100,
               weight_filler=dict(type="xavier"),
               bias_filler=dict(type="xavier"),
   ```




-- 
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: commits-unsubscribe@tvm.apache.org

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



[GitHub] [tvm] masahi commented on pull request #8260: [Caffe Frontend] supporting group > 1 cases for Deconv op

Posted by GitBox <gi...@apache.org>.
masahi commented on pull request #8260:
URL: https://github.com/apache/tvm/pull/8260#issuecomment-1008437395


   @zotanika please resolve the conflict.


-- 
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: commits-unsubscribe@tvm.apache.org

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



[GitHub] [tvm] mshr-h commented on pull request #8260: [Caffe Frontend] supporting group > 1 cases for Deconv op

Posted by GitBox <gi...@apache.org>.
mshr-h commented on pull request #8260:
URL: https://github.com/apache/tvm/pull/8260#issuecomment-882363038


   I want to try your PR.
   
   Is there any pretrained models which contains Deconv with group > 1?


-- 
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: commits-unsubscribe@tvm.apache.org

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



[GitHub] [tvm] zotanika commented on a change in pull request #8260: [Caffe Frontend] supporting group > 1 cases for Deconv op

Posted by GitBox <gi...@apache.org>.
zotanika commented on a change in pull request #8260:
URL: https://github.com/apache/tvm/pull/8260#discussion_r672730636



##########
File path: python/tvm/relay/frontend/caffe.py
##########
@@ -511,19 +511,72 @@ def convert_deconv(self, op):
         if weight:
             kh, kw = params["kernel_size"]
             weight_shape = [-1, conv_params.num_output, kh, kw]
-            weight_value = np.asarray(weight.data, np.float32)
+            if not weight.data:
+                if conv_params.weight_filler:
+                    _filler = conv_params.weight_filler.value
+                    weight_value = np.full(weight.shape.dim, _filler, np.float32)
+                else:
+                    raise tvm.error.OpAttributeInvalid("At least weight_filler must be given")
+            else:
+                weight_value = np.asarray(weight.data, np.float32)
             weight_value = np.reshape(weight_value, weight_shape)
         else:
-            raise Exception("No weight value of layer {} in caffemodel".format(op.name))
+            raise tvm.error.OpAttributeRequired(
+                "No weight value of layer {} in caffemodel".format(op.name)
+            )
 
         weight_expr = self.exp_tab.new_const(weight_value, dtype="float32")
         in_expr = self.exp_tab.get_expr(inputs[0])
-        out = _op.nn.conv2d_transpose(data=in_expr, weight=weight_expr, **params)
-        if bias:
 
+        groups = params["groups"]
+        channels = params["channels"]
+
+        if bias:
             bias_value = np.asarray(bias.data, np.float32)
             bias_expr = self.exp_tab.new_const(bias_value, dtype="float32")
-            out = _op.nn.bias_add(out, bias_expr)
+
+        if groups > channels:
+            raise tvm.error.OpAttributeInvalid(
+                "Groups cannot be larger than the number of input channels"
+            )
+
+        if groups == channels:

Review comment:
       Dear @makihiro ,Thank you for your valuable comment.
   `groups==1` is the only case that the original author intended to handle, no matter how many channels are given in this case. The routine at line 544 are actually falling back to the original implementation of back-end of Deconv op.
   For the necessity of handling multiple groups in Caffe Deconv op, you may refer to several implementations of image-enhancement networks including upscaling layers, such as [demosaicnet_caffe](https://github.com/mgharbi/demosaicnet_caffe).

##########
File path: python/tvm/relay/frontend/caffe.py
##########
@@ -511,19 +511,72 @@ def convert_deconv(self, op):
         if weight:
             kh, kw = params["kernel_size"]
             weight_shape = [-1, conv_params.num_output, kh, kw]
-            weight_value = np.asarray(weight.data, np.float32)
+            if not weight.data:
+                if conv_params.weight_filler:
+                    _filler = conv_params.weight_filler.value
+                    weight_value = np.full(weight.shape.dim, _filler, np.float32)
+                else:
+                    raise tvm.error.OpAttributeInvalid("At least weight_filler must be given")
+            else:
+                weight_value = np.asarray(weight.data, np.float32)
             weight_value = np.reshape(weight_value, weight_shape)
         else:
-            raise Exception("No weight value of layer {} in caffemodel".format(op.name))
+            raise tvm.error.OpAttributeRequired(
+                "No weight value of layer {} in caffemodel".format(op.name)
+            )
 
         weight_expr = self.exp_tab.new_const(weight_value, dtype="float32")
         in_expr = self.exp_tab.get_expr(inputs[0])
-        out = _op.nn.conv2d_transpose(data=in_expr, weight=weight_expr, **params)
-        if bias:
 
+        groups = params["groups"]
+        channels = params["channels"]
+
+        if bias:
             bias_value = np.asarray(bias.data, np.float32)
             bias_expr = self.exp_tab.new_const(bias_value, dtype="float32")
-            out = _op.nn.bias_add(out, bias_expr)
+
+        if groups > channels:
+            raise tvm.error.OpAttributeInvalid(
+                "Groups cannot be larger than the number of input channels"
+            )
+
+        if groups == channels:

Review comment:
       Dear @mshr-h, Thank you for your valuable comment.
   `groups==1` is the only case that the original author intended to handle, no matter how many channels are given in this case. The routine at line 544 are actually falling back to the original implementation of back-end of Deconv op.
   For the necessity of handling multiple groups in Caffe Deconv op, you may refer to several implementations of image-enhancement networks including upscaling layers, such as [demosaicnet_caffe](https://github.com/mgharbi/demosaicnet_caffe).

##########
File path: tests/python/frontend/caffe/test_forward.py
##########
@@ -452,6 +452,33 @@ def test_forward_Deconvolution():
             bias_filler=dict(type="xavier"),
         ),
     )
+    _test_deconvolution(
+        data,
+        convolution_param=dict(
+            num_output=16,
+            bias_term=False,
+            pad=0,
+            kernel_size=2,
+            stride=2,
+            dilation=1,
+            group=16,
+            weight_filler=dict(type="xavier"),
+            bias_filler=dict(type="xavier"),
+        ),
+    )
+    data = np.random.rand(1, 100, 32, 32).astype(np.float32)
+    _test_deconvolution(
+        data,
+        convolution_param=dict(
+            num_output=100,
+            bias_term=False,
+            pad=0,
+            kernel_size=2,
+            stride=2,
+            dilation=1,
+            group=100,

Review comment:
       Dear @lixiaoquan , Thank you for your suggestion. Fixed the test case.




-- 
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: commits-unsubscribe@tvm.apache.org

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



[GitHub] [tvm] zotanika commented on a change in pull request #8260: [Caffe Frontend] supporting group > 1 cases for Deconv op

Posted by GitBox <gi...@apache.org>.
zotanika commented on a change in pull request #8260:
URL: https://github.com/apache/tvm/pull/8260#discussion_r672762543



##########
File path: tests/python/frontend/caffe/test_forward.py
##########
@@ -452,6 +452,33 @@ def test_forward_Deconvolution():
             bias_filler=dict(type="xavier"),
         ),
     )
+    _test_deconvolution(
+        data,
+        convolution_param=dict(
+            num_output=16,
+            bias_term=False,
+            pad=0,
+            kernel_size=2,
+            stride=2,
+            dilation=1,
+            group=16,
+            weight_filler=dict(type="xavier"),
+            bias_filler=dict(type="xavier"),
+        ),
+    )
+    data = np.random.rand(1, 100, 32, 32).astype(np.float32)
+    _test_deconvolution(
+        data,
+        convolution_param=dict(
+            num_output=100,
+            bias_term=False,
+            pad=0,
+            kernel_size=2,
+            stride=2,
+            dilation=1,
+            group=100,

Review comment:
       Dear @lixiaoquan , Thank you for your suggestion. Fixed the test case.




-- 
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: commits-unsubscribe@tvm.apache.org

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



[GitHub] [tvm] zotanika commented on a change in pull request #8260: [Caffe Frontend] supporting group > 1 cases for Deconv op

Posted by GitBox <gi...@apache.org>.
zotanika commented on a change in pull request #8260:
URL: https://github.com/apache/tvm/pull/8260#discussion_r672730636



##########
File path: python/tvm/relay/frontend/caffe.py
##########
@@ -511,19 +511,72 @@ def convert_deconv(self, op):
         if weight:
             kh, kw = params["kernel_size"]
             weight_shape = [-1, conv_params.num_output, kh, kw]
-            weight_value = np.asarray(weight.data, np.float32)
+            if not weight.data:
+                if conv_params.weight_filler:
+                    _filler = conv_params.weight_filler.value
+                    weight_value = np.full(weight.shape.dim, _filler, np.float32)
+                else:
+                    raise tvm.error.OpAttributeInvalid("At least weight_filler must be given")
+            else:
+                weight_value = np.asarray(weight.data, np.float32)
             weight_value = np.reshape(weight_value, weight_shape)
         else:
-            raise Exception("No weight value of layer {} in caffemodel".format(op.name))
+            raise tvm.error.OpAttributeRequired(
+                "No weight value of layer {} in caffemodel".format(op.name)
+            )
 
         weight_expr = self.exp_tab.new_const(weight_value, dtype="float32")
         in_expr = self.exp_tab.get_expr(inputs[0])
-        out = _op.nn.conv2d_transpose(data=in_expr, weight=weight_expr, **params)
-        if bias:
 
+        groups = params["groups"]
+        channels = params["channels"]
+
+        if bias:
             bias_value = np.asarray(bias.data, np.float32)
             bias_expr = self.exp_tab.new_const(bias_value, dtype="float32")
-            out = _op.nn.bias_add(out, bias_expr)
+
+        if groups > channels:
+            raise tvm.error.OpAttributeInvalid(
+                "Groups cannot be larger than the number of input channels"
+            )
+
+        if groups == channels:

Review comment:
       Dear @makihiro ,Thank you for your valuable comment.
   `groups==1` is the only case that the original author intended to handle, no matter how many channels are given in this case. The routine at line 544 are actually falling back to the original implementation of back-end of Deconv op.
   For the necessity of handling multiple groups in Caffe Deconv op, you may refer to several implementations of image-enhancement networks including upscaling layers, such as [demosaicnet_caffe](https://github.com/mgharbi/demosaicnet_caffe).

##########
File path: python/tvm/relay/frontend/caffe.py
##########
@@ -511,19 +511,72 @@ def convert_deconv(self, op):
         if weight:
             kh, kw = params["kernel_size"]
             weight_shape = [-1, conv_params.num_output, kh, kw]
-            weight_value = np.asarray(weight.data, np.float32)
+            if not weight.data:
+                if conv_params.weight_filler:
+                    _filler = conv_params.weight_filler.value
+                    weight_value = np.full(weight.shape.dim, _filler, np.float32)
+                else:
+                    raise tvm.error.OpAttributeInvalid("At least weight_filler must be given")
+            else:
+                weight_value = np.asarray(weight.data, np.float32)
             weight_value = np.reshape(weight_value, weight_shape)
         else:
-            raise Exception("No weight value of layer {} in caffemodel".format(op.name))
+            raise tvm.error.OpAttributeRequired(
+                "No weight value of layer {} in caffemodel".format(op.name)
+            )
 
         weight_expr = self.exp_tab.new_const(weight_value, dtype="float32")
         in_expr = self.exp_tab.get_expr(inputs[0])
-        out = _op.nn.conv2d_transpose(data=in_expr, weight=weight_expr, **params)
-        if bias:
 
+        groups = params["groups"]
+        channels = params["channels"]
+
+        if bias:
             bias_value = np.asarray(bias.data, np.float32)
             bias_expr = self.exp_tab.new_const(bias_value, dtype="float32")
-            out = _op.nn.bias_add(out, bias_expr)
+
+        if groups > channels:
+            raise tvm.error.OpAttributeInvalid(
+                "Groups cannot be larger than the number of input channels"
+            )
+
+        if groups == channels:

Review comment:
       Dear @mshr-h, Thank you for your valuable comment.
   `groups==1` is the only case that the original author intended to handle, no matter how many channels are given in this case. The routine at line 544 are actually falling back to the original implementation of back-end of Deconv op.
   For the necessity of handling multiple groups in Caffe Deconv op, you may refer to several implementations of image-enhancement networks including upscaling layers, such as [demosaicnet_caffe](https://github.com/mgharbi/demosaicnet_caffe).

##########
File path: tests/python/frontend/caffe/test_forward.py
##########
@@ -452,6 +452,33 @@ def test_forward_Deconvolution():
             bias_filler=dict(type="xavier"),
         ),
     )
+    _test_deconvolution(
+        data,
+        convolution_param=dict(
+            num_output=16,
+            bias_term=False,
+            pad=0,
+            kernel_size=2,
+            stride=2,
+            dilation=1,
+            group=16,
+            weight_filler=dict(type="xavier"),
+            bias_filler=dict(type="xavier"),
+        ),
+    )
+    data = np.random.rand(1, 100, 32, 32).astype(np.float32)
+    _test_deconvolution(
+        data,
+        convolution_param=dict(
+            num_output=100,
+            bias_term=False,
+            pad=0,
+            kernel_size=2,
+            stride=2,
+            dilation=1,
+            group=100,

Review comment:
       Dear @lixiaoquan , Thank you for your suggestion. Fixed the test case.




-- 
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: commits-unsubscribe@tvm.apache.org

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



[GitHub] [tvm] mshr-h commented on a change in pull request #8260: [Caffe Frontend] supporting group > 1 cases for Deconv op

Posted by GitBox <gi...@apache.org>.
mshr-h commented on a change in pull request #8260:
URL: https://github.com/apache/tvm/pull/8260#discussion_r670054653



##########
File path: python/tvm/relay/frontend/caffe.py
##########
@@ -511,19 +511,72 @@ def convert_deconv(self, op):
         if weight:
             kh, kw = params["kernel_size"]
             weight_shape = [-1, conv_params.num_output, kh, kw]
-            weight_value = np.asarray(weight.data, np.float32)
+            if not weight.data:
+                if conv_params.weight_filler:
+                    _filler = conv_params.weight_filler.value
+                    weight_value = np.full(weight.shape.dim, _filler, np.float32)
+                else:
+                    raise tvm.error.OpAttributeInvalid("At least weight_filler must be given")
+            else:
+                weight_value = np.asarray(weight.data, np.float32)
             weight_value = np.reshape(weight_value, weight_shape)
         else:
-            raise Exception("No weight value of layer {} in caffemodel".format(op.name))
+            raise tvm.error.OpAttributeRequired(
+                "No weight value of layer {} in caffemodel".format(op.name)
+            )
 
         weight_expr = self.exp_tab.new_const(weight_value, dtype="float32")
         in_expr = self.exp_tab.get_expr(inputs[0])
-        out = _op.nn.conv2d_transpose(data=in_expr, weight=weight_expr, **params)
-        if bias:
 
+        groups = params["groups"]
+        channels = params["channels"]
+
+        if bias:
             bias_value = np.asarray(bias.data, np.float32)
             bias_expr = self.exp_tab.new_const(bias_value, dtype="float32")
-            out = _op.nn.bias_add(out, bias_expr)
+
+        if groups > channels:
+            raise tvm.error.OpAttributeInvalid(
+                "Groups cannot be larger than the number of input channels"
+            )
+
+        if groups == channels:

Review comment:
       If `groups == channels` and `groups==1` conditions are both true, it goes into line 544. Is this behavior correct?




-- 
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: commits-unsubscribe@tvm.apache.org

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



[GitHub] [tvm] zotanika commented on a change in pull request #8260: [Caffe Frontend] supporting group > 1 cases for Deconv op

Posted by GitBox <gi...@apache.org>.
zotanika commented on a change in pull request #8260:
URL: https://github.com/apache/tvm/pull/8260#discussion_r672730636



##########
File path: python/tvm/relay/frontend/caffe.py
##########
@@ -511,19 +511,72 @@ def convert_deconv(self, op):
         if weight:
             kh, kw = params["kernel_size"]
             weight_shape = [-1, conv_params.num_output, kh, kw]
-            weight_value = np.asarray(weight.data, np.float32)
+            if not weight.data:
+                if conv_params.weight_filler:
+                    _filler = conv_params.weight_filler.value
+                    weight_value = np.full(weight.shape.dim, _filler, np.float32)
+                else:
+                    raise tvm.error.OpAttributeInvalid("At least weight_filler must be given")
+            else:
+                weight_value = np.asarray(weight.data, np.float32)
             weight_value = np.reshape(weight_value, weight_shape)
         else:
-            raise Exception("No weight value of layer {} in caffemodel".format(op.name))
+            raise tvm.error.OpAttributeRequired(
+                "No weight value of layer {} in caffemodel".format(op.name)
+            )
 
         weight_expr = self.exp_tab.new_const(weight_value, dtype="float32")
         in_expr = self.exp_tab.get_expr(inputs[0])
-        out = _op.nn.conv2d_transpose(data=in_expr, weight=weight_expr, **params)
-        if bias:
 
+        groups = params["groups"]
+        channels = params["channels"]
+
+        if bias:
             bias_value = np.asarray(bias.data, np.float32)
             bias_expr = self.exp_tab.new_const(bias_value, dtype="float32")
-            out = _op.nn.bias_add(out, bias_expr)
+
+        if groups > channels:
+            raise tvm.error.OpAttributeInvalid(
+                "Groups cannot be larger than the number of input channels"
+            )
+
+        if groups == channels:

Review comment:
       Dear @mshr-h, Thank you for your valuable comment.
   `groups==1` is the only case that the original author intended to handle, no matter how many channels are given in this case. The routine at line 544 are actually falling back to the original implementation of back-end of Deconv op.
   For the necessity of handling multiple groups in Caffe Deconv op, you may refer to several implementations of image-enhancement networks including upscaling layers, such as [demosaicnet_caffe](https://github.com/mgharbi/demosaicnet_caffe).




-- 
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: commits-unsubscribe@tvm.apache.org

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



[GitHub] [tvm] zotanika commented on a change in pull request #8260: [Caffe Frontend] supporting group > 1 cases for Deconv op

Posted by GitBox <gi...@apache.org>.
zotanika commented on a change in pull request #8260:
URL: https://github.com/apache/tvm/pull/8260#discussion_r672730636



##########
File path: python/tvm/relay/frontend/caffe.py
##########
@@ -511,19 +511,72 @@ def convert_deconv(self, op):
         if weight:
             kh, kw = params["kernel_size"]
             weight_shape = [-1, conv_params.num_output, kh, kw]
-            weight_value = np.asarray(weight.data, np.float32)
+            if not weight.data:
+                if conv_params.weight_filler:
+                    _filler = conv_params.weight_filler.value
+                    weight_value = np.full(weight.shape.dim, _filler, np.float32)
+                else:
+                    raise tvm.error.OpAttributeInvalid("At least weight_filler must be given")
+            else:
+                weight_value = np.asarray(weight.data, np.float32)
             weight_value = np.reshape(weight_value, weight_shape)
         else:
-            raise Exception("No weight value of layer {} in caffemodel".format(op.name))
+            raise tvm.error.OpAttributeRequired(
+                "No weight value of layer {} in caffemodel".format(op.name)
+            )
 
         weight_expr = self.exp_tab.new_const(weight_value, dtype="float32")
         in_expr = self.exp_tab.get_expr(inputs[0])
-        out = _op.nn.conv2d_transpose(data=in_expr, weight=weight_expr, **params)
-        if bias:
 
+        groups = params["groups"]
+        channels = params["channels"]
+
+        if bias:
             bias_value = np.asarray(bias.data, np.float32)
             bias_expr = self.exp_tab.new_const(bias_value, dtype="float32")
-            out = _op.nn.bias_add(out, bias_expr)
+
+        if groups > channels:
+            raise tvm.error.OpAttributeInvalid(
+                "Groups cannot be larger than the number of input channels"
+            )
+
+        if groups == channels:

Review comment:
       Dear @makihiro ,Thank you for your valuable comment.
   `groups==1` is the only case that the original author intended to handle, no matter how many channels are given in this case. The routine at line 544 are actually falling back to the original implementation of back-end of Deconv op.
   For the necessity of handling multiple groups in Caffe Deconv op, you may refer to several implementations of image-enhancement networks including upscaling layers, such as [demosaicnet_caffe](https://github.com/mgharbi/demosaicnet_caffe).




-- 
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: commits-unsubscribe@tvm.apache.org

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



[GitHub] [tvm] mshr-h commented on pull request #8260: [Caffe Frontend] supporting group > 1 cases for Deconv op

Posted by GitBox <gi...@apache.org>.
mshr-h commented on pull request #8260:
URL: https://github.com/apache/tvm/pull/8260#issuecomment-882363038


   I want to try your PR.
   
   Is there any pretrained models which contains Deconv with group > 1?


-- 
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: commits-unsubscribe@tvm.apache.org

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