Browse Source

tf models support running fp16 mode and add models to the entrance guard

pull/14014/head
zengxianglong 5 years ago
parent
commit
381cbaa764
11 changed files with 170 additions and 112 deletions
  1. +16
    -0
      mindspore/lite/test/models_caffe.cfg
  2. +16
    -0
      mindspore/lite/test/models_caffe_fp16.cfg
  3. +2
    -0
      mindspore/lite/test/models_for_process_only.cfg
  4. +2
    -0
      mindspore/lite/test/models_npu.cfg
  5. +3
    -0
      mindspore/lite/test/models_onnx.cfg
  6. +6
    -0
      mindspore/lite/test/models_onnx_fp16.cfg
  7. +7
    -2
      mindspore/lite/test/models_tf_fp16.cfg
  8. +2
    -1
      mindspore/lite/test/models_tflite.cfg
  9. +1
    -0
      mindspore/lite/test/models_tflite_fp16.cfg
  10. +5
    -0
      mindspore/lite/test/models_with_multiple_inputs_fp16.cfg
  11. +110
    -109
      mindspore/lite/test/run_benchmark_nets.sh

+ 16
- 0
mindspore/lite/test/models_caffe.cfg View File

@@ -92,3 +92,19 @@ ml_handpose
ml_lable_model_hebing_device
ml_face_sex
ml_face_hat
ml_face_compare
ml_face_tracking
ml_face_beard
ml_face_age
ml_face_pose
ml_face_isface
ml_face_glasses
ml_segmentation_matting
ml_segmentation_atlanta_10
ml_bodymask
ml_Hand_deploy
ml_hand_3d_detection
ml_hand_3d_regression
ml_ARengine23_bodypose
ml_ocr_bank_card_detection_inception
ml_ocr_bank_card_recognition_fcny

+ 16
- 0
mindspore/lite/test/models_caffe_fp16.cfg View File

@@ -87,3 +87,19 @@ ml_video_edit_img_segment 3
ml_video_edit_video_segment_gauss_adaptis_part1 5
ml_handpose 175
hdc_Face_Aesthetic_MTI_Aesthetic 22
ml_face_compare 5.5
ml_face_tracking 2.5
ml_face_beard 0.5
ml_face_age 3.5
ml_face_pose 1
ml_face_isface 0.5
ml_face_glasses 2.5
# ml_segmentation_matting 26 # output value unstable
ml_segmentation_atlanta_10 5
ml_bodymask 14
ml_Hand_deploy 4
ml_hand_3d_detection 12
ml_hand_3d_regression 3
ml_ARengine23_bodypose 56
ml_ocr_bank_card_detection_inception 20
ml_ocr_bank_card_recognition_fcny 0.5

+ 2
- 0
mindspore/lite/test/models_for_process_only.cfg View File

@@ -22,3 +22,5 @@ quant_aware_bank_card_detection_inception.onnx
quant_aware_bank_card_recognition_fcny.onnx
quant_aware_identify_card_detect.onnx
tiny-yolov3-11.onnx;2;1,416,416,3:1,2
# cur acc for ml_video_edit_art_transfer is 2+%
ml_video_edit_art_transfer.onnx;3

+ 2
- 0
mindspore/lite/test/models_npu.cfg View File

@@ -79,3 +79,5 @@ hdc_mobilenet_1w_class.onnx 20
hdc_age_medium 504
posenet_mobilenet_float_075_1_default_1.tflite 395
nasnet_mobile.tflite 1
ml_video_edit_art_generate.onnx 0.5
ml_video_edit_art_transfer.onnx 3 3

+ 3
- 0
mindspore/lite/test/models_onnx.cfg View File

@@ -58,3 +58,6 @@ ml_edu_kit_hand_detection.onnx
ml_edu_kit_hand_key_position.onnx
ml_facedetector.onnx
ml_ei_facedetection.onnx
ml_video_edit_art_generate.onnx
ml_location_lane_counter.onnx
# ml_location_lane_counter0.onnx

+ 6
- 0
mindspore/lite/test/models_onnx_fp16.cfg View File

