mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
[Pytorch] Build lite interpreter as default for Android
Summary: Build lite interpreter as default for android, should wait until https://github.com/pytorch/pytorch/pull/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
This commit is contained in:
committed by
Facebook GitHub Bot
parent
d645088f2f
commit
0c3db1cb33
@ -97,13 +97,13 @@ WORKFLOW_DATA = [
|
||||
is_master_only=False,
|
||||
is_pr_only=True),
|
||||
AndroidGradleJob(
|
||||
"pytorch-linux-xenial-py3-clang5-android-ndk-r19c-gradle-custom-build-single_lite_interpreter",
|
||||
"pytorch-linux-xenial-py3-clang5-android-ndk-r19c-gradle-custom-build-single-full-jit",
|
||||
"pytorch_android_gradle_custom_build_single",
|
||||
[DOCKER_REQUIREMENT_NDK],
|
||||
is_master_only=False,
|
||||
is_pr_only=True,
|
||||
extra_props=tuple({
|
||||
"lite_interpreter": miniutils.quote(str(int(True)))
|
||||
"lite_interpreter": miniutils.quote(str(int(False)))
|
||||
}.items())),
|
||||
AndroidGradleJob(
|
||||
"pytorch-linux-xenial-py3-clang5-android-ndk-r19c-gradle-build",
|
||||
|
@ -6534,8 +6534,8 @@ workflows:
|
||||
only:
|
||||
- /gh\/.*\/head/
|
||||
- /pull\/.*/
|
||||
lite_interpreter: "1"
|
||||
name: pytorch-linux-xenial-py3-clang5-android-ndk-r19c-gradle-custom-build-single_lite_interpreter
|
||||
lite_interpreter: "0"
|
||||
name: pytorch-linux-xenial-py3-clang5-android-ndk-r19c-gradle-custom-build-single-full-jit
|
||||
requires:
|
||||
- docker-pytorch-linux-xenial-py3-clang5-android-ndk-r19c
|
||||
- pytorch_android_gradle_build:
|
||||
|
@ -1,5 +1,5 @@
|
||||
cmake_minimum_required(VERSION 3.4.1)
|
||||
option(BUILD_LITE_INTERPRETER "Master flag to build pytorch_jni_lite" OFF)
|
||||
option(BUILD_LITE_INTERPRETER "Master flag to build pytorch_jni_lite" ON)
|
||||
message(
|
||||
STATUS
|
||||
"BUILD_LITE_INTERPRETER (pytorch_jni_lite): ${BUILD_LITE_INTERPRETER}")
|
||||
|
@ -17,8 +17,8 @@ android {
|
||||
}
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
if(System.env.BUILD_LITE_INTERPRETER == '1') {
|
||||
arguments "-DANDROID_STL=c++_shared", "-DBUILD_LITE_INTERPRETER=ON"
|
||||
if(System.env.BUILD_LITE_INTERPRETER == '0') {
|
||||
arguments "-DANDROID_STL=c++_shared", "-DBUILD_LITE_INTERPRETER=OFF"
|
||||
} else {
|
||||
arguments "-DANDROID_STL=c++_shared"
|
||||
}
|
||||
@ -37,12 +37,12 @@ android {
|
||||
sourceSets {
|
||||
main {
|
||||
java {
|
||||
if(System.env.BUILD_LITE_INTERPRETER == '1') {
|
||||
println 'Build pytorch_jni_lite'
|
||||
} else {
|
||||
if(System.env.BUILD_LITE_INTERPRETER == '0') {
|
||||
println 'Build pytorch_jni'
|
||||
exclude 'org/pytorch/LiteModuleLoader.java'
|
||||
exclude 'org/pytorch/LiteNativePeer.java'
|
||||
} else {
|
||||
println 'Build pytorch_jni_lite'
|
||||
}
|
||||
}
|
||||
jniLibs.srcDirs = ['src/main/jniLibs']
|
||||
|
@ -10,7 +10,7 @@ public final class PyTorchAndroid {
|
||||
if (!NativeLoader.isInitialized()) {
|
||||
NativeLoader.init(new SystemDelegate());
|
||||
}
|
||||
NativeLoader.loadLibrary("pytorch_jni");
|
||||
NativeLoader.loadLibrary("pytorch_jni_lite");
|
||||
PyTorchCodegenLoader.loadNativeLibs();
|
||||
}
|
||||
|
||||
|
@ -104,12 +104,13 @@ fi
|
||||
CMAKE_ARGS+=("-DBUILD_TEST=OFF")
|
||||
CMAKE_ARGS+=("-DBUILD_BINARY=OFF")
|
||||
|
||||
# If there exists env variable and it equals to 1, build lite interpreter.
|
||||
# cmd: BUILD_LITE_INTERPRETER=1 ./scripts/build_android.sh
|
||||
if [ "${BUILD_LITE_INTERPRETER}" == 1 ]; then
|
||||
CMAKE_ARGS+=("-DBUILD_LITE_INTERPRETER=ON")
|
||||
else
|
||||
# If there exists env variable and it equals to 0, build full jit interpreter.
|
||||
# Default behavior is to build lite interpreter
|
||||
# cmd: BUILD_LITE_INTERPRETER=0 ./scripts/build_android.sh
|
||||
if [ "${BUILD_LITE_INTERPRETER}" == 0 ]; then
|
||||
CMAKE_ARGS+=("-DBUILD_LITE_INTERPRETER=OFF")
|
||||
else
|
||||
CMAKE_ARGS+=("-DBUILD_LITE_INTERPRETER=ON")
|
||||
fi
|
||||
CMAKE_ARGS+=("-DBUILD_MOBILE_BENCHMARK=$BUILD_MOBILE_BENCHMARK")
|
||||
CMAKE_ARGS+=("-DBUILD_MOBILE_TEST=$BUILD_MOBILE_TEST")
|
||||
|
0
tools/lite_interpreter/__init__.py
Normal file
0
tools/lite_interpreter/__init__.py
Normal file
Reference in New Issue
Block a user