fix bug in java api

pull/4256/head
hangq 5 years ago
parent 0115876363
commit 8859b83ee0

@ -56,7 +56,7 @@ public class Model {
}
if (null != fileDescriptor) {
try {
fis.close();
fileDescriptor.close();
} catch (IOException e) {
Log.e("MS_LITE", "Close fileDescriptor failed: " + e.getMessage());
}

@ -59,7 +59,7 @@ extern "C" JNIEXPORT jlong JNICALL Java_cn_huawei_mindspore_context_Context_crea
extern "C" JNIEXPORT void JNICALL Java_cn_huawei_mindspore_context_Context_free(JNIEnv *env, jobject thiz,
jlong context_ptr) {
auto *pointer = static_cast<void *>(context_ptr);
auto *pointer = reinterpret_cast<void *>(context_ptr);
if (pointer == nullptr) {
MS_LOGE("Context pointer from java is nullptr");
return;

@ -24,7 +24,7 @@
extern "C" JNIEXPORT jlong JNICALL Java_cn_huawei_mindspore_LiteSession_createSession(JNIEnv *env, jobject thiz,
jlong context_ptr) {
auto *pointer = static_cast<void *>(context_ptr);
auto *pointer = reinterpret_cast<void *>(context_ptr);
if (pointer == nullptr) {
MS_LOGE("Context pointer from java is nullptr");
return jlong(nullptr);
@ -41,13 +41,13 @@ extern "C" JNIEXPORT jlong JNICALL Java_cn_huawei_mindspore_LiteSession_createSe
extern "C" JNIEXPORT jboolean JNICALL Java_cn_huawei_mindspore_LiteSession_compileGraph(JNIEnv *env, jobject thiz,
jlong session_ptr,
jlong model_ptr) {
auto *session_pointer = static_cast<void *>(session_ptr);
auto *session_pointer = reinterpret_cast<void *>(session_ptr);
if (session_pointer == nullptr) {
MS_LOGE("Session pointer from java is nullptr");
return (jboolean) false;
}
auto *lite_session_ptr = static_cast<mindspore::session::LiteSession *>(session_pointer);
auto *model_pointer = static_cast<void *>(model_ptr);
auto *model_pointer = reinterpret_cast<void *>(model_ptr);
if (model_pointer == nullptr) {
MS_LOGE("Model pointer from java is nullptr");
return (jboolean) false;
@ -60,7 +60,7 @@ extern "C" JNIEXPORT jboolean JNICALL Java_cn_huawei_mindspore_LiteSession_compi
extern "C" JNIEXPORT void JNICALL Java_cn_huawei_mindspore_LiteSession_bindThread(JNIEnv *env, jobject thiz,
jlong session_ptr, jboolean if_bind) {
auto *pointer = static_cast<void *>(session_ptr);
auto *pointer = reinterpret_cast<void *>(session_ptr);
if (pointer == nullptr) {
MS_LOGE("Session pointer from java is nullptr");
return;
@ -71,7 +71,7 @@ extern "C" JNIEXPORT void JNICALL Java_cn_huawei_mindspore_LiteSession_bindThrea
extern "C" JNIEXPORT jboolean JNICALL Java_cn_huawei_mindspore_LiteSession_runGraph(JNIEnv *env, jobject thiz,
jlong session_ptr) {
auto *pointer = static_cast<void *>(session_ptr);
auto *pointer = reinterpret_cast<void *>(session_ptr);
if (pointer == nullptr) {
MS_LOGE("Session pointer from java is nullptr");
return (jboolean) false;
@ -90,7 +90,7 @@ extern "C" JNIEXPORT jobject JNICALL Java_cn_huawei_mindspore_LiteSession_getInp
jclass long_object = env->FindClass("java/lang/Long");
jmethodID long_object_construct = env->GetMethodID(long_object, "<init>", "(J)V");
auto *pointer = static_cast<void *>(session_ptr);
auto *pointer = reinterpret_cast<void *>(session_ptr);
if (pointer == nullptr) {
MS_LOGE("Session pointer from java is nullptr");
return ret;
@ -114,7 +114,7 @@ extern "C" JNIEXPORT jobject JNICALL Java_cn_huawei_mindspore_LiteSession_getInp
jclass long_object = env->FindClass("java/lang/Long");
jmethodID long_object_construct = env->GetMethodID(long_object, "<init>", "(J)V");
auto *pointer = static_cast<void *>(session_ptr);
auto *pointer = reinterpret_cast<void *>(session_ptr);
if (pointer == nullptr) {
MS_LOGE("Session pointer from java is nullptr");
return ret;
@ -135,7 +135,7 @@ extern "C" JNIEXPORT jobject JNICALL Java_cn_huawei_mindspore_LiteSession_getOut
jobject hash_map = env->NewObject(hash_map_clazz, hash_map_construct);
jmethodID hash_map_put =
env->GetMethodID(hash_map_clazz, "put", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;");
auto *pointer = static_cast<void *>(session_ptr);
auto *pointer = reinterpret_cast<void *>(session_ptr);
if (pointer == nullptr) {
MS_LOGE("Session pointer from java is nullptr");
return hash_map;
@ -170,7 +170,7 @@ extern "C" JNIEXPORT jobject JNICALL Java_cn_huawei_mindspore_LiteSession_getOut
jclass long_object = env->FindClass("java/lang/Long");
jmethodID long_object_construct = env->GetMethodID(long_object, "<init>", "(J)V");
auto *pointer = static_cast<void *>(session_ptr);
auto *pointer = reinterpret_cast<void *>(session_ptr);
if (pointer == nullptr) {
MS_LOGE("Session pointer from java is nullptr");
return ret;
@ -186,7 +186,7 @@ extern "C" JNIEXPORT jobject JNICALL Java_cn_huawei_mindspore_LiteSession_getOut
extern "C" JNIEXPORT void JNICALL Java_cn_huawei_mindspore_LiteSession_free(JNIEnv *env, jobject thiz,
jlong session_ptr) {
auto *pointer = static_cast<void *>(session_ptr);
auto *pointer = reinterpret_cast<void *>(session_ptr);
if (pointer == nullptr) {
MS_LOGE("Session pointer from java is nullptr");
return;

@ -40,7 +40,7 @@ extern "C" JNIEXPORT jlong JNICALL Java_cn_huawei_mindspore_Model_loadModel(JNIE
}
extern "C" JNIEXPORT void JNICALL Java_cn_huawei_mindspore_Model_free(JNIEnv *env, jobject thiz, jlong model_ptr) {
auto *pointer = static_cast<void *>(model_ptr);
auto *pointer = reinterpret_cast<void *>(model_ptr);
if (pointer == nullptr) {
MS_LOGE("Model pointer from java is nullptr");
return;

@ -41,7 +41,7 @@ extern "C" JNIEXPORT jlong JNICALL Java_cn_huawei_mindspore_MSTensor_createMSTen
extern "C" JNIEXPORT jintArray JNICALL Java_cn_huawei_mindspore_MSTensor_getShape(JNIEnv *env, jobject thiz,
jlong tensor_ptr) {
auto *pointer = static_cast<void *>(tensor_ptr);
auto *pointer = reinterpret_cast<void *>(tensor_ptr);
if (pointer == nullptr) {
MS_LOGE("Tensor pointer from java is nullptr");
return env->NewIntArray(0);
@ -64,7 +64,7 @@ extern "C" JNIEXPORT jboolean JNICALL Java_cn_huawei_mindspore_MSTensor_setShape
jint shape_len) {
jboolean is_copy = false;
jint *local_shape_arr = env->GetIntArrayElements(shape, &is_copy);
auto *pointer = static_cast<void *>(tensor_ptr);
auto *pointer = reinterpret_cast<void *>(tensor_ptr);
if (pointer == nullptr) {
MS_LOGE("Tensor pointer from java is nullptr");
return static_cast<jboolean>(false);
@ -80,7 +80,7 @@ extern "C" JNIEXPORT jboolean JNICALL Java_cn_huawei_mindspore_MSTensor_setShape
extern "C" JNIEXPORT jint JNICALL Java_cn_huawei_mindspore_MSTensor_getDataType(JNIEnv *env, jobject thiz,
jlong tensor_ptr) {
auto *pointer = static_cast<void *>(tensor_ptr);
auto *pointer = reinterpret_cast<void *>(tensor_ptr);
if (pointer == nullptr) {
MS_LOGE("Tensor pointer from java is nullptr");
return static_cast<jboolean>(false);
@ -91,7 +91,7 @@ extern "C" JNIEXPORT jint JNICALL Java_cn_huawei_mindspore_MSTensor_getDataType(
extern "C" JNIEXPORT jboolean JNICALL Java_cn_huawei_mindspore_MSTensor_setDataType(JNIEnv *env, jobject thiz,
jlong tensor_ptr, jint data_type) {
auto *pointer = static_cast<void *>(tensor_ptr);
auto *pointer = reinterpret_cast<void *>(tensor_ptr);
if (pointer == nullptr) {
MS_LOGE("Tensor pointer from java is nullptr");
return static_cast<jboolean>(false);
@ -103,7 +103,7 @@ extern "C" JNIEXPORT jboolean JNICALL Java_cn_huawei_mindspore_MSTensor_setDataT
extern "C" JNIEXPORT jbyteArray JNICALL Java_cn_huawei_mindspore_MSTensor_getData(JNIEnv *env, jobject thiz,
jlong tensor_ptr) {
auto *pointer = static_cast<void *>(tensor_ptr);
auto *pointer = reinterpret_cast<void *>(tensor_ptr);
if (pointer == nullptr) {
MS_LOGE("Tensor pointer from java is nullptr");
return env->NewByteArray(0);
@ -123,7 +123,7 @@ extern "C" JNIEXPORT jbyteArray JNICALL Java_cn_huawei_mindspore_MSTensor_getDat
extern "C" JNIEXPORT jboolean JNICALL Java_cn_huawei_mindspore_MSTensor_setData(JNIEnv *env, jobject thiz,
jlong tensor_ptr, jbyteArray data,
jlong data_len) {
auto *pointer = static_cast<void *>(tensor_ptr);
auto *pointer = reinterpret_cast<void *>(tensor_ptr);
if (pointer == nullptr) {
MS_LOGE("Tensor pointer from java is nullptr");
return static_cast<jboolean>(false);
@ -141,7 +141,7 @@ extern "C" JNIEXPORT jboolean JNICALL Java_cn_huawei_mindspore_MSTensor_setData(
}
extern "C" JNIEXPORT jlong JNICALL Java_cn_huawei_mindspore_MSTensor_size(JNIEnv *env, jobject thiz, jlong tensor_ptr) {
auto *pointer = static_cast<void *>(tensor_ptr);
auto *pointer = reinterpret_cast<void *>(tensor_ptr);
if (pointer == nullptr) {
MS_LOGE("Tensor pointer from java is nullptr");
return 0;
@ -152,7 +152,7 @@ extern "C" JNIEXPORT jlong JNICALL Java_cn_huawei_mindspore_MSTensor_size(JNIEnv
extern "C" JNIEXPORT jint JNICALL Java_cn_huawei_mindspore_MSTensor_elementsNum(JNIEnv *env, jobject thiz,
jlong tensor_ptr) {
auto *pointer = static_cast<void *>(tensor_ptr);
auto *pointer = reinterpret_cast<void *>(tensor_ptr);
if (pointer == nullptr) {
MS_LOGE("Tensor pointer from java is nullptr");
return 0;
@ -162,7 +162,7 @@ extern "C" JNIEXPORT jint JNICALL Java_cn_huawei_mindspore_MSTensor_elementsNum(
}
extern "C" JNIEXPORT void JNICALL Java_cn_huawei_mindspore_MSTensor_free(JNIEnv *env, jobject thiz, jlong tensor_ptr) {
auto *pointer = static_cast<void *>(tensor_ptr);
auto *pointer = reinterpret_cast<void *>(tensor_ptr);
if (pointer == nullptr) {
MS_LOGE("Tensor pointer from java is nullptr");
return;

Loading…
Cancel
Save