Browse Source

fix fp16 memory leaks and maven publish

tags/v1.1.0
yeyunpeng 5 years ago
parent
commit
da86901c88
7 changed files with 40 additions and 21 deletions
  1. +6
    -2
      build.sh
  2. +20
    -1
      mindspore/lite/java/java/app/build.gradle
  3. +4
    -8
      mindspore/lite/java/java/app/src/main/java/com/mindspore/lite/config/MSConfig.java
  4. +1
    -0
      mindspore/lite/java/java/app/src/main/native/CMakeLists.txt
  5. +7
    -8
      mindspore/lite/java/java/app/src/main/native/runtime/lite_session.cpp
  6. +1
    -1
      mindspore/lite/src/runtime/kernel/arm/fp32/convolution_depthwise_slidewindow.cc
  7. +1
    -1
      mindspore/lite/src/runtime/kernel/arm/fp32/deconvolution_depthwise.cc

+ 6
- 2
build.sh View File

@@ -304,7 +304,7 @@ checkopts()
LITE_LANGUAGE="cpp"
elif [[ "$OPTARG" == "java" ]]; then
LITE_LANGUAGE="java"
ENABLE_CONVERTER="off"
ENABLE_CONVERTER="off"
elif [[ "$OPTARG" == "object-c" ]]; then
LITE_LANGUAGE="object-c"
else
@@ -795,8 +795,12 @@ build_java() {
gradle wrapper
./gradlew build

gradle publish -PLITE_VERSION=${VERSION_STR}-SNAPSHOT

cd ${JAVA_PATH}/java/app/build
zip -r mindspore-lite-maven-${VERSION_STR}.zip mindspore
# copy output
cp ${JAVA_PATH}/java/app/build/outputs/aar/mindspore-lite.aar ${BASEPATH}/output/mindspore-lite-${VERSION_STR}.aar
cp mindspore-lite-maven-${VERSION_STR}.zip ${BASEPATH}/output/
exit 0
}



+ 20
- 1
mindspore/lite/java/java/app/build.gradle View File

@@ -1,4 +1,5 @@
apply plugin: 'com.android.library'
apply plugin: 'maven-publish'

android {
compileSdkVersion 30
@@ -8,7 +9,7 @@ android {
minSdkVersion 19
targetSdkVersion 30
versionCode 1
versionName "1.0"
versionName project.hasProperty("LITE_VERSION") ? LITE_VERSION : ""

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
externalNativeBuild {
@@ -47,3 +48,21 @@ dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
testImplementation 'junit:junit:4.12'
}

publishing {
repositories {
maven {
url uri("build")
}
}
publications {
maven(MavenPublication) {
groupId = 'mindspore'
artifactId = 'mindspore-lite'
version = project.hasProperty("LITE_VERSION") ? LITE_VERSION : ""
String path = project.buildDir.path + File.separator + "outputs" + File.separator + "aar" + File.separator + "mindspore-lite.aar";
artifact(path)
}
}
}


+ 4
- 8
mindspore/lite/java/java/app/src/main/java/com/mindspore/lite/config/MSConfig.java View File

@@ -23,14 +23,6 @@ public class MSConfig {
this.msConfigPtr = 0;
}

public long getMSConfigPtr() {
return msConfigPtr;
}

public void setMSConfigPtr(long msConfigPtr) {
this.msConfigPtr = msConfigPtr;
}

public boolean init(int deviceType, int threadNum, int cpuBindMode) {
this.msConfigPtr = createMSConfig(deviceType, threadNum, cpuBindMode);
return this.msConfigPtr != 0;
@@ -53,6 +45,10 @@ public class MSConfig {
this.msConfigPtr = 0;
}

public long getMSConfigPtr() {
return msConfigPtr;
}

private native long createMSConfig(int deviceType, int threadNum, int cpuBindMode);

private native void free(long msConfigPtr);


+ 1
- 0
mindspore/lite/java/java/app/src/main/native/CMakeLists.txt View File

@@ -6,6 +6,7 @@ set(MS_VERSION_MINOR ${MS_VERSION_MINOR})
set(MS_VERSION_REVISION ${MS_VERSION_REVISION})
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DMS_VERSION_MAJOR=${MS_VERSION_MAJOR} -DMS_VERSION_MINOR=${MS_VERSION_MINOR} -DMS_VERSION_REVISION=${MS_VERSION_REVISION}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DMS_VERSION_MAJOR=${MS_VERSION_MAJOR} -DMS_VERSION_MINOR=${MS_VERSION_MINOR} -DMS_VERSION_REVISION=${MS_VERSION_REVISION}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")

if (ENABLE_VERBOSE)
set(CMAKE_VERBOSE_MAKEFILE on)


+ 7
- 8
mindspore/lite/java/java/app/src/main/native/runtime/lite_session.cpp View File

@@ -102,9 +102,10 @@ extern "C" JNIEXPORT jobject JNICALL Java_com_mindspore_lite_LiteSession_getInpu
return ret;
}

extern "C" JNIEXPORT jobject JNICALL Java_com_mindspore_lite_LiteSession_getInputsByName(JNIEnv *env, jobject thiz,
jlong session_ptr,
jstring node_name) {
extern "C" JNIEXPORT jobject JNICALL Java_com_mindspore_lite_LiteSession_getInputsByTensorName(JNIEnv *env,
jobject thiz,
jlong session_ptr,
jstring tensor_name) {
jclass array_list = env->FindClass("java/util/ArrayList");
jmethodID array_list_construct = env->GetMethodID(array_list, "<init>", "()V");
jobject ret = env->NewObject(array_list, array_list_construct);
@@ -118,11 +119,9 @@ extern "C" JNIEXPORT jobject JNICALL Java_com_mindspore_lite_LiteSession_getInpu
return ret;
}
auto *lite_session_ptr = static_cast<mindspore::session::LiteSession *>(pointer);
auto inputs = lite_session_ptr->GetInputsByName(JstringToChar(env, node_name));
for (auto input : inputs) {
jobject tensor_addr = env->NewObject(long_object, long_object_construct, jlong(input));
env->CallBooleanMethod(ret, array_list_add, tensor_addr);
}
auto input = lite_session_ptr->GetInputsByTensorName(JstringToChar(env, tensor_name));
jobject tensor_addr = env->NewObject(long_object, long_object_construct, jlong(input));
env->CallBooleanMethod(ret, array_list_add, tensor_addr);
return ret;
}



+ 1
- 1
mindspore/lite/src/runtime/kernel/arm/fp32/convolution_depthwise_slidewindow.cc View File

@@ -33,7 +33,7 @@ ConvolutionDepthwiseSWCPUKernel::~ConvolutionDepthwiseSWCPUKernel() {
sliding_ = nullptr;
}
if (packed_weight_ != nullptr) {
delete packed_weight_;
free(packed_weight_);
packed_weight_ = nullptr;
}
}


+ 1
- 1
mindspore/lite/src/runtime/kernel/arm/fp32/deconvolution_depthwise.cc View File

@@ -33,7 +33,7 @@ DeconvolutionDepthwiseCPUKernel::~DeconvolutionDepthwiseCPUKernel() {
sliding_ = nullptr;
}
if (packed_weight_ != nullptr) {
delete packed_weight_;
free(packed_weight_);
packed_weight_ = nullptr;
}
}


Loading…
Cancel
Save