You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by "jwfromm (via GitHub)" <gi...@apache.org> on 2023/08/17 22:43:34 UTC

[GitHub] [tvm] jwfromm opened a new pull request, #15586: [Unity][Frontend][NN] Conv2D NN module

jwfromm opened a new pull request, #15586:
URL: https://github.com/apache/tvm/pull/15586

   In this PR I add support for `Conv2D` in our torch-like nn api. I'm planning on adding quite a few other such layers but wanted to get feedback on this one to make sure there arent any mistakes that would propagate :) 


-- 
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] jwfromm merged pull request #15586: [Unity][Frontend][NN] Conv2D NN module

Posted by "jwfromm (via GitHub)" <gi...@apache.org>.
jwfromm merged PR #15586:
URL: https://github.com/apache/tvm/pull/15586


-- 
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] LeshengJin commented on a diff in pull request #15586: [Unity][Frontend][NN] Conv2D NN module

Posted by "LeshengJin (via GitHub)" <gi...@apache.org>.
LeshengJin commented on code in PR #15586:
URL: https://github.com/apache/tvm/pull/15586#discussion_r1297897338


##########
python/tvm/relax/frontend/nn/modules.py:
##########
@@ -107,6 +107,65 @@ def forward(self, x: Tensor) -> Tensor:  # pylint: disable=invalid-name
         return x
 
 
+class Conv2D(Module):
+    """
+    Module for conv2d layer.
+    """
+
+    def __init__(  # pylint: disable=too-many-arguments
+        self,
+        in_channels: int,
+        out_channels: int,
+        kernel_size: int,
+        stride: int = 1,
+        padding: int = 0,
+        dilation: int = 1,
+        groups: int = 1,
+        bias: bool = True,
+        dtype: Optional[str] = None,
+    ):
+        super().__init__()
+        self.in_channels = in_channels
+        self.out_channels = out_channels
+        self.kernel_size = kernel_size
+        self.stride = stride
+        self.padding = padding
+        self.dilation = dilation
+        self.groups = groups
+
+        self.weight = Parameter(
+            (
+                self.out_channels,
+                int(self.in_channels / self.groups),
+                self.kernel_size,
+                self.kernel_size,
+            ),
+            dtype,
+        )
+        if bias:
+            self.bias = Parameter((self.out_channels,), dtype)
+        else:
+            self.bias = None
+
+    def forward(self, x: Tensor) -> Tensor:  # pylint: disable=invalid-name
+        """
+        Forward method for conv2d layer.
+
+        Parameters
+        ----------
+        x : Tensor
+            The input tensor.
+
+        Returns
+        -------
+        ret : Tensor
+            The output tensor for the linear layer.

Review Comment:
   A small typo. 
   `for the linear layer`



-- 
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] tvm-bot commented on pull request #15586: [Unity][Frontend][NN] Conv2D NN module

Posted by "tvm-bot (via GitHub)" <gi...@apache.org>.
tvm-bot commented on PR #15586:
URL: https://github.com/apache/tvm/pull/15586#issuecomment-1683072466

   <!---bot-comment-->
   
   Thanks for contributing to TVM! Please refer to the contributing guidelines https://tvm.apache.org/docs/contribute/ for useful information and tips. Please request code reviews from [Reviewers](https://github.com/apache/incubator-tvm/blob/master/CONTRIBUTORS.md#reviewers) by @-ing them in a comment.
   
   <!--bot-comment-ccs-start-->
    * cc @quic-sanirudh <sub>See [#10317](https://github.com/apache/tvm/issues/10317) for details</sub><!--bot-comment-ccs-end-->
   
   <sub>Generated by [tvm-bot](https://github.com/apache/tvm/blob/main/ci/README.md#github-actions)</sub>


-- 
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] LeshengJin commented on a diff in pull request #15586: [Unity][Frontend][NN] Conv2D NN module

Posted by "LeshengJin (via GitHub)" <gi...@apache.org>.
LeshengJin commented on code in PR #15586:
URL: https://github.com/apache/tvm/pull/15586#discussion_r1297897338


##########
python/tvm/relax/frontend/nn/modules.py:
##########
@@ -107,6 +107,65 @@ def forward(self, x: Tensor) -> Tensor:  # pylint: disable=invalid-name
         return x
 
 
+class Conv2D(Module):
+    """
+    Module for conv2d layer.
+    """
+
+    def __init__(  # pylint: disable=too-many-arguments
+        self,
+        in_channels: int,
+        out_channels: int,
+        kernel_size: int,
+        stride: int = 1,
+        padding: int = 0,
+        dilation: int = 1,
+        groups: int = 1,
+        bias: bool = True,
+        dtype: Optional[str] = None,
+    ):
+        super().__init__()
+        self.in_channels = in_channels
+        self.out_channels = out_channels
+        self.kernel_size = kernel_size
+        self.stride = stride
+        self.padding = padding
+        self.dilation = dilation
+        self.groups = groups
+
+        self.weight = Parameter(
+            (
+                self.out_channels,
+                int(self.in_channels / self.groups),
+                self.kernel_size,
+                self.kernel_size,
+            ),
+            dtype,
+        )
+        if bias:
+            self.bias = Parameter((self.out_channels,), dtype)
+        else:
+            self.bias = None
+
+    def forward(self, x: Tensor) -> Tensor:  # pylint: disable=invalid-name
+        """
+        Forward method for conv2d layer.
+
+        Parameters
+        ----------
+        x : Tensor
+            The input tensor.
+
+        Returns
+        -------
+        ret : Tensor
+            The output tensor for the linear layer.

Review Comment:
   A small typo



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