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 2020/03/15 21:02:00 UTC

[GitHub] [incubator-tvm] masahi opened a new pull request #5075: [Torch] Add initial 3D op support and test on Resnet 3D

masahi opened a new pull request #5075: [Torch] Add initial 3D op support and test on Resnet 3D
URL: https://github.com/apache/incubator-tvm/pull/5075
 
 
   Thanks for contributing to TVM!   Please refer to guideline https://docs.tvm.ai/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


With regards,
Apache Git Services

[GitHub] [incubator-tvm] anijain2305 commented on a change in pull request #5075: [Torch] Add initial 3D op support and test on Resnet 3D

Posted by GitBox <gi...@apache.org>.
anijain2305 commented on a change in pull request #5075: [Torch] Add initial 3D op support and test on Resnet 3D
URL: https://github.com/apache/incubator-tvm/pull/5075#discussion_r395140350
 
 

 ##########
 File path: python/tvm/relay/frontend/pytorch.py
 ##########
 @@ -183,9 +183,27 @@ def _impl(inputs, input_types):
         data = inputs[0]
         output_size = _infer_shape(inputs[1])
 
+        # returns dummy indices too
         return _op.nn.adaptive_max_pool2d(
             data,
-            output_size=output_size)
+            output_size=output_size), None
+    return _impl
+
+def _adaptive_max_3d():
 
 Review comment:
   Change name to _adaptive_max_pool_3d?

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


With regards,
Apache Git Services

[GitHub] [incubator-tvm] jwfromm commented on a change in pull request #5075: [Torch] Add initial 3D op support and test on Resnet 3D

Posted by GitBox <gi...@apache.org>.
jwfromm commented on a change in pull request #5075: [Torch] Add initial 3D op support and test on Resnet 3D
URL: https://github.com/apache/incubator-tvm/pull/5075#discussion_r393304654
 
 

 ##########
 File path: python/tvm/relay/frontend/pytorch.py
 ##########
 @@ -183,9 +183,27 @@ def _impl(inputs, input_types):
         data = inputs[0]
         output_size = _infer_shape(inputs[1])
 
+        # returns dummy indices too
         return _op.nn.adaptive_max_pool2d(
             data,
-            output_size=output_size)
+            output_size=output_size), None
+    return _impl
+
+def _adaptive_max_3d():
+    def _impl(inputs, input_types):
+        data = inputs[0]
+        output_size = _infer_shape(inputs[1])
+        # returns dummy indices too
+        return _op.nn.adaptive_max_pool3d(data, output_size=output_size), None
 
 Review comment:
   Does adaptive pooling in pytorch always return two values? The documentation seems to imply that it only returns indices if the `return_indices` parameter is `True`.

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


With regards,
Apache Git Services

[GitHub] [incubator-tvm] jwfromm commented on a change in pull request #5075: [Torch] Add initial 3D op support and test on Resnet 3D

Posted by GitBox <gi...@apache.org>.
jwfromm commented on a change in pull request #5075: [Torch] Add initial 3D op support and test on Resnet 3D
URL: https://github.com/apache/incubator-tvm/pull/5075#discussion_r393303491
 
 

 ##########
 File path: tests/python/frontend/pytorch/test_forward.py
 ##########
 @@ -708,6 +701,31 @@ def forward(self, x):
     verify_model(ToInt().eval(), torch.tensor(2.0))
 
 
