|
|
|
@ -1,4 +1,6 @@
|
|
|
|
|
#!/bin/bash
|
|
|
|
|
basepath=$(pwd)
|
|
|
|
|
echo $basepath
|
|
|
|
|
set -e
|
|
|
|
|
#example:sh run_benchmark_nets.sh -a /home/temp_test -c /home/temp_test -m /home/temp_test/models -d "8KE5T19620002408"
|
|
|
|
|
while getopts "a:c:m:d:" opt
|
|
|
|
@ -26,6 +28,8 @@ do
|
|
|
|
|
esac
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#unzip arm
|
|
|
|
|
cd $arm_path
|
|
|
|
|
tar -zxf MSLite-*-linux_arm64.tar.gz
|
|
|
|
@ -44,25 +48,32 @@ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./lib/:./third_party/protobuf/lib
|
|
|
|
|
#convert the models
|
|
|
|
|
cd $convertor_path/MSLite-*-linux_x86_64
|
|
|
|
|
|
|
|
|
|
models_config_filename=/home/workspace/mindspore_dataset/mslite/models/models_config.txt
|
|
|
|
|
#models_config_filename=/home/workspace/mindspore_dataset/mslite/models/models_config.txt
|
|
|
|
|
models_tflite_config=${basepath}/models_tflite.cfg
|
|
|
|
|
mkdir -p ${basepath}/ms_models
|
|
|
|
|
ms_models_path=${basepath}/ms_models
|
|
|
|
|
|
|
|
|
|
while read line;do
|
|
|
|
|
model_name=$line
|
|
|
|
|
./converter_lite --fmk=TFLITE --modelFile=$models_path/${model_name} --outputFile=$models_path/${model_name}
|
|
|
|
|
done < ${models_config_filename}
|
|
|
|
|
echo $model_name
|
|
|
|
|
echo './converter_lite --fmk=TFLITE --modelFile='${models_path}'/'${model_name}' --outputFile='${ms_models_path}'/'${model_name}''
|
|
|
|
|
./converter_lite --fmk=TFLITE --modelFile=$models_path/${model_name} --outputFile=${ms_models_path}/${model_name}
|
|
|
|
|
done < ${models_tflite_config}
|
|
|
|
|
|
|
|
|
|
#push to the arm and run benchmark:
|
|
|
|
|
|
|
|
|
|
#first:copy to the server which connected to the phone
|
|
|
|
|
mkdir -p ./benchmark_test
|
|
|
|
|
cp $arm_path/MSLite-0.6.0-linux_arm64/lib/libmindspore-lite.so ./benchmark_test/libmindspore-lite.so
|
|
|
|
|
cp $arm_path/MSLite-0.6.0-linux_arm64/benchmark/benchmark ./benchmark_test/benchmark
|
|
|
|
|
mkdir -p ${basepath}/benchmark_test
|
|
|
|
|
benchmark_test_path=${basepath}/benchmark_test
|
|
|
|
|
cd ${benchmark_test_path}
|
|
|
|
|
cp $arm_path/MSLite-0.6.0-linux_arm64/lib/libmindspore-lite.so ${benchmark_test_path}/libmindspore-lite.so
|
|
|
|
|
cp $arm_path/MSLite-0.6.0-linux_arm64/benchmark/benchmark ${benchmark_test_path}/benchmark
|
|
|
|
|
|
|
|
|
|
#copy the models:
|
|
|
|
|
cp $models_path/*.ms ./benchmark_test/
|
|
|
|
|
cp ${ms_models_path}/*.ms ${benchmark_test_path}
|
|
|
|
|
|
|
|
|
|
#second:adb push to the phone
|
|
|
|
|
adb -s $device_id push ./benchmark_test /data/local/tmp/
|
|
|
|
|
adb -s $device_id push ${benchmark_test_path} /data/local/tmp/
|
|
|
|
|
|
|
|
|
|
#third:run adb ,run session ,check the result:
|
|
|
|
|
echo 'cd /data/local/tmp/benchmark_test' > adb_cmd.txt
|
|
|
|
@ -71,8 +82,10 @@ echo 'chmod 777 benchmark' >> adb_cmd.txt
|
|
|
|
|
#run models:
|
|
|
|
|
while read line;do
|
|
|
|
|
model_name=$line
|
|
|
|
|
echo $model_name
|
|
|
|
|
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_cmd.txt
|
|
|
|
|
done < ${models_config_filename}
|
|
|
|
|
done < ${models_tflite_config}
|
|
|
|
|
|
|
|
|
|
adb -s $device_id shell < adb_cmd.txt
|
|
|
|
|
|
|
|
|
|