From 792b63f3c24c1a4d6f4171a541a0e176b094533f Mon Sep 17 00:00:00 2001 From: zhujingxuan Date: Fri, 7 May 2021 10:26:04 +0800 Subject: [PATCH] add arm32 ci --- .../nnacl/fp32/convolution_fp32_coder.cc | 1 + .../fp32/convolution_winograd_fp32_coder.cc | 1 + .../nnacl/fp32/deconv2d_fp32_coder.cc | 1 + .../nnacl/fp32/matmul_fp32_base_coder.cc | 1 + mindspore/lite/test/run_benchmark_nets.sh | 117 +++++++++++++++++- 5 files changed, 118 insertions(+), 3 deletions(-) diff --git a/mindspore/lite/micro/coder/opcoders/nnacl/fp32/convolution_fp32_coder.cc b/mindspore/lite/micro/coder/opcoders/nnacl/fp32/convolution_fp32_coder.cc index 1b8f774009..dc19f847c1 100644 --- a/mindspore/lite/micro/coder/opcoders/nnacl/fp32/convolution_fp32_coder.cc +++ b/mindspore/lite/micro/coder/opcoders/nnacl/fp32/convolution_fp32_coder.cc @@ -135,6 +135,7 @@ int ConvolutionFP32Coder::DoCode(CoderContext *const context) { "MatmulFp32.S", "MatmulFp32Opt.S", "PreSum4x16Int8Peroc.S", + "MatVecMulFp32.S", "PreSum4x16Int8Pert.S", "IndirectGemmInt16to32_8x4.S", "MatmulInt8.S", diff --git a/mindspore/lite/micro/coder/opcoders/nnacl/fp32/convolution_winograd_fp32_coder.cc b/mindspore/lite/micro/coder/opcoders/nnacl/fp32/convolution_winograd_fp32_coder.cc index c16331a3bd..13f0bb2e51 100644 --- a/mindspore/lite/micro/coder/opcoders/nnacl/fp32/convolution_winograd_fp32_coder.cc +++ b/mindspore/lite/micro/coder/opcoders/nnacl/fp32/convolution_winograd_fp32_coder.cc @@ -235,6 +235,7 @@ int ConvolutionWinogradFP32Coder::DoCode(CoderContext *const context) { { "MatmulFp32.S", "MatmulFp32Opt.S", + "MatVecMulFp32.S", "PreSum4x16Int8Peroc.S", "PreSum4x16Int8Pert.S", "IndirectGemmInt16to32_8x4.S", diff --git a/mindspore/lite/micro/coder/opcoders/nnacl/fp32/deconv2d_fp32_coder.cc b/mindspore/lite/micro/coder/opcoders/nnacl/fp32/deconv2d_fp32_coder.cc index 902a36bdfa..12258a3b52 100644 --- a/mindspore/lite/micro/coder/opcoders/nnacl/fp32/deconv2d_fp32_coder.cc +++ b/mindspore/lite/micro/coder/opcoders/nnacl/fp32/deconv2d_fp32_coder.cc @@ -141,6 +141,7 @@ int DeConvolutionFP32Coder::DoCode(CoderContext *const context) { "MatmulFp32.S", "MatmulFp32Opt.S", "PreSum4x16Int8Peroc.S", + "MatVecMulFp32.S", "PreSum4x16Int8Pert.S", "IndirectGemmInt16to32_8x4.S", "MatmulInt8.S", diff --git a/mindspore/lite/micro/coder/opcoders/nnacl/fp32/matmul_fp32_base_coder.cc b/mindspore/lite/micro/coder/opcoders/nnacl/fp32/matmul_fp32_base_coder.cc index b0db7a9e48..9b4eeeb19c 100644 --- a/mindspore/lite/micro/coder/opcoders/nnacl/fp32/matmul_fp32_base_coder.cc +++ b/mindspore/lite/micro/coder/opcoders/nnacl/fp32/matmul_fp32_base_coder.cc @@ -142,6 +142,7 @@ int MatMulFP32BaseCoder::CollectFilesForTarget(CoderContext *const context) { "MatmulFp32.S", "MatmulFp32Opt.S", "MatmulFp32Opt12x4.S", + "MatVecMulFp32.S", }); } else if (target_ == kARM64) { Collect(context, {}, {}, diff --git a/mindspore/lite/test/run_benchmark_nets.sh b/mindspore/lite/test/run_benchmark_nets.sh index f597d17c49..fb10be6e6f 100644 --- a/mindspore/lite/test/run_benchmark_nets.sh +++ b/mindspore/lite/test/run_benchmark_nets.sh @@ -1309,7 +1309,7 @@ function Run_arm64_codegen() { fi { - echo ${model_name} + echo "arm64_codegen: ${model_name}" echo "${CODEGEN_PATH}/codegen --codePath=${build_path} --modelPath=${ms_models_path}/${model_name}.ms --target=ARM64" ${CODEGEN_PATH}/codegen --codePath=${build_path} --modelPath=${ms_models_path}/${model_name}.ms --target=ARM64 } >> ${run_arm64_fp32_codegen_log_file} @@ -1379,6 +1379,94 @@ function Run_arm64_codegen() { rm -rf ${build_path} } +function Run_arm32_codegen() { + echo "ANDROID_NDK: ${ANDROID_NDK}" >> ${run_arm32_fp32_codegen_log_file} + cd ${arm32_path} || exit 1 + tar -zxf mindspore-lite-${version}-inference-android-aarch32.tar.gz || exit 1 + local PKG_PATH=${arm32_path}/mindspore-lite-${version}-inference-android-aarch32 + local CODEGEN_PATH=${x86_path}/mindspore-lite-${version}-inference-linux-x64/tools/codegen + + rm -rf ${build_path} + mkdir -p ${build_path} + + # Run tflite converted models: + while read line; do + model_name=${line} + if [[ $model_name == \#* ]]; then + continue + fi + + { + echo "arm32_codegen: ${model_name}" + echo "${CODEGEN_PATH}/codegen --codePath=${build_path} --modelPath=${ms_models_path}/${model_name}.ms --target=ARM32A" + ${CODEGEN_PATH}/codegen --codePath=${build_path} --modelPath=${ms_models_path}/${model_name}.ms --target=ARM32A + } >> ${run_arm32_fp32_codegen_log_file} + + rm -rf ${build_path}/benchmark + mkdir -p ${build_path}/benchmark && cd ${build_path}/benchmark || exit 1 + + { + echo "cmake -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK}/build/cmake/android.toolchain.cmake \ + -DANDROID_ABI=armeabi-v7a \ + -DANDROID_TOOLCHAIN_NAME=clang \ + -DANDROID_NATIVE_API_LEVEL=19 \ + -DPLATFORM_ARM32=ON \ + -DPKG_PATH=${PKG_PATH} ${build_path}/${model_name}" + + cmake -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_TOOLCHAIN_FILE="${ANDROID_NDK}/build/cmake/android.toolchain.cmake" \ + -DANDROID_ABI="armeabi-v7a" \ + -DANDROID_TOOLCHAIN_NAME="clang" \ + -DANDROID_NATIVE_API_LEVEL="19" \ + -DPLATFORM_ARM32=ON \ + -DPKG_PATH=${PKG_PATH} ${build_path}/${model_name} + + make -j4 + } >> ${run_arm32_fp32_codegen_log_file} + + rm -rf ${build_path}/codegen_test + mkdir ${build_path}/codegen_test && cd ${build_path}/codegen_test || exit 1 + cp -a ${build_path}/benchmark/benchmark ${build_path}/codegen_test/benchmark || exit 1 + cp -a ${build_path}/${model_name}/src/net.bin ${build_path}/codegen_test/net.bin || exit 1 + + { + echo 'ls ${build_path}/codegen_test' + ls ${build_path}/codegen_test + } >> ${run_arm32_fp32_codegen_log_file} + + # adb push all needed files to the phone + adb -s ${device_id} push ${build_path}/codegen_test /data/local/tmp/ > adb_push_log.txt + + { + echo 'cd /data/local/tmp/codegen_test' + echo 'chmod 777 benchmark' + echo 'chmod 777 net.bin' + echo 'ls' + echo './benchmark /data/local/tmp/input_output/input/'${model_name}'.ms.bin ./net.bin 1 /data/local/tmp/input_output/output/'${model_name}'.ms.out' + echo 'cd .. && rm -rf codegen_test' + } >> ${run_arm32_fp32_codegen_log_file} + + { + echo 'cd /data/local/tmp/codegen_test' + echo 'chmod 777 benchmark' + echo 'chmod 777 net.bin' + echo 'ls' + echo './benchmark /data/local/tmp/input_output/input/'${model_name}'.ms.bin ./net.bin 1 /data/local/tmp/input_output/output/'${model_name}'.ms.out' + echo 'cd .. && rm -rf codegen_test' + } > adb_run_cmd.txt + + adb -s ${device_id} shell < adb_run_cmd.txt >> ${run_arm32_fp32_codegen_log_file} + if [ $? = 0 ]; then + run_result='arm32_codegen: '${model_name}' pass'; echo ${run_result} >> ${run_benchmark_result_file} + else + run_result='arm32_codegen: '${model_name}' failed'; echo ${run_result} >> ${run_benchmark_result_file}; return 1 + fi + done < ${models_codegen_config} + + rm -rf ${build_path} +} + # Run on arm64 platform: function Run_arm64() { cd ${arm64_path} || exit 1 @@ -2633,6 +2721,9 @@ echo 'run arm64_fp32 logs: ' > ${run_arm64_fp32_log_file} run_arm64_fp32_codegen_log_file=${basepath}/run_arm64_fp32_codegen_log.txt echo 'run arm64_codegen logs: ' > ${run_arm64_fp32_codegen_log_file} +run_arm32_fp32_codegen_log_file=${basepath}/run_arm32_fp32_codegen_log.txt +echo 'run arm32_codegen logs: ' > ${run_arm32_fp32_codegen_log_file} + run_arm64_fp16_log_file=${basepath}/run_arm64_fp16_log.txt echo 'run arm64_fp16 logs: ' > ${run_arm64_fp16_log_file} @@ -2712,6 +2803,19 @@ if [[ $backend == "all" || $backend == "arm_cpu" || $backend == "arm64_codegen" sleep 1 fi +if [[ $backend == "all" || $backend == "arm_cpu" || $backend == "arm32_codegen" ]]; then + # Run on arm32 + arm32_path=${release_path}/android_aarch32 + file_name=$(ls ${arm32_path}/*inference-android-aarch32.tar.gz) + IFS="-" read -r -a file_name_array <<< "$file_name" + version=${file_name_array[2]} + + echo "start Run arm32 codegen ..." + Run_arm32_codegen + Run_arm32_codegen_status=$? + sleep 1 +fi + if [[ $backend == "all" || $backend == "arm_cpu" || $backend == "arm32_fp16" ]]; then # Run on armv82-a32-fp16 armv82_path=${release_path}/android_aarch32 @@ -2869,8 +2973,15 @@ if [[ $backend == "all" || $backend == "arm_cpu" || $backend == "arm64_fp32" ]]; fi if [[ $backend == "all" || $backend == "arm_cpu" || $backend == "arm64_codegen" ]]; then if [[ ${Run_arm64_codegen_status} != 0 ]];then - echo "Run_arm64_fp32 failed" - cat ${run_arm64_fp32_log_file} + echo "Run_arm64_codegen failed" + cat ${run_arm64_fp32_codegen_log_file} + isFailed=1 + fi +fi +if [[ $backend == "all" || $backend == "arm_cpu" || $backend == "arm32_codegen" ]]; then + if [[ ${Run_arm32_codegen_status} != 0 ]];then + echo "Run_arm32 codegen failed" + cat ${run_arm32_fp32_codegen_log_file} isFailed=1 fi fi