forked from mindspore-Ecosystem/mindspore
add java build_aar.sh
This commit is contained in:
parent
d3ef9f77c5
commit
8d87da4d9f
|
@ -4,6 +4,15 @@ mindspore/lib
|
|||
output
|
||||
*.ir
|
||||
|
||||
# mindspore lite java
|
||||
mindspore/lite/java/java/.gradle
|
||||
mindspore/lite/java/java/build
|
||||
mindspore/lite/java/java/gradle
|
||||
mindspore/lite/java/java/gradlew
|
||||
mindspore/lite/java/java/gradlew.bat
|
||||
mindspore/lite/java/java/app/build
|
||||
mindspore/lite/java/java/app/libs
|
||||
|
||||
# flatbuffer
|
||||
mindspore/lite/tools/converter/parser/tflite/schema_generated.h
|
||||
mindspore/lite/tools/converter/parser/caffe/caffe.pb.cc
|
||||
|
|
|
@ -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} )
|
|
@ -20,7 +20,7 @@
|
|||
#include "common/ms_log.h"
|
||||
#include "include/context.h"
|
||||
|
||||
extern "C" JNIEXPORT jlong JNICALL Java_cn_huawei_mindspore_context_Context_createContext(JNIEnv *env, jobject thiz,
|
||||
extern "C" JNIEXPORT jlong JNICALL Java_com_mindspore_lite_context_Context_createContext(JNIEnv *env, jobject thiz,
|
||||
jint device_type,
|
||||
jint thread_num,
|
||||
jint cpu_bind_mode) {
|
||||
|
@ -57,7 +57,7 @@ extern "C" JNIEXPORT jlong JNICALL Java_cn_huawei_mindspore_context_Context_crea
|
|||
return (jlong)context;
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL Java_cn_huawei_mindspore_context_Context_free(JNIEnv *env, jobject thiz,
|
||||
extern "C" JNIEXPORT void JNICALL Java_com_mindspore_lite_context_Context_free(JNIEnv *env, jobject thiz,
|
||||
jlong context_ptr) {
|
||||
auto *pointer = reinterpret_cast<void *>(context_ptr);
|
||||
if (pointer == nullptr) {
|
|
@ -22,7 +22,7 @@
|
|||
#include "include/lite_session.h"
|
||||
#include "include/errorcode.h"
|
||||
|
||||
extern "C" JNIEXPORT jlong JNICALL Java_cn_huawei_mindspore_LiteSession_createSession(JNIEnv *env, jobject thiz,
|
||||
extern "C" JNIEXPORT jlong JNICALL Java_com_mindspore_lite_LiteSession_createSession(JNIEnv *env, jobject thiz,
|
||||
jlong context_ptr) {
|
||||
auto *pointer = reinterpret_cast<void *>(context_ptr);
|
||||
if (pointer == nullptr) {
|
||||
|
@ -38,7 +38,7 @@ extern "C" JNIEXPORT jlong JNICALL Java_cn_huawei_mindspore_LiteSession_createSe
|
|||
return jlong(session);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jboolean JNICALL Java_cn_huawei_mindspore_LiteSession_compileGraph(JNIEnv *env, jobject thiz,
|
||||
extern "C" JNIEXPORT jboolean JNICALL Java_com_mindspore_lite_LiteSession_compileGraph(JNIEnv *env, jobject thiz,
|
||||
jlong session_ptr,
|
||||
jlong model_ptr) {
|
||||
auto *session_pointer = reinterpret_cast<void *>(session_ptr);
|
||||
|
@ -58,7 +58,7 @@ extern "C" JNIEXPORT jboolean JNICALL Java_cn_huawei_mindspore_LiteSession_compi
|
|||
return (jboolean)(ret == mindspore::lite::RET_OK);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL Java_cn_huawei_mindspore_LiteSession_bindThread(JNIEnv *env, jobject thiz,
|
||||
extern "C" JNIEXPORT void JNICALL Java_com_mindspore_lite_LiteSession_bindThread(JNIEnv *env, jobject thiz,
|
||||
jlong session_ptr, jboolean if_bind) {
|
||||
auto *pointer = reinterpret_cast<void *>(session_ptr);
|
||||
if (pointer == nullptr) {
|
||||
|
@ -69,7 +69,7 @@ extern "C" JNIEXPORT void JNICALL Java_cn_huawei_mindspore_LiteSession_bindThrea
|
|||
lite_session_ptr->BindThread(if_bind);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jboolean JNICALL Java_cn_huawei_mindspore_LiteSession_runGraph(JNIEnv *env, jobject thiz,
|
||||
extern "C" JNIEXPORT jboolean JNICALL Java_com_mindspore_lite_LiteSession_runGraph(JNIEnv *env, jobject thiz,
|
||||
jlong session_ptr) {
|
||||
auto *pointer = reinterpret_cast<void *>(session_ptr);
|
||||
if (pointer == nullptr) {
|
||||
|
@ -81,7 +81,7 @@ extern "C" JNIEXPORT jboolean JNICALL Java_cn_huawei_mindspore_LiteSession_runGr
|
|||
return (jboolean)(ret == mindspore::lite::RET_OK);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jobject JNICALL Java_cn_huawei_mindspore_LiteSession_getInputs(JNIEnv *env, jobject thiz,
|
||||
extern "C" JNIEXPORT jobject JNICALL Java_com_mindspore_lite_LiteSession_getInputs(JNIEnv *env, jobject thiz,
|
||||
jlong session_ptr) {
|
||||
jclass array_list = env->FindClass("java/util/ArrayList");
|
||||
jmethodID array_list_construct = env->GetMethodID(array_list, "<init>", "()V");
|
||||
|
@ -104,7 +104,7 @@ extern "C" JNIEXPORT jobject JNICALL Java_cn_huawei_mindspore_LiteSession_getInp
|
|||
return ret;
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jobject JNICALL Java_cn_huawei_mindspore_LiteSession_getInputsByName(JNIEnv *env, jobject thiz,
|
||||
extern "C" JNIEXPORT jobject JNICALL Java_com_mindspore_lite_LiteSession_getInputsByName(JNIEnv *env, jobject thiz,
|
||||
jlong session_ptr,
|
||||
jstring node_name) {
|
||||
jclass array_list = env->FindClass("java/util/ArrayList");
|
||||
|
@ -128,7 +128,7 @@ extern "C" JNIEXPORT jobject JNICALL Java_cn_huawei_mindspore_LiteSession_getInp
|
|||
return ret;
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jobject JNICALL Java_cn_huawei_mindspore_LiteSession_getOutputs(JNIEnv *env, jobject thiz,
|
||||
extern "C" JNIEXPORT jobject JNICALL Java_com_mindspore_lite_LiteSession_getOutputs(JNIEnv *env, jobject thiz,
|
||||
jlong session_ptr) {
|
||||
jclass hash_map_clazz = env->FindClass("java/util/HashMap");
|
||||
jmethodID hash_map_construct = env->GetMethodID(hash_map_clazz, "<init>", "()V");
|
||||
|
@ -160,7 +160,7 @@ extern "C" JNIEXPORT jobject JNICALL Java_cn_huawei_mindspore_LiteSession_getOut
|
|||
return hash_map;
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jobject JNICALL Java_cn_huawei_mindspore_LiteSession_getOutputsByName(JNIEnv *env, jobject thiz,
|
||||
extern "C" JNIEXPORT jobject JNICALL Java_com_mindspore_lite_LiteSession_getOutputsByName(JNIEnv *env, jobject thiz,
|
||||
jlong session_ptr,
|
||||
jstring node_name) {
|
||||
jclass array_list = env->FindClass("java/util/ArrayList");
|
||||
|
@ -184,7 +184,7 @@ extern "C" JNIEXPORT jobject JNICALL Java_cn_huawei_mindspore_LiteSession_getOut
|
|||
return ret;
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL Java_cn_huawei_mindspore_LiteSession_free(JNIEnv *env, jobject thiz,
|
||||
extern "C" JNIEXPORT void JNICALL Java_com_mindspore_lite_LiteSession_free(JNIEnv *env, jobject thiz,
|
||||
jlong session_ptr) {
|
||||
auto *pointer = reinterpret_cast<void *>(session_ptr);
|
||||
if (pointer == nullptr) {
|
|
@ -20,7 +20,7 @@
|
|||
#include "common/ms_log.h"
|
||||
#include "include/model.h"
|
||||
|
||||
extern "C" JNIEXPORT jlong JNICALL Java_cn_huawei_mindspore_Model_loadModel(JNIEnv *env, jobject thiz, jobject buffer) {
|
||||
extern "C" JNIEXPORT jlong JNICALL Java_com_mindspore_lite_Model_loadModel(JNIEnv *env, jobject thiz, jobject buffer) {
|
||||
MS_LOGD("Start getting buffer from java");
|
||||
if (buffer == nullptr) {
|
||||
MS_LOGE("Buffer from java is nullptr");
|
||||
|
@ -39,7 +39,7 @@ extern "C" JNIEXPORT jlong JNICALL Java_cn_huawei_mindspore_Model_loadModel(JNIE
|
|||
return reinterpret_cast<jlong>(model);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL Java_cn_huawei_mindspore_Model_free(JNIEnv *env, jobject thiz, jlong model_ptr) {
|
||||
extern "C" JNIEXPORT void JNICALL Java_com_mindspore_lite_Model_free(JNIEnv *env, jobject thiz, jlong model_ptr) {
|
||||
auto *pointer = reinterpret_cast<void *>(model_ptr);
|
||||
if (pointer == nullptr) {
|
||||
MS_LOGE("Model pointer from java is nullptr");
|
|
@ -21,7 +21,7 @@
|
|||
#include "include/ms_tensor.h"
|
||||
#include "ir/dtype/type_id.h"
|
||||
|
||||
extern "C" JNIEXPORT jlong JNICALL Java_cn_huawei_mindspore_MSTensor_createMSTensor(JNIEnv *env, jobject thiz,
|
||||
extern "C" JNIEXPORT jlong JNICALL Java_com_mindspore_lite_MSTensor_createMSTensor(JNIEnv *env, jobject thiz,
|
||||
jint data_type, jintArray shape,
|
||||
jint shape_len) {
|
||||
jboolean is_copy = false;
|
||||
|
@ -39,7 +39,7 @@ extern "C" JNIEXPORT jlong JNICALL Java_cn_huawei_mindspore_MSTensor_createMSTen
|
|||
return reinterpret_cast<jlong>(ms_tensor);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jintArray JNICALL Java_cn_huawei_mindspore_MSTensor_getShape(JNIEnv *env, jobject thiz,
|
||||
extern "C" JNIEXPORT jintArray JNICALL Java_com_mindspore_lite_MSTensor_getShape(JNIEnv *env, jobject thiz,
|
||||
jlong tensor_ptr) {
|
||||
auto *pointer = reinterpret_cast<void *>(tensor_ptr);
|
||||
if (pointer == nullptr) {
|
||||
|
@ -59,7 +59,7 @@ extern "C" JNIEXPORT jintArray JNICALL Java_cn_huawei_mindspore_MSTensor_getShap
|
|||
return shape;
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jboolean JNICALL Java_cn_huawei_mindspore_MSTensor_setShape(JNIEnv *env, jobject thiz,
|
||||
extern "C" JNIEXPORT jboolean JNICALL Java_com_mindspore_lite_MSTensor_setShape(JNIEnv *env, jobject thiz,
|
||||
jlong tensor_ptr, jintArray shape,
|
||||
jint shape_len) {
|
||||
jboolean is_copy = false;
|
||||
|
@ -78,7 +78,7 @@ extern "C" JNIEXPORT jboolean JNICALL Java_cn_huawei_mindspore_MSTensor_setShape
|
|||
return ret == shape_len;
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL Java_cn_huawei_mindspore_MSTensor_getDataType(JNIEnv *env, jobject thiz,
|
||||
extern "C" JNIEXPORT jint JNICALL Java_com_mindspore_lite_MSTensor_getDataType(JNIEnv *env, jobject thiz,
|
||||
jlong tensor_ptr) {
|
||||
auto *pointer = reinterpret_cast<void *>(tensor_ptr);
|
||||
if (pointer == nullptr) {
|
||||
|
@ -89,7 +89,7 @@ extern "C" JNIEXPORT jint JNICALL Java_cn_huawei_mindspore_MSTensor_getDataType(
|
|||
return jint(ms_tensor_ptr->data_type());
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jboolean JNICALL Java_cn_huawei_mindspore_MSTensor_setDataType(JNIEnv *env, jobject thiz,
|
||||
extern "C" JNIEXPORT jboolean JNICALL Java_com_mindspore_lite_MSTensor_setDataType(JNIEnv *env, jobject thiz,
|
||||
jlong tensor_ptr, jint data_type) {
|
||||
auto *pointer = reinterpret_cast<void *>(tensor_ptr);
|
||||
if (pointer == nullptr) {
|
||||
|
@ -101,7 +101,7 @@ extern "C" JNIEXPORT jboolean JNICALL Java_cn_huawei_mindspore_MSTensor_setDataT
|
|||
return ret == data_type;
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jbyteArray JNICALL Java_cn_huawei_mindspore_MSTensor_getData(JNIEnv *env, jobject thiz,
|
||||
extern "C" JNIEXPORT jbyteArray JNICALL Java_com_mindspore_lite_MSTensor_getData(JNIEnv *env, jobject thiz,
|
||||
jlong tensor_ptr) {
|
||||
auto *pointer = reinterpret_cast<void *>(tensor_ptr);
|
||||
if (pointer == nullptr) {
|
||||
|
@ -120,7 +120,7 @@ extern "C" JNIEXPORT jbyteArray JNICALL Java_cn_huawei_mindspore_MSTensor_getDat
|
|||
return ret;
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jboolean JNICALL Java_cn_huawei_mindspore_MSTensor_setData(JNIEnv *env, jobject thiz,
|
||||
extern "C" JNIEXPORT jboolean JNICALL Java_com_mindspore_lite_MSTensor_setData(JNIEnv *env, jobject thiz,
|
||||
jlong tensor_ptr, jbyteArray data,
|
||||
jlong data_len) {
|
||||
auto *pointer = reinterpret_cast<void *>(tensor_ptr);
|
||||
|
@ -140,7 +140,7 @@ extern "C" JNIEXPORT jboolean JNICALL Java_cn_huawei_mindspore_MSTensor_setData(
|
|||
return static_cast<jboolean>(true);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jlong JNICALL Java_cn_huawei_mindspore_MSTensor_size(JNIEnv *env, jobject thiz, jlong tensor_ptr) {
|
||||
extern "C" JNIEXPORT jlong JNICALL Java_com_mindspore_lite_MSTensor_size(JNIEnv *env, jobject thiz, jlong tensor_ptr) {
|
||||
auto *pointer = reinterpret_cast<void *>(tensor_ptr);
|
||||
if (pointer == nullptr) {
|
||||
MS_LOGE("Tensor pointer from java is nullptr");
|
||||
|
@ -150,7 +150,7 @@ extern "C" JNIEXPORT jlong JNICALL Java_cn_huawei_mindspore_MSTensor_size(JNIEnv
|
|||
return ms_tensor_ptr->Size();
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL Java_cn_huawei_mindspore_MSTensor_elementsNum(JNIEnv *env, jobject thiz,
|
||||
extern "C" JNIEXPORT jint JNICALL Java_com_mindspore_lite_MSTensor_elementsNum(JNIEnv *env, jobject thiz,
|
||||
jlong tensor_ptr) {
|
||||
auto *pointer = reinterpret_cast<void *>(tensor_ptr);
|
||||
if (pointer == nullptr) {
|
||||
|
@ -161,7 +161,7 @@ extern "C" JNIEXPORT jint JNICALL Java_cn_huawei_mindspore_MSTensor_elementsNum(
|
|||
return ms_tensor_ptr->ElementsNum();
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL Java_cn_huawei_mindspore_MSTensor_free(JNIEnv *env, jobject thiz, jlong tensor_ptr) {
|
||||
extern "C" JNIEXPORT void JNICALL Java_com_mindspore_lite_MSTensor_free(JNIEnv *env, jobject thiz, jlong tensor_ptr) {
|
||||
auto *pointer = reinterpret_cast<void *>(tensor_ptr);
|
||||
if (pointer == nullptr) {
|
||||
MS_LOGE("Tensor pointer from java is nullptr");
|
|
@ -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