Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Pytorch][Vulkan] mean.dim #111609

Closed
wants to merge 1 commit into from
Closed

[Pytorch][Vulkan] mean.dim #111609

wants to merge 1 commit into from

Conversation

copyrightly
Copy link
Contributor

Summary:
We implement torch.mean(input, dim, keepdim) for tensors of 2d to 4d.

Since 0-dim tensor hasn't been supported yet, we only support dim.size() < input.dim() for now. We will support following cases in the future work:

  • dim.size() == input.dim()
  • input.dim() == 1

Test Plan:

[luwei@devbig984.prn1 /data/users/luwei/fbsource (970fcd90c)]$ LD_LIBRARY_PATH=third-party/swiftshader/lib/linux-x64/ buck run fbcode/mode/dev-nosan //xplat/caffe2:pt_vulkan_api_test_bin -- --gtest_filter="*mean*"
Building: finished in 0.1 sec (100%) 339/339 jobs, 0/339 updated
  Total time: 0.1 sec
BUILD SUCCEEDED
Running main() from third-party/googletest/1.11.0/googletest/googletest/src/gtest_main.cc
Note: Google Test filter = *mean*
[==========] Running 7 tests from 1 test suite.
[----------] Global test environment set-up.
[----------] 7 tests from VulkanAPITest
[ RUN      ] VulkanAPITest.mean_invalid_inputs
[       OK ] VulkanAPITest.mean_invalid_inputs (46 ms)
[ RUN      ] VulkanAPITest.mean_dim_2d
[       OK ] VulkanAPITest.mean_dim_2d (127 ms)
[ RUN      ] VulkanAPITest.mean_dim_3d
[       OK ] VulkanAPITest.mean_dim_3d (103 ms)
[ RUN      ] VulkanAPITest.mean_dim_4d
[       OK ] VulkanAPITest.mean_dim_4d (89 ms)
[ RUN      ] VulkanAPITest.mean_dim_keepdim_2d
[       OK ] VulkanAPITest.mean_dim_keepdim_2d (66 ms)
[ RUN      ] VulkanAPITest.mean_dim_keepdim_3d
[       OK ] VulkanAPITest.mean_dim_keepdim_3d (127 ms)
[ RUN      ] VulkanAPITest.mean_dim_keepdim_4d
[       OK ] VulkanAPITest.mean_dim_keepdim_4d (4 ms)
[----------] 7 tests from VulkanAPITest (564 ms total)

[----------] Global test environment tear-down
[==========] 7 tests from 1 test suite ran. (564 ms total)
[  PASSED  ] 7 tests.

Reviewed By: yipjustin

Differential Revision: D50312990

@pytorch-bot
Copy link

