From b8fbeaa1ac309ea033c730ac9a36c2a8c7edd36d Mon Sep 17 00:00:00 2001 From: andy Date: Sat, 8 Aug 2020 18:30:43 +0800 Subject: [PATCH] add new caffe nets --- mindspore/lite/test/models_caffe.cfg | 1 + mindspore/lite/test/run_benchmark_nets.sh | 34 +++++++++++++++++++---- 2 files changed, 29 insertions(+), 6 deletions(-) create mode 100644 mindspore/lite/test/models_caffe.cfg diff --git a/mindspore/lite/test/models_caffe.cfg b/mindspore/lite/test/models_caffe.cfg new file mode 100644 index 000000000..b2ec5c3e2 --- /dev/null +++ b/mindspore/lite/test/models_caffe.cfg @@ -0,0 +1 @@ +ml_face_div_parsing diff --git a/mindspore/lite/test/run_benchmark_nets.sh b/mindspore/lite/test/run_benchmark_nets.sh index 9a8484067..37e937b72 100644 --- a/mindspore/lite/test/run_benchmark_nets.sh +++ b/mindspore/lite/test/run_benchmark_nets.sh @@ -50,10 +50,13 @@ cd $convertor_path/MSLite-*-linux_x86_64 #models_config_filename=/home/workspace/mindspore_dataset/mslite/models/models_config.txt models_tflite_config=${basepath}/models_tflite.cfg +models_caffe_config=${basepath}/models_caffe.cfg + rm -rf ${basepath}/ms_models mkdir -p ${basepath}/ms_models ms_models_path=${basepath}/ms_models +#convert tflite models: while read line;do model_name=$line echo $model_name @@ -61,9 +64,20 @@ while read line;do ./converter_lite --fmk=TFLITE --modelFile=$models_path/${model_name} --outputFile=${ms_models_path}/${model_name} done < ${models_tflite_config} +#convert caffe models: +pwd +export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./lib/:./third_party/protobuf/lib +while read line;do + model_name=$line + echo $model_name + echo './converter_lite --fmk=CAFFE --modelFile='${models_path}'/'${model_name}'.prototxt --weightFile='${models_path}'/'${model_name}'.caffemodel --outputFile='${ms_models_path}'/'${model_name}'' + ./converter_lite --fmk=TFLITE --modelFile=$models_path/${model_name} --outputFile=${ms_models_path}/${model_name} +done < ${models_caffe_config} + + #push to the arm and run benchmark: -#first:copy to the server which connected to the phone +#=====first:copy benchmark exe and so files to the server which connected to the phone rm -rf ${basepath}/benchmark_test mkdir -p ${basepath}/benchmark_test benchmark_test_path=${basepath}/benchmark_test @@ -71,20 +85,20 @@ cd ${benchmark_test_path} cp $arm_path/MSLite-*-linux_arm64/lib/libmindspore-lite.so ${benchmark_test_path}/libmindspore-lite.so cp $arm_path/MSLite-*-linux_arm64/benchmark/benchmark ${benchmark_test_path}/benchmark -#copy the models: +#copy the MindSpore models: cp ${ms_models_path}/*.ms ${benchmark_test_path} -#second:adb push to the phone +#=====second:adb push all needed files to the phone adb -s $device_id push ${benchmark_test_path} /data/local/tmp/ -#third:run adb ,run session ,check the result: +#=====third:run adb ,run session ,check the result: echo 'cd /data/local/tmp/benchmark_test' > adb_cmd.txt echo 'cp /data/local/tmp/libc++_shared.so ./' >> adb_cmd.txt echo 'chmod 777 benchmark' >> adb_cmd.txt adb -s $device_id shell < adb_cmd.txt -#run models: +#run tflite converted models: while read line;do model_name=$line echo $model_name @@ -94,4 +108,12 @@ while read line;do adb -s $device_id shell < adb_run_cmd.txt done < ${models_tflite_config} - +#run caffe converted models: +while read line;do + model_name=$line + echo $model_name + echo 'cd /data/local/tmp/benchmark_test' > adb_run_cmd.txt + echo 'export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/data/local/tmp/benchmark_test;./benchmark --modelPath='${model_name}'.ms --inDataPath=/data/local/tmp/input_output/input/'${model_name}'.ms.bin --calibDataPath=/data/local/tmp/input_output/output/'${model_name}'.ms.out --warmUpLoopCount=1 --loopCount=1' + echo 'export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/data/local/tmp/benchmark_test;./benchmark --modelPath='${model_name}'.ms --inDataPath=/data/local/tmp/input_output/input/'${model_name}'.ms.bin --calibDataPath=/data/local/tmp/input_output/output/'${model_name}'.ms.out --warmUpLoopCount=1 --loopCount=1' >> adb_run_cmd.txt + adb -s $device_id shell < adb_run_cmd.txt +done < ${models_caffe_config} -- GitLab