From 7d887f54fa1e0100b2439fd6db76ebb35f0a835d Mon Sep 17 00:00:00 2001
From: Kirill Snezhko <4477094+argrento@users.noreply.github.com>
Date: Fri, 1 Apr 2022 17:35:37 +0300
Subject: [PATCH 01/12] Update gradle version in android_rpc app
---
apps/android_rpc/app/build.gradle | 22 +++++++++++++------
.../app/src/main/AndroidManifest.xml | 1 +
apps/android_rpc/build.gradle | 2 +-
3 files changed, 17 insertions(+), 8 deletions(-)
diff --git a/apps/android_rpc/app/build.gradle b/apps/android_rpc/app/build.gradle
index 747809317cb3..8059c381b0e7 100644
--- a/apps/android_rpc/app/build.gradle
+++ b/apps/android_rpc/app/build.gradle
@@ -48,16 +48,24 @@ android {
jniLibs.srcDirs = ['src/main/libs']
}
}
+
+ gradle.taskGraph.whenReady {graph ->
+ def tasks = graph.getAllTasks()
+ tasks.each {task ->
+ def name = task.getName()
+ if (name.contains("lint")) task.setEnabled(false)
+ }
+ }
}
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:2.2.2', {
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 'com.android.support:appcompat-v7:26.0.1'
+ implementation 'com.android.support.constraint:constraint-layout:1.0.2'
+ implementation 'com.android.support:design:26.0.1'
+ implementation 'org.apache.tvm:tvm4j-core:0.0.1-SNAPSHOT'
+ testImplementation 'junit:junit:4.12'
}
diff --git a/apps/android_rpc/app/src/main/AndroidManifest.xml b/apps/android_rpc/app/src/main/AndroidManifest.xml
index d6e1ef8e63ed..4a7ba917dad0 100644
--- a/apps/android_rpc/app/src/main/AndroidManifest.xml
+++ b/apps/android_rpc/app/src/main/AndroidManifest.xml
@@ -23,6 +23,7 @@ under the License.
package="org.apache.tvm.tvmrpc" >
+
Date: Mon, 4 Apr 2022 16:39:31 +0300
Subject: [PATCH 02/12] Support latest gradle, bump versions, replace ndk build
script with gradle tasks
---
apps/android_rpc/app/build.gradle | 50 ++++++++++++++-----
.../org/apache/tvm/tvmrpc/MainActivity.java | 5 +-
.../org/apache/tvm/tvmrpc/RPCActivity.java | 2 +-
apps/android_rpc/app/src/main/jni/build.sh | 26 ----------
.../app/src/main/res/layout/activity_main.xml | 10 ++--
.../app/src/main/res/layout/activity_rpc.xml | 10 ++--
apps/android_rpc/build.gradle | 6 +--
apps/android_rpc/gradle.properties | 2 +
8 files changed, 57 insertions(+), 54 deletions(-)
delete mode 100755 apps/android_rpc/app/src/main/jni/build.sh
create mode 100644 apps/android_rpc/gradle.properties
diff --git a/apps/android_rpc/app/build.gradle b/apps/android_rpc/app/build.gradle
index 8059c381b0e7..0d5290f110f1 100644
--- a/apps/android_rpc/app/build.gradle
+++ b/apps/android_rpc/app/build.gradle
@@ -17,8 +17,35 @@
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) {
@@ -26,8 +53,7 @@ tasks.withType(JavaCompile) {
}
android {
- compileSdkVersion 26
- buildToolsVersion "26.0.1"
+ compileSdkVersion 31
defaultConfig {
applicationId "org.apache.tvm.tvmrpc"
minSdkVersion 24
@@ -50,22 +76,22 @@ android {
}
gradle.taskGraph.whenReady {graph ->
- def tasks = graph.getAllTasks()
- tasks.each {task ->
- def name = task.getName()
+ def tasks = graph.getAllTasks()
+ tasks.each {task ->
+ def name = task.getName()
if (name.contains("lint")) task.setEnabled(false)
- }
+ }
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
- androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
+ androidTestImplementation('com.android.support.test.espresso:espresso-core:3.4.0', {
exclude group: 'com.android.support', module: 'support-annotations'
})
- implementation 'com.android.support:appcompat-v7:26.0.1'
- implementation 'com.android.support.constraint:constraint-layout:1.0.2'
- implementation 'com.android.support:design:26.0.1'
+ 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.12'
+ testImplementation 'junit:junit:4.13.2'
}
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 35105df92b0d..26d553b59fd4 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,9 +23,10 @@
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;
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 0d7f04782d3a..1481c854f966 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 001d206ffd5d..000000000000
--- 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/res/layout/activity_main.xml b/apps/android_rpc/app/src/main/res/layout/activity_main.xml
index f5cad5443cd1..f317a1cb7988 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.
-->
-
-
-
-
+
-
+
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 7e282b5a02f3..9c586e0cc0c7 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.
-->
-
-
-
-
+
-
+
diff --git a/apps/android_rpc/build.gradle b/apps/android_rpc/build.gradle
index 7cff5de3e4d3..1cd5ac9b656f 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:4.2.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_rpc/gradle.properties b/apps/android_rpc/gradle.properties
new file mode 100644
index 000000000000..646c51b977f3
--- /dev/null
+++ b/apps/android_rpc/gradle.properties
@@ -0,0 +1,2 @@
+android.useAndroidX=true
+android.enableJetifier=true
From ef748b19690f96870203f081ed2a8490f43fa06a Mon Sep 17 00:00:00 2001
From: Kirill Snezhko <4477094+argrento@users.noreply.github.com>
Date: Mon, 4 Apr 2022 17:39:27 +0300
Subject: [PATCH 03/12] [android_rpc] Fix linter errors, disable weird ones
---
apps/android_rpc/app/build.gradle | 16 ++++++++-----
.../app/src/main/AndroidManifest.xml | 9 ++++----
.../org/apache/tvm/tvmrpc/MainActivity.java | 13 ++++++-----
.../app/src/main/res/layout/content_main.xml | 23 +++++++++++--------
.../app/src/main/res/values/strings.xml | 5 ++++
5 files changed, 40 insertions(+), 26 deletions(-)
diff --git a/apps/android_rpc/app/build.gradle b/apps/android_rpc/app/build.gradle
index 0d5290f110f1..750660bde1b1 100644
--- a/apps/android_rpc/app/build.gradle
+++ b/apps/android_rpc/app/build.gradle
@@ -52,6 +52,12 @@ tasks.withType(JavaCompile) {
compileTask -> compileTask.dependsOn buildJni
}
+gradle.projectsEvaluated {
+ tasks.withType(JavaCompile) {
+ options.compilerArgs << "-Xlint:deprecation"
+ }
+}
+
android {
compileSdkVersion 31
defaultConfig {
@@ -75,13 +81,11 @@ android {
}
}
- gradle.taskGraph.whenReady {graph ->
- def tasks = graph.getAllTasks()
- tasks.each {task ->
- def name = task.getName()
- if (name.contains("lint")) task.setEnabled(false)
+ 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 {
diff --git a/apps/android_rpc/app/src/main/AndroidManifest.xml b/apps/android_rpc/app/src/main/AndroidManifest.xml
index 4a7ba917dad0..217dbb859a76 100644
--- a/apps/android_rpc/app/src/main/AndroidManifest.xml
+++ b/apps/android_rpc/app/src/main/AndroidManifest.xml
@@ -23,19 +23,18 @@ under the License.
package="org.apache.tvm.tvmrpc" >
-
+ android:icon="@mipmap/ic_launcher">
+ android:screenOrientation="unspecified"
+ android:exported="true">
@@ -49,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">
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 26d553b59fd4..f28507b46f8e 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
@@ -29,7 +29,7 @@
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;
@@ -56,7 +56,7 @@ public Intent updateRPCPrefs() {
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());
@@ -80,7 +80,7 @@ public Intent updateRPCPrefs() {
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()) {
@@ -90,7 +90,8 @@ public void run() {
}
}
};
- Handler handler = new Handler();
+
+ Handler handler = new Handler(Looper.getMainLooper());
handler.postDelayed(rPCStarter, HANDLER_RESTART_DELAY);
}
@@ -102,7 +103,7 @@ protected void onCreate(Bundle savedInstanceState) {
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) {
@@ -137,7 +138,7 @@ private void enableInputView(boolean enable) {
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/res/layout/content_main.xml b/apps/android_rpc/app/src/main/res/layout/content_main.xml
index d6eff2b06383..483f60a72170 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.
-
+
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 72c19cd4e5b0..960e5a3b92a7 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.
Key
Enable RPC
+ 192.168.1.1
+ 9190
+ android
+
+
Enabled
Disabled
From 433d65bcb75ba34fc307402cf844bd3765b7ea5d Mon Sep 17 00:00:00 2001
From: Kirill Snezhko <4477094+argrento@users.noreply.github.com>
Date: Mon, 4 Apr 2022 18:23:13 +0300
Subject: [PATCH 04/12] [android_deploy] Support latest gradle, bump versions,
fix linter errors, disable some of them
---
apps/android_deploy/app/build.gradle | 60 ++++++++++++++-----
.../android_deploy/app/download-models.gradle | 2 +-
.../app/src/main/AndroidManifest.xml | 9 ++-
.../apache/tvm/android/demo/MainActivity.java | 10 ++--
apps/android_deploy/app/src/main/jni/build.sh | 26 --------
.../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/app/build.gradle | 10 ++--
11 files changed, 92 insertions(+), 81 deletions(-)
delete mode 100644 apps/android_deploy/app/src/main/jni/build.sh
diff --git a/apps/android_deploy/app/build.gradle b/apps/android_deploy/app/build.gradle
index c00528ba49fd..d79d0055b740 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
+ applicationId "org.apache.tvm.tvmrpc"
+ minSdkVersion 24
targetSdkVersion 26
versionCode 1
versionName "1.0"
@@ -55,19 +81,25 @@ 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 'org.apache.tvm:tvm4j-core:0.0.1-SNAPSHOT'
+ 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 ed660e0221ee..4d1620bfd953 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 bf3463f4d9c6..ce1b1fac4552 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.
+
+ android:exported="true"
+ android:screenOrientation="unspecified">
@@ -52,6 +53,4 @@ under the License.
-
-
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 85cc7a277b4d..6320b6aa8afd 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.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.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 @@ private final String getTempLibFilePath(String fileName) throws IOException {
*/
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 void onClick(DialogInterface dialog, int id) {
@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/jni/build.sh b/apps/android_deploy/app/src/main/jni/build.sh
deleted file mode 100644
index 001d206ffd5d..000000000000
--- a/apps/android_deploy/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_deploy/app/src/main/res/layout/activity_main.xml b/apps/android_deploy/app/src/main/res/layout/activity_main.xml
index 0778374223d8..4b019e1fbdb3 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:layout_height="match_parent"
+ tools:context="org.apache.tvm.tvmrpc.MainActivity">
-
+ android:theme="@style/AppTheme.AppBarOverlay">
-
+
-
+
-
+
+
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 aa1b0ea72b3e..6bf3c19f7f81 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.
+ android:text="@string/btnPickImage_text" />
+ android:layout_weight="1"
+ android:contentDescription="@string/image_description"/>
TVM Android Demo
+ Select or Capture Picture
+ Input Image
diff --git a/apps/android_deploy/build.gradle b/apps/android_deploy/build.gradle
index fc98e3479fe7..35d20c9b3692 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 5d2b9cef0728..972e391a31ea 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/app/build.gradle b/apps/android_rpc/app/build.gradle
index 750660bde1b1..3817ca559cd2 100644
--- a/apps/android_rpc/app/build.gradle
+++ b/apps/android_rpc/app/build.gradle
@@ -52,11 +52,11 @@ tasks.withType(JavaCompile) {
compileTask -> compileTask.dependsOn buildJni
}
-gradle.projectsEvaluated {
- tasks.withType(JavaCompile) {
- options.compilerArgs << "-Xlint:deprecation"
- }
-}
+// gradle.projectsEvaluated {
+// tasks.withType(JavaCompile) {
+// options.compilerArgs << "-Xlint:deprecation"
+// }
+// }
android {
compileSdkVersion 31
From df9822ae48050746ea3f08d578e5b370917443cd Mon Sep 17 00:00:00 2001
From: Kirill Snezhko <4477094+argrento@users.noreply.github.com>
Date: Tue, 5 Apr 2022 14:14:33 +0300
Subject: [PATCH 05/12] [android_camera] Support latest gradle, bump versions,
rewrite readme
---
apps/android_camera/README.md | 129 ++++++++++++++----
apps/android_camera/app/build.gradle | 52 +++++--
.../app/src/main/jni/Android.mk | 3 +
apps/android_camera/app/src/main/jni/build.sh | 27 ----
.../app/src/main/jni/tvm_runtime.h | 4 +
apps/android_camera/build.gradle | 13 +-
apps/android_camera/models/prepare_model.py | 2 +-
apps/android_deploy/app/build.gradle | 3 +-
apps/android_rpc/README.md | 14 +-
9 files changed, 168 insertions(+), 79 deletions(-)
delete mode 100755 apps/android_camera/app/src/main/jni/build.sh
diff --git a/apps/android_camera/README.md b/apps/android_camera/README.md
index c292ce40c582..f659e905f281 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
------------------
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+# 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
+
+### Prepare Models
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...
+```
+
+### Build APK
+
+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 8a772a3d29f3..d11ee494ee42 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,12 @@ 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
+ 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 {
@@ -61,13 +93,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 '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'
+ 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/jni/Android.mk b/apps/android_camera/app/src/main/jni/Android.mk
index a5eacb0c0c2d..4ff3da8f3327 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/build.sh b/apps/android_camera/app/src/main/jni/build.sh
deleted file mode 100755
index e9b7303d901b..000000000000
--- a/apps/android_camera/app/src/main/jni/build.sh
+++ /dev/null
@@ -1,27 +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.
-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
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 07a812c4b840..ec5ebdc87150 100644
--- a/apps/android_camera/app/src/main/jni/tvm_runtime.h
+++ b/apps/android_camera/app/src/main/jni/tvm_runtime.h
@@ -44,11 +44,15 @@
#include "../src/runtime/ndarray.cc"
#include "../src/runtime/object.cc"
#include "../src/runtime/registry.cc"
+#include "../src/runtime/profiling.cc"
#include "../src/runtime/rpc/rpc_event_impl.cc"
#include "../src/runtime/rpc/rpc_module.cc"
#include "../src/runtime/rpc/rpc_server_env.cc"
#include "../src/runtime/rpc/rpc_session.cc"
#include "../src/runtime/rpc/rpc_socket_impl.cc"
+#include "../src/runtime/rpc/rpc_channel.cc"
+#include "../src/runtime/rpc/rpc_endpoint.cc"
+#include "../src/runtime/rpc/rpc_local_session.cc"
#include "../src/runtime/system_library.cc"
#include "../src/runtime/thread_pool.cc"
#include "../src/runtime/threading_backend.cc"
diff --git a/apps/android_camera/build.gradle b/apps/android_camera/build.gradle
index a58bc631dac5..1cd5ac9b656f 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/models/prepare_model.py b/apps/android_camera/models/prepare_model.py
index 2ea1b0a120af..959e93f8b47b 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_deploy/app/build.gradle b/apps/android_deploy/app/build.gradle
index d79d0055b740..bcca460a01d0 100644
--- a/apps/android_deploy/app/build.gradle
+++ b/apps/android_deploy/app/build.gradle
@@ -64,7 +64,7 @@ tasks.withType(JavaCompile) {
android {
compileSdkVersion 31
defaultConfig {
- applicationId "org.apache.tvm.tvmrpc"
+ applicationId "org.apache.tvm.android.demo"
minSdkVersion 24
targetSdkVersion 26
versionCode 1
@@ -88,7 +88,6 @@ android {
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.
-
}
}
diff --git a/apps/android_rpc/README.md b/apps/android_rpc/README.md
index c5e21ecbbc12..2e301af6d996 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'
}
```
From d58a2990ef8db56eca7f9dfb7c99a996028eabb7 Mon Sep 17 00:00:00 2001
From: Kirill Snezhko <4477094+argrento@users.noreply.github.com>
Date: Tue, 5 Apr 2022 15:03:21 +0300
Subject: [PATCH 06/12] [android_camera] Fix linter errors
---
apps/android_camera/app/build.gradle | 2 --
apps/android_camera/app/src/main/AndroidManifest.xml | 2 +-
.../tvm/android/androidcamerademo/Camera2BasicFragment.java | 2 +-
.../org/apache/tvm/android/androidcamerademo/MainActivity.java | 1 +
apps/android_camera/app/src/main/res/layout/listview_row.xml | 2 +-
5 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/apps/android_camera/app/build.gradle b/apps/android_camera/app/build.gradle
index d11ee494ee42..0814148e9680 100644
--- a/apps/android_camera/app/build.gradle
+++ b/apps/android_camera/app/build.gradle
@@ -83,8 +83,6 @@ android {
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.
}
}
diff --git a/apps/android_camera/app/src/main/AndroidManifest.xml b/apps/android_camera/app/src/main/AndroidManifest.xml
index 0821286d5543..e5b6465c5874 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">
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 8a5f54a3e399..3a55a62d739c 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 @@ private Bitmap YUV_420_888_toRGB(Image image, int width, int height) {
}
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 f9c573a5d1fe..06b1c9730d05 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 @@ private void startFragment() {
@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/res/layout/listview_row.xml b/apps/android_camera/app/src/main/res/layout/listview_row.xml
index 4c233dc40379..5038a27557e9 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"
From c92b7900f85ac7ee88ea3c375d8af71cc1c02e5b Mon Sep 17 00:00:00 2001
From: Kirill Snezhko <4477094+argrento@users.noreply.github.com>
Date: Fri, 8 Apr 2022 11:58:08 +0300
Subject: [PATCH 07/12] Fix sanity check errors
---
.../app/src/main/jni/tvm_runtime.h | 8 ++++----
apps/android_camera/gradle.properties | 1 -
apps/android_rpc/gradle.properties | 17 +++++++++++++++++
3 files changed, 21 insertions(+), 5 deletions(-)
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 ec5ebdc87150..148d7bde09b3 100644
--- a/apps/android_camera/app/src/main/jni/tvm_runtime.h
+++ b/apps/android_camera/app/src/main/jni/tvm_runtime.h
@@ -43,16 +43,16 @@
#include "../src/runtime/module.cc"
#include "../src/runtime/ndarray.cc"
#include "../src/runtime/object.cc"
-#include "../src/runtime/registry.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"
#include "../src/runtime/rpc/rpc_socket_impl.cc"
-#include "../src/runtime/rpc/rpc_channel.cc"
-#include "../src/runtime/rpc/rpc_endpoint.cc"
-#include "../src/runtime/rpc/rpc_local_session.cc"
#include "../src/runtime/system_library.cc"
#include "../src/runtime/thread_pool.cc"
#include "../src/runtime/threading_backend.cc"
diff --git a/apps/android_camera/gradle.properties b/apps/android_camera/gradle.properties
index f1328bf5fd43..1add1b540993 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_rpc/gradle.properties b/apps/android_rpc/gradle.properties
index 646c51b977f3..97b133967be2 100644
--- a/apps/android_rpc/gradle.properties
+++ b/apps/android_rpc/gradle.properties
@@ -1,2 +1,19 @@
+# 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.useAndroidX=true
android.enableJetifier=true
From 0c1395f1f1586c85d90a7fbbece8ff86c91bf11f Mon Sep 17 00:00:00 2001
From: Kirill Snezhko <4477094+argrento@users.noreply.github.com>
Date: Sun, 8 May 2022 19:26:40 +0300
Subject: [PATCH 08/12] Add Android jobs for Github Actions
---
.github/workflows/main.yml | 170 +++++++++++++++++--------
apps/android_camera/app/build.gradle | 2 +-
apps/android_deploy/app/build.gradle | 2 +-
apps/android_rpc/app/build.gradle | 2 +-
tests/scripts/task_config_build_jvm.sh | 34 +++++
5 files changed, 155 insertions(+), 55 deletions(-)
create mode 100755 tests/scripts/task_config_build_jvm.sh
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 48b9d62bb9b7..c2b4e00dbf78 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -38,59 +38,125 @@ 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: Set up NDK
+ run: |
+ echo "y" | sudo /usr/local/lib/android/sdk/tools/bin/sdkmanager --install "ndk;24.0.8215888" --sdk_root=${ANDROID_SDK_ROOT}
+ - name: Build TVM
+ shell: bash -l {0}
+ run: |
+ mkdir build
+ cd build
+ ../tests/scripts/task_config_build_jvm.sh .
+ cmake ..
+ make -j8
+ - name: Build TVM4J
+ run: |
+ make jvmpkg
+ - name: Build android_rpc
+ working-directory: apps/android_rpc
+ run: |
+ export PATH="${ANDROID_HOME}/ndk/24.0.8215888:$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_HOME}/ndk/24.0.8215888:$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_HOME}/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android30-clang++
+ export TVM_HOME=~/work/tvm/tvm
+ export PYTHONPATH=$TVM_HOME/python:${PYTHONPATH}
+ pip3 install numpy decorator attrs scipy keras mxnet tensorflow
+ cd models
+ python3 prepare_model.py
+ cd ..
+ export PATH="${ANDROID_HOME}/ndk/24.0.8215888:$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/app/build.gradle b/apps/android_camera/app/build.gradle
index 0814148e9680..c7767559e4df 100644
--- a/apps/android_camera/app/build.gradle
+++ b/apps/android_camera/app/build.gradle
@@ -94,7 +94,7 @@ dependencies {
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'
+ 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"
diff --git a/apps/android_deploy/app/build.gradle b/apps/android_deploy/app/build.gradle
index bcca460a01d0..2949775349bb 100644
--- a/apps/android_deploy/app/build.gradle
+++ b/apps/android_deploy/app/build.gradle
@@ -99,6 +99,6 @@ dependencies {
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'
+ 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_rpc/app/build.gradle b/apps/android_rpc/app/build.gradle
index 3817ca559cd2..14d4a7bb9a61 100644
--- a/apps/android_rpc/app/build.gradle
+++ b/apps/android_rpc/app/build.gradle
@@ -96,6 +96,6 @@ dependencies {
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'
+ implementation files('../../../jvm/core/target/tvm4j-core-0.0.1-SNAPSHOT.jar')
testImplementation 'junit:junit:4.13.2'
}
diff --git a/tests/scripts/task_config_build_jvm.sh b/tests/scripts/task_config_build_jvm.sh
new file mode 100755
index 000000000000..f14c90bebd4b
--- /dev/null
+++ b/tests/scripts/task_config_build_jvm.sh
@@ -0,0 +1,34 @@
+
+#!/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
+# 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.
+
+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
From 7e213b8356531e6de0cec4dfc9272e32cec968fc Mon Sep 17 00:00:00 2001
From: Kirill Snezhko <4477094+argrento@users.noreply.github.com>
Date: Wed, 18 May 2022 14:26:31 +0300
Subject: [PATCH 09/12] Add python requirements for TVM and android_camera, use
preinstalled NDK
---
.github/workflows/main.yml | 17 ++++++++---------
apps/android_camera/models/requirements.txt | 4 ++++
2 files changed, 12 insertions(+), 9 deletions(-)
create mode 100644 apps/android_camera/models/requirements.txt
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index c2b4e00dbf78..cfc1bf33aa49 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -108,9 +108,6 @@ jobs:
with:
distribution: 'zulu'
java-version: '11'
- - name: Set up NDK
- run: |
- echo "y" | sudo /usr/local/lib/android/sdk/tools/bin/sdkmanager --install "ndk;24.0.8215888" --sdk_root=${ANDROID_SDK_ROOT}
- name: Build TVM
shell: bash -l {0}
run: |
@@ -118,14 +115,14 @@ jobs:
cd build
../tests/scripts/task_config_build_jvm.sh .
cmake ..
- make -j8
+ cmake --build . --target tvm_runtime
- name: Build TVM4J
run: |
make jvmpkg
- name: Build android_rpc
working-directory: apps/android_rpc
run: |
- export PATH="${ANDROID_HOME}/ndk/24.0.8215888:$PATH"
+ export PATH="${ANDROID_NDK_HOME}:$PATH"
gradle clean build
- name: Upload android_rpc APK
uses: actions/upload-artifact@v2
@@ -135,7 +132,7 @@ jobs:
- name: Build android_deploy
working-directory: apps/android_deploy
run: |
- export PATH="${ANDROID_HOME}/ndk/24.0.8215888:$PATH"
+ export PATH="${ANDROID_NDK_HOME}:$PATH"
gradle clean build
- name: Upload android_deploy APK
uses: actions/upload-artifact@v2
@@ -146,14 +143,16 @@ jobs:
working-directory: apps/android_camera
run: |
mkdir -p app/src/main/assets/models/
- export TVM_NDK_CC=${ANDROID_HOME}/ndk/24.0.8215888/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android30-clang++
+ 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}
- pip3 install numpy decorator attrs scipy keras mxnet tensorflow
+ python3 ../../python/gen_requirements.py
+ pip3 install -r ../../python/requirements/core.txt
cd models
+ pip3 install -r requirements.txt
python3 prepare_model.py
cd ..
- export PATH="${ANDROID_HOME}/ndk/24.0.8215888:$PATH"
+ export PATH="${ANDROID_NDK_HOME}:$PATH"
gradle clean build
- name: Upload android_camera APK
uses: actions/upload-artifact@v2
diff --git a/apps/android_camera/models/requirements.txt b/apps/android_camera/models/requirements.txt
new file mode 100644
index 000000000000..98aa53def46f
--- /dev/null
+++ b/apps/android_camera/models/requirements.txt
@@ -0,0 +1,4 @@
+keras
+mxnet
+scipy
+tensorflow
\ No newline at end of file
From a0bbd40445b50d3555cb3ec5257844a38a9853eb Mon Sep 17 00:00:00 2001
From: Kirill Snezhko <4477094+argrento@users.noreply.github.com>
Date: Fri, 20 May 2022 10:05:10 +0300
Subject: [PATCH 10/12] Revert to build with make
---
.github/workflows/main.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index cfc1bf33aa49..2b07ed94a41c 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -115,7 +115,7 @@ jobs:
cd build
../tests/scripts/task_config_build_jvm.sh .
cmake ..
- cmake --build . --target tvm_runtime
+ make
- name: Build TVM4J
run: |
make jvmpkg
From a9fa1d683297a4dbbbf43f7c59bab8fbe93a683b Mon Sep 17 00:00:00 2001
From: Kirill Snezhko <4477094+argrento@users.noreply.github.com>
Date: Fri, 20 May 2022 15:10:25 +0300
Subject: [PATCH 11/12] Add minrpc include (PR #11232)
---
apps/android_camera/app/src/main/jni/tvm_runtime.h | 1 +
apps/android_rpc/app/src/main/jni/tvm_runtime.h | 1 +
2 files changed, 2 insertions(+)
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 88982d99ec2a..b20227b34db4 100644
--- a/apps/android_camera/app/src/main/jni/tvm_runtime.h
+++ b/apps/android_camera/app/src/main/jni/tvm_runtime.h
@@ -40,6 +40,7 @@
#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"
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 1dd37f1c5345..95b793a985d1 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"
From b890d77b9f494f925ddf32660897a1b88c00e914 Mon Sep 17 00:00:00 2001
From: Kirill Snezhko <4477094+argrento@users.noreply.github.com>
Date: Mon, 23 May 2022 11:45:42 +0300
Subject: [PATCH 12/12] Remove relative paths
---
.github/workflows/main.yml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 2b07ed94a41c..313c440cbd21 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -146,8 +146,8 @@ jobs:
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 ../../python/gen_requirements.py
- pip3 install -r ../../python/requirements/core.txt
+ 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