pytorch-bot bot commented Oct 19, 2023

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/111609

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit 4784ab7 with merge base 7709382 (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@pytorch-bot pytorch-bot bot added ciflow/periodic Trigger jobs ran periodically on master (periodic.yml) on the PR module: vulkan release notes: vulkan release notes category labels Oct 19, 2023
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D50312990

copyrightly added a commit that referenced this pull request Oct 20, 2023
Summary:

We implement [`torch.mean(input, dim, keepdim)`](https://pytorch.org/docs/stable/generated/torch.mean.html) for tensors of 2d to 4d.

Since 0-dim tensor hasn't been supported yet, we only support `dim.size() < input.dim()` for now. We will support following cases in the future work:
- `dim.size() == input.dim()`
- `input.dim() == 1`

Test Plan:
```
[luwei@devbig984.prn1 /data/users/luwei/fbsource (970fcd90c)]$ LD_LIBRARY_PATH=third-party/swiftshader/lib/linux-x64/ buck run fbcode/mode/dev-nosan //xplat/caffe2:pt_vulkan_api_test_bin -- --gtest_filter="*mean*"
Building: finished in 0.1 sec (100%) 339/339 jobs, 0/339 updated
  Total time: 0.1 sec
BUILD SUCCEEDED
Running main() from third-party/googletest/1.11.0/googletest/googletest/src/gtest_main.cc
Note: Google Test filter = *mean*
[==========] Running 7 tests from 1 test suite.
[----------] Global test environment set-up.
[----------] 7 tests from VulkanAPITest
[ RUN      ] VulkanAPITest.mean_invalid_inputs
[       OK ] VulkanAPITest.mean_invalid_inputs (46 ms)
[ RUN      ] VulkanAPITest.mean_dim_2d
[       OK ] VulkanAPITest.mean_dim_2d (127 ms)
[ RUN      ] VulkanAPITest.mean_dim_3d
[       OK ] VulkanAPITest.mean_dim_3d (103 ms)
[ RUN      ] VulkanAPITest.mean_dim_4d
[       OK ] VulkanAPITest.mean_dim_4d (89 ms)
[ RUN      ] VulkanAPITest.mean_dim_keepdim_2d
[       OK ] VulkanAPITest.mean_dim_keepdim_2d (66 ms)
[ RUN      ] VulkanAPITest.mean_dim_keepdim_3d
[       OK ] VulkanAPITest.mean_dim_keepdim_3d (127 ms)
[ RUN      ] VulkanAPITest.mean_dim_keepdim_4d
[       OK ] VulkanAPITest.mean_dim_keepdim_4d (4 ms)
[----------] 7 tests from VulkanAPITest (564 ms total)

[----------] Global test environment tear-down
[==========] 7 tests from 1 test suite ran. (564 ms total)
[  PASSED  ] 7 tests.
```

Reviewed By: yipjustin

Differential Revision: D50312990
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D50312990

copyrightly added a commit that referenced this pull request Oct 20, 2023
Summary:

We implement [`torch.mean(input, dim, keepdim)`](https://pytorch.org/docs/stable/generated/torch.mean.html) for tensors of 2d to 4d.

Since 0-dim tensor hasn't been supported yet, we only support `dim.size() < input.dim()` for now. We will support following cases in the future work:
- `dim.size() == input.dim()`
- `input.dim() == 1`

Test Plan:
```
[luwei@devbig984.prn1 /data/users/luwei/fbsource (970fcd90c)]$ LD_LIBRARY_PATH=third-party/swiftshader/lib/linux-x64/ buck run fbcode/mode/dev-nosan //xplat/caffe2:pt_vulkan_api_test_bin -- --gtest_filter="*mean*"
Building: finished in 0.1 sec (100%) 339/339 jobs, 0/339 updated
  Total time: 0.1 sec
BUILD SUCCEEDED
Running main() from third-party/googletest/1.11.0/googletest/googletest/src/gtest_main.cc
Note: Google Test filter = *mean*
[==========] Running 7 tests from 1 test suite.
[----------] Global test environment set-up.
[----------] 7 tests from VulkanAPITest
[ RUN      ] VulkanAPITest.mean_invalid_inputs
[       OK ] VulkanAPITest.mean_invalid_inputs (46 ms)
[ RUN      ] VulkanAPITest.mean_dim_2d
[       OK ] VulkanAPITest.mean_dim_2d (127 ms)
[ RUN      ] VulkanAPITest.mean_dim_3d
[       OK ] VulkanAPITest.mean_dim_3d (103 ms)
[ RUN      ] VulkanAPITest.mean_dim_4d
[       OK ] VulkanAPITest.mean_dim_4d (89 ms)
[ RUN      ] VulkanAPITest.mean_dim_keepdim_2d
[       OK ] VulkanAPITest.mean_dim_keepdim_2d (66 ms)
[ RUN      ] VulkanAPITest.mean_dim_keepdim_3d
[       OK ] VulkanAPITest.mean_dim_keepdim_3d (127 ms)
[ RUN      ] VulkanAPITest.mean_dim_keepdim_4d
[       OK ] VulkanAPITest.mean_dim_keepdim_4d (4 ms)
[----------] 7 tests from VulkanAPITest (564 ms total)

[----------] Global test environment tear-down
[==========] 7 tests from 1 test suite ran. (564 ms total)
[  PASSED  ] 7 tests.
```

Reviewed By: yipjustin

Differential Revision: D50312990
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D50312990

Summary:

We implement [`torch.mean(input, dim, keepdim)`](https://pytorch.org/docs/stable/generated/torch.mean.html) for tensors of 2d to 4d.

Since 0-dim tensor hasn't been supported yet, we only support `dim.size() < input.dim()` for now. We will support following cases in the future work:
- `dim.size() == input.dim()`
- `input.dim() == 1`

Test Plan:
```
[luwei@devbig984.prn1 /data/users/luwei/fbsource (970fcd90c)]$ LD_LIBRARY_PATH=third-party/swiftshader/lib/linux-x64/ buck run fbcode/mode/dev-nosan //xplat/caffe2:pt_vulkan_api_test_bin -- --gtest_filter="*mean*"
Building: finished in 0.1 sec (100%) 339/339 jobs, 0/339 updated
  Total time: 0.1 sec
BUILD SUCCEEDED
Running main() from third-party/googletest/1.11.0/googletest/googletest/src/gtest_main.cc
Note: Google Test filter = *mean*
[==========] Running 7 tests from 1 test suite.
[----------] Global test environment set-up.
[----------] 7 tests from VulkanAPITest
[ RUN      ] VulkanAPITest.mean_invalid_inputs
[       OK ] VulkanAPITest.mean_invalid_inputs (46 ms)
[ RUN      ] VulkanAPITest.mean_dim_2d
[       OK ] VulkanAPITest.mean_dim_2d (127 ms)
[ RUN      ] VulkanAPITest.mean_dim_3d
[       OK ] VulkanAPITest.mean_dim_3d (103 ms)
[ RUN      ] VulkanAPITest.mean_dim_4d
[       OK ] VulkanAPITest.mean_dim_4d (89 ms)
[ RUN      ] VulkanAPITest.mean_dim_keepdim_2d
[       OK ] VulkanAPITest.mean_dim_keepdim_2d (66 ms)
[ RUN      ] VulkanAPITest.mean_dim_keepdim_3d
[       OK ] VulkanAPITest.mean_dim_keepdim_3d (127 ms)
[ RUN      ] VulkanAPITest.mean_dim_keepdim_4d
[       OK ] VulkanAPITest.mean_dim_keepdim_4d (4 ms)
[----------] 7 tests from VulkanAPITest (564 ms total)

[----------] Global test environment tear-down
[==========] 7 tests from 1 test suite ran. (564 ms total)
[  PASSED  ] 7 tests.
```

Reviewed By: yipjustin

Differential Revision: D50312990
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D50312990

@facebook-github-bot
Copy link
Contributor

@pytorchbot merge

(Initiating merge automatically since Phabricator Diff has merged)

@pytorch-bot pytorch-bot bot added the ciflow/trunk Trigger trunk jobs on your pull request label Oct 23, 2023
@pytorchmergebot
Copy link
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

andreigh pushed a commit to andreigh/pytorch that referenced this pull request Oct 26, 2023
Summary:
We implement [`torch.mean(input, dim, keepdim)`](https://pytorch.org/docs/stable/generated/torch.mean.html) for tensors of 2d to 4d.

Since 0-dim tensor hasn't been supported yet, we only support `dim.size() < input.dim()` for now. We will support following cases in the future work:
- `dim.size() == input.dim()`
- `input.dim() == 1`

Test Plan:
```
[luwei@devbig984.prn1 /data/users/luwei/fbsource (970fcd90c)]$ LD_LIBRARY_PATH=third-party/swiftshader/lib/linux-x64/ buck run fbcode/mode/dev-nosan //xplat/caffe2:pt_vulkan_api_test_bin -- --gtest_filter="*mean*"
Building: finished in 0.1 sec (100%) 339/339 jobs, 0/339 updated
  Total time: 0.1 sec
BUILD SUCCEEDED
Running main() from third-party/googletest/1.11.0/googletest/googletest/src/gtest_main.cc
Note: Google Test filter = *mean*
[==========] Running 7 tests from 1 test suite.
[----------] Global test environment set-up.
[----------] 7 tests from VulkanAPITest
[ RUN      ] VulkanAPITest.mean_invalid_inputs
[       OK ] VulkanAPITest.mean_invalid_inputs (46 ms)
[ RUN      ] VulkanAPITest.mean_dim_2d
[       OK ] VulkanAPITest.mean_dim_2d (127 ms)
[ RUN      ] VulkanAPITest.mean_dim_3d
[       OK ] VulkanAPITest.mean_dim_3d (103 ms)
[ RUN      ] VulkanAPITest.mean_dim_4d
[       OK ] VulkanAPITest.mean_dim_4d (89 ms)
[ RUN      ] VulkanAPITest.mean_dim_keepdim_2d
[       OK ] VulkanAPITest.mean_dim_keepdim_2d (66 ms)
[ RUN      ] VulkanAPITest.mean_dim_keepdim_3d
[       OK ] VulkanAPITest.mean_dim_keepdim_3d (127 ms)
[ RUN      ] VulkanAPITest.mean_dim_keepdim_4d
[       OK ] VulkanAPITest.mean_dim_keepdim_4d (4 ms)
[----------] 7 tests from VulkanAPITest (564 ms total)

[----------] Global test environment tear-down
[==========] 7 tests from 1 test suite ran. (564 ms total)
[  PASSED  ] 7 tests.
```

Reviewed By: yipjustin

Differential Revision: D50312990

Pull Request resolved: pytorch#111609
Approved by: https://github.com/yipjustin
@facebook-github-bot facebook-github-bot deleted the export-D50312990 branch October 27, 2023 14:24
xuhancn pushed a commit to xuhancn/pytorch that referenced this pull request Nov 7, 2023
Summary:
We implement [`torch.mean(input, dim, keepdim)`](https://pytorch.org/docs/stable/generated/torch.mean.html) for tensors of 2d to 4d.

Since 0-dim tensor hasn't been supported yet, we only support `dim.size() < input.dim()` for now. We will support following cases in the future work:
- `dim.size() == input.dim()`
- `input.dim() == 1`

Test Plan:
```
[luwei@devbig984.prn1 /data/users/luwei/fbsource (970fcd90c)]$ LD_LIBRARY_PATH=third-party/swiftshader/lib/linux-x64/ buck run fbcode/mode/dev-nosan //xplat/caffe2:pt_vulkan_api_test_bin -- --gtest_filter="*mean*"
Building: finished in 0.1 sec (100%) 339/339 jobs, 0/339 updated
  Total time: 0.1 sec
BUILD SUCCEEDED
Running main() from third-party/googletest/1.11.0/googletest/googletest/src/gtest_main.cc
Note: Google Test filter = *mean*
[==========] Running 7 tests from 1 test suite.
[----------] Global test environment set-up.
[----------] 7 tests from VulkanAPITest
[ RUN      ] VulkanAPITest.mean_invalid_inputs
[       OK ] VulkanAPITest.mean_invalid_inputs (46 ms)
[ RUN      ] VulkanAPITest.mean_dim_2d
[       OK ] VulkanAPITest.mean_dim_2d (127 ms)
[ RUN      ] VulkanAPITest.mean_dim_3d
[       OK ] VulkanAPITest.mean_dim_3d (103 ms)
[ RUN      ] VulkanAPITest.mean_dim_4d
[       OK ] VulkanAPITest.mean_dim_4d (89 ms)
[ RUN      ] VulkanAPITest.mean_dim_keepdim_2d
[       OK ] VulkanAPITest.mean_dim_keepdim_2d (66 ms)
[ RUN      ] VulkanAPITest.mean_dim_keepdim_3d
[       OK ] VulkanAPITest.mean_dim_keepdim_3d (127 ms)
[ RUN      ] VulkanAPITest.mean_dim_keepdim_4d
[       OK ] VulkanAPITest.mean_dim_keepdim_4d (4 ms)
[----------] 7 tests from VulkanAPITest (564 ms total)

[----------] Global test environment tear-down
[==========] 7 tests from 1 test suite ran. (564 ms total)
[  PASSED  ] 7 tests.
```

Reviewed By: yipjustin

Differential Revision: D50312990

Pull Request resolved: pytorch#111609
Approved by: https://github.com/yipjustin
Skylion007 pushed a commit to Skylion007/pytorch that referenced this pull request Nov 14, 2023
Summary:
We implement [`torch.mean(input, dim, keepdim)`](https://pytorch.org/docs/stable/generated/torch.mean.html) for tensors of 2d to 4d.

Since 0-dim tensor hasn't been supported yet, we only support `dim.size() < input.dim()` for now. We will support following cases in the future work:
- `dim.size() == input.dim()`
- `input.dim() == 1`

Test Plan:
```
[luwei@devbig984.prn1 /data/users/luwei/fbsource (970fcd90c)]$ LD_LIBRARY_PATH=third-party/swiftshader/lib/linux-x64/ buck run fbcode/mode/dev-nosan //xplat/caffe2:pt_vulkan_api_test_bin -- --gtest_filter="*mean*"
Building: finished in 0.1 sec (100%) 339/339 jobs, 0/339 updated
  Total time: 0.1 sec
BUILD SUCCEEDED
Running main() from third-party/googletest/1.11.0/googletest/googletest/src/gtest_main.cc
Note: Google Test filter = *mean*
[==========] Running 7 tests from 1 test suite.
[----------] Global test environment set-up.
[----------] 7 tests from VulkanAPITest
[ RUN      ] VulkanAPITest.mean_invalid_inputs
[       OK ] VulkanAPITest.mean_invalid_inputs (46 ms)
[ RUN      ] VulkanAPITest.mean_dim_2d
[       OK ] VulkanAPITest.mean_dim_2d (127 ms)
[ RUN      ] VulkanAPITest.mean_dim_3d
[       OK ] VulkanAPITest.mean_dim_3d (103 ms)
[ RUN      ] VulkanAPITest.mean_dim_4d
[       OK ] VulkanAPITest.mean_dim_4d (89 ms)
[ RUN      ] VulkanAPITest.mean_dim_keepdim_2d
[       OK ] VulkanAPITest.mean_dim_keepdim_2d (66 ms)
[ RUN      ] VulkanAPITest.mean_dim_keepdim_3d
[       OK ] VulkanAPITest.mean_dim_keepdim_3d (127 ms)
[ RUN      ] VulkanAPITest.mean_dim_keepdim_4d
[       OK ] VulkanAPITest.mean_dim_keepdim_4d (4 ms)
[----------] 7 tests from VulkanAPITest (564 ms total)

[----------] Global test environment tear-down
[==========] 7 tests from 1 test suite ran. (564 ms total)
[  PASSED  ] 7 tests.
```

Reviewed By: yipjustin

Differential Revision: D50312990

Pull Request resolved: pytorch#111609
Approved by: https://github.com/yipjustin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ciflow/periodic Trigger jobs ran periodically on master (periodic.yml) on the PR ciflow/trunk Trigger trunk jobs on your pull request fb-exported Merged module: vulkan release notes: vulkan release notes category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants