SIGN IN SIGN UP

Implement grid_priors op (#4440)

Summary:
Pull Request resolved: https://github.com/pytorch/executorch/pull/4440

Modify the spec of customized op `grid_prirors` to take a tensor as input. Compared to previous definition, the `height` and `width` arguments will be determined by the input tensor as `height, width = self.shape[-2:]`. The reason we change the spec is: if we want to support dynamic shape, the input should be a tensor.

Implement customized op `grid_priors`.  This op is used to generate mapped x,y points from different level feature map to original images. Op spec:
```
(Tensor self, int stride, float offset) -> Tensor
```

Example:
```
input_tensor = torch.rand(size = [1, 5, 2, 3])
stride = 8
offset = 0.5
output.shape = [3x2, 2]
output = tensor([[ 4.,  4.],
        [12.,  4.],
        [20.,  4.],
        [ 4., 12.],
        [12., 12.],
        [20., 12.]])
```
Add smoke test for now due to some issue to lower customized op to Vulkan backend.

Will add unit test and nn.Module test when be able to lower customized op from PyTorch to Vulkan backend.

bypass-github-export-checks
bypass-github-pytorch-ci-checks
bypass-github-executorch-ci-checks

Reviewed By: copyrightly

Differential Revision: D60203196

fbshipit-source-id: 93e5180e80e07cc0b9acb50890a1187ce0f82951
Y
Yujie Hui committed
9aeceeee3df8096ba7c89f422f584e26ace60733
Parent: 69f3f1c
Committed by Facebook GitHub Bot <facebook-github-bot@users.noreply.github.com> on 7/30/2024, 10:29:34 PM