This is an automated email from the ASF dual-hosted git repository.
masahi pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tvm.git
The following commit(s) were added to refs/heads/main by this push:
new 014208e62a [Android] Update gradle version and other changes in
android apps, CI modification to auto-build Android apps and upload artifacts
(#11241)
014208e62a is described below
commit 014208e62ad9c0b22dfe9251eee2e47dbe72f999
Author: Kirill Snezhko <[email protected]>
AuthorDate: Wed May 25 11:18:06 2022 +0300
[Android] Update gradle version and other changes in android apps, CI
modification to auto-build Android apps and upload artifacts (#11241)
* Update gradle version in android_rpc app
* Support latest gradle, bump versions, replace ndk build script with
gradle tasks
* [android_rpc] Fix linter errors, disable weird ones
* [android_deploy] Support latest gradle, bump versions, fix linter errors,
disable some of them
* [android_camera] Support latest gradle, bump versions, rewrite readme
* [android_camera] Fix linter errors
* Fix sanity check errors
* Add Android jobs for Github Actions
* Add python requirements for TVM and android_camera, use preinstalled NDK
* Revert to build with make
* Add minrpc include (PR #11232)
* Remove relative paths
---
.github/workflows/main.yml | 169 ++++++++++++++-------
apps/android_camera/README.md | 129 +++++++++++++---
apps/android_camera/app/build.gradle | 52 +++++--
.../app/src/main/AndroidManifest.xml | 2 +-
.../androidcamerademo/Camera2BasicFragment.java | 2 +-
.../android/androidcamerademo/MainActivity.java | 1 +
apps/android_camera/app/src/main/jni/Android.mk | 3 +
apps/android_camera/app/src/main/jni/tvm_runtime.h | 5 +
.../app/src/main/res/layout/listview_row.xml | 2 +-
apps/android_camera/build.gradle | 13 +-
apps/android_camera/gradle.properties | 1 -
apps/android_camera/models/prepare_model.py | 2 +-
apps/android_camera/models/requirements.txt | 4 +
apps/android_deploy/app/build.gradle | 57 +++++--
apps/android_deploy/app/download-models.gradle | 2 +-
.../app/src/main/AndroidManifest.xml | 9 +-
.../org/apache/tvm/android/demo/MainActivity.java | 10 +-
.../app/src/main/res/layout/activity_main.xml | 37 +++--
.../app/src/main/res/layout/content_main.xml | 7 +-
.../app/src/main/res/values/strings.xml | 2 +
apps/android_deploy/build.gradle | 8 +-
apps/android_deploy/gradle.properties | 2 +
apps/android_rpc/README.md | 14 +-
apps/android_rpc/app/build.gradle | 58 +++++--
apps/android_rpc/app/src/main/AndroidManifest.xml | 8 +-
.../java/org/apache/tvm/tvmrpc/MainActivity.java | 18 ++-
.../java/org/apache/tvm/tvmrpc/RPCActivity.java | 2 +-
apps/android_rpc/app/src/main/jni/build.sh | 26 ----
apps/android_rpc/app/src/main/jni/tvm_runtime.h | 1 +
.../app/src/main/res/layout/activity_main.xml | 10 +-
.../app/src/main/res/layout/activity_rpc.xml | 10 +-
.../app/src/main/res/layout/content_main.xml | 23 +--
.../app/src/main/res/values/strings.xml | 5 +
apps/android_rpc/build.gradle | 6 +-
.../jni/build.sh => android_rpc/gradle.properties} | 19 +--
.../scripts/task_config_build_jvm.sh | 29 ++--
36 files changed, 497 insertions(+), 251 deletions(-)
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 48b9d62bb9..313c440cbd 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -38,59 +38,124 @@ jobs:
MacOS:
runs-on: macOS-latest
steps:
- - uses: actions/checkout@v2
- with:
- submodules: 'recursive'
- - name: Set up environment
- uses: ./.github/actions/setup
- - name: Conda Build
- shell: bash -l {0}
- run: >-
- conda build --output-folder=conda/pkg conda/recipe &&
- conda install tvm -c ./conda/pkg
- - name: Build iOS RPC
- run: |
- IOS_VERSION="14.0"
- CMAKE_FLAGS="-DCMAKE_BUILD_TYPE=Release \
- -DCMAKE_SYSTEM_NAME=iOS \
- -DCMAKE_SYSTEM_VERSION=${IOS_VERSION} \
- -DCMAKE_OSX_SYSROOT=iphonesimulator \
- -DCMAKE_OSX_ARCHITECTURES=x86_64 \
- -DCMAKE_OSX_DEPLOYMENT_TARGET=14.0 \
- -DCMAKE_BUILD_WITH_INSTALL_NAME_DIR=ON \
- -DUSE_IOS_RPC=ON"
-
- mkdir build-ios-simulator
- cd build-ios-simulator
- cmake .. ${CMAKE_FLAGS}
- cmake --build . --target ios_rpc
- - name: Test
- shell: bash -l {0}
- run: >-
- python -m pytest -v tests/python/all-platform-minimal-test
- - name: Test iOS RPC
- shell: bash -l {0}
- run: >-
- python -m pip install tornado psutil cloudpickle &&
- export PYTHONPATH=tests/python/contrib:${PYTHONPATH} &&
- export BUNDLE_ID=org.apache.tvmrpc &&
- export
BUNDLE_PATH=build-ios-simulator/apps/ios_rpc/ios_rpc/src/ios_rpc-build/Release-iphonesimulator/tvmrpc.app
&&
- python -m pytest -v tests/python/contrib/test_rpc_server_device.py
+ - uses: actions/checkout@v2
+ with:
+ submodules: 'recursive'
+ - name: Set up environment
+ uses: ./.github/actions/setup
+ - name: Conda Build
+ shell: bash -l {0}
+ run: >-
+ conda build --output-folder=conda/pkg conda/recipe &&
+ conda install tvm -c ./conda/pkg
+ - name: Build iOS RPC
+ run: |
+ IOS_VERSION="14.0"
+ CMAKE_FLAGS="-DCMAKE_BUILD_TYPE=Release \
+ -DCMAKE_SYSTEM_NAME=iOS \
+ -DCMAKE_SYSTEM_VERSION=${IOS_VERSION} \
+ -DCMAKE_OSX_SYSROOT=iphonesimulator \
+ -DCMAKE_OSX_ARCHITECTURES=x86_64 \
+ -DCMAKE_OSX_DEPLOYMENT_TARGET=14.0 \
+ -DCMAKE_BUILD_WITH_INSTALL_NAME_DIR=ON \
+ -DUSE_IOS_RPC=ON"
+
+ mkdir build-ios-simulator
+ cd build-ios-simulator
+ cmake .. ${CMAKE_FLAGS}
+ cmake --build . --target ios_rpc
+ - name: Test
+ shell: bash -l {0}
+ run: >-
+ python -m pytest -v tests/python/all-platform-minimal-test
+ - name: Test iOS RPC
+ shell: bash -l {0}
+ run: >-
+ python -m pip install tornado psutil cloudpickle &&
+ export PYTHONPATH=tests/python/contrib:${PYTHONPATH} &&
+ export BUNDLE_ID=org.apache.tvmrpc &&
+ export
BUNDLE_PATH=build-ios-simulator/apps/ios_rpc/ios_rpc/src/ios_rpc-build/Release-iphonesimulator/tvmrpc.app
&&
+ python -m pytest -v tests/python/contrib/test_rpc_server_device.py
Windows:
runs-on: windows-2019
steps:
- - uses: actions/checkout@v2
- with:
- submodules: 'recursive'
- - name: Set up environment
- uses: ./.github/actions/setup
- - name: Conda Build
- shell: cmd /C call {0}
- run: >-
- conda build --output-folder=conda/pkg conda/recipe &&
- conda install tvm -c ./conda/pkg
- - name: Test
- shell: cmd /C call {0}
- run: >-
- python -m pytest -v tests/python/all-platform-minimal-test
+ - uses: actions/checkout@v2
+ with:
+ submodules: 'recursive'
+ - name: Set up environment
+ uses: ./.github/actions/setup
+ - name: Conda Build
+ shell: cmd /C call {0}
+ run: >-
+ conda build --output-folder=conda/pkg conda/recipe &&
+ conda install tvm -c ./conda/pkg
+ - name: Test
+ shell: cmd /C call {0}
+ run: >-
+ python -m pytest -v tests/python/all-platform-minimal-test
+
+ Android:
+ runs-on: Ubuntu-20.04
+ steps:
+ - uses: actions/checkout@v2
+ with:
+ submodules: 'recursive'
+ - name: Set up environment
+ uses: ./.github/actions/setup
+ - name: Set up java
+ uses: actions/setup-java@v3
+ with:
+ distribution: 'zulu'
+ java-version: '11'
+ - name: Build TVM
+ shell: bash -l {0}
+ run: |
+ mkdir build
+ cd build
+ ../tests/scripts/task_config_build_jvm.sh .
+ cmake ..
+ make
+ - name: Build TVM4J
+ run: |
+ make jvmpkg
+ - name: Build android_rpc
+ working-directory: apps/android_rpc
+ run: |
+ export PATH="${ANDROID_NDK_HOME}:$PATH"
+ gradle clean build
+ - name: Upload android_rpc APK
+ uses: actions/upload-artifact@v2
+ with:
+ name: android_rpc-debug.apk
+ path: ./apps/android_rpc/app/build/outputs/apk/debug/app-debug.apk
+ - name: Build android_deploy
+ working-directory: apps/android_deploy
+ run: |
+ export PATH="${ANDROID_NDK_HOME}:$PATH"
+ gradle clean build
+ - name: Upload android_deploy APK
+ uses: actions/upload-artifact@v2
+ with:
+ name: android_deploy-debug.apk
+ path: ./apps/android_deploy/app/build/outputs/apk/debug/app-debug.apk
+ - name: Build android_camera
+ working-directory: apps/android_camera
+ run: |
+ mkdir -p app/src/main/assets/models/
+ export
TVM_NDK_CC=${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android30-clang++
+ export TVM_HOME=~/work/tvm/tvm
+ export PYTHONPATH=$TVM_HOME/python:${PYTHONPATH}
+ python3 ${TVM_HOME}/python/gen_requirements.py
+ pip3 install -r ${TVM_HOME}/python/requirements/core.txt
+ cd models
+ pip3 install -r requirements.txt
+ python3 prepare_model.py
+ cd ..
+ export PATH="${ANDROID_NDK_HOME}:$PATH"
+ gradle clean build
+ - name: Upload android_camera APK
+ uses: actions/upload-artifact@v2
+ with:
+ name: android_camera-debug.apk
+ path: ./apps/android_camera/app/build/outputs/apk/debug/app-debug.apk
\ No newline at end of file
diff --git a/apps/android_camera/README.md b/apps/android_camera/README.md
index c292ce40c5..f659e905f2 100644
--- a/apps/android_camera/README.md
+++ b/apps/android_camera/README.md
@@ -1,28 +1,107 @@
-[//]: # Licensed to the Apache Software Foundation (ASF) under one
-[//]: # or more contributor license agreements. See the NOTICE file
-[//]: # distributed with this work for additional information
-[//]: # regarding copyright ownership. The ASF licenses this file
-[//]: # to you under the Apache License, Version 2.0 (the
-[//]: # "License"); you may not use this file except in compliance
-[//]: # with the License. You may obtain a copy of the License at
-[//]: #
-[//]: # http://www.apache.org/licenses/LICENSE-2.0
-[//]: #
-[//]: # Unless required by applicable law or agreed to in writing,
-[//]: # software distributed under the License is distributed on an
-[//]: # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-[//]: # KIND, either express or implied. See the License for the
-[//]: # specific language governing permissions and limitations
-[//]: # under the License.
-
-Android Camera Demo Sample App
-==============================
-
-The Android Camera Demo Sample App provides a basic implementation of an
Android
-app that uses the tvm runtime to perform image classification in real time.
-
-Converting Models
------------------
+<!--- Licensed to the Apache Software Foundation (ASF) under one -->
+<!--- or more contributor license agreements. See the NOTICE file -->
+<!--- distributed with this work for additional information -->
+<!--- regarding copyright ownership. The ASF licenses this file -->
+<!--- to you under the Apache License, Version 2.0 (the -->
+<!--- "License"); you may not use this file except in compliance -->
+<!--- with the License. You may obtain a copy of the License at -->
+
+<!--- http://www.apache.org/licenses/LICENSE-2.0 -->
+
+<!--- Unless required by applicable law or agreed to in writing, -->
+<!--- software distributed under the License is distributed on an -->
+<!--- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -->
+<!--- KIND, either express or implied. See the License for the -->
+<!--- specific language governing permissions and limitations -->
+<!--- under the License. -->
+
+
+# Android Camera Demo Sample App
+
+The Android Camera Demo Sample App provides a basic implementation of an
Android app that uses the tvm runtime to perform image classification in real
time.
+
+You will need JDK, [Android NDK](https://developer.android.com/ndk) and an
Android device to use this.
+
+## Build and Installation
+
+### <a name="preparemodels">Prepare Models</a>
The `models/prepare_models.py` script provides a example flow for dumping model
parameter files for use by the app.
+
+1. Set path to the NDK CC: `export TVM_NDK_CC=[Path to CC, e.g.
/opt/android-toolchain-arm64/bin/aarch64-linux-android-g++]`
+2. Switch to the script directory: `cd models`
+3. Run script: `python3 prepare_model.py`
+
+#### Sample output
+```
+mobilenet_v2
+getting model...
+building...
+dumping lib...
+dumping graph...
+dumping params...
+dumping labels...
+resnet18_v1
+getting model...
+building...
+dumping lib...
+dumping graph...
+dumping params...
+dumping labels...
+```
+
+### <a name="buildapk">Build APK</a>
+
+We use [Gradle](https://gradle.org) to build. Please follow [the installation
instruction](https://gradle.org/install) for your operating system.
+
+Before you build the Android application, please refer to [TVM4J Installation
Guide](https://github.com/apache/tvm/blob/main/jvm/README.md) and install
tvm4j-core to your local maven repository. You can find tvm4j dependency
declare in `app/build.gradle`. Modify it if it is necessary.
+
+```
+dependencies {
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
+ androidTestImplementation('androidx.test.espresso:espresso-core:3.2.0', {
+ exclude group: 'com.android.support', module: 'support-annotations'
+ })
+ implementation 'androidx.appcompat:appcompat:1.4.0'
+ implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
+ implementation 'com.google.android.material:material:1.5.0'
+ implementation 'org.apache.tvm:tvm4j-core:0.0.1-SNAPSHOT'
+ testImplementation 'junit:junit:4.13.2'
+
+ implementation "androidx.concurrent:concurrent-futures:1.0.0"
+ implementation "androidx.camera:camera-core:1.0.0-beta01"
+ implementation "androidx.camera:camera-camera2:1.0.0-beta01"
+ implementation "androidx.camera:camera-view:1.0.0-alpha08"
+ implementation "androidx.camera:camera-extensions:1.0.0-alpha08"
+ implementation "androidx.camera:camera-lifecycle:1.0.0-beta01"
+}
+```
+
+Now use Gradle to compile JNI, resolve Java dependencies and build the Android
application together with tvm4j. Run following script to generate the apk file.
+
+```bash
+export ANDROID_HOME=[Path to your Android SDK, e.g., ~/Android/sdk]
+cd apps/android_camera
+gradle clean build
+```
+
+In `app/build/outputs/apk` you'll find `app-release-unsigned.apk`, use
`dev_tools/gen_keystore.sh` to generate a signature and use
`dev_tools/sign_apk.sh` to get the signed apk file
`app/build/outputs/apk/release/tv8mdemo-release.apk`.
+
+Upload `tv8mdemo-release.apk` to your Android device and install it:
+
+```bash
+$ANDROID_HOME/platform-tools/adb install
app/build/outputs/apk/release/tv8mdemo-release.apk
+```
+
+If you see error:
+
+ adb: failed to install app/build/outputs/apk/release/tv8mdemo-release.apk:
+ Failure [INSTALL_FAILED_UPDATE_INCOMPATIBLE:
+ Package ml.apache.tvm.android.androidcamerademo signatures do not match
the previously installed version; ignoring!]
+
+Run uninstall first:
+
+```bash
+$ANDROID_HOME/platform-tools/adb uninstall
ml.apache.tvm.android.androidcamerademo
+```
diff --git a/apps/android_camera/app/build.gradle
b/apps/android_camera/app/build.gradle
index 8a772a3d29..c7767559e4 100644
--- a/apps/android_camera/app/build.gradle
+++ b/apps/android_camera/app/build.gradle
@@ -17,20 +17,47 @@
apply plugin: 'com.android.application'
+task generateJniHeaders(type: Exec, description: 'Generate JNI Headers') {
+ def headerPath = "${project.projectDir}/src/main/jni"
+ def classPath = "${project.projectDir}/../../../jvm/core/target/*"
+ def filePath =
"${project.projectDir}/../../../jvm/core/src/main/java/org/apache/tvm/LibInfo.java"
+ commandLine "javac", "-h", headerPath, "-classpath", classPath, filePath
+ doLast {
+
file("${headerPath}/org_apache_tvm_LibInfo.h").renameTo(file("${headerPath}/org_apache_tvm_native_c_api.h"))
+ }
+}
+
+task copyFiles(type: Copy, description: 'Copy Sources for ndk-build') {
+ dependsOn "generateJniHeaders"
+ def ndkFilesPath =
"${project.projectDir}/../../../jvm/native/src/main/native"
+ def srcPath = "${project.projectDir}/src/main/jni/"
+
+ from "${ndkFilesPath}/org_apache_tvm_native_c_api.cc",
"${ndkFilesPath}/jni_helper_func.h"
+ into srcPath
+}
+
+task deleteLibs(type: Delete, description: "Delete Compiled Libraries") {
+ dependsOn "copyFiles"
+ def libsPath = "${project.projectDir}/src/main/libs"
+ delete libsPath
+}
+
task buildJni(type: Exec, description: 'Build JNI libs') {
- commandLine 'sh', 'src/main/jni/build.sh'
+ dependsOn "deleteLibs"
+ def buildPath = "${project.projectDir}/src/main/jni"
+ commandLine "ndk-build", "--directory", buildPath
}
tasks.withType(JavaCompile) {
- //compileTask -> compileTask.dependsOn buildJni
+ compileTask -> compileTask.dependsOn buildJni
}
android {
- compileSdkVersion 29
+ compileSdkVersion 31
defaultConfig {
applicationId "ml.apache.tvm.android.androidcamerademo"
minSdkVersion 24
- targetSdkVersion 29
+ targetSdkVersion 26
renderscriptTargetApi 18
renderscriptSupportModeEnabled true
versionCode 1
@@ -53,7 +80,10 @@ android {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
- buildToolsVersion = '29.0.3'
+
+ lintOptions {
+ disable "Instantiatable" // MainActivity and RPCActivity must extend
android.app.Activity
+ }
}
dependencies {
@@ -61,13 +91,13 @@ dependencies {
androidTestImplementation('androidx.test.espresso:espresso-core:3.2.0', {
exclude group: 'com.android.support', module: 'support-annotations'
})
- implementation 'androidx.appcompat:appcompat:1.1.0'
- implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
- implementation 'com.google.android.material:material:1.1.0'
- implementation 'org.apache.tvm:tvm4j-core:0.0.1-SNAPSHOT'
- testImplementation 'junit:junit:4.13'
+ implementation 'androidx.appcompat:appcompat:1.4.0'
+ implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
+ implementation 'com.google.android.material:material:1.5.0'
+ implementation
files('../../../jvm/core/target/tvm4j-core-0.0.1-SNAPSHOT.jar')
+ testImplementation 'junit:junit:4.13.2'
- implementation("androidx.concurrent:concurrent-futures:1.0.0")
+ implementation "androidx.concurrent:concurrent-futures:1.0.0"
implementation "androidx.camera:camera-core:1.0.0-beta01"
implementation "androidx.camera:camera-camera2:1.0.0-beta01"
// If you want to use the CameraX View class
diff --git a/apps/android_camera/app/src/main/AndroidManifest.xml
b/apps/android_camera/app/src/main/AndroidManifest.xml
index 0821286d55..e5b6465c58 100644
--- a/apps/android_camera/app/src/main/AndroidManifest.xml
+++ b/apps/android_camera/app/src/main/AndroidManifest.xml
@@ -28,7 +28,7 @@
tools:ignore="AllowBackup,MissingApplicationIcon">
<activity
android:name="org.apache.tvm.android.androidcamerademo.MainActivity"
- android:label="@string/app_name"
+ android:exported="true"
android:screenOrientation="portrait"
android:theme="@style/AppTheme.NoActionBar"
tools:ignore="LockedOrientationActivity">
diff --git
a/apps/android_camera/app/src/main/java/org/apache/tvm/android/androidcamerademo/Camera2BasicFragment.java
b/apps/android_camera/app/src/main/java/org/apache/tvm/android/androidcamerademo/Camera2BasicFragment.java
index 8a5f54a3e3..3a55a62d73 100644
---
a/apps/android_camera/app/src/main/java/org/apache/tvm/android/androidcamerademo/Camera2BasicFragment.java
+++
b/apps/android_camera/app/src/main/java/org/apache/tvm/android/androidcamerademo/Camera2BasicFragment.java
@@ -382,7 +382,7 @@ public class Camera2BasicFragment extends Fragment {
}
private float[] getFrame(ImageProxy imageProxy) {
- @SuppressLint("UnsafeExperimentalUsageError")
+ @SuppressLint("UnsafeOptInUsageError")
Image image = imageProxy.getImage();
// extract the jpeg content
if (image == null) {
diff --git
a/apps/android_camera/app/src/main/java/org/apache/tvm/android/androidcamerademo/MainActivity.java
b/apps/android_camera/app/src/main/java/org/apache/tvm/android/androidcamerademo/MainActivity.java
index f9c573a5d1..06b1c9730d 100644
---
a/apps/android_camera/app/src/main/java/org/apache/tvm/android/androidcamerademo/MainActivity.java
+++
b/apps/android_camera/app/src/main/java/org/apache/tvm/android/androidcamerademo/MainActivity.java
@@ -78,6 +78,7 @@ public class MainActivity extends AppCompatActivity implements
@Override
public void onRequestPermissionsResult(
int requestCode, @NonNull String[] permissions, @NonNull int[]
grantResults) {
+ super.onRequestPermissionsResult(requestCode, permissions,
grantResults);
if (allPermissionsGranted()) {
startFragment();
} else {
diff --git a/apps/android_camera/app/src/main/jni/Android.mk
b/apps/android_camera/app/src/main/jni/Android.mk
index a5eacb0c0c..4ff3da8f33 100644
--- a/apps/android_camera/app/src/main/jni/Android.mk
+++ b/apps/android_camera/app/src/main/jni/Android.mk
@@ -34,11 +34,14 @@ endif
include $(config)
LOCAL_SRC_FILES := org_apache_tvm_native_c_api.cc
+
LOCAL_LDFLAGS := -L$(SYSROOT)/usr/lib/ -llog
LOCAL_C_INCLUDES := $(ROOT_PATH)/include \
+ $(ROOT_PATH)/src/runtime/rpc \
$(ROOT_PATH)/3rdparty/dlpack/include \
$(ROOT_PATH)/3rdparty/dmlc-core/include \
+ $(MY_PATH)
LOCAL_MODULE = tvm4j_runtime_packed
diff --git a/apps/android_camera/app/src/main/jni/tvm_runtime.h
b/apps/android_camera/app/src/main/jni/tvm_runtime.h
index bed3bc82d5..b20227b34d 100644
--- a/apps/android_camera/app/src/main/jni/tvm_runtime.h
+++ b/apps/android_camera/app/src/main/jni/tvm_runtime.h
@@ -40,11 +40,16 @@
#include "../src/runtime/graph_executor/graph_executor.cc"
#include "../src/runtime/library_module.cc"
#include "../src/runtime/logging.cc"
+#include "../src/runtime/minrpc/minrpc_logger.cc"
#include "../src/runtime/module.cc"
#include "../src/runtime/ndarray.cc"
#include "../src/runtime/object.cc"
+#include "../src/runtime/profiling.cc"
#include "../src/runtime/registry.cc"
+#include "../src/runtime/rpc/rpc_channel.cc"
+#include "../src/runtime/rpc/rpc_endpoint.cc"
#include "../src/runtime/rpc/rpc_event_impl.cc"
+#include "../src/runtime/rpc/rpc_local_session.cc"
#include "../src/runtime/rpc/rpc_module.cc"
#include "../src/runtime/rpc/rpc_server_env.cc"
#include "../src/runtime/rpc/rpc_session.cc"
diff --git a/apps/android_camera/app/src/main/res/layout/listview_row.xml
b/apps/android_camera/app/src/main/res/layout/listview_row.xml
index 4c233dc403..5038a27557 100644
--- a/apps/android_camera/app/src/main/res/layout/listview_row.xml
+++ b/apps/android_camera/app/src/main/res/layout/listview_row.xml
@@ -20,7 +20,7 @@
android:id="@+id/listview_row_text"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:layout_marginRight="2dp"
+ android:layout_marginEnd="2dp"
android:background="@drawable/item_selector"
android:padding="10dp"
android:textSize="18sp"
diff --git a/apps/android_camera/build.gradle b/apps/android_camera/build.gradle
index a58bc631da..1cd5ac9b65 100644
--- a/apps/android_camera/build.gradle
+++ b/apps/android_camera/build.gradle
@@ -19,14 +19,14 @@
buildscript {
repositories {
- jcenter()
+ gradlePluginPortal()
maven {
url 'https://maven.google.com'
}
- google()
}
dependencies {
- classpath 'com.android.tools.build:gradle:3.6.1'
+ classpath 'com.android.tools.build:gradle:7.1.2'
+
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
@@ -34,16 +34,15 @@ buildscript {
allprojects {
repositories {
- jcenter()
+ gradlePluginPortal()
maven {
- url 'https://maven.google.com'
+ url 'https://maven.google.com'
}
mavenLocal()
mavenCentral()
- google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
-}
\ No newline at end of file
+}
diff --git a/apps/android_camera/gradle.properties
b/apps/android_camera/gradle.properties
index f1328bf5fd..1add1b5409 100644
--- a/apps/android_camera/gradle.properties
+++ b/apps/android_camera/gradle.properties
@@ -1,4 +1,3 @@
-
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
diff --git a/apps/android_camera/models/prepare_model.py
b/apps/android_camera/models/prepare_model.py
index 2ea1b0a120..959e93f8b4 100644
--- a/apps/android_camera/models/prepare_model.py
+++ b/apps/android_camera/models/prepare_model.py
@@ -106,7 +106,7 @@ def main(model_str, output_path):
f.write(graph)
print("dumping params...")
with open(output_path_str + "/" + "deploy_param.params", "wb") as f:
- f.write(runtime.save_param_dict(params))
+ f.write(tvm.runtime.save_param_dict(params))
print("dumping labels...")
synset_url = "".join(
[
diff --git a/apps/android_camera/models/requirements.txt
b/apps/android_camera/models/requirements.txt
new file mode 100644
index 0000000000..98aa53def4
--- /dev/null
+++ b/apps/android_camera/models/requirements.txt
@@ -0,0 +1,4 @@
+keras
+mxnet
+scipy
+tensorflow
\ No newline at end of file
diff --git a/apps/android_deploy/app/build.gradle
b/apps/android_deploy/app/build.gradle
index c00528ba49..2949775349 100644
--- a/apps/android_deploy/app/build.gradle
+++ b/apps/android_deploy/app/build.gradle
@@ -26,8 +26,35 @@ apply from: "download-models.gradle"
apply plugin: 'com.android.application'
+task generateJniHeaders(type: Exec, description: 'Generate JNI Headers') {
+ def headerPath = "${project.projectDir}/src/main/jni"
+ def classPath = "${project.projectDir}/../../../jvm/core/target/*"
+ def filePath =
"${project.projectDir}/../../../jvm/core/src/main/java/org/apache/tvm/LibInfo.java"
+ commandLine "javac", "-h", headerPath, "-classpath", classPath, filePath
+ doLast {
+
file("${headerPath}/org_apache_tvm_LibInfo.h").renameTo(file("${headerPath}/org_apache_tvm_native_c_api.h"))
+ }
+}
+
+task copyFiles(type: Copy, description: 'Copy Sources for ndk-build') {
+ dependsOn "generateJniHeaders"
+ def ndkFilesPath =
"${project.projectDir}/../../../jvm/native/src/main/native"
+ def srcPath = "${project.projectDir}/src/main/jni/"
+
+ from "${ndkFilesPath}/org_apache_tvm_native_c_api.cc",
"${ndkFilesPath}/jni_helper_func.h"
+ into srcPath
+}
+
+task deleteLibs(type: Delete, description: "Delete Compiled Libraries") {
+ dependsOn "copyFiles"
+ def libsPath = "${project.projectDir}/src/main/libs"
+ delete libsPath
+}
+
task buildJni(type: Exec, description: 'Build JNI libs') {
- commandLine 'sh', 'src/main/jni/build.sh'
+ dependsOn "deleteLibs"
+ def buildPath = "${project.projectDir}/src/main/jni"
+ commandLine "ndk-build", "--directory", buildPath
}
tasks.withType(JavaCompile) {
@@ -35,11 +62,10 @@ tasks.withType(JavaCompile) {
}
android {
- compileSdkVersion 26
- buildToolsVersion "26.0.1"
+ compileSdkVersion 31
defaultConfig {
applicationId "org.apache.tvm.android.demo"
- minSdkVersion 17
+ minSdkVersion 24
targetSdkVersion 26
versionCode 1
versionName "1.0"
@@ -55,19 +81,24 @@ android {
main {
jni.srcDirs = []
jniLibs.srcDirs = ['src/main/libs']
- assets.srcDirs = [project.ext.ASSET_DIR]
}
}
+
+ lintOptions {
+ disable "Instantiatable" // MainActivity and RPCActivity must extend
android.app.Activity
+ disable "MissingApplicationIcon" // Should explicitly set
android:icon, there is no default
+ disable "UnsafeNativeCodeLocation" // Shared libraries should not be
placed in the res or assets directories.
+ }
}
dependencies {
- compile fileTree(dir: 'libs', include: ['*.jar'])
-
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
+
androidTestImplementation('com.android.support.test.espresso:espresso-core:3.4.0',
{
exclude group: 'com.android.support', module: 'support-annotations'
})
- compile 'com.android.support:appcompat-v7:26.0.1'
- compile 'com.android.support.constraint:constraint-layout:1.0.2'
- compile 'com.android.support:design:26.0.1'
- compile 'org.apache.tvm:tvm4j-core:0.0.1-SNAPSHOT'
- testCompile 'junit:junit:4.12'
-}
+ implementation 'androidx.appcompat:appcompat:1.4.1'
+ implementation 'com.android.support.constraint:constraint-layout:2.1.3'
+ implementation 'com.android.support:design:28.0.0'
+ implementation
files('../../../jvm/core/target/tvm4j-core-0.0.1-SNAPSHOT.jar')
+ testImplementation 'junit:junit:4.13.2'
+}
\ No newline at end of file
diff --git a/apps/android_deploy/app/download-models.gradle
b/apps/android_deploy/app/download-models.gradle
index ed660e0221..4d1620bfd9 100644
--- a/apps/android_deploy/app/download-models.gradle
+++ b/apps/android_deploy/app/download-models.gradle
@@ -34,7 +34,7 @@ buildscript {
jcenter()
}
dependencies {
- classpath 'de.undercouch:gradle-download-task:3.2.0'
+ classpath 'de.undercouch:gradle-download-task:5.0.4'
}
}
diff --git a/apps/android_deploy/app/src/main/AndroidManifest.xml
b/apps/android_deploy/app/src/main/AndroidManifest.xml
index bf3463f4d9..ce1b1fac45 100644
--- a/apps/android_deploy/app/src/main/AndroidManifest.xml
+++ b/apps/android_deploy/app/src/main/AndroidManifest.xml
@@ -25,6 +25,7 @@ under the License.
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
+ <uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
@@ -33,16 +34,16 @@ under the License.
android:theme="@style/AppTheme" >
<activity
android:name="org.apache.tvm.android.demo.MainActivity"
- android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar"
- android:screenOrientation="portrait">
+ android:exported="true"
+ android:screenOrientation="unspecified">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<provider
- android:name="android.support.v4.content.FileProvider"
+ android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.provider"
android:exported="false"
android:grantUriPermissions="true">
@@ -52,6 +53,4 @@ under the License.
</provider>
</application>
- <uses-permission android:name="android.permission.INTERNET" />
-
</manifest>
diff --git
a/apps/android_deploy/app/src/main/java/org/apache/tvm/android/demo/MainActivity.java
b/apps/android_deploy/app/src/main/java/org/apache/tvm/android/demo/MainActivity.java
index 85cc7a277b..6320b6aa8a 100644
---
a/apps/android_deploy/app/src/main/java/org/apache/tvm/android/demo/MainActivity.java
+++
b/apps/android_deploy/app/src/main/java/org/apache/tvm/android/demo/MainActivity.java
@@ -35,9 +35,9 @@ import android.os.Bundle;
import android.os.Environment;
import android.os.SystemClock;
import android.provider.MediaStore;
-import android.support.v4.content.FileProvider;
-import android.support.v7.app.AppCompatActivity;
-import android.support.v7.widget.Toolbar;
+import androidx.core.content.FileProvider;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.appcompat.widget.Toolbar;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
@@ -51,6 +51,7 @@ import java.io.InputStream;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
+import java.util.Locale;
import java.util.Vector;
import org.apache.tvm.Function;
@@ -487,7 +488,7 @@ public class MainActivity extends AppCompatActivity {
*/
private File createImageFile() {
// Create an image file name
- String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new
Date());
+ String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss",
Locale.US).format(new Date());
String imageFileName = "JPEG_" + timeStamp + "_";
File storageDir = Environment.getExternalStoragePublicDirectory(
Environment.DIRECTORY_PICTURES);
@@ -527,6 +528,7 @@ public class MainActivity extends AppCompatActivity {
@Override
public void onRequestPermissionsResult (final int requestCode, final
String[] permissions, final int[] grantResults){
+ super.onRequestPermissionsResult(requestCode, permissions,
grantResults);
if (requestCode == PERMISSIONS_REQUEST) {
if (grantResults.length > 0
&& grantResults[0] == PackageManager.PERMISSION_GRANTED
diff --git a/apps/android_deploy/app/src/main/res/layout/activity_main.xml
b/apps/android_deploy/app/src/main/res/layout/activity_main.xml
index 0778374223..4b019e1fbd 100644
--- a/apps/android_deploy/app/src/main/res/layout/activity_main.xml
+++ b/apps/android_deploy/app/src/main/res/layout/activity_main.xml
@@ -19,29 +19,28 @@ specific language governing permissions and limitations
under the License.
-->
-<android.support.design.widget.CoordinatorLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:app="http://schemas.android.com/apk/res-auto"
- xmlns:tools="http://schemas.android.com/tools"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- tools:context="org.apache.tvm.android.demo.MainActivity">
-
- <android.support.design.widget.AppBarLayout
- android:layout_height="wrap_content"
+<androidx.coordinatorlayout.widget.CoordinatorLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
- android:theme="@style/AppTheme.AppBarOverlay">
+ android:layout_height="match_parent"
+ tools:context="org.apache.tvm.tvmrpc.MainActivity">
- <android.support.v7.widget.Toolbar
- android:id="@+id/toolbar"
+ <com.google.android.material.appbar.AppBarLayout
+ android:layout_height="wrap_content"
android:layout_width="match_parent"
- android:layout_height="?attr/actionBarSize"
- android:background="?attr/colorPrimary"
- app:popupTheme="@style/AppTheme.PopupOverlay" />
+ android:theme="@style/AppTheme.AppBarOverlay">
- </android.support.design.widget.AppBarLayout>
+ <androidx.appcompat.widget.Toolbar
+ android:id="@+id/toolbar"
+ android:layout_width="match_parent"
+ android:layout_height="?attr/actionBarSize"
+ android:background="?attr/colorPrimary"
+ app:popupTheme="@style/AppTheme.PopupOverlay" />
- <include layout="@layout/content_main"/>
+ </com.google.android.material.appbar.AppBarLayout>
-</android.support.design.widget.CoordinatorLayout>
+ <include layout="@layout/content_main"/>
+</androidx.coordinatorlayout.widget.CoordinatorLayout>
diff --git a/apps/android_deploy/app/src/main/res/layout/content_main.xml
b/apps/android_deploy/app/src/main/res/layout/content_main.xml
index aa1b0ea72b..6bf3c19f7f 100644
--- a/apps/android_deploy/app/src/main/res/layout/content_main.xml
+++ b/apps/android_deploy/app/src/main/res/layout/content_main.xml
@@ -35,10 +35,10 @@ under the License.
<Button
android:id="@+id/btnPickImage"
- android:layout_width="match_parent"
+ android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
- android:text="Select or Capture picture" />
+ android:text="@string/btnPickImage_text" />
</LinearLayout>
<View
@@ -58,7 +58,8 @@ under the License.
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="375dp"
- android:layout_weight="1" />
+ android:layout_weight="1"
+ android:contentDescription="@string/image_description"/>
<View
android:layout_width="match_parent"
diff --git a/apps/android_deploy/app/src/main/res/values/strings.xml
b/apps/android_deploy/app/src/main/res/values/strings.xml
index 734fc85d2d..2a38774253 100644
--- a/apps/android_deploy/app/src/main/res/values/strings.xml
+++ b/apps/android_deploy/app/src/main/res/values/strings.xml
@@ -20,4 +20,6 @@ under the License.
<resources>
<string name="app_name">TVM Android Demo</string>
+ <string name="btnPickImage_text">Select or Capture Picture</string>
+ <string name="image_description">Input Image</string>
</resources>
diff --git a/apps/android_deploy/build.gradle b/apps/android_deploy/build.gradle
index fc98e3479f..35d20c9b36 100644
--- a/apps/android_deploy/build.gradle
+++ b/apps/android_deploy/build.gradle
@@ -19,14 +19,14 @@
buildscript {
repositories {
- jcenter()
+ gradlePluginPortal()
maven {
url 'https://maven.google.com'
}
}
dependencies {
- classpath 'com.android.tools.build:gradle:3.1.0'
- classpath 'org.apache.httpcomponents:httpclient:4.5.4'
+ classpath 'com.android.tools.build:gradle:7.1.2'
+ classpath 'org.apache.httpcomponents:httpclient:4.5.13'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
@@ -35,7 +35,7 @@ buildscript {
allprojects {
repositories {
- jcenter()
+ gradlePluginPortal()
maven {
url 'https://maven.google.com'
}
diff --git a/apps/android_deploy/gradle.properties
b/apps/android_deploy/gradle.properties
index 5d2b9cef07..972e391a31 100644
--- a/apps/android_deploy/gradle.properties
+++ b/apps/android_deploy/gradle.properties
@@ -16,3 +16,5 @@
# under the License.
org.gradle.jvmargs=-Xmx4096M
+android.useAndroidX=true
+android.enableJetifier=true
\ No newline at end of file
diff --git a/apps/android_rpc/README.md b/apps/android_rpc/README.md
index c5e21ecbbc..2e301af6d9 100644
--- a/apps/android_rpc/README.md
+++ b/apps/android_rpc/README.md
@@ -32,15 +32,15 @@ Before you build the Android application, please refer to
[TVM4J Installation Gu
```
dependencies {
- compile fileTree(dir: 'libs', include: ['*.jar'])
-
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
+
androidTestImplementation('com.android.support.test.espresso:espresso-core:3.4.0',
{
exclude group: 'com.android.support', module: 'support-annotations'
})
- compile 'com.android.support:appcompat-v7:26.0.1'
- compile 'com.android.support.constraint:constraint-layout:1.0.2'
- compile 'com.android.support:design:26.0.1'
- compile 'org.apache.tvm:tvm4j-core:0.0.1-SNAPSHOT'
- testCompile 'junit:junit:4.12'
+ implementation 'androidx.appcompat:appcompat:1.4.1'
+ implementation 'com.android.support.constraint:constraint-layout:2.1.3'
+ implementation 'com.android.support:design:28.0.0'
+ implementation 'org.apache.tvm:tvm4j-core:0.0.1-SNAPSHOT'
+ testImplementation 'junit:junit:4.13.2'
}
```
diff --git a/apps/android_rpc/app/build.gradle
b/apps/android_rpc/app/build.gradle
index 747809317c..14d4a7bb9a 100644
--- a/apps/android_rpc/app/build.gradle
+++ b/apps/android_rpc/app/build.gradle
@@ -17,17 +17,49 @@
apply plugin: 'com.android.application'
+task generateJniHeaders(type: Exec, description: 'Generate JNI Headers') {
+ def headerPath = "${project.projectDir}/src/main/jni"
+ def classPath = "${project.projectDir}/../../../jvm/core/target/*"
+ def filePath =
"${project.projectDir}/../../../jvm/core/src/main/java/org/apache/tvm/LibInfo.java"
+ commandLine "javac", "-h", headerPath, "-classpath", classPath, filePath
+ doLast {
+
file("${headerPath}/org_apache_tvm_LibInfo.h").renameTo(file("${headerPath}/org_apache_tvm_native_c_api.h"))
+ }
+}
+
+task copyFiles(type: Copy, description: 'Copy Sources for ndk-build') {
+ dependsOn "generateJniHeaders"
+ def ndkFilesPath =
"${project.projectDir}/../../../jvm/native/src/main/native"
+ def srcPath = "${project.projectDir}/src/main/jni/"
+
+ from "${ndkFilesPath}/org_apache_tvm_native_c_api.cc",
"${ndkFilesPath}/jni_helper_func.h"
+ into srcPath
+}
+
+task deleteLibs(type: Delete, description: "Delete Compiled Libraries") {
+ dependsOn "copyFiles"
+ def libsPath = "${project.projectDir}/src/main/libs"
+ delete libsPath
+}
+
task buildJni(type: Exec, description: 'Build JNI libs') {
- commandLine 'sh', 'src/main/jni/build.sh'
+ dependsOn "deleteLibs"
+ def buildPath = "${project.projectDir}/src/main/jni"
+ commandLine "ndk-build", "--directory", buildPath
}
tasks.withType(JavaCompile) {
compileTask -> compileTask.dependsOn buildJni
}
+// gradle.projectsEvaluated {
+// tasks.withType(JavaCompile) {
+// options.compilerArgs << "-Xlint:deprecation"
+// }
+// }
+
android {
- compileSdkVersion 26
- buildToolsVersion "26.0.1"
+ compileSdkVersion 31
defaultConfig {
applicationId "org.apache.tvm.tvmrpc"
minSdkVersion 24
@@ -48,16 +80,22 @@ android {
jniLibs.srcDirs = ['src/main/libs']
}
}
+
+ lintOptions {
+ disable "Instantiatable" // MainActivity and RPCActivity must extend
android.app.Activity
+ disable "MissingClass" // .RPCWatchdogService was not found in the
project or the libraries
+ disable "IconDipSize" // The image ic_launcher.png varies
significantly in its density-independent size
+ }
}
dependencies {
- compile fileTree(dir: 'libs', include: ['*.jar'])
-
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
+
androidTestImplementation('com.android.support.test.espresso:espresso-core:3.4.0',
{
exclude group: 'com.android.support', module: 'support-annotations'
})
- compile 'com.android.support:appcompat-v7:26.0.1'
- compile 'com.android.support.constraint:constraint-layout:1.0.2'
- compile 'com.android.support:design:26.0.1'
- compile 'org.apache.tvm:tvm4j-core:0.0.1-SNAPSHOT'
- testCompile 'junit:junit:4.12'
+ implementation 'androidx.appcompat:appcompat:1.4.1'
+ implementation 'com.android.support.constraint:constraint-layout:2.1.3'
+ implementation 'com.android.support:design:28.0.0'
+ implementation
files('../../../jvm/core/target/tvm4j-core-0.0.1-SNAPSHOT.jar')
+ testImplementation 'junit:junit:4.13.2'
}
diff --git a/apps/android_rpc/app/src/main/AndroidManifest.xml
b/apps/android_rpc/app/src/main/AndroidManifest.xml
index d6e1ef8e63..217dbb859a 100644
--- a/apps/android_rpc/app/src/main/AndroidManifest.xml
+++ b/apps/android_rpc/app/src/main/AndroidManifest.xml
@@ -29,12 +29,12 @@ under the License.
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme"
- android:icon="@mipmap/ic_launcher" >
+ android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"
- android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar"
- android:screenOrientation="portrait">
+ android:screenOrientation="unspecified"
+ android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
@@ -48,7 +48,7 @@ under the License.
android:process=":RPCProcess"
android:label="@string/rpc_name"
android:theme="@style/AppTheme.NoActionBar"
- android:screenOrientation="portrait">
+ android:screenOrientation="unspecified">
</activity>
</application>
diff --git
a/apps/android_rpc/app/src/main/java/org/apache/tvm/tvmrpc/MainActivity.java
b/apps/android_rpc/app/src/main/java/org/apache/tvm/tvmrpc/MainActivity.java
index 35105df92b..f28507b46f 100644
--- a/apps/android_rpc/app/src/main/java/org/apache/tvm/tvmrpc/MainActivity.java
+++ b/apps/android_rpc/app/src/main/java/org/apache/tvm/tvmrpc/MainActivity.java
@@ -23,12 +23,13 @@ import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Handler;
+import android.os.Looper;
-import android.support.v7.app.AppCompatActivity;
-import android.support.v7.widget.Toolbar;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.appcompat.widget.Toolbar;
import android.widget.CompoundButton;
import android.widget.EditText;
-import android.widget.Switch;
+import androidx.appcompat.widget.SwitchCompat;
import android.content.Intent;
@@ -55,7 +56,7 @@ public class MainActivity extends AppCompatActivity {
EditText edProxyAddress = findViewById(R.id.input_address);
EditText edProxyPort = findViewById(R.id.input_port);
EditText edAppKey = findViewById(R.id.input_key);
- Switch inputSwitch = findViewById(R.id.switch_persistent);
+ SwitchCompat inputSwitch = findViewById(R.id.switch_persistent);
final String proxyHost = edProxyAddress.getText().toString();
final int proxyPort = Integer.parseInt(edProxyPort.getText().toString());
@@ -79,7 +80,7 @@ public class MainActivity extends AppCompatActivity {
private void setupRelaunch() {
final Context context = this;
- final Switch switchPersistent = findViewById(R.id.switch_persistent);
+ final SwitchCompat switchPersistent = findViewById(R.id.switch_persistent);
final Runnable rPCStarter = new Runnable() {
public void run() {
if (switchPersistent.isChecked()) {
@@ -89,7 +90,8 @@ public class MainActivity extends AppCompatActivity {
}
}
};
- Handler handler = new Handler();
+
+ Handler handler = new Handler(Looper.getMainLooper());
handler.postDelayed(rPCStarter, HANDLER_RESTART_DELAY);
}
@@ -101,7 +103,7 @@ public class MainActivity extends AppCompatActivity {
setSupportActionBar(toolbar);
final Context context = this;
- Switch switchPersistent = findViewById(R.id.switch_persistent);
+ SwitchCompat switchPersistent = findViewById(R.id.switch_persistent);
switchPersistent.setOnCheckedChangeListener(new
CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean
isChecked) {
@@ -136,7 +138,7 @@ public class MainActivity extends AppCompatActivity {
EditText edProxyAddress = findViewById(R.id.input_address);
EditText edProxyPort = findViewById(R.id.input_port);
EditText edAppKey = findViewById(R.id.input_key);
- Switch input_switch = findViewById(R.id.switch_persistent);
+ SwitchCompat input_switch = findViewById(R.id.switch_persistent);
edProxyAddress.setEnabled(enable);
edProxyPort.setEnabled(enable);
edAppKey.setEnabled(enable);
diff --git
a/apps/android_rpc/app/src/main/java/org/apache/tvm/tvmrpc/RPCActivity.java
b/apps/android_rpc/app/src/main/java/org/apache/tvm/tvmrpc/RPCActivity.java
index 0d7f04782d..1481c854f9 100644
--- a/apps/android_rpc/app/src/main/java/org/apache/tvm/tvmrpc/RPCActivity.java
+++ b/apps/android_rpc/app/src/main/java/org/apache/tvm/tvmrpc/RPCActivity.java
@@ -18,7 +18,7 @@
package org.apache.tvm.tvmrpc;
import android.os.Bundle;
-import android.support.v7.app.AppCompatActivity;
+import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.widget.Button;
import android.view.View;
diff --git a/apps/android_rpc/app/src/main/jni/build.sh
b/apps/android_rpc/app/src/main/jni/build.sh
deleted file mode 100755
index 001d206ffd..0000000000
--- a/apps/android_rpc/app/src/main/jni/build.sh
+++ /dev/null
@@ -1,26 +0,0 @@
-#!/bin/bash
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-PATH="$PATH:/usr/local/bin"
-CURR_DIR=$(cd `dirname $0`; pwd)
-ROOT_DIR="$CURR_DIR/../../../../../.."
-javac -h $CURR_DIR -classpath "$ROOT_DIR/jvm/core/target/*"
$ROOT_DIR/jvm/core/src/main/java/org/apache/tvm/LibInfo.java || exit -1
-mv $CURR_DIR/org_apache_tvm_LibInfo.h $CURR_DIR/org_apache_tvm_native_c_api.h
-cp -f $ROOT_DIR/jvm/native/src/main/native/org_apache_tvm_native_c_api.cc
$CURR_DIR/ || exit -1
-cp -f $ROOT_DIR/jvm/native/src/main/native/jni_helper_func.h $CURR_DIR/ ||
exit -1
-rm -rf $CURR_DIR/../libs
-ndk-build --directory=$CURR_DIR
diff --git a/apps/android_rpc/app/src/main/jni/tvm_runtime.h
b/apps/android_rpc/app/src/main/jni/tvm_runtime.h
index 1dd37f1c53..95b793a985 100644
--- a/apps/android_rpc/app/src/main/jni/tvm_runtime.h
+++ b/apps/android_rpc/app/src/main/jni/tvm_runtime.h
@@ -42,6 +42,7 @@
#include "../src/runtime/graph_executor/graph_executor_factory.cc"
#include "../src/runtime/library_module.cc"
#include "../src/runtime/logging.cc"
+#include "../src/runtime/minrpc/minrpc_logger.cc"
#include "../src/runtime/module.cc"
#include "../src/runtime/ndarray.cc"
#include "../src/runtime/object.cc"
diff --git a/apps/android_rpc/app/src/main/res/layout/activity_main.xml
b/apps/android_rpc/app/src/main/res/layout/activity_main.xml
index f5cad5443c..f317a1cb79 100644
--- a/apps/android_rpc/app/src/main/res/layout/activity_main.xml
+++ b/apps/android_rpc/app/src/main/res/layout/activity_main.xml
@@ -19,7 +19,7 @@ specific language governing permissions and limitations
under the License.
-->
-<android.support.design.widget.CoordinatorLayout
+<androidx.coordinatorlayout.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
@@ -27,20 +27,20 @@ under the License.
android:layout_height="match_parent"
tools:context="org.apache.tvm.tvmrpc.MainActivity">
- <android.support.design.widget.AppBarLayout
+ <com.google.android.material.appbar.AppBarLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:theme="@style/AppTheme.AppBarOverlay">
- <android.support.v7.widget.Toolbar
+ <androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay" />
- </android.support.design.widget.AppBarLayout>
+ </com.google.android.material.appbar.AppBarLayout>
<include layout="@layout/content_main"/>
-</android.support.design.widget.CoordinatorLayout>
+</androidx.coordinatorlayout.widget.CoordinatorLayout>
diff --git a/apps/android_rpc/app/src/main/res/layout/activity_rpc.xml
b/apps/android_rpc/app/src/main/res/layout/activity_rpc.xml
index 7e282b5a02..9c586e0cc0 100644
--- a/apps/android_rpc/app/src/main/res/layout/activity_rpc.xml
+++ b/apps/android_rpc/app/src/main/res/layout/activity_rpc.xml
@@ -19,7 +19,7 @@ specific language governing permissions and limitations
under the License.
-->
-<android.support.design.widget.CoordinatorLayout
+<androidx.coordinatorlayout.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
@@ -27,20 +27,20 @@ under the License.
android:layout_height="match_parent"
tools:context="org.apache.tvm.tvmrpc.RPCActivity">
- <android.support.design.widget.AppBarLayout
+ <com.google.android.material.appbar.AppBarLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:theme="@style/AppTheme.AppBarOverlay">
- <android.support.v7.widget.Toolbar
+ <androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay" />
- </android.support.design.widget.AppBarLayout>
+ </com.google.android.material.appbar.AppBarLayout>
<include layout="@layout/content_rpc"/>
-</android.support.design.widget.CoordinatorLayout>
+</androidx.coordinatorlayout.widget.CoordinatorLayout>
diff --git a/apps/android_rpc/app/src/main/res/layout/content_main.xml
b/apps/android_rpc/app/src/main/res/layout/content_main.xml
index d6eff2b063..483f60a721 100644
--- a/apps/android_rpc/app/src/main/res/layout/content_main.xml
+++ b/apps/android_rpc/app/src/main/res/layout/content_main.xml
@@ -38,6 +38,7 @@ under the License.
<EditText
android:id="@+id/input_address"
android:hint="@string/input_address"
+ android:autofillHints="@string/label_address_hint"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="phone"
@@ -55,6 +56,7 @@ under the License.
<EditText
android:id="@+id/input_port"
android:hint="@string/input_port"
+ android:autofillHints="@string/label_port_hint"
android:minWidth="100dip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@@ -73,6 +75,8 @@ under the License.
<EditText
android:id="@+id/input_key"
android:hint="@string/input_key"
+ android:autofillHints="@string/label_key_hint"
+ android:inputType="text"
android:minWidth="100dip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@@ -87,15 +91,16 @@ under the License.
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/label_persistent"/>
- <Switch
- android:id="@+id/switch_persistent"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:switchMinWidth="55dp"
- android:paddingLeft="10dip"
- android:checked="false"
- android:textOff="@string/switch_off"
- android:textOn="@string/switch_on" />
+ <androidx.appcompat.widget.SwitchCompat
+ android:id="@+id/switch_persistent"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:switchMinWidth="55dp"
+ android:paddingLeft="10dip"
+ android:paddingRight="10dip"
+ android:checked="false"
+ android:textOff="@string/switch_off"
+ android:textOn="@string/switch_on" />
</LinearLayout>
</LinearLayout>
diff --git a/apps/android_rpc/app/src/main/res/values/strings.xml
b/apps/android_rpc/app/src/main/res/values/strings.xml
index 72c19cd4e5..960e5a3b92 100644
--- a/apps/android_rpc/app/src/main/res/values/strings.xml
+++ b/apps/android_rpc/app/src/main/res/values/strings.xml
@@ -31,6 +31,11 @@ under the License.
<string name="label_key">Key</string>
<string name="label_persistent">Enable RPC</string>
+ <string name="label_address_hint">192.168.1.1</string>
+ <string name="label_port_hint">9190</string>
+ <string name="label_key_hint">android</string>
+
+
<string name="switch_on">Enabled</string>
<string name="switch_off">Disabled</string>
diff --git a/apps/android_rpc/build.gradle b/apps/android_rpc/build.gradle
index be00a5e521..1cd5ac9b65 100644
--- a/apps/android_rpc/build.gradle
+++ b/apps/android_rpc/build.gradle
@@ -19,13 +19,13 @@
buildscript {
repositories {
- jcenter()
+ gradlePluginPortal()
maven {
url 'https://maven.google.com'
}
}
dependencies {
- classpath 'com.android.tools.build:gradle:3.1.0'
+ classpath 'com.android.tools.build:gradle:7.1.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
@@ -34,7 +34,7 @@ buildscript {
allprojects {
repositories {
- jcenter()
+ gradlePluginPortal()
maven {
url 'https://maven.google.com'
}
diff --git a/apps/android_deploy/app/src/main/jni/build.sh
b/apps/android_rpc/gradle.properties
similarity index 54%
rename from apps/android_deploy/app/src/main/jni/build.sh
rename to apps/android_rpc/gradle.properties
index 001d206ffd..97b133967b 100644
--- a/apps/android_deploy/app/src/main/jni/build.sh
+++ b/apps/android_rpc/gradle.properties
@@ -1,4 +1,3 @@
-#!/bin/bash
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
@@ -6,21 +5,15 @@
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-PATH="$PATH:/usr/local/bin"
-CURR_DIR=$(cd `dirname $0`; pwd)
-ROOT_DIR="$CURR_DIR/../../../../../.."
-javac -h $CURR_DIR -classpath "$ROOT_DIR/jvm/core/target/*"
$ROOT_DIR/jvm/core/src/main/java/org/apache/tvm/LibInfo.java || exit -1
-mv $CURR_DIR/org_apache_tvm_LibInfo.h $CURR_DIR/org_apache_tvm_native_c_api.h
-cp -f $ROOT_DIR/jvm/native/src/main/native/org_apache_tvm_native_c_api.cc
$CURR_DIR/ || exit -1
-cp -f $ROOT_DIR/jvm/native/src/main/native/jni_helper_func.h $CURR_DIR/ ||
exit -1
-rm -rf $CURR_DIR/../libs
-ndk-build --directory=$CURR_DIR
+
+android.useAndroidX=true
+android.enableJetifier=true
diff --git a/apps/android_camera/app/src/main/jni/build.sh
b/tests/scripts/task_config_build_jvm.sh
similarity index 58%
rename from apps/android_camera/app/src/main/jni/build.sh
rename to tests/scripts/task_config_build_jvm.sh
index e9b7303d90..f14c90bebd 100755
--- a/apps/android_camera/app/src/main/jni/build.sh
+++ b/tests/scripts/task_config_build_jvm.sh
@@ -1,4 +1,5 @@
-#!/bin/bash
+
+#!/usr/bin/env bash
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
@@ -15,13 +16,19 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-set -x
-PATH="$PATH:/usr/local/bin"
-CURR_DIR=$(cd `dirname $0`; pwd)
-ROOT_DIR="$CURR_DIR/../../../../../.."
-javac -h $CURR_DIR -classpath "$ROOT_DIR/jvm/core/target/*"
$ROOT_DIR/jvm/core/src/main/java/org/apache/tvm/LibInfo.java || exit -1
-mv $CURR_DIR/org_apache_tvm_LibInfo.h $CURR_DIR/org_apache_tvm_native_c_api.h
-cp -f $ROOT_DIR/jvm/native/src/main/native/org_apache_tvm_native_c_api.cc
$CURR_DIR/ || exit -1
-cp -f $ROOT_DIR/jvm/native/src/main/native/jni_helper_func.h $CURR_DIR/ ||
exit -1
-rm -rf $CURR_DIR/../libs
-ndk-build --directory=$CURR_DIR
+
+set -e
+set -u
+
+BUILD_DIR=$1
+mkdir -p "$BUILD_DIR"
+cd "$BUILD_DIR"
+cp ../cmake/config.cmake .
+
+echo set\(USE_SORT ON\) >> config.cmake
+echo set\(USE_RPC ON\) >> config.cmake
+echo set\(USE_PROFILER ON\) >> config.cmake
+echo set\(CMAKE_CXX_FLAGS -Werror\) >> config.cmake
+echo set\(USE_CCACHE OFF\) >> config.cmake
+echo set\(SUMMARIZE ON\) >> config.cmake
+echo set\(USE_LLVM ON\) >> config.cmake
\ No newline at end of file