+def test_adaptive_pool3d():
+    inp = torch.rand((1, 32, 16, 16, 16))
+    verify_model(torch.nn.AdaptiveMaxPool3d((1, 1, 1)).eval(), inp)
+    verify_model(torch.nn.AdaptiveMaxPool3d((2, 2, 2)).eval(), inp)
+    verify_model(torch.nn.AdaptiveAvgPool3d((1, 1, 1)).eval(), inp)
+    verify_model(torch.nn.AdaptiveAvgPool3d((2, 2, 2)).eval(), inp)
+    verify_model(torch.nn.AdaptiveAvgPool3d((4, 8, 8)).eval(), inp)
+    verify_model(torch.nn.AdaptiveMaxPool3d((7, 8, 9)).eval(), inp)
+
+
+def test_conv3d():
+    inp = torch.rand((1, 32, 16, 16, 16))
+    verify_model(torch.nn.Conv3d(32, 16, (3, 3, 3),
+                                 padding=(1, 1, 1)).eval(),
+                 inp),
+    verify_model(torch.nn.Conv3d(32, 16, (5, 5, 5),
+                                 padding=(2, 2, 2)).eval(),
+                 inp),
+    verify_model(torch.nn.Conv3d(32, 16, kernel_size=1).eval(),
+                 inp)
+    # downsample
+    verify_model(torch.nn.Conv3d(32, 16, kernel_size=1, stride=2).eval(),
 
 Review comment:
   Probably worth adding one other input shape to test here as well.

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


With regards,
Apache Git Services

[GitHub] [incubator-tvm] anijain2305 commented on issue #5075: [Torch] Add initial 3D op support and test on Resnet 3D

Posted by GitBox <gi...@apache.org>.
anijain2305 commented on issue #5075: [Torch] Add initial 3D op support and test on Resnet 3D
URL: https://github.com/apache/incubator-tvm/pull/5075#issuecomment-601405610
 
 
   Thanks @masahi @jwfromm This is merged

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


With regards,
Apache Git Services

[GitHub] [incubator-tvm] masahi commented on a change in pull request #5075: [Torch] Add initial 3D op support and test on Resnet 3D

Posted by GitBox <gi...@apache.org>.
masahi commented on a change in pull request #5075: [Torch] Add initial 3D op support and test on Resnet 3D
URL: https://github.com/apache/incubator-tvm/pull/5075#discussion_r393313322
 
 

 ##########
 File path: python/tvm/relay/frontend/pytorch.py
 ##########
 @@ -183,9 +183,27 @@ def _impl(inputs, input_types):
         data = inputs[0]
         output_size = _infer_shape(inputs[1])
 
+        # returns dummy indices too
         return _op.nn.adaptive_max_pool2d(
             data,
-            output_size=output_size)
+            output_size=output_size), None
+    return _impl
+
+def _adaptive_max_3d():
+    def _impl(inputs, input_types):
+        data = inputs[0]
+        output_size = _infer_shape(inputs[1])
+        # returns dummy indices too
+        return _op.nn.adaptive_max_pool3d(data, output_size=output_size), None
 
 Review comment:
   That is for python layer, after jitting torchscript `aten::adaptive_max_pool3d` (and 2d) op always returns 2 results. If `return_indices` is False, I think the second tensor is empty.
   
   See 
   https://github.com/pytorch/pytorch/blob/master/aten/src/ATen/native/AdaptiveMaxPooling3d.cpp#L421

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


With regards,
Apache Git Services

[GitHub] [incubator-tvm] masahi commented on a change in pull request #5075: [Torch] Add initial 3D op support and test on Resnet 3D

Posted by GitBox <gi...@apache.org>.
masahi commented on a change in pull request #5075: [Torch] Add initial 3D op support and test on Resnet 3D
URL: https://github.com/apache/incubator-tvm/pull/5075#discussion_r393317839
 
 

 ##########
 File path: tests/python/frontend/pytorch/test_forward.py
 ##########
 @@ -708,6 +701,31 @@ def forward(self, x):
     verify_model(ToInt().eval(), torch.tensor(2.0))
 
 
