fix java build error

This commit is contained in:
yeyunpeng 2020-10-20 16:37:14 +08:00
parent 34ef8af1c3
commit 729073d50a
2 changed files with 18 additions and 8 deletions

View File

@ -805,7 +805,7 @@ build_java() {
gradle wrapper gradle wrapper
./gradlew build ./gradlew build
gradle publish -PLITE_VERSION=${VERSION_STR}-SNAPSHOT gradle publish -PLITE_VERSION=${VERSION_STR}
cd ${JAVA_PATH}/java/app/build cd ${JAVA_PATH}/java/app/build
zip -r mindspore-lite-maven-${VERSION_STR}.zip mindspore zip -r mindspore-lite-maven-${VERSION_STR}.zip mindspore

View File

@ -29,36 +29,46 @@ extern "C" JNIEXPORT jlong JNICALL Java_com_mindspore_lite_config_MSConfig_creat
MS_LOGE("new Context fail!"); MS_LOGE("new Context fail!");
return (jlong)context; return (jlong)context;
} }
auto &cpu_device_ctx = context->device_list_[0];
switch (device_type) { switch (device_type) {
case 0: case 0:
context->device_type_ = mindspore::lite::DT_CPU; context->device_list_[0].device_type_ = mindspore::lite::DT_CPU;
break; break;
case 1: case 1:
context->device_type_ = mindspore::lite::DT_GPU; context->device_list_[0].device_type_ = mindspore::lite::DT_GPU;
break; break;
case 2: case 2:
context->device_type_ = mindspore::lite::DT_NPU; context->device_list_[0].device_type_ = mindspore::lite::DT_NPU;
break; break;
default: default:
MS_LOGE("Invalid device_type : %d", device_type); MS_LOGE("Invalid device_type : %d", device_type);
return (jlong)context; return (jlong)context;
} }
switch (cpu_bind_mode) { switch (cpu_bind_mode) {
case 0: 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; break;
case 1: 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; break;
case 2: 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; break;
default: default:
MS_LOGE("Invalid cpu_bind_mode : %d", cpu_bind_mode); MS_LOGE("Invalid cpu_bind_mode : %d", cpu_bind_mode);
return (jlong)context; 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->thread_num_ = thread_num;
context->enable_float16_ = enable_float16;
return (jlong)context; return (jlong)context;
} }