diff --git a/mindspore/lite/test/config/models_onnx.cfg b/mindspore/lite/test/config/models_onnx.cfg index 50df3b5213e..96197e39920 100644 --- a/mindspore/lite/test/config/models_onnx.cfg +++ b/mindspore/lite/test/config/models_onnx.cfg @@ -84,3 +84,4 @@ ml_video_edit_art_generate_20210513.onnx ml_asr_encoder_int8_202103.onnx rpnt_pdr_conv2d_16_fixed_last.onnx hdc_efficientnet_b3_1w_class.onnx +yolov5s.onnx diff --git a/mindspore/lite/test/config/models_onnx_fp16.cfg b/mindspore/lite/test/config/models_onnx_fp16.cfg index 8b6dce2a72d..9f549dbb00c 100644 --- a/mindspore/lite/test/config/models_onnx_fp16.cfg +++ b/mindspore/lite/test/config/models_onnx_fp16.cfg @@ -93,3 +93,4 @@ ml_asr_encoder_int8_202103.onnx 2.1 # The input range of hdc_efficientnet_b3_1w_class.onnx is [-5, 5], the computation of middle layers contains small # values(<1e-5), The fp16 computation precision is low in this case. hdc_efficientnet_b3_1w_class.onnx 18 +yolov5s.onnx 2 diff --git a/mindspore/lite/tools/optimizer/graph/unify_format_pass.cc b/mindspore/lite/tools/optimizer/graph/unify_format_pass.cc index fa7b861a77f..7b323b83ee2 100644 --- a/mindspore/lite/tools/optimizer/graph/unify_format_pass.cc +++ b/mindspore/lite/tools/optimizer/graph/unify_format_pass.cc @@ -150,6 +150,10 @@ void ConvertNcTensor2Nh(const FuncGraphPtr &func_graph, const CNodePtr &cnode, s lite::DataInfo data_info; int status; if (utils::isa(cnode->input(index))) { + auto input_node = cnode->input(index)->cast(); + if (!input_node->has_default()) { + return; + } status = lite::FetchDataFromParameterNode(cnode, index, fmk_type, train_flag, &data_info); } else { status = lite::FetchDataFromValueNode(cnode, index, fmk_type, train_flag, &data_info); @@ -161,7 +165,7 @@ void ConvertNcTensor2Nh(const FuncGraphPtr &func_graph, const CNodePtr &cnode, s (data_info.data_type_ != kNumberTypeFloat32 && data_info.data_type_ != kNumberTypeFloat)) { return; } - std::vector new_shape; + std::vector new_shape = data_info.shape_; if (data_info.shape_.size() == 1) { new_shape = {1, 1, 1, data_info.shape_[0]}; } else if (data_info.shape_.size() == 2) {