[pytorch] CMakeLists changes to enable libtorch for Android#19762
[pytorch] CMakeLists changes to enable libtorch for Android#19762ljk53 wants to merge 11 commits intogh/ljk53/14/basefrom
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;
dzhulgakov
left a comment
There was a problem hiding this comment.
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
|
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
dzhulgakov
left a comment
There was a problem hiding this comment.
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