forked from mindspore-Ecosystem/mindspore
fix fp16 memory leaks and maven publish
This commit is contained in:
parent
634cdd3485
commit
da86901c88
8
build.sh
8
build.sh
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ ConvolutionDepthwiseSWCPUKernel::~ConvolutionDepthwiseSWCPUKernel() {
|
|||
sliding_ = nullptr;
|
||||
}
|
||||
if (packed_weight_ != nullptr) {
|
||||
delete packed_weight_;
|
||||
free(packed_weight_);
|
||||
packed_weight_ = nullptr;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ DeconvolutionDepthwiseCPUKernel::~DeconvolutionDepthwiseCPUKernel() {
|
|||
sliding_ = nullptr;
|
||||
}
|
||||
if (packed_weight_ != nullptr) {
|
||||
delete packed_weight_;
|
||||
free(packed_weight_);
|
||||
packed_weight_ = nullptr;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue