Commit 22fd2a7
[PyTorch] Add Vulkan support and tests for at::select.int operator, 4 dim/rank tensor case (#96228)
Summary:
Pull Request resolved: #96228
Currently, selection along a dimension/rank is only supported for 3D/rank tensors in PyTorch Vulkan. This adds support for 4D/rank tensors at selection along batch, channel (depth), height, and width.
Additionally:
- The existing implementations have been name-refactored to reflect whether they operate on 3d or 4d tensors.
- The params buffer for all select operations now use `ivec2` or `ivec4` only, for memory alignment safety.
Test Plan:
**Internal:**
1. `buck run --target-platforms ovr_config//platform/macos:arm64-fbsource //xplat/caffe2:pt_vulkan_api_test_binAppleMac\#macosx-arm64 -c pt.vulkan_full_precision=1` on Apple M1 MacBook
2. Confirm all tests pass with no regression, and the directly affected tests `select_4d_*`, refactored `select_3d_`, pass
3. Test output P636928908, in particular:
```
[...bunch of other tests...]
[ RUN ] VulkanAPITest.select_3d_depth_small
[ OK ] VulkanAPITest.select_3d_depth_small (1 ms)
[ RUN ] VulkanAPITest.select_3d_depth_medium
[ OK ] VulkanAPITest.select_3d_depth_medium (0 ms)
[ RUN ] VulkanAPITest.select_3d_depth_large
[ OK ] VulkanAPITest.select_3d_depth_large (1 ms)
[ RUN ] VulkanAPITest.select_3d_height_small
[ OK ] VulkanAPITest.select_3d_height_small (0 ms)
[ RUN ] VulkanAPITest.select_3d_height_medium
[ OK ] VulkanAPITest.select_3d_height_medium (0 ms)
[ RUN ] VulkanAPITest.select_3d_height_medium1
[ OK ] VulkanAPITest.select_3d_height_medium1 (0 ms)
[ RUN ] VulkanAPITest.select_3d_height_medium2
[ OK ] VulkanAPITest.select_3d_height_medium2 (0 ms)
[ RUN ] VulkanAPITest.select_3d_height_large
[ OK ] VulkanAPITest.select_3d_height_large (1 ms)
[ RUN ] VulkanAPITest.select_3d_width_small
[ OK ] VulkanAPITest.select_3d_width_small (0 ms)
[ RUN ] VulkanAPITest.select_3d_width_medium
[ OK ] VulkanAPITest.select_3d_width_medium (0 ms)
[ RUN ] VulkanAPITest.select_3d_width_medium2
[ OK ] VulkanAPITest.select_3d_width_medium2 (0 ms)
[ RUN ] VulkanAPITest.select_3d_width_large
[ OK ] VulkanAPITest.select_3d_width_large (1 ms)
[ RUN ] VulkanAPITest.select_4d_batch_small
[ OK ] VulkanAPITest.select_4d_batch_small (0 ms)
[ RUN ] VulkanAPITest.select_4d_batch_medium
[ OK ] VulkanAPITest.select_4d_batch_medium (0 ms)
[ RUN ] VulkanAPITest.select_4d_batch_large
[ OK ] VulkanAPITest.select_4d_batch_large (1 ms)
[ RUN ] VulkanAPITest.select_4d_depth_small
[ OK ] VulkanAPITest.select_4d_depth_small (1 ms)
[ RUN ] VulkanAPITest.select_4d_depth_medium
[ OK ] VulkanAPITest.select_4d_depth_medium (0 ms)
[ RUN ] VulkanAPITest.select_4d_depth_large
[ OK ] VulkanAPITest.select_4d_depth_large (1 ms)
[ RUN ] VulkanAPITest.select_4d_height_small
[ OK ] VulkanAPITest.select_4d_height_small (0 ms)
[ RUN ] VulkanAPITest.select_4d_height_medium
[ OK ] VulkanAPITest.select_4d_height_medium (0 ms)
[ RUN ] VulkanAPITest.select_4d_height_large
[ OK ] VulkanAPITest.select_4d_height_large (1 ms)
[ RUN ] VulkanAPITest.select_4d_width_small
[ OK ] VulkanAPITest.select_4d_width_small (0 ms)
[ RUN ] VulkanAPITest.select_4d_width_medium
[ OK ] VulkanAPITest.select_4d_width_medium (0 ms)
[ RUN ] VulkanAPITest.select_4d_width_large
[ OK ] VulkanAPITest.select_4d_width_large (1 ms)
[...bunch of other tests...]
[ FAILED ] 7 tests, listed below:
[ FAILED ] VulkanAPITest.cat_dim1_singledepth_success
[ FAILED ] VulkanAPITest.gru_success
[ FAILED ] VulkanAPITest.gru_mclareninputs_success
[ FAILED ] VulkanAPITest.gru_prepack_success
[ FAILED ] VulkanAPITest.lstm_success
[ FAILED ] VulkanAPITest.lstm_mclareninputs_success
[ FAILED ] VulkanAPITest.lstm_prepack_success
```
Reviewed By: SS-JIA
Differential Revision: D42623181
fbshipit-source-id: 5b42fe7f2ceb3d4d3dddd7a7389ccc343320da7d1 parent b3a0798 commit 22fd2a7
10 files changed
Lines changed: 549 additions & 69 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
Lines changed: 9 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
13 | | - | |
14 | | - | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
15 | 19 | | |
16 | 20 | | |
17 | 21 | | |
| |||
21 | 25 | | |
22 | 26 | | |
23 | 27 | | |
24 | | - | |
| 28 | + | |
25 | 29 | | |
26 | 30 | | |
27 | 31 | | |
| |||
31 | 35 | | |
32 | 36 | | |
33 | 37 | | |
34 | | - | |
| 38 | + | |
35 | 39 | | |
36 | 40 | | |
37 | 41 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
Lines changed: 9 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
13 | | - | |
14 | | - | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
15 | 19 | | |
16 | 20 | | |
17 | 21 | | |
18 | 22 | | |
19 | 23 | | |
20 | 24 | | |
21 | 25 | | |
22 | | - | |
| 26 | + | |
23 | 27 | | |
24 | 28 | | |
25 | 29 | | |
| |||
31 | 35 | | |
32 | 36 | | |
33 | 37 | | |
34 | | - | |
| 38 | + | |
35 | 39 | | |
36 | 40 | | |
37 | 41 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
0 commit comments