+def test_adaptive_pool3d():
+    inp = torch.rand((1, 32, 16, 16, 16))
+    verify_model(torch.nn.AdaptiveMaxPool3d((1, 1, 1)).eval(), inp)
+    verify_model(torch.nn.AdaptiveMaxPool3d((2, 2, 2)).eval(), inp)
+    verify_model(torch.nn.AdaptiveAvgPool3d((1, 1, 1)).eval(), inp)
+    verify_model(torch.nn.AdaptiveAvgPool3d((2, 2, 2)).eval(), inp)
+    verify_model(torch.nn.AdaptiveAvgPool3d((4, 8, 8)).eval(), inp)
+    verify_model(torch.nn.AdaptiveMaxPool3d((7, 8, 9)).eval(), inp)
+
+
+def test_conv3d():
+    inp = torch.rand((1, 32, 16, 16, 16))
+    verify_model(torch.nn.Conv3d(32, 16, (3, 3, 3),
+                                 padding=(1, 1, 1)).eval(),
+                 inp),
+    verify_model(torch.nn.Conv3d(32, 16, (5, 5, 5),
+                                 padding=(2, 2, 2)).eval(),
+                 inp),
+    verify_model(torch.nn.Conv3d(32, 16, kernel_size=1).eval(),
+                 inp)
+    # downsample
+    verify_model(torch.nn.Conv3d(32, 16, kernel_size=1, stride=2).eval(),
 
 Review comment:
   added more tests

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


With regards,
Apache Git Services

[GitHub] [incubator-tvm] masahi commented on issue #5075: [Torch] Add initial 3D op support and test on Resnet 3D

Posted by GitBox <gi...@apache.org>.
masahi commented on issue #5075: [Torch] Add initial 3D op support and test on Resnet 3D
URL: https://github.com/apache/incubator-tvm/pull/5075#issuecomment-601403205
 
 
   @anijain2305 ready to go

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


With regards,
Apache Git Services

[GitHub] [incubator-tvm] jwfromm commented on a change in pull request #5075: [Torch] Add initial 3D op support and test on Resnet 3D

Posted by GitBox <gi...@apache.org>.
jwfromm commented on a change in pull request #5075: [Torch] Add initial 3D op support and test on Resnet 3D
URL: https://github.com/apache/incubator-tvm/pull/5075#discussion_r393304654
 
 

 ##########
 File path: python/tvm/relay/frontend/pytorch.py
 ##########
 @@ -183,9 +183,27 @@ def _impl(inputs, input_types):
         data = inputs[0]
         output_size = _infer_shape(inputs[1])
 
+        # returns dummy indices too
         return _op.nn.adaptive_max_pool2d(
             data,
-            output_size=output_size)
+            output_size=output_size), None
+    return _impl
+
+def _adaptive_max_3d():
+    def _impl(inputs, input_types):
+        data = inputs[0]
+        output_size = _infer_shape(inputs[1])
+        # returns dummy indices too
+        return _op.nn.adaptive_max_pool3d(data, output_size=output_size), None
 
 Review comment:
   Does adaptive pooling in pytorch always return two values? The documentation seems to imply that it only returns indices if the `return_indices` parameters is `True`.

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


With regards,
Apache Git Services

[GitHub] [incubator-tvm] jwfromm commented on a change in pull request #5075: [Torch] Add initial 3D op support and test on Resnet 3D

Posted by GitBox <gi...@apache.org>.
jwfromm commented on a change in pull request #5075: [Torch] Add initial 3D op support and test on Resnet 3D
URL: https://github.com/apache/incubator-tvm/pull/5075#discussion_r393303279
 
 

 ##########
 File path: tests/python/frontend/pytorch/test_forward.py
 ##########
 @@ -708,6 +701,31 @@ def forward(self, x):
     verify_model(ToInt().eval(), torch.tensor(2.0))
 
 
+def test_adaptive_pool3d():
+    inp = torch.rand((1, 32, 16, 16, 16))
+    verify_model(torch.nn.AdaptiveMaxPool3d((1, 1, 1)).eval(), inp)
+    verify_model(torch.nn.AdaptiveMaxPool3d((2, 2, 2)).eval(), inp)
+    verify_model(torch.nn.AdaptiveAvgPool3d((1, 1, 1)).eval(), inp)
+    verify_model(torch.nn.AdaptiveAvgPool3d((2, 2, 2)).eval(), inp)
+    verify_model(torch.nn.AdaptiveAvgPool3d((4, 8, 8)).eval(), inp)
+    verify_model(torch.nn.AdaptiveMaxPool3d((7, 8, 9)).eval(), inp)
 
 Review comment:
   Maybe instead of the (2,2,2) output shape tests, we can test a different (non-power-of-two) shaped input.

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


