diff --git a/mindspore/lite/test/models_tflite.cfg b/mindspore/lite/test/models_tflite.cfg index 1537fb5784..b321623182 100644 --- a/mindspore/lite/test/models_tflite.cfg +++ b/mindspore/lite/test/models_tflite.cfg @@ -56,3 +56,4 @@ ml_ocr_latin.tflite hiai_ssd_mobilenetv2_object.tflite inception_v4.tflite ml_object_detect.tflite +mtk_model_normalize_object_scene_ps_20200519_f16.tflite \ No newline at end of file diff --git a/mindspore/lite/tools/converter/parser/tflite/tflite_model_parser.cc b/mindspore/lite/tools/converter/parser/tflite/tflite_model_parser.cc index b9990d0ace..0086a3ec0d 100644 --- a/mindspore/lite/tools/converter/parser/tflite/tflite_model_parser.cc +++ b/mindspore/lite/tools/converter/parser/tflite/tflite_model_parser.cc @@ -43,8 +43,7 @@ std::unique_ptr TfliteModelParser::ReadTfliteModel(const char *m } STATUS TfliteModelParser::CopyConstTensorData(const std::vector> &tflite_model_buffer, - const tflite::TensorT *tflite_tensor, - schema::TensorT *tensor) { + const tflite::TensorT *tflite_tensor, schema::TensorT *tensor) { auto count = 1; std::for_each(tflite_tensor->shape.begin(), tflite_tensor->shape.end(), [&](int32_t sha) { count *= sha; }); auto data_size = count * GetDataTypeSize(TypeId(tensor->dataType)); @@ -92,8 +91,7 @@ void TfliteModelParser::SetTensorQuantParam(const std::unique_ptr &tflite_model, const std::unique_ptr &tflite_subgraph, - const QuantType &quant_type, - schema::MetaGraphT* sub_graph) { + const QuantType &quant_type, schema::MetaGraphT *sub_graph) { int idx = 0; for (const auto &tflite_op : tflite_subgraph->operators) { auto tflite_op_type = (tflite_model->operator_codes[tflite_op->opcode_index])->builtin_code; @@ -126,7 +124,7 @@ STATUS TfliteModelParser::ConvertOp(const std::unique_ptr &tflit STATUS TfliteModelParser::ConvertTensor(const std::unique_ptr &tflite_subgraph, const std::vector> &tflite_model_buffer, - schema::MetaGraphT* sub_graph) { + schema::MetaGraphT *sub_graph) { for (int i = 0; i < tensorsId.size(); i++) { auto idx = tensorsId[i]; if (idx < 0) { @@ -164,8 +162,9 @@ STATUS TfliteModelParser::ConvertTensor(const std::unique_ptr } // quant param - if (!(tflite_tensor->quantization->scale.empty() && tflite_tensor->quantization->zero_point.empty() && - tflite_tensor->quantization->min.empty() && tflite_tensor->quantization->max.empty())) { + if (tflite_tensor->quantization != nullptr && + !(tflite_tensor->quantization->scale.empty() && tflite_tensor->quantization->zero_point.empty() && + tflite_tensor->quantization->min.empty() && tflite_tensor->quantization->max.empty())) { SetTensorQuantParam(tflite_tensor, tensor.get()); } @@ -180,7 +179,7 @@ STATUS TfliteModelParser::ConvertTensor(const std::unique_ptr } STATUS TfliteModelParser::GetGraphInfo(const std::unique_ptr &tflite_subgraph, - schema::MetaGraphT* sub_graph) { + schema::MetaGraphT *sub_graph) { int id; // graph input @@ -217,7 +216,7 @@ STATUS TfliteModelParser::GetGraphInfo(const std::unique_ptr return RET_OK; } -STATUS TfliteModelParser::UpdateOp(schema::MetaGraphT* sub_graph) { +STATUS TfliteModelParser::UpdateOp(schema::MetaGraphT *sub_graph) { for (auto &op : sub_graph->nodes) { if (op->primitive->value.type == schema::PrimitiveType_DepthwiseConv2D) { auto attr = op->primitive->value.AsDepthwiseConv2D(); @@ -270,9 +269,7 @@ STATUS TfliteModelParser::UpdateOp(schema::MetaGraphT* sub_graph) { return RET_OK; } - -MetaGraphT *TfliteModelParser::Parse(const std::string &model_file, - const std::string &weight_file, +MetaGraphT *TfliteModelParser::Parse(const std::string &model_file, const std::string &weight_file, const QuantType &quant_type) { std::unique_ptr sub_graph(new schema::MetaGraphT); sub_graph->name = "MS_model converted by TF-Lite";