@@ -55,3 +55,9 @@ hdc_Face_Emotion_MTI_Aesthetic.onnx 144
ml_video_edit_imitate_filter.onnx 103
ml_facedetector.onnx 3
ml_ei_facedetection.onnx 2
#ml_video_edit_art_generate.onnx #mul operator overflows, not suitable for fp16
ml_location_lane_counter.onnx 6
# ml_location_lane_counter0.onnx 0.5
#The encoder an decoder model are used in ml_asr scene, both have value overflow. Not suitable for fp16.
#But added for guarding process.
encoder.onnx;1,32,83 1262

+ 7
- 2
mindspore/lite/test/models_tf_fp16.cfg View File

@@ -1,2 +1,7 @@
decoder_step_201217_modified.pb 5;;0.5
encoder_0111_control_flow.pb 4;1:1,44:1:1;10
ml_vision_guide_detection1.pb 0.5
ml_vision_guide_detection3.pb 0.5
ml_video_edit_generate_filter.pb 2
ml_ocr_jk.pb 0.5
ml_ocr_latin.pb 135
scan_hms_angle.pb 1.5
scan_hms_detect.pb 2.5

+ 2
- 1
mindspore/lite/test/models_tflite.cfg View File

@@ -161,4 +161,5 @@ Q_landmark.tflite
Q_language_model_hrmini_Q4_b4_17w.tflite
Q_new_detect.tflite
Q_object_scene.tflite
Q_pose.tflite
Q_pose.tflite
ml_ei_landmark_pb2tflite.tflite

+ 1
- 0
mindspore/lite/test/models_tflite_fp16.cfg View File

@@ -157,3 +157,4 @@ lite-model_on_device_vision_classifier_landmarks_classifier_asia_V1_1.tflite 25
lite-model_on_device_vision_classifier_landmarks_classifier_oceania_antarctica_V1_1.tflite 10
lite-model_on_device_vision_classifier_landmarks_classifier_europe_V1_1.tflite 32
lite-model_on_device_vision_classifier_landmarks_classifier_south_america_V1_1.tflite 14
ml_ei_landmark_pb2tflite.tflite 2

+ 5
- 0
mindspore/lite/test/models_with_multiple_inputs_fp16.cfg View File

@@ -5,3 +5,8 @@ ml_video_edit_img_segment_adaptise_pb2tflite.tflite;2 0.5
ml_video_edit_person_divison_video;2 38
ml_video_edit_oneclick_adaptis.pb;3 6
hdc_tb_cn_neg.tflite;3 281
decoder_step_201217.pb;5 187
ml_video_edit_art_transfer.onnx;3 3
decoder.onnx;2;1,7,512:1,7 113
decoder_step_201217_modified.pb;5 0.5
encoder_0111_control_flow.pb;4;1:1,44:1:1 10

+ 110
- 109
mindspore/lite/test/run_benchmark_nets.sh View File

