Skip to content

[pytorch] CMakeLists changes to enable libtorch for Android#19762

Closed
ljk53 wants to merge 11 commits intogh/ljk53/14/basefrom
gh/ljk53/14/head
Closed

[pytorch] CMakeLists changes to enable libtorch for Android#19762
ljk53 wants to merge 11 commits intogh/ljk53/14/basefrom
gh/ljk53/14/head

Conversation

@ljk53
Copy link
Copy Markdown
Contributor

@ljk53 ljk53 commented Apr 25, 2019

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:

  • Make sure pytorch android CI job succeeds;
  • Test libtorch.so on Android device;

Differential Revision: D15087653

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 dzhulgakov requested review from kostmo and orionr April 26, 2019 07:00
Copy link
Copy Markdown
Collaborator

@dzhulgakov dzhulgakov left a 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

Comment thread CMakeLists.txt Outdated
Comment thread CMakeLists.txt Outdated
Comment thread cmake/TorchConfig.cmake.in
Copy link
Copy Markdown
Contributor

@orionr orionr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exciting stuff! Biggest comment is that we should be able to go with just BUILD_MOBILE and remove the separate BUILD_TORCH_MOBILE and BUILD_ATEN_MOBILE options. I think @smessmer and @ezyang might have comments on whether ATen core will be needed then or not.

Comment thread CMakeLists.txt Outdated
Comment thread CMakeLists.txt Outdated
Comment thread aten/CMakeLists.txt Outdated
Comment thread caffe2/CMakeLists.txt Outdated
Comment thread cmake/Codegen.cmake Outdated
Comment thread cmake/Codegen.cmake Outdated
Comment thread cmake/Dependencies.cmake
Comment thread cmake/TorchConfig.cmake.in
@t-vi
Copy link
Copy Markdown
Collaborator

t-vi commented Apr 26, 2019 via email

[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
ljk53 added 2 commits April 29, 2019 19:13
[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
Copy link
Copy Markdown
Collaborator

@dzhulgakov dzhulgakov left a 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

Comment thread .jenkins/pytorch/build.sh Outdated
Comment thread cmake/TorchConfig.cmake.in
ljk53 added 3 commits April 30, 2019 15:24
[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
ljk53 added 2 commits May 2, 2019 12:27
[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
Comment thread cmake/Summary.cmake
[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
@zou3519 zou3519 deleted the gh/ljk53/14/head branch May 3, 2019 16:31
zdevito pushed a commit to zdevito/ATen that referenced this pull request May 3, 2019
Summary:
Pull Request resolved: pytorch/pytorch#19762
ghimport-source-id: 287aa7fea4efd38994e14d794123eb2046b91fc0

Differential Revision: D15087653

Pulled By: ljk53

fbshipit-source-id: 4498ff9f7f7903c3e25541184302b811267958e9
@t-vi
Copy link
Copy Markdown
Collaborator

t-vi commented May 3, 2019

I'm building PyTorch for Android now. Thank you @ljk53 and everyone involved. You are awesome!

@facebook-github-bot
Copy link
Copy Markdown
Contributor

@ljk53 merged this pull request in c7c0272.

@ljk53
Copy link
Copy Markdown
Contributor Author

ljk53 commented May 3, 2019

@t-vi thanks for initiating this effort! It's all based on your work :)

@kindlychung
Copy link
Copy Markdown

Is there a documentation on how to use this on android? Thanks.

@ezyang
Copy link
Copy Markdown
Contributor

ezyang commented Jul 3, 2019 via email

@ljk53
Copy link
Copy Markdown
Contributor Author

ljk53 commented Jul 6, 2019

What @ezyang said, you can build the current version with scripts/build_android.sh + "BUILD_CAFFE2_MOBILE=OFF" and pytorch environment for codegen:

./scripts/build_android.sh \
-DBUILD_CAFFE2_MOBILE=OFF \
-DCMAKE_PREFIX_PATH=$(python -c 'from distutils.sysconfig import get_python_lib; print(get_python_lib())') \
-DPYTHON_EXECUTABLE=$(python -c 'import sys; print(sys.executable)')

The work is not done - we are working on improvements in terms of build size, perf and documentation. Stay tuned!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

caffe2 module: build Build system issues module: ci Related to continuous integration module: internals Related to internal abstractions in c10 and ATen

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants