Browse Source

!16099 fix gpu ut

From: @yeyunpeng2020
Reviewed-by: @zhanghaibo5,@ddwsky
Signed-off-by: @zhanghaibo5
pull/16099/MERGE
mindspore-ci-bot Gitee 4 years ago
parent
commit
7c3d64e0c9
4 changed files with 18 additions and 10 deletions
  1. +5
    -5
      mindspore/lite/test/run_ut_gpu.sh
  2. +8
    -2
      mindspore/lite/test/ut/src/runtime/kernel/opencl/common.cc
  3. +2
    -2
      mindspore/lite/test/ut/src/runtime/kernel/opencl/matmul_tests.cc
  4. +3
    -1
      mindspore/lite/test/ut_gpu.cfg

+ 5
- 5
mindspore/lite/test/run_ut_gpu.sh View File

@@ -7,8 +7,8 @@ echo ${basepath}
while getopts "r:d:" opt; do while getopts "r:d:" opt; do
case ${opt} in case ${opt} in
r) r)
release_path=${OPTARG}
echo "release_path is ${OPTARG}"
lite_test_path=${OPTARG}
echo "lite_test_path is ${OPTARG}"
;; ;;
d) d)
device_id=${OPTARG} device_id=${OPTARG}
@@ -24,7 +24,7 @@ ut_test_path=${basepath}/ut_test
rm -rf ${ut_test_path} rm -rf ${ut_test_path}
mkdir -p ${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} echo ' ' > ${run_ut_result_file}
run_gpu_ut_log_file=${basepath}/run_gpu_ut_log.txt run_gpu_ut_log_file=${basepath}/run_gpu_ut_log.txt
echo 'run gpu ut logs: ' > ${run_gpu_ut_log_file} 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 ut_gpu_config=${basepath}/ut_gpu.cfg


function Run_gpu_ut() { 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 cp -r ${basepath}/ut/src/runtime/kernel/opencl/test_data ${ut_test_path} || exit 1


# adb push all needed files to the phone # adb push all needed files to the phone


+ 8
- 2
mindspore/lite/test/ut/src/runtime/kernel/opencl/common.cc View File

@@ -103,6 +103,9 @@ void TestMain(const std::vector<ArgsTupleWithDtype> &input_infos, const std::vec
// simulating benchmark: session_->CompileGraph() -> scheduler.Schedule() -> BuildKernels() // simulating benchmark: session_->CompileGraph() -> scheduler.Schedule() -> BuildKernels()
MS_LOG(DEBUG) << "create OpenCLKernel"; MS_LOG(DEBUG) << "create OpenCLKernel";
kernel::KernelKey key{kernel::kGPU, kernel_inputs.front()->data_type(), primitive_type}; 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); auto creator = KernelRegistry::GetInstance()->GetCreator(key);
if (creator == nullptr) { if (creator == nullptr) {
std::cerr << "can't get registry function for: " << schema::EnumNamePrimitiveType(primitive_type) std::cerr << "can't get registry function for: " << schema::EnumNamePrimitiveType(primitive_type)
@@ -117,7 +120,7 @@ void TestMain(const std::vector<ArgsTupleWithDtype> &input_infos, const std::vec
FAIL(); FAIL();
} }
kernel->set_name(schema::EnumNamesPrimitiveType()[primitive_type]); kernel->set_name(schema::EnumNamesPrimitiveType()[primitive_type]);
kernel->set_desc(key);
// simulating benchmark: session_->CompileGraph() -> scheduler.Schedule() -> ConstructSubGraphs() // simulating benchmark: session_->CompileGraph() -> scheduler.Schedule() -> ConstructSubGraphs()
MS_LOG(DEBUG) << "create SubGraph"; MS_LOG(DEBUG) << "create SubGraph";
std::vector<LiteKernel *> kernels{kernel}; std::vector<LiteKernel *> kernels{kernel};
@@ -246,6 +249,9 @@ void TestMain(const std::vector<ArgsTupleWithDtype> &input_infos, std::tuple<std
// simulating benchmark: session_->CompileGraph() -> scheduler.Schedule() -> BuildKernels() // simulating benchmark: session_->CompileGraph() -> scheduler.Schedule() -> BuildKernels()
MS_LOG(DEBUG) << "create OpenCLKernel"; MS_LOG(DEBUG) << "create OpenCLKernel";
kernel::KernelKey key{kernel::kGPU, kernel_inputs.front()->data_type(), primitive_type}; 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); auto creator = KernelRegistry::GetInstance()->GetCreator(key);
if (creator == nullptr) { if (creator == nullptr) {
std::cerr << "can't get registry function for: " << schema::EnumNamePrimitiveType(primitive_type) std::cerr << "can't get registry function for: " << schema::EnumNamePrimitiveType(primitive_type)
@@ -260,7 +266,7 @@ void TestMain(const std::vector<ArgsTupleWithDtype> &input_infos, std::tuple<std
FAIL(); FAIL();
} }
kernel->set_name(schema::EnumNamesPrimitiveType()[primitive_type]); kernel->set_name(schema::EnumNamesPrimitiveType()[primitive_type]);
kernel->set_desc(key);
// simulating benchmark: session_->CompileGraph() -> scheduler.Schedule() -> ConstructSubGraphs() // simulating benchmark: session_->CompileGraph() -> scheduler.Schedule() -> ConstructSubGraphs()
MS_LOG(DEBUG) << "create SubGraph"; MS_LOG(DEBUG) << "create SubGraph";
std::vector<LiteKernel *> kernels{kernel}; std::vector<LiteKernel *> kernels{kernel};


+ 2
- 2
mindspore/lite/test/ut/src/runtime/kernel/opencl/matmul_tests.cc View File

@@ -89,7 +89,7 @@ TEST_F(TestOpenCL_MatMul, 3D) {
param, fp16_enable); param, fp16_enable);
} }
} }
// Check and optimize
TEST_F(TestOpenCL_MatMul, ActWeightTransposeB3D) { TEST_F(TestOpenCL_MatMul, ActWeightTransposeB3D) {
int a = 2; int a = 2;
int m = 2; int m = 2;
@@ -109,7 +109,7 @@ TEST_F(TestOpenCL_MatMul, ActWeightTransposeB3D) {
fp16_enable); fp16_enable);
} }
} }
// Check and optimize
TEST_F(TestOpenCL_MatMul, ActWeight3D) { TEST_F(TestOpenCL_MatMul, ActWeight3D) {
int a = 2; int a = 2;
int m = 2; int m = 2;


+ 3
- 1
mindspore/lite/test/ut_gpu.cfg View File

@@ -24,7 +24,9 @@ TestOpenCL_Pad.2D
TestOpenCL_Pad.3D TestOpenCL_Pad.3D
TestOpenCL_Pad.4D TestOpenCL_Pad.4D
TestOpenCL_OneHot.* TestOpenCL_OneHot.*
TestOpenCL_MatMul.*
TestOpenCL_MatMul.2D
TestOpenCL_MatMul.3D
TestOpenCL_MatMul.4D
TestOpenCL_LayerNorm.* TestOpenCL_LayerNorm.*
TestOpenCL_Gather.* TestOpenCL_Gather.*
TestOpenCL_FullConnection.* TestOpenCL_FullConnection.*


Loading…
Cancel
Save