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/02/29 21:38:09 UTC
[GitHub] [incubator-tvm] anijain2305 commented on a change in pull request
#4961: [Torch] Upsampling op support and enable registering a user defined
op conversion map
anijain2305 commented on a change in pull request #4961: [Torch] Upsampling op support and enable registering a user defined op conversion map
URL: https://github.com/apache/incubator-tvm/pull/4961#discussion_r386057076
##########
File path: tests/python/frontend/pytorch/test_forward.py
##########
@@ -730,6 +752,55 @@ def test_vgg11_bn():
"""
+def test_custom_conversion_map():
+ def get_roi_align():
+ pool_size = 5
+ n_channels = 2 * (pool_size ** 2)
+ x = torch.rand(2, n_channels, 10, 10)
+ rois = torch.tensor([[0, 0, 0, 9, 9], # format is (xyxy)
+ [0, 0, 5, 4, 9],
+ [0, 5, 5, 9, 9],
+ [1, 0, 0, 9, 9]], dtype=torch.float)
+ roi_align = torchvision.ops.RoIAlign(pool_size, spatial_scale=1,
+ sampling_ratio=-1)
+ return roi_align.eval(), [x, rois]
+
+ def convert_roi_align():
+ def _impl(inputs, input_types):
+ spatial_scale = inputs[2]
+ pooled_size = (inputs[3], inputs[4])
+ sampling_ratio = inputs[5]
+ return relay.op.vision.roi_align(inputs[0], inputs[1],
+ pooled_size, spatial_scale,
+ sampling_ratio)
+ return _impl
+
+ custom_map = {'torchvision::roi_align': convert_roi_align()}
+ model, inputs = get_roi_align()
+
+ verify_model(model, inputs, custom_map)
+
+
+def test_segmentaton_models():
+ class SegmentationModelWrapper(Module):
+ def __init__(self, model):
+ super().__init__()
+ self.model = model
+
+ def forward(self, inp):
+ out = self.model(inp)
+ return out["out"]
+
+ fcn = torchvision.models.segmentation.fcn_resnet101(pretrained=True)
+ deeplab = torchvision.models.segmentation.deeplabv3_resnet101(pretrained=True)
+
+ inp = [torch.rand((1, 3, 300, 300), dtype=torch.float)]
+
+ for model in [fcn, deeplab]:
+ verify_model(SegmentationModelWrapper(model.eval()), inp,
+ ctx_list=[("cuda", tvm.gpu(0))]) # dilated covolution not supported on x86
Review comment:
Maybe adding the issue number is helpful here?
----------------------------------------------------------------
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