From 729073d50a63f5a425ecec80e09c991af9c40cf2 Mon Sep 17 00:00:00 2001 From: yeyunpeng Date: Tue, 20 Oct 2020 16:37:14 +0800 Subject: [PATCH] fix java build error --- build.sh | 2 +- .../app/src/main/native/runtime/ms_config.cpp | 24 +++++++++++++------ 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/build.sh b/build.sh index 8d00f2d313b..65f5140917d 100755 --- a/build.sh +++ b/build.sh @@ -805,7 +805,7 @@ build_java() { gradle wrapper ./gradlew build - gradle publish -PLITE_VERSION=${VERSION_STR}-SNAPSHOT + gradle publish -PLITE_VERSION=${VERSION_STR} cd ${JAVA_PATH}/java/app/build zip -r mindspore-lite-maven-${VERSION_STR}.zip mindspore diff --git a/mindspore/lite/java/java/app/src/main/native/runtime/ms_config.cpp b/mindspore/lite/java/java/app/src/main/native/runtime/ms_config.cpp index cd7619986e3..3768a9681b8 100644 --- a/mindspore/lite/java/java/app/src/main/native/runtime/ms_config.cpp +++ b/mindspore/lite/java/java/app/src/main/native/runtime/ms_config.cpp @@ -29,36 +29,46 @@ extern "C" JNIEXPORT jlong JNICALL Java_com_mindspore_lite_config_MSConfig_creat MS_LOGE("new Context fail!"); return (jlong)context; } + + auto &cpu_device_ctx = context->device_list_[0]; switch (device_type) { case 0: - context->device_type_ = mindspore::lite::DT_CPU; + context->device_list_[0].device_type_ = mindspore::lite::DT_CPU; break; case 1: - context->device_type_ = mindspore::lite::DT_GPU; + context->device_list_[0].device_type_ = mindspore::lite::DT_GPU; break; case 2: - context->device_type_ = mindspore::lite::DT_NPU; + context->device_list_[0].device_type_ = mindspore::lite::DT_NPU; break; default: MS_LOGE("Invalid device_type : %d", device_type); return (jlong)context; } + switch (cpu_bind_mode) { case 0: - context->cpu_bind_mode_ = mindspore::lite::NO_BIND; + cpu_device_ctx.device_info_.cpu_device_info_.cpu_bind_mode_ = mindspore::lite::NO_BIND; break; case 1: - context->cpu_bind_mode_ = mindspore::lite::HIGHER_CPU; + cpu_device_ctx.device_info_.cpu_device_info_.cpu_bind_mode_ = mindspore::lite::HIGHER_CPU; break; case 2: - context->cpu_bind_mode_ = mindspore::lite::MID_CPU; + cpu_device_ctx.device_info_.cpu_device_info_.cpu_bind_mode_ = mindspore::lite::MID_CPU; break; default: MS_LOGE("Invalid cpu_bind_mode : %d", cpu_bind_mode); return (jlong)context; } + + cpu_device_ctx.device_info_.cpu_device_info_.enable_float16_ = enable_float16; + + if (device_type == mindspore::lite::DT_GPU) { + mindspore::lite::DeviceContext gpu_device_ctx{mindspore::lite::DT_GPU, {false}}; + gpu_device_ctx.device_info_.gpu_device_info_.enable_float16_ = enable_float16; + context->device_list_.push_back(gpu_device_ctx); + } context->thread_num_ = thread_num; - context->enable_float16_ = enable_float16; return (jlong)context; }