From 9c47a2092df67ef6f19a105dce69ca2e8dc118e8 Mon Sep 17 00:00:00 2001 From: yeyunpeng2020 Date: Sat, 8 May 2021 14:19:24 +0800 Subject: [PATCH] fix gpu ut --- mindspore/lite/test/run_ut_gpu.sh | 10 +++++----- .../lite/test/ut/src/runtime/kernel/opencl/common.cc | 10 ++++++++-- .../test/ut/src/runtime/kernel/opencl/matmul_tests.cc | 4 ++-- mindspore/lite/test/ut_gpu.cfg | 4 +++- 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/mindspore/lite/test/run_ut_gpu.sh b/mindspore/lite/test/run_ut_gpu.sh index 8794b584da..3d1585bac0 100644 --- a/mindspore/lite/test/run_ut_gpu.sh +++ b/mindspore/lite/test/run_ut_gpu.sh @@ -7,8 +7,8 @@ echo ${basepath} while getopts "r:d:" opt; do case ${opt} in r) - release_path=${OPTARG} - echo "release_path is ${OPTARG}" + lite_test_path=${OPTARG} + echo "lite_test_path is ${OPTARG}" ;; d) device_id=${OPTARG} @@ -24,7 +24,7 @@ ut_test_path=${basepath}/ut_test rm -rf ${ut_test_path} mkdir -p ${ut_test_path} -run_ut_result_file=${basepath}/run_benchmark_result.txt +run_ut_result_file=${basepath}/run_gpu_ut_result.txt echo ' ' > ${run_ut_result_file} run_gpu_ut_log_file=${basepath}/run_gpu_ut_log.txt echo 'run gpu ut logs: ' > ${run_gpu_ut_log_file} @@ -32,9 +32,9 @@ echo 'run gpu ut logs: ' > ${run_gpu_ut_log_file} ut_gpu_config=${basepath}/ut_gpu.cfg function Run_gpu_ut() { - cd ${release_path} || exit 1 + cd ${lite_test_path} || exit 1 - cp -a ${release_path}/lite-test ${ut_test_path}/lite-test || exit 1 + cp -a ${lite_test_path}/lite-test ${ut_test_path}/lite-test || exit 1 cp -r ${basepath}/ut/src/runtime/kernel/opencl/test_data ${ut_test_path} || exit 1 # adb push all needed files to the phone diff --git a/mindspore/lite/test/ut/src/runtime/kernel/opencl/common.cc b/mindspore/lite/test/ut/src/runtime/kernel/opencl/common.cc index 4ed17c7a3b..c34f44dd94 100644 --- a/mindspore/lite/test/ut/src/runtime/kernel/opencl/common.cc +++ b/mindspore/lite/test/ut/src/runtime/kernel/opencl/common.cc @@ -103,6 +103,9 @@ void TestMain(const std::vector &input_infos, const std::vec // simulating benchmark: session_->CompileGraph() -> scheduler.Schedule() -> BuildKernels() MS_LOG(DEBUG) << "create OpenCLKernel"; kernel::KernelKey key{kernel::kGPU, kernel_inputs.front()->data_type(), primitive_type}; + if (key.data_type == kNumberTypeFloat32 && fp16_enable) { + key.data_type = kNumberTypeFloat16; + } auto creator = KernelRegistry::GetInstance()->GetCreator(key); if (creator == nullptr) { std::cerr << "can't get registry function for: " << schema::EnumNamePrimitiveType(primitive_type) @@ -117,7 +120,7 @@ void TestMain(const std::vector &input_infos, const std::vec FAIL(); } kernel->set_name(schema::EnumNamesPrimitiveType()[primitive_type]); - + kernel->set_desc(key); // simulating benchmark: session_->CompileGraph() -> scheduler.Schedule() -> ConstructSubGraphs() MS_LOG(DEBUG) << "create SubGraph"; std::vector kernels{kernel}; @@ -246,6 +249,9 @@ void TestMain(const std::vector &input_infos, std::tupleCompileGraph() -> scheduler.Schedule() -> BuildKernels() MS_LOG(DEBUG) << "create OpenCLKernel"; kernel::KernelKey key{kernel::kGPU, kernel_inputs.front()->data_type(), primitive_type}; + if (key.data_type == kNumberTypeFloat32 && fp16_enable) { + key.data_type = kNumberTypeFloat16; + } auto creator = KernelRegistry::GetInstance()->GetCreator(key); if (creator == nullptr) { std::cerr << "can't get registry function for: " << schema::EnumNamePrimitiveType(primitive_type) @@ -260,7 +266,7 @@ void TestMain(const std::vector &input_infos, std::tupleset_name(schema::EnumNamesPrimitiveType()[primitive_type]); - + kernel->set_desc(key); // simulating benchmark: session_->CompileGraph() -> scheduler.Schedule() -> ConstructSubGraphs() MS_LOG(DEBUG) << "create SubGraph"; std::vector kernels{kernel}; diff --git a/mindspore/lite/test/ut/src/runtime/kernel/opencl/matmul_tests.cc b/mindspore/lite/test/ut/src/runtime/kernel/opencl/matmul_tests.cc index 178cfde73e..a8ba17aec6 100644 --- a/mindspore/lite/test/ut/src/runtime/kernel/opencl/matmul_tests.cc +++ b/mindspore/lite/test/ut/src/runtime/kernel/opencl/matmul_tests.cc @@ -89,7 +89,7 @@ TEST_F(TestOpenCL_MatMul, 3D) { param, fp16_enable); } } - +// Check and optimize TEST_F(TestOpenCL_MatMul, ActWeightTransposeB3D) { int a = 2; int m = 2; @@ -109,7 +109,7 @@ TEST_F(TestOpenCL_MatMul, ActWeightTransposeB3D) { fp16_enable); } } - +// Check and optimize TEST_F(TestOpenCL_MatMul, ActWeight3D) { int a = 2; int m = 2; diff --git a/mindspore/lite/test/ut_gpu.cfg b/mindspore/lite/test/ut_gpu.cfg index fd854d3b72..e716bd543c 100644 --- a/mindspore/lite/test/ut_gpu.cfg +++ b/mindspore/lite/test/ut_gpu.cfg @@ -24,7 +24,9 @@ TestOpenCL_Pad.2D TestOpenCL_Pad.3D TestOpenCL_Pad.4D TestOpenCL_OneHot.* -TestOpenCL_MatMul.* +TestOpenCL_MatMul.2D +TestOpenCL_MatMul.3D +TestOpenCL_MatMul.4D TestOpenCL_LayerNorm.* TestOpenCL_Gather.* TestOpenCL_FullConnection.*