diff --git a/mindspore/lite/src/runtime/kernel/arm/base/quant_dtype_cast.cc b/mindspore/lite/src/runtime/kernel/arm/base/quant_dtype_cast.cc index 8ef4881b51..cc3a47cbc7 100644 --- a/mindspore/lite/src/runtime/kernel/arm/base/quant_dtype_cast.cc +++ b/mindspore/lite/src/runtime/kernel/arm/base/quant_dtype_cast.cc @@ -111,8 +111,10 @@ int QuantDTypeCastCPUKernel::QuantDTypeCast(int task_id) { MS_LOG(ERROR) << "QuantDTypeCast need quantization parameters which is not found."; return RET_ERROR; } - auto quant_arg = out_tensors_.front()->quant_params().front().inited ? out_tensors_.front()->quant_params().front() - : in_tensors_.front()->quant_params().front(); + auto quant_arg = + (!out_tensors_.front()->quant_params().empty() && out_tensors_.front()->quant_params().front().inited) + ? out_tensors_.front()->quant_params().front() + : in_tensors_.front()->quant_params().front(); int ret = RET_OK; if (src_dtype == TypeId::kNumberTypeInt8 && dst_dtype == TypeId::kNumberTypeFloat32) { ret = DoDequantizeInt8ToFp32(int8_ptr_ + thread_offset, float32_ptr_ + thread_offset, quant_arg.scale, diff --git a/mindspore/lite/test/models_mindspore.cfg b/mindspore/lite/test/models_mindspore.cfg index cca5f36835..d684b289d0 100644 --- a/mindspore/lite/test/models_mindspore.cfg +++ b/mindspore/lite/test/models_mindspore.cfg @@ -12,3 +12,6 @@ ocr_mobilenetV2.mindir 1.5 mobilenet_quant.mindir 5 mindspore_ghostnet_ssd_13x.mindir 1.5 mindspore_ghost-nose-pets-811.mindir 0.5 +mindspore_ghost-pets-8244.mindir 1.5 +mindspore_ghostnet600M-pets.mindir 1.5 +mindspore_ghostnet_1x_pets_int8.mindir 12 diff --git a/mindspore/lite/test/models_with_several_inputs_or_without_outputs.cfg b/mindspore/lite/test/models_with_several_inputs_or_without_outputs.cfg index 1efff5e30c..d749993212 100644 --- a/mindspore/lite/test/models_with_several_inputs_or_without_outputs.cfg +++ b/mindspore/lite/test/models_with_several_inputs_or_without_outputs.cfg @@ -27,3 +27,6 @@ mtk_transformer_encoder.tflite mtk_transformer_decoder_joint.tflite ml_ei_facedetection.onnx mobilebert_1_default_1.tflite +quant_aware_bank_card_detection_inception.onnx +quant_aware_bank_card_recognition_fcny.onnx +quant_aware_identify_card_detect.onnx diff --git a/mindspore/lite/tools/optimizer/fusion/constant_folding_fusion.cc b/mindspore/lite/tools/optimizer/fusion/constant_folding_fusion.cc index 0ee73c9702..25ff498afe 100644 --- a/mindspore/lite/tools/optimizer/fusion/constant_folding_fusion.cc +++ b/mindspore/lite/tools/optimizer/fusion/constant_folding_fusion.cc @@ -157,7 +157,7 @@ lite::STATUS ReplaceCNode(const FuncGraphPtr &func_graph, const CNodePtr &any_no MS_LOG(ERROR) << "CreateNewParamter failed, name: " << input_node->fullname_with_scope(); return lite::RET_ERROR; } - new_parameter->set_name(input_node->fullname_with_scope()); + new_parameter->set_name("constfold_" + input_node->fullname_with_scope()); manager->Replace(input_node, new_parameter); } return lite::RET_OK; diff --git a/mindspore/lite/tools/optimizer/graph/weight_format_hardcode_pass.cc b/mindspore/lite/tools/optimizer/graph/weight_format_hardcode_pass.cc index 86fe3e6345..5bc468da1b 100644 --- a/mindspore/lite/tools/optimizer/graph/weight_format_hardcode_pass.cc +++ b/mindspore/lite/tools/optimizer/graph/weight_format_hardcode_pass.cc @@ -103,6 +103,7 @@ lite::STATUS WeightFormatHardCodePass::HardCodeMS(const AnfNodePtr &conv_node, const ParamValueLitePtr ¶m_value) const { MS_ASSERT(conv_cnode != nullptr); MS_ASSERT(param_value != nullptr); + auto weight_node = conv_node->cast()->input(kConvWeightIndex); auto op_type = GetCNodeType(conv_node); switch (this->quant_type) { case QuantType_AwareTraining: { @@ -121,10 +122,8 @@ lite::STATUS WeightFormatHardCodePass::HardCodeMS(const AnfNodePtr &conv_node, if (op_type == schema::PrimitiveType_Conv2D) { param_value->set_format(schema::Format::Format_KCHW); } else if (op_type == schema::PrimitiveType_DepthwiseConv2D) { - // the format is initialized to NUM_OF_FORMAT, and set to NHWC in const folding. - if (param_value->format() == schema::Format::Format_NHWC) { - param_value->set_format(schema::Format::Format_KCHW); - } else { + // the format should be set to KCHW while the weight is output of constfolding . + if (weight_node->fullname_with_scope().find("constfold") == weight_node->fullname_with_scope().npos) { param_value->set_format(schema::Format::Format_CKHW); } } else if (op_type == schema::PrimitiveType_DeDepthwiseConv2D) {