commit
4585509f55
@ -0,0 +1,48 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
BASE_PATH=$(cd "$(dirname $0)"; pwd)
|
||||
TOP_PATH="${BASE_PATH}/../../.."
|
||||
# build mindspore-lite arm64
|
||||
cd ${TOP_PATH}
|
||||
bash build.sh -I arm64
|
||||
COMPILE_RET=$?
|
||||
|
||||
if [[ "${COMPILE_RET}" -ne 0 ]]; then
|
||||
echo "---------------- mindspore lite: build failed ----------------"
|
||||
exit
|
||||
fi
|
||||
|
||||
# copy arm64 so
|
||||
cd ${TOP_PATH}/output/
|
||||
rm -rf MSLite-0.6.0-linux_arm64
|
||||
tar -zxvf MSLite-0.6.0-linux_arm64.tar.gz
|
||||
cp ${TOP_PATH}/output/MSLite-0.6.0-linux_arm64/lib/libmindspore-lite.so ${BASE_PATH}/lib/
|
||||
cp ${ANDROID_NDK}/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/aarch64-linux-android/libc++_shared.so ${BASE_PATH}/lib/
|
||||
|
||||
# build jni so
|
||||
cd ${BASE_PATH}/native
|
||||
rm -rf build
|
||||
mkdir build
|
||||
cd build
|
||||
cmake -DCMAKE_TOOLCHAIN_FILE="${ANDROID_NDK}/build/cmake/android.toolchain.cmake" -DANDROID_NATIVE_API_LEVEL="19" \
|
||||
-DANDROID_NDK="${ANDROID_NDK}" -DANDROID_ABI="arm64-v8a" -DANDROID_TOOLCHAIN_NAME="aarch64-linux-android-clang" \
|
||||
-DANDROID_STL="c++_shared" -DCMAKE_BUILD_TYPE=Debug ..
|
||||
VERBOSE=2 make -j8
|
||||
cp ${BASE_PATH}/native/build/libmindspore-lite-jni.so ${BASE_PATH}/lib/
|
||||
|
||||
# build aar
|
||||
## check sdk gradle
|
||||
cd ${BASE_PATH}/java
|
||||
rm -rf .gradle build gradle gradlew gradlew.bat build app/build
|
||||
rm -rf ${BASE_PATH}/java/app/libs/arm64-v8a/*
|
||||
cp ${BASE_PATH}/lib/*.so ${BASE_PATH}/java/app/libs/arm64-v8a/
|
||||
gradle init
|
||||
gradle wrapper
|
||||
./gradlew build
|
||||
|
||||
# copy output
|
||||
cd ${BASE_PATH}/
|
||||
rm -rf output
|
||||
mkdir -pv output
|
||||
cp ${BASE_PATH}/java/app/build/outputs/aar/mindspore-lite.aar ${BASE_PATH}/output/
|
@ -0,0 +1,45 @@
|
||||
apply plugin: 'com.android.library'
|
||||
|
||||
android {
|
||||
compileSdkVersion 30
|
||||
buildToolsVersion "30.0.1"
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion 19
|
||||
targetSdkVersion 30
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
cppFlags "-std=c++17"
|
||||
}
|
||||
}
|
||||
ndk {
|
||||
abiFilters 'arm64-v8a'
|
||||
}
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
sourceSets {
|
||||
main {
|
||||
jniLibs.srcDirs=['libs']
|
||||
}
|
||||
}
|
||||
}
|
||||
android.libraryVariants.all {
|
||||
variant->variant.outputs.all {
|
||||
outputFileName = "mindspore-lite.aar"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(dir: "libs", include: ["*.jar"])
|
||||
testImplementation 'junit:junit:4.12'
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.mindspore.lite">
|
||||
</manifest>
|
@ -1,4 +1,4 @@
|
||||
package cn.huawei.mindspore;
|
||||
package com.mindspore.lite;
|
||||
|
||||
public class DataType {
|
||||
public static final int kNumberTypeBool = 30;
|
@ -1,15 +1,13 @@
|
||||
package cn.huawei.mindspore;
|
||||
package com.mindspore.lite;
|
||||
|
||||
import cn.huawei.mindspore.context.Context;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.mindspore.lite.context.Context;
|
||||
|
||||
public class LiteSession {
|
||||
static {
|
||||
System.loadLibrary("mindspore-lite-jni");
|
@ -1,4 +1,4 @@
|
||||
package cn.huawei.mindspore;
|
||||
package com.mindspore.lite;
|
||||
|
||||
public class MSTensor {
|
||||
private long tensorPtr;
|
@ -1,10 +1,9 @@
|
||||
package cn.huawei.mindspore;
|
||||
package com.mindspore.lite;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.AssetFileDescriptor;
|
||||
import android.util.Log;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.MappedByteBuffer;
|
@ -1,4 +1,4 @@
|
||||
package cn.huawei.mindspore.context;
|
||||
package com.mindspore.lite.context;
|
||||
|
||||
public class Context {
|
||||
private long contextPtr;
|
@ -1,4 +1,4 @@
|
||||
package cn.huawei.mindspore.context;
|
||||
package com.mindspore.lite.context;
|
||||
|
||||
public class CpuBindMode {
|
||||
public static final int MID_CPU = -1;
|
@ -1,4 +1,4 @@
|
||||
package cn.huawei.mindspore.context;
|
||||
package com.mindspore.lite.context;
|
||||
|
||||
public class DeviceType {
|
||||
public static final int DT_CPU = 0;
|
@ -0,0 +1,21 @@
|
||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
buildscript {
|
||||
repositories {
|
||||
google()
|
||||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
classpath "com.android.tools.build:gradle:4.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
google()
|
||||
jcenter()
|
||||
}
|
||||
}
|
||||
|
||||
task clean(type: Delete) {
|
||||
delete rootProject.buildDir
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
/*
|
||||
* This file was generated by the Gradle 'init' task.
|
||||
*
|
||||
* The settings file is used to specify which projects to include in your build.
|
||||
*
|
||||
* Detailed information about configuring a multi-project build in Gradle can be found
|
||||
* in the user manual at https://docs.gradle.org/6.6/userguide/multi_project_builds.html
|
||||
*/
|
||||
|
||||
include ':app'
|
||||
rootProject.name = 'mindspore-lite-aar'
|
@ -0,0 +1,21 @@
|
||||
cmake_minimum_required(VERSION 3.14)
|
||||
project (Lite-java)
|
||||
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/)
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../../lite/)
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../../core/)
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../../../third_party/flatbuffers/include)
|
||||
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/../lib)
|
||||
|
||||
add_library(mindspore-lite-jni SHARED
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/common/ms_log.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/common/jni_utils.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/runtime/model.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/runtime/context.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/runtime/ms_tensor.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/runtime/lite_session.cpp
|
||||
)
|
||||
|
||||
find_library(log-lib log)
|
||||
|
||||
target_link_libraries(mindspore-lite-jni mindspore-lite ${log-lib} )
|
@ -1,18 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.4.1)
|
||||
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src)
|
||||
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/libs/${ANDROID_ABI})
|
||||
|
||||
add_library(mindspore-lite-jni SHARED
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/common/ms_log.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/common/jni_utils.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/runtime/model.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/runtime/context.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/runtime/ms_tensor.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/runtime/lite_session.cpp
|
||||
)
|
||||
|
||||
find_library(log-lib log)
|
||||
|
||||
target_link_libraries(mindspore-lite-jni mindspore-lite ${log-lib} )
|
Loading…
Reference in new issue