forked from mindspore-Ecosystem/mindspore
support java call opencl
This commit is contained in:
parent
07578ca31e
commit
f254fa2578
10
build.sh
10
build.sh
|
@ -503,12 +503,13 @@ build_lite()
|
|||
|
||||
LITE_ENABLE_GPU=${ENABLE_GPU}
|
||||
LITE_ENABLE_NPU=${ENABLE_NPU}
|
||||
if [[ "${DEVICE}" == "" && "${LITE_PLATFORM}" == "arm64" ]]; then
|
||||
if [ "${DEVICE}" == "" ] && [ "${LITE_PLATFORM}" == "arm64" ]; then
|
||||
LITE_ENABLE_GPU="on"
|
||||
LITE_ENABLE_NPU="on"
|
||||
fi
|
||||
|
||||
if [ "${ENABLE_GPU}" == "on" ] && [ "${LITE_PLATFORM}" == "arm64" ] || [ $1 == "arm64" ]; then
|
||||
if [ "${LITE_ENABLE_GPU}" == "on" ] || [ $1 == "arm64" ]; then
|
||||
LITE_ENABLE_GPU="on"
|
||||
echo "start get opencl"
|
||||
fi
|
||||
if [ "${LITE_ENABLE_NPU}" == "on" ]; then
|
||||
|
@ -545,7 +546,7 @@ build_lite()
|
|||
-DANDROID_STL=${ANDROID_STL} -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
|
||||
-DPLATFORM_ARM32=on -DENABLE_NEON=on -DSUPPORT_TRAIN=${SUPPORT_TRAIN} \
|
||||
-DENABLE_TOOLS=${ENABLE_TOOLS} -DENABLE_CONVERTER=${ENABLE_CONVERTER} -DBUILD_TESTCASES=${RUN_TESTCASES} \
|
||||
-DSUPPORT_GPU=${ENABLE_GPU} -DSUPPORT_NPU=${ENABLE_NPU} -DENABLE_V0=on \
|
||||
-DSUPPORT_GPU=${LITE_ENABLE_GPU} -DSUPPORT_NPU=${ENABLE_NPU} -DENABLE_V0=on \
|
||||
-DOFFLINE_COMPILE=${OPENCL_OFFLINE_COMPILE} -DBUILD_MINDDATA=${COMPILE_MINDDATA_LITE} \
|
||||
-DCMAKE_INSTALL_PREFIX=${BASEPATH}/output/tmp -DMS_VERSION_MAJOR=${VERSION_MAJOR} \
|
||||
-DMS_VERSION_MINOR=${VERSION_MINOR} -DMS_VERSION_REVISION=${VERSION_REVISION} -DENABLE_VERBOSE=${ENABLE_VERBOSE} \
|
||||
|
@ -553,7 +554,7 @@ build_lite()
|
|||
else
|
||||
cmake -DPLATFORM_ARM64=off -DSUPPORT_TRAIN=${SUPPORT_TRAIN} \
|
||||
-DENABLE_TOOLS=${ENABLE_TOOLS} -DENABLE_CONVERTER=${ENABLE_CONVERTER} -DBUILD_TESTCASES=${RUN_TESTCASES} \
|
||||
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DSUPPORT_GPU=${ENABLE_GPU} -DSUPPORT_NPU=${ENABLE_NPU} \
|
||||
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DSUPPORT_GPU=${LITE_ENABLE_GPU} -DSUPPORT_NPU=${ENABLE_NPU} \
|
||||
-DBUILD_MINDDATA=${COMPILE_MINDDATA_LITE} -DENABLE_V0=on \
|
||||
-DOFFLINE_COMPILE=${OPENCL_OFFLINE_COMPILE} -DCMAKE_INSTALL_PREFIX=${BASEPATH}/output/tmp \
|
||||
-DMS_VERSION_MAJOR=${VERSION_MAJOR} -DMS_VERSION_MINOR=${VERSION_MINOR} -DMS_VERSION_REVISION=${VERSION_REVISION} \
|
||||
|
@ -647,6 +648,7 @@ build_jni_arm32() {
|
|||
|
||||
build_java() {
|
||||
JAVA_PATH=${BASEPATH}/mindspore/lite/java
|
||||
LITE_ENABLE_GPU="on"
|
||||
get_version
|
||||
build_lite_java_arm64
|
||||
build_lite_java_arm32
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
if (ENABLE_GITEE)
|
||||
set(REQ_URL "https://gitee.com/mirrors/OpenCL-Headers/repository/archive/v2020.06.16.tar.gz")
|
||||
set(MD5 "fc7627b5a8a95ecbe3d5df43bc88aa44")
|
||||
set(MD5 "8797a525aff953ea536ebe338a9f5ef6")
|
||||
set(PKG_GIT_TAG "")
|
||||
__download_pkg_with_git(OpenCL-Headers ${REQ_URL} ${PKG_GIT_TAG} ${MD5})
|
||||
set(REQ_URL "https://gitee.com/mirrors/OpenCL-CLHPP/repository/archive/v2.0.12.tar.gz")
|
||||
set(MD5 "bd00fca8f861b3b65660d719f00a58dd")
|
||||
set(MD5 "a07b45d676b02644482bc2c3bb90b891")
|
||||
set(PKG_GIT_TAG "")
|
||||
__download_pkg_with_git(OpenCL-CLHPP ${REQ_URL} ${PKG_GIT_TAG} ${MD5})
|
||||
else()
|
||||
|
|
|
@ -32,9 +32,12 @@ extern "C" JNIEXPORT jlong JNICALL Java_com_mindspore_lite_config_MSConfig_creat
|
|||
context->device_list_[0].device_type_ = mindspore::lite::DT_CPU;
|
||||
break;
|
||||
case 1: // DT_GPU
|
||||
MS_LOGE("We only support CPU now.");
|
||||
return (jlong)context;
|
||||
{
|
||||
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);
|
||||
break;
|
||||
}
|
||||
case 2: // DT_NPU
|
||||
MS_LOGE("We only support CPU now.");
|
||||
return (jlong)context;
|
||||
|
|
|
@ -150,7 +150,9 @@ void *OpenCLAllocator::Malloc(size_t size, const std::vector<size_t> &img_size,
|
|||
total_size_ += size;
|
||||
const uint64_t max_size = ocl_runtime_->GetGlobalMemSize();
|
||||
if (total_size_ >= max_size) {
|
||||
UnLock();
|
||||
MS_LOG(ERROR) << "Mem pool out of max_size, total size: " << total_size_ << ", max size: " << max_size;
|
||||
return nullptr;
|
||||
}
|
||||
cl::Buffer *buffer = nullptr;
|
||||
cl::Image2D *image = nullptr;
|
||||
|
|
Loading…
Reference in New Issue