From 34361e2fe49b63324b7041af7c678b7d5dc2c59c Mon Sep 17 00:00:00 2001 From: lyvette Date: Sat, 29 Aug 2020 11:55:51 +0800 Subject: [PATCH] fix reshape and l2norm tflite parser bug --- .../parser/tflite/tflite_activation_parser.cc | 1 - .../converter/parser/tflite/tflite_l2norm_parser.cc | 4 ---- .../parser/tflite/tflite_reshape_parser.cc | 13 ++++++++++--- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/mindspore/lite/tools/converter/parser/tflite/tflite_activation_parser.cc b/mindspore/lite/tools/converter/parser/tflite/tflite_activation_parser.cc index 5a4adeec4d..1b3a28b721 100644 --- a/mindspore/lite/tools/converter/parser/tflite/tflite_activation_parser.cc +++ b/mindspore/lite/tools/converter/parser/tflite/tflite_activation_parser.cc @@ -51,7 +51,6 @@ STATUS TfliteActivationParser::Parse(const std::unique_ptr &t if (std::strcmp(node_name, "Relu") == 0) { MS_LOG(DEBUG) << "parse TfliteReluParser"; attr->type = schema::ActivationType_RELU; - } else if (std::strcmp(node_name, "Relu6") == 0) { MS_LOG(DEBUG) << "parse TfliteRelu6Parser"; attr->type = schema::ActivationType_RELU6; diff --git a/mindspore/lite/tools/converter/parser/tflite/tflite_l2norm_parser.cc b/mindspore/lite/tools/converter/parser/tflite/tflite_l2norm_parser.cc index a8957822bb..177097482e 100644 --- a/mindspore/lite/tools/converter/parser/tflite/tflite_l2norm_parser.cc +++ b/mindspore/lite/tools/converter/parser/tflite/tflite_l2norm_parser.cc @@ -51,10 +51,6 @@ STATUS TfliteL2NormParser::Parse(const std::unique_ptr &tflit return RET_NULL_PTR; } auto data_index = tflite_op->inputs[0]; - if (static_cast(tflite_op->inputs.size()) <= data_index) { - MS_LOG(ERROR) << "the size of input should be greater than " << data_index; - return RET_ERROR; - } const auto &data_tensor = tflite_tensors[data_index]; if (data_tensor == nullptr) { MS_LOG(ERROR) << "the input tensor is null"; diff --git a/mindspore/lite/tools/converter/parser/tflite/tflite_reshape_parser.cc b/mindspore/lite/tools/converter/parser/tflite/tflite_reshape_parser.cc index 58f97ba177..b05d5ea854 100644 --- a/mindspore/lite/tools/converter/parser/tflite/tflite_reshape_parser.cc +++ b/mindspore/lite/tools/converter/parser/tflite/tflite_reshape_parser.cc @@ -57,9 +57,16 @@ STATUS TfliteReshapeParser::Parse(const std::unique_ptr &tfli MS_LOG(ERROR) << "shape_tensor is null"; return RET_NULL_PTR; } - if (GetTfliteData(tflite_op->inputs[1], tflite_tensors, tflite_model_buffer, attr->shape)) { - MS_LOG(ERROR) << "get reshape -> shape failed"; - return RET_ERROR; + auto &buf_data = tflite_model_buffer[shape_tensor->buffer]; + if (buf_data == nullptr) { + MS_LOG(ERROR) << "buf_data is null"; + return RET_NULL_PTR; + } + if (!buf_data->data.empty()) { + if (GetTfliteData(tflite_op->inputs[1], tflite_tensors, tflite_model_buffer, attr->shape)) { + MS_LOG(ERROR) << "get reshape -> shape failed"; + return RET_ERROR; + } } } else { attr->format = schema::Format_NHWC;