Skip to content

Conversation

ljk53
Copy link
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 orionr and kostmo April 26, 2019 07:00
Copy link
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

Copy link
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.

@t-vi
Copy link
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
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

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
[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
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
Contributor

@ljk53 merged this pull request in c7c0272.

@ljk53
Copy link
Contributor Author

ljk53 commented May 3, 2019

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

@kindlychung
Copy link

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

@ezyang
Copy link
Contributor

ezyang commented Jul 3, 2019 via email

@ljk53
Copy link
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