Browse Source

[MS][LITE] support encoder fp16

tags/v1.2.0-rc1
cjh9368 5 years ago
parent
commit
738598af28
4 changed files with 38 additions and 30 deletions
  1. +2
    -1
      mindspore/lite/test/models_tf_fp16.cfg
  2. +29
    -28
      mindspore/lite/test/run_benchmark_nets.sh
  3. +6
    -0
      mindspore/lite/tools/optimizer/common/gllo_utils.cc
  4. +1
    -1
      mindspore/lite/tools/optimizer/common/pass_manager_extends.cc

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

@@ -1 +1,2 @@
decoder_step_201217_modified.pb 5
decoder_step_201217_modified.pb 5;;0.5
encoder_0111_control_flow.pb 4;1:1,44:1:1;10

+ 29
- 28
mindspore/lite/test/run_benchmark_nets.sh View File

@@ -346,34 +346,6 @@ function Run_Converter() {
fi
done < ${models_multiple_inputs_fp16_config}

# Run tf fp16 models
while read line; do
model_name_and_input_num=${line%;*}
length=${#model_name_and_input_num}
input_shapes=${line:length+1}
tf_line_info=${model_name_and_input_num}
if [[ $model_name == \#* ]]; then
continue
fi
model_name=`echo ${tf_line_info}|awk -F ' ' '{print $1}'`
input_num=`echo ${tf_line_info}|awk -F ' ' '{print $2}'`
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}'.ms --inDataFile='${input_files}' --benchmarkDataFile=/data/local/tmp/input_output/output/'${model_name}'.ms.out --enableFp16=true' >> "${run_arm64_fp16_log_file}"
echo 'export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/data/local/tmp/benchmark_test;./benchmark --inputShapes='${input_shapes}' --modelFile='${model_name}'.ms --inDataFile='${input_files}' --benchmarkDataFile=/data/local/tmp/input_output/output/'${model_name}'.ms.out --enableFp16=true' >> adb_run_cmd.txt
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}

# Convert models which does not need to be cared about the accuracy:
while read line; do
if [[ $line == \#* ]]; then
@@ -1875,6 +1847,35 @@ 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() {


+ 6
- 0
mindspore/lite/tools/optimizer/common/gllo_utils.cc View File

@@ -543,6 +543,12 @@ bool IsConvNode(const BaseRef &n) {
if (prim == nullptr) {
return false;
}

if (prim->GetAttr(ops::kActivationType) != nullptr &&
GetValue<int64_t>(prim->GetAttr(ops::kActivationType)) != NO_ACTIVATION) {
return false;
}

bool is_depth_wise =
prim->GetAttr(ops::kIsDepthWise) != nullptr && GetValue<bool>(prim->GetAttr(ops::kIsDepthWise));
return CheckPrimitiveType(anf_node, prim::kPrimConv2DFusion) ||


+ 1
- 1
mindspore/lite/tools/optimizer/common/pass_manager_extends.cc View File

@@ -26,7 +26,6 @@

namespace mindspore {
namespace opt {
static size_t count = 0;
constexpr size_t kMaxRepassTimes = 12;
const std::vector<PassPtr> &PassManager::Passes() const { return passes_; }

@@ -77,6 +76,7 @@ bool PassManager::Run(const FuncGraphPtr &func_graph) const {
return false;
}
bool changed = false;
size_t count = 0;
// run all passes
bool change = true;
while (change) {


Loading…
Cancel
Save