Skip to content

Commit 0c3db1c

Browse files
cccclaifacebook-github-bot
authored andcommitted
[Pytorch] Build lite interpreter as default for Android
Summary: Build lite interpreter as default for android, should wait until #56002 lands Mainly two changes: 1. Use lite interpreter as default for Android 2. Switch the lite interpreter build test to full jit build test Test Plan: Imported from OSS Differential Revision: D27695530 Reviewed By: IvanKobzarev Pulled By: cccclai fbshipit-source-id: e1b2c70fee6590accc22c7404b9dd52c7d7c36e2
1 parent d645088 commit 0c3db1c

File tree

7 files changed

+17
-16
lines changed

7 files changed

+17
-16
lines changed

.circleci/cimodel/data/simple/android_definitions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,13 @@ def gen_tree(self):
9797
is_master_only=False,
9898
is_pr_only=True),
9999
AndroidGradleJob(
100-
"pytorch-linux-xenial-py3-clang5-android-ndk-r19c-gradle-custom-build-single_lite_interpreter",
100+
"pytorch-linux-xenial-py3-clang5-android-ndk-r19c-gradle-custom-build-single-full-jit",
101101
"pytorch_android_gradle_custom_build_single",
102102
[DOCKER_REQUIREMENT_NDK],
103103
is_master_only=False,
104104
is_pr_only=True,
105105
extra_props=tuple({
106-
"lite_interpreter": miniutils.quote(str(int(True)))
106+
"lite_interpreter": miniutils.quote(str(int(False)))
107107
}.items())),
108108
AndroidGradleJob(
109109
"pytorch-linux-xenial-py3-clang5-android-ndk-r19c-gradle-build",

.circleci/config.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6534,8 +6534,8 @@ workflows:
65346534
only:
65356535
- /gh\/.*\/head/
65366536
- /pull\/.*/
6537-
lite_interpreter: "1"
6538-
name: pytorch-linux-xenial-py3-clang5-android-ndk-r19c-gradle-custom-build-single_lite_interpreter
6537+
lite_interpreter: "0"
6538+
name: pytorch-linux-xenial-py3-clang5-android-ndk-r19c-gradle-custom-build-single-full-jit
65396539
requires:
65406540
- docker-pytorch-linux-xenial-py3-clang5-android-ndk-r19c
65416541
- pytorch_android_gradle_build:

android/pytorch_android/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
cmake_minimum_required(VERSION 3.4.1)
2-
option(BUILD_LITE_INTERPRETER "Master flag to build pytorch_jni_lite" OFF)
2+
option(BUILD_LITE_INTERPRETER "Master flag to build pytorch_jni_lite" ON)
33
message(
44
STATUS
55
"BUILD_LITE_INTERPRETER (pytorch_jni_lite): ${BUILD_LITE_INTERPRETER}")

android/pytorch_android/build.gradle

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ android {
1717
}
1818
externalNativeBuild {
1919
cmake {
20-
if(System.env.BUILD_LITE_INTERPRETER == '1') {
21-
arguments "-DANDROID_STL=c++_shared", "-DBUILD_LITE_INTERPRETER=ON"
20+
if(System.env.BUILD_LITE_INTERPRETER == '0') {
21+
arguments "-DANDROID_STL=c++_shared", "-DBUILD_LITE_INTERPRETER=OFF"
2222
} else {
2323
arguments "-DANDROID_STL=c++_shared"
2424
}
@@ -37,12 +37,12 @@ android {
3737
sourceSets {
3838
main {
3939
java {
40-
if(System.env.BUILD_LITE_INTERPRETER == '1') {
41-
println 'Build pytorch_jni_lite'
42-
} else {
40+
if(System.env.BUILD_LITE_INTERPRETER == '0') {
4341
println 'Build pytorch_jni'
4442
exclude 'org/pytorch/LiteModuleLoader.java'
4543
exclude 'org/pytorch/LiteNativePeer.java'
44+
} else {
45+
println 'Build pytorch_jni_lite'
4646
}
4747
}
4848
jniLibs.srcDirs = ['src/main/jniLibs']

android/pytorch_android/src/main/java/org/pytorch/PyTorchAndroid.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public final class PyTorchAndroid {
1010
if (!NativeLoader.isInitialized()) {
1111
NativeLoader.init(new SystemDelegate());
1212
}
13-
NativeLoader.loadLibrary("pytorch_jni");
13+
NativeLoader.loadLibrary("pytorch_jni_lite");
1414
PyTorchCodegenLoader.loadNativeLibs();
1515
}
1616

scripts/build_android.sh

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,13 @@ fi
104104
CMAKE_ARGS+=("-DBUILD_TEST=OFF")
105105
CMAKE_ARGS+=("-DBUILD_BINARY=OFF")
106106

107-
# If there exists env variable and it equals to 1, build lite interpreter.
108-
# cmd: BUILD_LITE_INTERPRETER=1 ./scripts/build_android.sh
109-
if [ "${BUILD_LITE_INTERPRETER}" == 1 ]; then
110-
CMAKE_ARGS+=("-DBUILD_LITE_INTERPRETER=ON")
111-
else
107+
# If there exists env variable and it equals to 0, build full jit interpreter.
108+
# Default behavior is to build lite interpreter
109+
# cmd: BUILD_LITE_INTERPRETER=0 ./scripts/build_android.sh
110+
if [ "${BUILD_LITE_INTERPRETER}" == 0 ]; then
112111
CMAKE_ARGS+=("-DBUILD_LITE_INTERPRETER=OFF")
112+
else
113+
CMAKE_ARGS+=("-DBUILD_LITE_INTERPRETER=ON")
113114
fi
114115
CMAKE_ARGS+=("-DBUILD_MOBILE_BENCHMARK=$BUILD_MOBILE_BENCHMARK")
115116
CMAKE_ARGS+=("-DBUILD_MOBILE_TEST=$BUILD_MOBILE_TEST")

tools/lite_interpreter/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)