@@ -167,69 +167,6 @@ function Run_Converter() {
fi
done < ${models_tflite_awaretraining_config}

# Copy fp16 ms models:
while read line; do
fp16_line_info=${line}
if [[ $fp16_line_info == \#* ]]; then
continue
fi
model_info=`echo ${fp16_line_info}|awk -F ' ' '{print $1}'`
model_name=${model_info%%;*}
echo 'cp '${ms_models_path}'/'${model_name}'.ms' ${ms_models_path}'/'${model_name}'.fp16.ms'
cp ${ms_models_path}/${model_name}.ms ${ms_models_path}/${model_name}.fp16.ms
if [ $? = 0 ]; then
converter_result='converter fp16 '${model_name}' pass';echo ${converter_result} >> ${run_converter_result_file}
else
converter_result='converter fp16 '${model_name}' failed';echo ${converter_result} >> ${run_converter_result_file};return 1
fi
done < ${models_onnx_fp16_config}

while read line; do
fp16_line_info=${line}
if [[ $fp16_line_info == \#* ]]; then
continue
fi
model_name=`echo ${fp16_line_info}|awk -F ' ' '{print $1}'`
echo 'cp '${ms_models_path}'/'${model_name}'.ms' ${ms_models_path}'/'${model_name}'.fp16.ms'
cp ${ms_models_path}/${model_name}.ms ${ms_models_path}/${model_name}.fp16.ms
if [ $? = 0 ]; then
converter_result='converter fp16 '${model_name}' pass';echo ${converter_result} >> ${run_converter_result_file}
else
converter_result='converter fp16 '${model_name}' failed';echo ${converter_result} >> ${run_converter_result_file};return 1
fi
done < ${models_caffe_fp16_config}

while read line; do
fp16_line_info=${line}
if [[ $fp16_line_info == \#* ]]; then
continue
fi
model_name=`echo ${fp16_line_info}|awk -F ' ' '{print $1}'`
echo 'cp '${ms_models_path}'/'${model_name}'.ms' ${ms_models_path}'/'${model_name}'.fp16.ms'
cp ${ms_models_path}/${model_name}.ms ${ms_models_path}/${model_name}.fp16.ms
if [ $? = 0 ]; then
converter_result='converter fp16 '${model_name}' pass';echo ${converter_result} >> ${run_converter_result_file}
else
converter_result='converter fp16 '${model_name}' failed';echo ${converter_result} >> ${run_converter_result_file};return 1
fi
done < ${models_tflite_fp16_config}

while read line; do
fp16_line_info=${line}
if [[ $fp16_line_info == \#* ]]; then
continue
fi
model_name=`echo ${fp16_line_info}|awk -F ' ' '{print $1}'`
input_num=`echo ${fp16_line_info}|awk -F ' ' '{print $2}'`
echo 'cp '${ms_models_path}'/'${model_name}'.ms' ${ms_models_path}'/'${model_name}'.fp16.ms'
cp ${ms_models_path}/${model_name}.ms ${ms_models_path}/${model_name}.fp16.ms
if [ $? = 0 ]; then
converter_result='converter fp16 '${model_name}' pass';echo ${converter_result} >> ${run_converter_result_file}
else
converter_result='converter fp16 '${model_name}' failed';echo ${converter_result} >> ${run_converter_result_file};return 1
fi
done < ${models_tf_fp16_config}

# Convert tflite weightquant models:
while read line; do
weight_quant_line_info=${line}
@@ -331,22 +268,6 @@ function Run_Converter() {
fi
done < ${models_with_multiple_inputs_config}

while read line; do
fp16_line_info=${line}
if [[ $fp16_line_info == \#* ]]; then
continue
fi
model_info=`echo ${fp16_line_info}|awk -F ' ' '{print $1}'`
model_name=${model_info%%;*}
echo 'cp '${ms_models_path}'/'${model_name}'.ms' ${ms_models_path}'/'${model_name}'.fp16.ms'
cp ${ms_models_path}/${model_name}.ms ${ms_models_path}/${model_name}.fp16.ms
if [ $? = 0 ]; then
converter_result='converter fp16 '${model_name}' pass';echo ${converter_result} >> ${run_converter_result_file}
else
converter_result='converter fp16 '${model_name}' failed';echo ${converter_result} >> ${run_converter_result_file};return 1
fi
done < ${models_multiple_inputs_fp16_config}

# Convert models which does not need to be cared about the accuracy:
while read line; do
if [[ $line == \#* ]]; then
@@ -387,6 +308,85 @@ function Run_Converter() {
converter_result='converter '${model_type}' '${model_name}' failed';echo ${converter_result} >> ${run_converter_result_file};return 1
fi
done < ${models_for_process_only_config}

# Copy fp16 ms models:
while read line; do
fp16_line_info=${line}
if [[ $fp16_line_info == \#* ]]; then
continue
fi
model_info=`echo ${fp16_line_info}|awk -F ' ' '{print $1}'`
model_name=${model_info%%;*}
echo 'cp '${ms_models_path}'/'${model_name}'.ms' ${ms_models_path}'/'${model_name}'.fp16.ms'
cp ${ms_models_path}/${model_name}.ms ${ms_models_path}/${model_name}.fp16.ms
if [ $? = 0 ]; then
converter_result='converter fp16 '${model_name}' pass';echo ${converter_result} >> ${run_converter_result_file}
else
converter_result='converter fp16 '${model_name}' failed';echo ${converter_result} >> ${run_converter_result_file};return 1
fi
done < ${models_onnx_fp16_config}

while read line; do
fp16_line_info=${line}
if [[ $fp16_line_info == \#* ]]; then
continue
fi
model_name=`echo ${fp16_line_info}|awk -F ' ' '{print $1}'`
echo 'cp '${ms_models_path}'/'${model_name}'.ms' ${ms_models_path}'/'${model_name}'.fp16.ms'
cp ${ms_models_path}/${model_name}.ms ${ms_models_path}/${model_name}.fp16.ms
if [ $? = 0 ]; then
converter_result='converter fp16 '${model_name}' pass';echo ${converter_result} >> ${run_converter_result_file}
else
converter_result='converter fp16 '${model_name}' failed';echo ${converter_result} >> ${run_converter_result_file};return 1
fi
done < ${models_caffe_fp16_config}

while read line; do
fp16_line_info=${line}
if [[ $fp16_line_info == \#* ]]; then
continue
fi
model_name=`echo ${fp16_line_info}|awk -F ' ' '{print $1}'`
echo 'cp '${ms_models_path}'/'${model_name}'.ms' ${ms_models_path}'/'${model_name}'.fp16.ms'
cp ${ms_models_path}/${model_name}.ms ${ms_models_path}/${model_name}.fp16.ms
if [ $? = 0 ]; then
converter_result='converter fp16 '${model_name}' pass';echo ${converter_result} >> ${run_converter_result_file}
else
converter_result='converter fp16 '${model_name}' failed';echo ${converter_result} >> ${run_converter_result_file};return 1
fi
done < ${models_tflite_fp16_config}

while read line; do
fp16_line_info=${line}
if [[ $fp16_line_info == \#* ]]; then
continue
fi
model_info=`echo ${fp16_line_info}|awk -F ' ' '{print $1}'`
model_name=${model_info%%;*}
echo 'cp '${ms_models_path}'/'${model_name}'.ms' ${ms_models_path}'/'${model_name}'.fp16.ms'
cp ${ms_models_path}/${model_name}.ms ${ms_models_path}/${model_name}.fp16.ms
if [ $? = 0 ]; then
converter_result='converter fp16 '${model_name}' pass';echo ${converter_result} >> ${run_converter_result_file}
else
converter_result='converter fp16 '${model_name}' failed';echo ${converter_result} >> ${run_converter_result_file};return 1
fi
done < ${models_tf_fp16_config}

while read line; do
fp16_line_info=${line}
if [[ $fp16_line_info == \#* ]]; then
continue
fi
model_info=`echo ${fp16_line_info}|awk -F ' ' '{print $1}'`
model_name=${model_info%%;*}
echo 'cp '${ms_models_path}'/'${model_name}'.ms' ${ms_models_path}'/'${model_name}'.fp16.ms'
cp ${ms_models_path}/${model_name}.ms ${ms_models_path}/${model_name}.fp16.ms
if [ $? = 0 ]; then
converter_result='converter fp16 '${model_name}' pass';echo ${converter_result} >> ${run_converter_result_file}
else
converter_result='converter fp16 '${model_name}' failed';echo ${converter_result} >> ${run_converter_result_file};return 1
fi
done < ${models_multiple_inputs_fp16_config}
}

# Run on x86 platform:
@@ -1811,6 +1811,36 @@ function Run_arm64_fp16() {
fi
done < ${models_tflite_fp16_config}

# Run fp16 converted models:
while read line; do
fp16_line_info=${line}
if [[ $fp16_line_info == \#* ]]; then
continue
fi
model_info=`echo ${fp16_line_info}|awk -F ' ' '{print $1}'`
accuracy_limit=`echo ${fp16_line_info}|awk -F ' ' '{print $2}'`
model_name=${model_info%%;*}
length=${#model_name}
input_shapes=${model_info:length+1}
echo "---------------------------------------------------------" >> "${run_arm64_fp16_log_file}"
echo "fp16 run: ${model_name}, accuracy limit:${accuracy_limit}" >> "${run_arm64_fp16_log_file}"

echo 'cd /data/local/tmp/benchmark_test' > adb_run_cmd.txt
echo 'export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/data/local/tmp/benchmark_test' >> adb_run_cmd.txt
if [[ $accuracy_limit == "-1" ]]; then
echo './benchmark --modelFile='${model_name}'.fp16.ms --inDataFile=/data/local/tmp/input_output/input/'${model_name}'.ms.bin --enableFp16=true --inputShapes='${input_shapes} >> adb_run_cmd.txt
else
echo './benchmark --modelFile='${model_name}'.fp16.ms --inDataFile=/data/local/tmp/input_output/input/'${model_name}'.ms.bin --benchmarkDataFile=/data/local/tmp/input_output/output/'${model_name}'.ms.out --enableFp16=true --accuracyThreshold='${accuracy_limit} ' --inputShapes='${input_shapes} >> adb_run_cmd.txt
fi
cat adb_run_cmd.txt >> "${run_arm64_fp16_log_file}"
adb -s ${device_id} shell < adb_run_cmd.txt >> "${run_arm64_fp16_log_file}"
if [ $? = 0 ]; then
run_result='arm64_fp16: '${model_name}' pass'; echo ${run_result} >> ${run_benchmark_result_file}
else
run_result='arm64_fp16: '${model_name}' failed'; echo ${run_result} >> ${run_benchmark_result_file}; return 1
fi
done < ${models_tf_fp16_config}

# Run converted models which has multiple inputs in fp16 mode:
while read line; do
fp16_line_info=${line}
@@ -1848,35 +1878,6 @@ function Run_arm64_fp16() {
run_result='arm64_fp16: '${model_name}' failed'; echo ${run_result} >> ${run_benchmark_result_file}; return 1
fi
done < ${models_multiple_inputs_fp16_config}

# Run tf fp16 models
while read line; do
tf_line_info=${line}
if [[ $tf_line_info == \#* ]]; then
continue
fi
model_name=`echo ${tf_line_info}|awk -F ' ' '{print $1}'`
model_info=`echo ${tf_line_info}|awk -F ' ' '{print $2}'`
input_num=`echo ${model_info}|awk -F ';' '{print $1}'`
input_shapes=`echo ${model_info}|awk -F ';' '{print $2}'`
accuracy_limit=`echo ${model_info}|awk -F ';' '{print $3}'`
input_files=''
for i in $(seq 1 $input_num)
do
input_files=$input_files'/data/local/tmp/input_output/input/'$model_name'.ms_'$i'.bin,'
done
echo ${model_name} >> "${run_arm64_fp16_log_file}"
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 --inputShapes='${input_shapes}' --modelFile='${model_name}'.fp16.ms --inDataFile='${input_files}' --benchmarkDataFile=/data/local/tmp/input_output/output/'${model_name}'.ms.out --enableFp16=true --accuracyThreshold='${accuracy_limit} >> adb_run_cmd.txt
echo 'export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/data/local/tmp/benchmark_test;./benchmark --inputShapes='${input_shapes}' --modelFile='${model_name}'.fp16.ms --inDataFile='${input_files}' --benchmarkDataFile=/data/local/tmp/input_output/output/'${model_name}'.ms.out --enableFp16=true --accuracyThreshold='${accuracy_limit} >> adb_run_cmd.txt
cat adb_run_cmd.txt >> "${run_arm64_fp16_log_file}"
adb -s ${device_id} shell < adb_run_cmd.txt >> "${run_arm64_fp16_log_file}"
if [ $? = 0 ]; then
run_result='arm64_fp16: '${model_name}' pass'; echo ${run_result} >> ${run_benchmark_result_file}
else
run_result='arm64_fp16: '${model_name}' failed'; echo ${run_result} >> ${run_benchmark_result_file}; return 1
fi
done < ${models_tf_fp16_config}
}
# Run on gpu platform:
function Run_gpu() {
@@ -2133,6 +2134,7 @@ models_onnx_config=${basepath}/models_onnx.cfg
models_onnx_fp16_config=${basepath}/models_onnx_fp16.cfg
models_caffe_fp16_config=${basepath}/models_caffe_fp16.cfg
models_tflite_fp16_config=${basepath}/models_tflite_fp16.cfg
models_tf_fp16_config=${basepath}/models_tf_fp16.cfg
models_multiple_inputs_fp16_config=${basepath}/models_with_multiple_inputs_fp16.cfg
models_mindspore_config=${basepath}/models_mindspore.cfg
models_mindspore_train_config=${basepath}/models_mindspore_train.cfg
@@ -2146,7 +2148,6 @@ models_npu_config=${basepath}/models_npu.cfg
models_compatibility_config=${basepath}/models_compatibility.cfg
models_with_multiple_inputs_config=${basepath}/models_with_multiple_inputs.cfg
models_for_process_only_config=${basepath}/models_for_process_only.cfg
models_tf_fp16_config=${basepath}/models_tf_fp16.cfg

ms_models_path=${basepath}/ms_models



Loading…
Cancel
Save