-
Notifications
You must be signed in to change notification settings - Fork 25.2k
[pytorch] CMakeLists changes to enable libtorch for Android #19762
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
Conversation
Summary: Stole from #16242 Only include CMakeLists changes to make it easer for reviewers. Change pytorch android CI job to build libtorch instead of caffe2 - turns out it's as simple as adding a few cmake macros. Will properly update tools/build_pytorch_libs.py in subsequent diffs. Test Plan: - Make sure pytorch android CI job succeeds; - Test libtorch.so on Android device;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder whether it'd be easier to understand the details if we had separate vars for platform (e.g. what current BUILD_ATEN_MOBILE is) and have derived var BUILD_ATEN or BUILD_JIT determined based on it. That way we'd have mostly single conditionals around instead of BUILD_ATEN_MOBILE AND NOT BUILD_TORCH_MOBILE. But it's a soft suggestion, not insisting
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The TorchConfig change is needed to keep CMake from finding host libs when building C++ extensions / custom ops for Android.
|
[pytorch] CMakeLists changes to enable libtorch for Android Summary: Stole from #16242 Only include CMakeLists changes to make it easer for reviewers. Change pytorch android CI job to build libtorch instead of caffe2 - turns out it's as simple as adding a few cmake macros. Will properly update tools/build_pytorch_libs.py in subsequent diffs. Test Plan: - Make sure pytorch android CI job succeeds; - Test libtorch.so on Android device; gh-metadata: pytorch pytorch 19762 gh/ljk53/14/head
[pytorch] CMakeLists changes to enable libtorch for Android Summary: Stole from #16242 Only include CMakeLists changes to make it easer for reviewers. Change pytorch android CI job to build libtorch instead of caffe2 - turns out it's as simple as adding a few cmake macros. Will properly update tools/build_pytorch_libs.py in subsequent diffs. Test Plan: - Make sure pytorch android CI job succeeds; - Test libtorch.so on Android device; gh-metadata: pytorch pytorch 19762 gh/ljk53/14/head
[pytorch] CMakeLists changes to enable libtorch for Android Summary: Stole from #16242 Only include CMakeLists changes to make it easer for reviewers. Change pytorch android CI job to build libtorch instead of caffe2 - turns out it's as simple as adding a few cmake macros. Will properly update tools/build_pytorch_libs.py in subsequent diffs. Test Plan: - Make sure pytorch android CI job succeeds; - Test libtorch.so on Android device; gh-metadata: pytorch pytorch 19762 gh/ljk53/14/head
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new setup looks good. I'll let other folks take a final look and accept
[pytorch] CMakeLists changes to enable libtorch for Android Summary: Stole from #16242 Only include CMakeLists changes to make it easer for reviewers. Change pytorch android CI job to build libtorch instead of caffe2 - turns out it's as simple as adding a few cmake macros. Will properly update tools/build_pytorch_libs.py in subsequent diffs. Test Plan: - Make sure pytorch android CI job succeeds; - Test libtorch.so on Android device; gh-metadata: pytorch pytorch 19762 gh/ljk53/14/head
[pytorch] CMakeLists changes to enable libtorch for Android Summary: Stole from #16242 Only include CMakeLists changes to make it easer for reviewers. Change pytorch android CI job to build libtorch instead of caffe2 - turns out it's as simple as adding a few cmake macros. Will properly update tools/build_pytorch_libs.py in subsequent diffs. Test Plan: - Make sure pytorch android CI job succeeds; - Test libtorch.so on Android device; gh-metadata: pytorch pytorch 19762 gh/ljk53/14/head
[pytorch] CMakeLists changes to enable libtorch for Android Summary: Stole from #16242 Only include CMakeLists changes to make it easer for reviewers. Change pytorch android CI job to build libtorch instead of caffe2 - turns out it's as simple as adding a few cmake macros. Will properly update tools/build_pytorch_libs.py in subsequent diffs. Test Plan: - Make sure pytorch android CI job succeeds; - Test libtorch.so on Android device; gh-metadata: pytorch pytorch 19762 gh/ljk53/14/head
[pytorch] CMakeLists changes to enable libtorch for Android Summary: Stole from #16242 Only include CMakeLists changes to make it easer for reviewers. Change pytorch android CI job to build libtorch instead of caffe2 - turns out it's as simple as adding a few cmake macros. Will properly update tools/build_pytorch_libs.py in subsequent diffs. Test Plan: - Make sure pytorch android CI job succeeds; - Test libtorch.so on Android device; gh-metadata: pytorch pytorch 19762 gh/ljk53/14/head
[pytorch] CMakeLists changes to enable libtorch for Android Summary: Stole from #16242 Only include CMakeLists changes to make it easer for reviewers. Change pytorch android CI job to build libtorch instead of caffe2 - turns out it's as simple as adding a few cmake macros. Will properly update tools/build_pytorch_libs.py in subsequent diffs. Test Plan: - Make sure pytorch android CI job succeeds; - Test libtorch.so on Android device; gh-metadata: pytorch pytorch 19762 gh/ljk53/14/head
[pytorch] CMakeLists changes to enable libtorch for Android Summary: Stole from #16242 Only include CMakeLists changes to make it easer for reviewers. Change pytorch android CI job to build libtorch instead of caffe2 - turns out it's as simple as adding a few cmake macros. Will properly update tools/build_pytorch_libs.py in subsequent diffs. Test Plan: - Make sure pytorch android CI job succeeds; - Test libtorch.so on Android device; gh-metadata: pytorch pytorch 19762 gh/ljk53/14/head
Summary: Pull Request resolved: pytorch/pytorch#19762 ghimport-source-id: 287aa7fea4efd38994e14d794123eb2046b91fc0 Differential Revision: D15087653 Pulled By: ljk53 fbshipit-source-id: 4498ff9f7f7903c3e25541184302b811267958e9
I'm building PyTorch for Android now. Thank you @ljk53 and everyone involved. You are awesome! |
@t-vi thanks for initiating this effort! It's all based on your work :) |
Is there a documentation on how to use this on android? Thanks. |
What @ezyang said, you can build the current version with scripts/build_android.sh + "BUILD_CAFFE2_MOBILE=OFF" and pytorch environment for codegen:
The work is not done - we are working on improvements in terms of build size, perf and documentation. Stay tuned! |
Stack from ghstack:
Summary:
Stole from #16242
Only include CMakeLists changes to make it easer for reviewers.
Change pytorch android CI job to build libtorch instead of caffe2 -
turns out it's as simple as adding a few cmake macros. Will properly
update tools/build_pytorch_libs.py in subsequent diffs.
Test Plan:
Differential Revision: D15087653