From 00a1369d4ed0f137a1bcef4655ed0f1d4296ebc4 Mon Sep 17 00:00:00 2001 From: wandongdong Date: Fri, 18 Dec 2020 00:06:18 -0800 Subject: [PATCH] remove third_party/Opencl and support depthwise batch>1 --- .gitmodules | 6 -- build.sh | 58 ------------------- mindspore/lite/CMakeLists.txt | 4 +- .../kernel/opencl/kernel/depthwise_conv2d.cc | 2 +- third_party/OpenCL-CLHPP | 1 - third_party/OpenCL-Headers | 1 - 6 files changed, 3 insertions(+), 69 deletions(-) delete mode 160000 third_party/OpenCL-CLHPP delete mode 160000 third_party/OpenCL-Headers diff --git a/.gitmodules b/.gitmodules index 753f48c2c2..9101b86d8f 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,9 +4,3 @@ [submodule "graphengine"] path = graphengine url = https://gitee.com/mindspore/graphengine.git -[submodule "third_party/OpenCL-CLHPP"] - path = third_party/OpenCL-CLHPP - url = https://github.com/KhronosGroup/OpenCL-CLHPP.git -[submodule "third_party/OpenCL-Headers"] - path = third_party/OpenCL-Headers - url = https://github.com/KhronosGroup/OpenCL-Headers.git diff --git a/build.sh b/build.sh index c207d46f9c..c913198e86 100755 --- a/build.sh +++ b/build.sh @@ -492,63 +492,6 @@ checkddk() { fi } -gene_clhpp() { - CL_SRC_DIR="${BASEPATH}/mindspore/lite/src/runtime/kernel/opencl/cl" - if [ ! -d "${CL_SRC_DIR}" ]; then - return - fi - cd ${CL_SRC_DIR}/ - rm -rf *.inc - echo "$(cd "$(dirname $0)"; pwd)" - for file_path in "${CL_SRC_DIR}"/* - do - file="$(basename ${file_path})" - inc_file=$(echo ${CL_SRC_DIR}/${file} | sed 's/$/.inc/') - sed 's/\\/\\\\/g;s/\"/\\\"/g;s/^/\"/;s/$/\\n\" \\/' ${CL_SRC_DIR}/${file} > ${inc_file} - kernel_name=$(echo ${file} | sed s'/.\{3\}$//') - sed -i "1i\static const char *${kernel_name}_source =\"\\n\" \\" ${inc_file} - sed -i '$a\;' ${inc_file} - done -} - -gene_ocl_program() { - OCL_SRC_DIR="${BASEPATH}/mindspore/lite/src/runtime/kernel/opencl/cl" - SPIRV_DIR=build/spirv - [ -n "${SPIRV_DIR}" ] && rm -rf ${SPIRV_DIR} - mkdir -pv ${SPIRV_DIR} - if [ ! -d "${OCL_SRC_DIR}" ]; then - return - fi - for file_path in "${OCL_SRC_DIR}"/* - do - ocl_file="$(basename ${file_path})" - if [ "${ocl_file##*.}" != "cl" ]; then - continue - fi - clang -Xclang -finclude-default-header -cl-std=CL2.0 --target=spir64-unknown-unknown -emit-llvm \ - -c -O0 -o ${SPIRV_DIR}/${ocl_file%.*}.bc ${OCL_SRC_DIR}/${ocl_file} - done - - bcs=$(ls ${SPIRV_DIR}/*.bc) - llvm-link ${bcs} -o ${SPIRV_DIR}/program.bc - llvm-spirv -o ${SPIRV_DIR}/program.spv ${SPIRV_DIR}/program.bc - - CL_PROGRAM_PATH="${BASEPATH}/mindspore/lite/src/runtime/kernel/opencl/cl/program.inc" - echo "#include " > ${CL_PROGRAM_PATH} - echo "std::vector g_program_binary = {" >> ${CL_PROGRAM_PATH} - #hexdump -v -e '16/1 "0x%02x, " "\n"' ${SPIRV_DIR}/program.spv >> ${CL_PROGRAM_PATH} - hexdump -v -e '1/1 "0x%02x, "' ${SPIRV_DIR}/program.spv >> ${CL_PROGRAM_PATH} - echo "};" >> ${CL_PROGRAM_PATH} - echo "Compile SPIRV done" -} - -get_opencl() { - cd ${BASEPATH} - git submodule update --init third_party/OpenCL-Headers - git submodule update --init third_party/OpenCL-CLHPP -} - - get_version() { VERSION_MAJOR=$(grep "const int ms_version_major =" ${BASEPATH}/mindspore/lite/include/version.h | tr -dc "[0-9]") VERSION_MINOR=$(grep "const int ms_version_minor =" ${BASEPATH}/mindspore/lite/include/version.h | tr -dc "[0-9]") @@ -568,7 +511,6 @@ build_lite() if [ "${ENABLE_GPU}" == "on" ] && [ "${LITE_PLATFORM}" == "arm64" ] || [ $1 == "arm64" ]; then echo "start get opencl" - get_opencl fi if [ "${ENABLE_NPU}" == "on" ]; then checkddk diff --git a/mindspore/lite/CMakeLists.txt b/mindspore/lite/CMakeLists.txt index 96bffa9f39..ed949173f4 100644 --- a/mindspore/lite/CMakeLists.txt +++ b/mindspore/lite/CMakeLists.txt @@ -161,8 +161,8 @@ if (SUPPORT_GPU) if (OFFLINE_COMPILE) add_compile_definitions(PROGRAM_WITH_IL) endif () - include_directories(${TOP_DIR}/third_party/OpenCL-Headers) - include_directories(${TOP_DIR}/third_party/OpenCL-CLHPP/include) + include_directories(${CMAKE_CURRENT_SOURCE_DIR}/build/_deps/opencl-headers-src/) + include_directories(${CMAKE_CURRENT_SOURCE_DIR}/build/_deps/opencl-clhpp-src/include) endif () if (WIN32) diff --git a/mindspore/lite/src/runtime/kernel/opencl/kernel/depthwise_conv2d.cc b/mindspore/lite/src/runtime/kernel/opencl/kernel/depthwise_conv2d.cc index e142ca65dc..4b913ab3f2 100644 --- a/mindspore/lite/src/runtime/kernel/opencl/kernel/depthwise_conv2d.cc +++ b/mindspore/lite/src/runtime/kernel/opencl/kernel/depthwise_conv2d.cc @@ -197,7 +197,7 @@ void DepthwiseConv2dOpenCLKernel::SetGlobalLocal() { // set global size_t CO4 = UP_DIV(out_tensors_[0]->Channel(), C4NUM * block_size_[2]); global_size_ = {CO4, (size_t)UP_DIV(out_tensors_[0]->Width(), block_size_[1]), - (size_t)UP_DIV(out_tensors_[0]->Height(), block_size_[0])}; + (size_t)UP_DIV(out_tensors_[0]->Height() * out_tensors_[0]->Batch(), block_size_[0])}; // set local const int max_group_size = ocl_runtime_->DeviceMaxWorkGroupSize(); int z = global_size_[0]; diff --git a/third_party/OpenCL-CLHPP b/third_party/OpenCL-CLHPP deleted file mode 160000 index 524f5ca96c..0000000000 --- a/third_party/OpenCL-CLHPP +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 524f5ca96c3b9775f9d1debbdbcc2666bcce5c07 diff --git a/third_party/OpenCL-Headers b/third_party/OpenCL-Headers deleted file mode 160000 index 879576679f..0000000000 --- a/third_party/OpenCL-Headers +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 879576679f7cf319d4f27ed6639a85207dd91e07