With regards,
Apache Git Services

[GitHub] [incubator-tvm] masahi commented on issue #5075: [Torch] Add initial 3D op support and test on Resnet 3D

Posted by GitBox <gi...@apache.org>.
masahi commented on issue #5075: [Torch] Add initial 3D op support and test on Resnet 3D
URL: https://github.com/apache/incubator-tvm/pull/5075#issuecomment-600023089
 
 
   Ready to merge @kevinthesun @anijain2305 @icemelon9 @yzhliu @tqchen 

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


With regards,
Apache Git Services

[GitHub] [incubator-tvm] anijain2305 merged pull request #5075: [Torch] Add initial 3D op support and test on Resnet 3D

Posted by GitBox <gi...@apache.org>.
anijain2305 merged pull request #5075: [Torch] Add initial 3D op support and test on Resnet 3D
URL: https://github.com/apache/incubator-tvm/pull/5075
 
 
   

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


With regards,
Apache Git Services

[GitHub] [incubator-tvm] anijain2305 commented on a change in pull request #5075: [Torch] Add initial 3D op support and test on Resnet 3D

Posted by GitBox <gi...@apache.org>.
anijain2305 commented on a change in pull request #5075: [Torch] Add initial 3D op support and test on Resnet 3D
URL: https://github.com/apache/incubator-tvm/pull/5075#discussion_r395140623
 
 

 ##########
 File path: python/tvm/relay/frontend/pytorch.py
 ##########
 @@ -183,9 +183,27 @@ def _impl(inputs, input_types):
         data = inputs[0]
         output_size = _infer_shape(inputs[1])
 
+        # returns dummy indices too
         return _op.nn.adaptive_max_pool2d(
             data,
-            output_size=output_size)
+            output_size=output_size), None
+    return _impl
+
+def _adaptive_max_3d():
+    def _impl(inputs, input_types):
+        data = inputs[0]
+        output_size = _infer_shape(inputs[1])
+        # returns dummy indices too
+        return _op.nn.adaptive_max_pool3d(data, output_size=output_size), None
+
+    return _impl
+
+def _adaptive_avg_3d():
 
 Review comment:
   Change name to _adaptive_avg_pool_3d?

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


With regards,
Apache Git Services

[GitHub] [incubator-tvm] masahi commented on a change in pull request #5075: [Torch] Add initial 3D op support and test on Resnet 3D

Posted by GitBox <gi...@apache.org>.
masahi commented on a change in pull request #5075: [Torch] Add initial 3D op support and test on Resnet 3D
URL: https://github.com/apache/incubator-tvm/pull/5075#discussion_r393317483
 
 

 ##########
 File path: tests/python/frontend/pytorch/test_forward.py
 ##########
 @@ -708,6 +701,31 @@ def forward(self, x):
     verify_model(ToInt().eval(), torch.tensor(2.0))
 
 
+def test_adaptive_pool3d():
+    inp = torch.rand((1, 32, 16, 16, 16))
+    verify_model(torch.nn.AdaptiveMaxPool3d((1, 1, 1)).eval(), inp)
+    verify_model(torch.nn.AdaptiveMaxPool3d((2, 2, 2)).eval(), inp)
+    verify_model(torch.nn.AdaptiveAvgPool3d((1, 1, 1)).eval(), inp)
+    verify_model(torch.nn.AdaptiveAvgPool3d((2, 2, 2)).eval(), inp)
+    verify_model(torch.nn.AdaptiveAvgPool3d((4, 8, 8)).eval(), inp)
+    verify_model(torch.nn.AdaptiveMaxPool3d((7, 8, 9)).eval(), inp)
 
 Review comment:
   Added two more input shapes. Since video use case seems to be more common, the new input shape has the depth dimension different than height/width.

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


With regards,
Apache Git Services