diff --git a/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_l2norm_parser_test.cc b/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_l2norm_parser_test.cc index 0fa8b0f6da40b72ca3f546bc93402627146187a4..675d8f82a70a483e4f2837d42e0cc9a87f6fc9e4 100644 --- a/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_l2norm_parser_test.cc +++ b/mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_l2norm_parser_test.cc @@ -27,6 +27,7 @@ class TestTfliteParserL2Norm : public TestTfliteParser { TEST_F(TestTfliteParserL2Norm, OpType) { ASSERT_NE(meta_graph, nullptr); ASSERT_GT(meta_graph->nodes.size(), 0); + ASSERT_NE(meta_graph->nodes.front()->primitive.get(), nullptr); ASSERT_EQ(meta_graph->nodes.front()->primitive->value.type, schema::PrimitiveType_L2Norm) << "wrong Op Type"; } 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 b5babf04ce9f0a24f3f42bc2c2cd66035333d810..0e495cfca45b15d6072542cc7c0709047ce5f448 100644 --- a/mindspore/lite/tools/converter/parser/tflite/tflite_activation_parser.cc +++ b/mindspore/lite/tools/converter/parser/tflite/tflite_activation_parser.cc @@ -38,7 +38,7 @@ STATUS TfliteActivationParser::Parse(const std::unique_ptr<tflite::OperatorT> &t MS_LOG(ERROR) << "op->primitive is null"; return RET_NULL_PTR; } - std::unique_ptr<schema::ActivationT> attr(new schema::ActivationT()); + std::unique_ptr<schema::ActivationT> attr = std::make_unique<schema::ActivationT>(); std::vector<std::string> node_name_str; Split(op->name, &node_name_str, "-"); @@ -89,7 +89,7 @@ STATUS TflitePreluParser::Parse(const std::unique_ptr<tflite::OperatorT> &tflite MS_LOG(ERROR) << "op->primitive is null"; return RET_NULL_PTR; } - std::unique_ptr<schema::PreluT> attr(new schema::PreluT()); + std::unique_ptr<schema::PreluT> attr = std::make_unique<schema::PreluT>(); if (GetTfliteData(tflite_op->inputs[1], tflite_tensors, tflite_model_buffer, attr->slope)) { MS_LOG(ERROR) << "get pRelu -> slope failed"; @@ -124,7 +124,7 @@ STATUS TfliteLeakyReluParser::Parse(const std::unique_ptr<tflite::OperatorT> &tf return RET_NULL_PTR; } - std::unique_ptr<schema::LeakyReLUT> attr(new schema::LeakyReLUT()); + std::unique_ptr<schema::LeakyReLUT> attr = std::make_unique<schema::LeakyReLUT>(); const auto &tflite_attr = tflite_op->builtin_options.AsLeakyReluOptions(); if (tflite_attr == nullptr) { diff --git a/mindspore/lite/tools/converter/parser/tflite/tflite_addn_parser.cc b/mindspore/lite/tools/converter/parser/tflite/tflite_addn_parser.cc index b88666fca93df4dbe539b75cb06fdc364cc7a33c..130e9eb53e29397080edaf6efa8697e2fa0b10da 100644 --- a/mindspore/lite/tools/converter/parser/tflite/tflite_addn_parser.cc +++ b/mindspore/lite/tools/converter/parser/tflite/tflite_addn_parser.cc @@ -42,7 +42,7 @@ STATUS TfliteAddNParser::Parse(const std::unique_ptr<tflite::OperatorT> &tflite_ return RET_NULL_PTR; } - std::unique_ptr<schema::AddNT> attr(new schema::AddNT()); + std::unique_ptr<schema::AddNT> attr = std::make_unique<schema::AddNT>(); attr->N = tflite_tensors.size() - 1; op->primitive->value.type = schema::PrimitiveType_AddN; diff --git a/mindspore/lite/tools/converter/parser/tflite/tflite_argmax_parser.cc b/mindspore/lite/tools/converter/parser/tflite/tflite_argmax_parser.cc index 1ccf2ea46513ac4bf15619c815f00d419de86931..d1aedeea20dd19380f5b692a1c98593e0c2aa5e2 100644 --- a/mindspore/lite/tools/converter/parser/tflite/tflite_argmax_parser.cc +++ b/mindspore/lite/tools/converter/parser/tflite/tflite_argmax_parser.cc @@ -40,7 +40,7 @@ STATUS TfliteArgmaxParser::Parse(const std::unique_ptr<tflite::OperatorT> &tflit return RET_NULL_PTR; } - std::unique_ptr<schema::ArgMaxT> attr(new schema::ArgMaxT()); + std::unique_ptr<schema::ArgMaxT> attr = std::make_unique<schema::ArgMaxT>(); attr->outMaxValue = false; attr->topK = 1; diff --git a/mindspore/lite/tools/converter/parser/tflite/tflite_argmin_parser.cc b/mindspore/lite/tools/converter/parser/tflite/tflite_argmin_parser.cc index 1ce77d5ebace0fa0a0fadbd3092fd1606d6f7896..998db501d9f643d41c023ef89a759455f204d600 100644 --- a/mindspore/lite/tools/converter/parser/tflite/tflite_argmin_parser.cc +++ b/mindspore/lite/tools/converter/parser/tflite/tflite_argmin_parser.cc @@ -40,7 +40,7 @@ STATUS TfliteArgminParser::Parse(const std::unique_ptr<tflite::OperatorT> &tflit return RET_NULL_PTR; } - std::unique_ptr<schema::ArgMinT> attr(new schema::ArgMinT()); + std::unique_ptr<schema::ArgMinT> attr = std::make_unique<schema::ArgMinT>(); attr->outMaxValue = false; attr->topK = 1; diff --git a/mindspore/lite/tools/converter/parser/tflite/tflite_arithmetic_parser.cc b/mindspore/lite/tools/converter/parser/tflite/tflite_arithmetic_parser.cc index 2ebaa61131da43222c519cbbd740c8ba33bead9f..914391c55618955b5c69a8625db87656d754b550 100644 --- a/mindspore/lite/tools/converter/parser/tflite/tflite_arithmetic_parser.cc +++ b/mindspore/lite/tools/converter/parser/tflite/tflite_arithmetic_parser.cc @@ -44,7 +44,7 @@ STATUS TfliteDoubleInputOpParser::Parse(const std::unique_ptr<tflite::OperatorT> const char *node_name = node_name_str.data()->c_str(); if (std::strcmp(node_name, "Add") == 0) { MS_LOG(DEBUG) << "parse TfliteAddParser"; - std::unique_ptr<schema::AddT> attr(new schema::AddT()); + std::unique_ptr<schema::AddT> attr = std::make_unique<schema::AddT>(); const auto &tfliteAttr = tflite_op->builtin_options.AsAddOptions(); if (nullptr == tfliteAttr) { MS_LOG(ERROR) << "get op: " << op->name.c_str() << " attr failed"; @@ -55,7 +55,7 @@ STATUS TfliteDoubleInputOpParser::Parse(const std::unique_ptr<tflite::OperatorT> op->primitive->value.value = attr.release(); } else if (std::strcmp(node_name, "Sub") == 0) { MS_LOG(DEBUG) << "parse TfliteSubParser"; - std::unique_ptr<schema::SubT> attr(new schema::SubT()); + std::unique_ptr<schema::SubT> attr = std::make_unique<schema::SubT>(); const auto &tfliteAttr = tflite_op->builtin_options.AsSubOptions(); if (nullptr == tfliteAttr) { MS_LOG(ERROR) << "get op: " << op->name.c_str() << " attr failed"; @@ -66,7 +66,7 @@ STATUS TfliteDoubleInputOpParser::Parse(const std::unique_ptr<tflite::OperatorT> op->primitive->value.value = attr.release(); } else if (std::strcmp(node_name, "Mul") == 0) { MS_LOG(DEBUG) << "parse TfliteMulParser"; - std::unique_ptr<schema::MulT> attr(new schema::MulT()); + std::unique_ptr<schema::MulT> attr = std::make_unique<schema::MulT>(); const auto &tfliteAttr = tflite_op->builtin_options.AsMulOptions(); if (nullptr == tfliteAttr) { MS_LOG(ERROR) << "get op: " << op->name.c_str() << " attr failed"; @@ -77,7 +77,7 @@ STATUS TfliteDoubleInputOpParser::Parse(const std::unique_ptr<tflite::OperatorT> op->primitive->value.value = attr.release(); } else if (std::strcmp(node_name, "Div") == 0) { MS_LOG(DEBUG) << "parse TfliteDivParser"; - std::unique_ptr<schema::DivT> attr(new schema::DivT()); + std::unique_ptr<schema::DivT> attr = std::make_unique<schema::DivT>(); const auto &tfliteAttr = tflite_op->builtin_options.AsDivOptions(); if (nullptr == tfliteAttr) { MS_LOG(ERROR) << "get op: " << op->name.c_str() << " attr failed"; @@ -88,27 +88,27 @@ STATUS TfliteDoubleInputOpParser::Parse(const std::unique_ptr<tflite::OperatorT> op->primitive->value.value = attr.release(); } else if (std::strcmp(node_name, "FloorDiv") == 0) { MS_LOG(DEBUG) << "parse TfliteFloorDivParser"; - std::unique_ptr<schema::FloorDivT> attr(new schema::FloorDivT()); + std::unique_ptr<schema::FloorDivT> attr = std::make_unique<schema::FloorDivT>(); op->primitive->value.type = schema::PrimitiveType_FloorDiv; op->primitive->value.value = attr.release(); } else if (std::strcmp(node_name, "FloorMod") == 0) { MS_LOG(DEBUG) << "parse TfliteFloorModParser"; - std::unique_ptr<schema::FloorModT> attr(new schema::FloorModT()); + std::unique_ptr<schema::FloorModT> attr = std::make_unique<schema::FloorModT>(); op->primitive->value.type = schema::PrimitiveType_FloorMod; op->primitive->value.value = attr.release(); } else if (std::strcmp(node_name, "RealDiv") == 0) { MS_LOG(DEBUG) << "parse TfliteRealDivParser"; - std::unique_ptr<schema::RealDivT> attr(new schema::RealDivT()); + std::unique_ptr<schema::RealDivT> attr = std::make_unique<schema::RealDivT>(); op->primitive->value.type = schema::PrimitiveType_Div; op->primitive->value.value = attr.release(); } else if (std::strcmp(node_name, "SquaredDifference") == 0) { MS_LOG(DEBUG) << "parse TfliteSquaredDifferenceParser"; - std::unique_ptr<schema::SquaredDifferenceT> attr(new schema::SquaredDifferenceT()); + std::unique_ptr<schema::SquaredDifferenceT> attr = std::make_unique<schema::SquaredDifferenceT>(); op->primitive->value.type = schema::PrimitiveType_SquaredDifference; op->primitive->value.value = attr.release(); } else if (std::strcmp(node_name, "Pow") == 0) { MS_LOG(DEBUG) << "parse TflitePowParser"; - std::unique_ptr<schema::PowerT> attr(new schema::PowerT()); + std::unique_ptr<schema::PowerT> attr = std::make_unique<schema::PowerT>(); attr->power = 0.0f; attr->scale = 1.0f; attr->shift = 0.0f; @@ -116,12 +116,12 @@ STATUS TfliteDoubleInputOpParser::Parse(const std::unique_ptr<tflite::OperatorT> op->primitive->value.value = attr.release(); } else if (std::strcmp(node_name, "Maximum") == 0) { MS_LOG(DEBUG) << "parse TfliteMaximumParser"; - std::unique_ptr<schema::MaximumT> attr(new schema::MaximumT()); + std::unique_ptr<schema::MaximumT> attr = std::make_unique<schema::MaximumT>(); op->primitive->value.type = schema::PrimitiveType_Maximum; op->primitive->value.value = attr.release(); } else if (std::strcmp(node_name, "Minimum") == 0) { MS_LOG(DEBUG) << "parse TfliteMinimumParser"; - std::unique_ptr<schema::MinimumT> attr(new schema::MinimumT()); + std::unique_ptr<schema::MinimumT> attr = std::make_unique<schema::MinimumT>(); op->primitive->value.type = schema::PrimitiveType_Minimum; op->primitive->value.value = attr.release(); } @@ -158,57 +158,57 @@ STATUS TfliteSingleInputOpParser::Parse(const std::unique_ptr<tflite::OperatorT> const char *node_name = node_name_str.data()->c_str(); if (std::strcmp(node_name, "Abs") == 0) { MS_LOG(DEBUG) << "parse TfliteAbsParser"; - std::unique_ptr<schema::AbsT> attr(new schema::AbsT()); + std::unique_ptr<schema::AbsT> attr = std::make_unique<schema::AbsT>(); op->primitive->value.type = schema::PrimitiveType_Abs; op->primitive->value.value = attr.release(); } else if (std::strcmp(node_name, "Exp") == 0) { MS_LOG(DEBUG) << "parse TfliteExpParser"; - std::unique_ptr<schema::ExpT> attr(new schema::ExpT()); + std::unique_ptr<schema::ExpT> attr = std::make_unique<schema::ExpT>(); op->primitive->value.type = schema::PrimitiveType_Exp; op->primitive->value.value = attr.release(); } else if (std::strcmp(node_name, "Sqrt") == 0) { MS_LOG(DEBUG) << "parse TfliteSqrtParser"; - std::unique_ptr<schema::SqrtT> attr(new schema::SqrtT()); + std::unique_ptr<schema::SqrtT> attr = std::make_unique<schema::SqrtT>(); op->primitive->value.type = schema::PrimitiveType_Sqrt; op->primitive->value.value = attr.release(); } else if (std::strcmp(node_name, "Rsqrt") == 0) { MS_LOG(DEBUG) << "parse TfliteRsqrtParser"; - std::unique_ptr<schema::RsqrtT> attr(new schema::RsqrtT()); + std::unique_ptr<schema::RsqrtT> attr = std::make_unique<schema::RsqrtT>(); op->primitive->value.type = schema::PrimitiveType_Rsqrt; op->primitive->value.value = attr.release(); } else if (std::strcmp(node_name, "Square") == 0) { MS_LOG(DEBUG) << "parse TfliteSquareParser"; - std::unique_ptr<schema::SquareT> attr(new schema::SquareT()); + std::unique_ptr<schema::SquareT> attr = std::make_unique<schema::SquareT>(); op->primitive->value.type = schema::PrimitiveType_Square; op->primitive->value.value = attr.release(); } else if (std::strcmp(node_name, "Sin") == 0) { MS_LOG(DEBUG) << "parse TfliteSinParser"; - std::unique_ptr<schema::SinT> attr(new schema::SinT()); + std::unique_ptr<schema::SinT> attr = std::make_unique<schema::SinT>(); op->primitive->value.type = schema::PrimitiveType_Sin; op->primitive->value.value = attr.release(); } else if (std::strcmp(node_name, "Cos") == 0) { MS_LOG(DEBUG) << "parse TfliteCosParser"; - std::unique_ptr<schema::CosT> attr(new schema::CosT()); + std::unique_ptr<schema::CosT> attr = std::make_unique<schema::CosT>(); op->primitive->value.type = schema::PrimitiveType_Cos; op->primitive->value.value = attr.release(); } else if (std::strcmp(node_name, "Log") == 0) { MS_LOG(DEBUG) << "parse TfliteLogParser"; - std::unique_ptr<schema::LogT> attr(new schema::LogT()); + std::unique_ptr<schema::LogT> attr = std::make_unique<schema::LogT>(); op->primitive->value.type = schema::PrimitiveType_Log; op->primitive->value.value = attr.release(); } else if (std::strcmp(node_name, "Round") == 0) { MS_LOG(DEBUG) << "parse TfliteRoundParser"; - std::unique_ptr<schema::RoundT> attr(new schema::RoundT()); + std::unique_ptr<schema::RoundT> attr = std::make_unique<schema::RoundT>(); op->primitive->value.type = schema::PrimitiveType_Round; op->primitive->value.value = attr.release(); } else if (std::strcmp(node_name, "Ceil") == 0) { MS_LOG(DEBUG) << "parse TfliteCeilParser"; - std::unique_ptr<schema::CeilT> attr(new schema::CeilT()); + std::unique_ptr<schema::CeilT> attr = std::make_unique<schema::CeilT>(); op->primitive->value.type = schema::PrimitiveType_Ceil; op->primitive->value.value = attr.release(); } else if (std::strcmp(node_name, "flOOR") == 0) { MS_LOG(DEBUG) << "parse TfliteFloorParser"; - std::unique_ptr<schema::FloorT> attr(new schema::FloorT()); + std::unique_ptr<schema::FloorT> attr = std::make_unique<schema::FloorT>(); op->primitive->value.type = schema::PrimitiveType_Floor; op->primitive->value.value = attr.release(); } @@ -242,32 +242,32 @@ STATUS TfliteCompareOpParser::Parse(const std::unique_ptr<tflite::OperatorT> &tf const char *node_name = node_name_str.data()->c_str(); if (std::strcmp(node_name, "Equal") == 0) { MS_LOG(DEBUG) << "parse TfliteEqualParser"; - std::unique_ptr<schema::EqualT> attr(new schema::EqualT()); + std::unique_ptr<schema::EqualT> attr = std::make_unique<schema::EqualT>(); op->primitive->value.type = schema::PrimitiveType_Equal; op->primitive->value.value = attr.release(); } else if (std::strcmp(node_name, "NotEqual") == 0) { MS_LOG(DEBUG) << "parse TfliteNotEqualParser"; - std::unique_ptr<schema::NotEqualT> attr(new schema::NotEqualT()); + std::unique_ptr<schema::NotEqualT> attr = std::make_unique<schema::NotEqualT>(); op->primitive->value.type = schema::PrimitiveType_NotEqual; op->primitive->value.value = attr.release(); } else if (std::strcmp(node_name, "Greater") == 0) { MS_LOG(DEBUG) << "parse TfliteGreaterParser"; - std::unique_ptr<schema::GreaterT> attr(new schema::GreaterT()); + std::unique_ptr<schema::GreaterT> attr = std::make_unique<schema::GreaterT>(); op->primitive->value.type = schema::PrimitiveType_Greater; op->primitive->value.value = attr.release(); } else if (std::strcmp(node_name, "GreaterEqual") == 0) { MS_LOG(DEBUG) << "parse TfliteGreaterEqualParser"; - std::unique_ptr<schema::GreaterEqualT> attr(new schema::GreaterEqualT()); + std::unique_ptr<schema::GreaterEqualT> attr = std::make_unique<schema::GreaterEqualT>(); op->primitive->value.type = schema::PrimitiveType_GreaterEqual; op->primitive->value.value = attr.release(); } else if (std::strcmp(node_name, "Less") == 0) { MS_LOG(DEBUG) << "parse TfliteLessParser"; - std::unique_ptr<schema::LessT> attr(new schema::LessT()); + std::unique_ptr<schema::LessT> attr = std::make_unique<schema::LessT>(); op->primitive->value.type = schema::PrimitiveType_Less; op->primitive->value.value = attr.release(); } else if (std::strcmp(node_name, "LessEqual") == 0) { MS_LOG(DEBUG) << "parse TfliteLessEqualParser"; - std::unique_ptr<schema::LessEqualT> attr(new schema::LessEqualT()); + std::unique_ptr<schema::LessEqualT> attr = std::make_unique<schema::LessEqualT>(); op->primitive->value.type = schema::PrimitiveType_LessEqual; op->primitive->value.value = attr.release(); } diff --git a/mindspore/lite/tools/converter/parser/tflite/tflite_batch_to_space_parser.cc b/mindspore/lite/tools/converter/parser/tflite/tflite_batch_to_space_parser.cc index 3c490ac4e44cb67612782aca041c7cc0c3db6189..adc8f2f105f8f160250e1ffa633d4685caaa857e 100644 --- a/mindspore/lite/tools/converter/parser/tflite/tflite_batch_to_space_parser.cc +++ b/mindspore/lite/tools/converter/parser/tflite/tflite_batch_to_space_parser.cc @@ -49,7 +49,7 @@ STATUS TfliteBatchToSpaceParser::Parse(const std::unique_ptr<tflite::OperatorT> MS_LOG(DEBUG) << "parse TfliteBatchToSpaceNDParser"; } - std::unique_ptr<schema::BatchToSpaceT> attr(new schema::BatchToSpaceT()); + std::unique_ptr<schema::BatchToSpaceT> attr = std::make_unique<schema::BatchToSpaceT>(); if (GetTfliteData(tflite_op->inputs[1], tflite_tensors, tflite_model_buffer, attr->blockShape)) { MS_LOG(ERROR) << "get batchToSpace -> blockShape failed"; diff --git a/mindspore/lite/tools/converter/parser/tflite/tflite_broadcast_to_parser.cc b/mindspore/lite/tools/converter/parser/tflite/tflite_broadcast_to_parser.cc index 199aff567b2a2a90efcd08d9b1541ab953e0247b..0a4d36decb368ed20b17adf17cd6a139897fa908 100644 --- a/mindspore/lite/tools/converter/parser/tflite/tflite_broadcast_to_parser.cc +++ b/mindspore/lite/tools/converter/parser/tflite/tflite_broadcast_to_parser.cc @@ -41,7 +41,7 @@ STATUS TfliteBroadcastToParser::Parse(const std::unique_ptr<tflite::OperatorT> & return RET_NULL_PTR; } - std::unique_ptr<schema::BroadcastToT> attr(new schema::BroadcastToT()); + std::unique_ptr<schema::BroadcastToT> attr = std::make_unique<schema::BroadcastToT>(); if (GetTfliteData(tflite_op->inputs[1], tflite_tensors, tflite_model_buffer, attr->dst_shape)) { MS_LOG(ERROR) << "get broadCastTo -> dst_shape failed"; diff --git a/mindspore/lite/tools/converter/parser/tflite/tflite_cast_parser.cc b/mindspore/lite/tools/converter/parser/tflite/tflite_cast_parser.cc index ee5120ddec8b71a747b7e048fb44392c59e3eef3..7ff446973e255fad939a7f346e008f419302dd4b 100644 --- a/mindspore/lite/tools/converter/parser/tflite/tflite_cast_parser.cc +++ b/mindspore/lite/tools/converter/parser/tflite/tflite_cast_parser.cc @@ -40,7 +40,7 @@ STATUS TfliteCastParser::Parse(const std::unique_ptr<tflite::OperatorT> &tflite_ return RET_NULL_PTR; } - std::unique_ptr<schema::CastT> attr(new schema::CastT()); + std::unique_ptr<schema::CastT> attr = std::make_unique<schema::CastT>(); const auto &in_tensor = tflite_tensors[tflite_op->inputs[0]]; if (in_tensor == nullptr) { diff --git a/mindspore/lite/tools/converter/parser/tflite/tflite_concat_parser.cc b/mindspore/lite/tools/converter/parser/tflite/tflite_concat_parser.cc index 86c4d98b89af1483dbcc74ed75b48799453bf7bc..cc17a473d2819c6cf6142c4980e7479b7d508b50 100644 --- a/mindspore/lite/tools/converter/parser/tflite/tflite_concat_parser.cc +++ b/mindspore/lite/tools/converter/parser/tflite/tflite_concat_parser.cc @@ -41,7 +41,7 @@ STATUS TfliteConcatParser::Parse(const std::unique_ptr<tflite::OperatorT> &tflit return RET_NULL_PTR; } - std::unique_ptr<schema::ConcatT> attr(new schema::ConcatT()); + std::unique_ptr<schema::ConcatT> attr = std::make_unique<schema::ConcatT>(); const auto &tfliteAttr = tflite_op->builtin_options.AsConcatenationOptions(); if (tfliteAttr == nullptr) { diff --git a/mindspore/lite/tools/converter/parser/tflite/tflite_conv_parser.cc b/mindspore/lite/tools/converter/parser/tflite/tflite_conv_parser.cc index 8de26527b25eda674a34396142f8b776b768a57c..fec5f76d5a236229125cc5dde59449f5be1d475e 100644 --- a/mindspore/lite/tools/converter/parser/tflite/tflite_conv_parser.cc +++ b/mindspore/lite/tools/converter/parser/tflite/tflite_conv_parser.cc @@ -40,7 +40,7 @@ STATUS TfliteConvParser::Parse(const std::unique_ptr<tflite::OperatorT> &tflite_ return RET_NULL_PTR; } - std::unique_ptr<schema::Conv2DT> attr(new schema::Conv2DT()); + std::unique_ptr<schema::Conv2DT> attr = std::make_unique<schema::Conv2DT>(); const auto &tflite_attr = tflite_op->builtin_options.AsConv2DOptions(); if (tflite_attr == nullptr) { MS_LOG(ERROR) << "get op: " << op->name.c_str() << " attr failed"; diff --git a/mindspore/lite/tools/converter/parser/tflite/tflite_deconv_parser.cc b/mindspore/lite/tools/converter/parser/tflite/tflite_deconv_parser.cc index 565bceb8a453f396d8507bd020889beae3a09348..cf9d55d830a58774b1bc13c7142da2832e1676a7 100644 --- a/mindspore/lite/tools/converter/parser/tflite/tflite_deconv_parser.cc +++ b/mindspore/lite/tools/converter/parser/tflite/tflite_deconv_parser.cc @@ -40,7 +40,7 @@ STATUS TfliteDeConvParser::Parse(const std::unique_ptr<tflite::OperatorT> &tflit return RET_NULL_PTR; } - std::unique_ptr<schema::DeConv2DT> attr(new schema::DeConv2DT()); + std::unique_ptr<schema::DeConv2DT> attr = std::make_unique<schema::DeConv2DT>(); const auto &tflite_attr = tflite_op->builtin_options.AsTransposeConvOptions(); if (tflite_attr == nullptr) { MS_LOG(ERROR) << "get op: " << op->name.c_str() << " attr failed"; diff --git a/mindspore/lite/tools/converter/parser/tflite/tflite_depth_to_space_parser.cc b/mindspore/lite/tools/converter/parser/tflite/tflite_depth_to_space_parser.cc index b8fceaed9a716a822b3a7c5776af6f72710f6c45..d37f17ed3b075107149be1e230a027fc98b5fd04 100644 --- a/mindspore/lite/tools/converter/parser/tflite/tflite_depth_to_space_parser.cc +++ b/mindspore/lite/tools/converter/parser/tflite/tflite_depth_to_space_parser.cc @@ -41,7 +41,7 @@ STATUS TfliteDepthToSpaceParser::Parse(const std::unique_ptr<tflite::OperatorT> return RET_NULL_PTR; } - std::unique_ptr<schema::DepthToSpaceT> attr(new schema::DepthToSpaceT()); + std::unique_ptr<schema::DepthToSpaceT> attr = std::make_unique<schema::DepthToSpaceT>(); const auto &tflite_attr = tflite_op->builtin_options.AsDepthToSpaceOptions(); if (tflite_attr == nullptr) { diff --git a/mindspore/lite/tools/converter/parser/tflite/tflite_depthwise_conv_parser.cc b/mindspore/lite/tools/converter/parser/tflite/tflite_depthwise_conv_parser.cc index 5ebe2583730dbd0989b97da777b1f009f0f2e8ef..f6ff3eab71122f61cd58655baa6f6c2e7c74cbcd 100644 --- a/mindspore/lite/tools/converter/parser/tflite/tflite_depthwise_conv_parser.cc +++ b/mindspore/lite/tools/converter/parser/tflite/tflite_depthwise_conv_parser.cc @@ -41,7 +41,7 @@ STATUS TfliteDepthwiseConv2DParser::Parse(const std::unique_ptr<tflite::Operator return RET_NULL_PTR; } - std::unique_ptr<schema::DepthwiseConv2DT> attr(new schema::DepthwiseConv2DT()); + std::unique_ptr<schema::DepthwiseConv2DT> attr = std::make_unique<schema::DepthwiseConv2DT>(); const auto &tflite_attr = tflite_op->builtin_options.AsDepthwiseConv2DOptions(); if (tflite_attr == nullptr) { MS_LOG(ERROR) << "get op: " << op->name.c_str() << " attr failed"; diff --git a/mindspore/lite/tools/converter/parser/tflite/tflite_dequantize_parser.cc b/mindspore/lite/tools/converter/parser/tflite/tflite_dequantize_parser.cc index 5854166fd326e7b6dc25a8bd56b55fa9d4e28c79..3e7f4129cb886c2c80c51f3cb2753782d2f5a678 100644 --- a/mindspore/lite/tools/converter/parser/tflite/tflite_dequantize_parser.cc +++ b/mindspore/lite/tools/converter/parser/tflite/tflite_dequantize_parser.cc @@ -40,7 +40,7 @@ STATUS TfliteDequantizeParser::Parse(const std::unique_ptr<tflite::OperatorT> &t return RET_NULL_PTR; } - std::unique_ptr<schema::CastT> attr(new schema::CastT); + std::unique_ptr<schema::CastT> attr = std::make_unique<schema::CastT>(); // get the dequantize input tensor const auto &in_tensor = tflite_tensors[tflite_op->inputs[0]]; diff --git a/mindspore/lite/tools/converter/parser/tflite/tflite_expand_dims_parser.cc b/mindspore/lite/tools/converter/parser/tflite/tflite_expand_dims_parser.cc index 0d3c91528f99c0a5b2c5958fa2bf192f0bdc06ea..191c3bff9847fabdd189239a7429e9dbb12b785f 100644 --- a/mindspore/lite/tools/converter/parser/tflite/tflite_expand_dims_parser.cc +++ b/mindspore/lite/tools/converter/parser/tflite/tflite_expand_dims_parser.cc @@ -28,6 +28,8 @@ STATUS TfliteExpandDimsParser::Parse(const std::unique_ptr<tflite::OperatorT> &t std::vector<int32_t> *tensors_id, std::vector<schema::Format> *tensors_format, std::map<int, int> *tensors_id_map) { + MS_LOG(DEBUG) << "parse TfliteExpandDimsParser"; + if (op == nullptr) { MS_LOG(ERROR) << "op is null"; return RET_NULL_PTR; @@ -38,8 +40,7 @@ STATUS TfliteExpandDimsParser::Parse(const std::unique_ptr<tflite::OperatorT> &t return RET_NULL_PTR; } - MS_LOG(DEBUG) << "parse TfliteExpandDimsParser"; - std::unique_ptr<schema::ExpandDimsT> attr(new schema::ExpandDimsT()); + std::unique_ptr<schema::ExpandDimsT> attr = std::make_unique<schema::ExpandDimsT>(); const auto &tflite_attr = tflite_op->builtin_options.AsExpandDimsOptions(); if (tflite_attr == nullptr) { diff --git a/mindspore/lite/tools/converter/parser/tflite/tflite_fill_parser.cc b/mindspore/lite/tools/converter/parser/tflite/tflite_fill_parser.cc index 70405dbf1e1a7887230f17cc96a578e0c3b4bd3b..a563bcc7c738cc03fe65ee32c76ca92a4a5ecb64 100644 --- a/mindspore/lite/tools/converter/parser/tflite/tflite_fill_parser.cc +++ b/mindspore/lite/tools/converter/parser/tflite/tflite_fill_parser.cc @@ -40,7 +40,7 @@ STATUS TfliteFillParser::Parse(const std::unique_ptr<tflite::OperatorT> &tflite_ return RET_NULL_PTR; } - std::unique_ptr<schema::FillT> attr(new schema::FillT()); + std::unique_ptr<schema::FillT> attr = std::make_unique<schema::FillT>(); if (tflite_op->inputs.size() > 1) { if (GetTfliteData(tflite_op->inputs[1], tflite_tensors, tflite_model_buffer, attr->dims)) { diff --git a/mindspore/lite/tools/converter/parser/tflite/tflite_fullyconnected_parser.cc b/mindspore/lite/tools/converter/parser/tflite/tflite_fullyconnected_parser.cc index f84bff6bdf71ef644d6af39ea8cc41b9cc600fcd..447fb7ae74f5c93ee99c071ab65fec04bc4d3bb8 100644 --- a/mindspore/lite/tools/converter/parser/tflite/tflite_fullyconnected_parser.cc +++ b/mindspore/lite/tools/converter/parser/tflite/tflite_fullyconnected_parser.cc @@ -47,7 +47,7 @@ STATUS TfliteFullyConnectedParser::Parse(const std::unique_ptr<tflite::OperatorT } else if (std::strcmp(node_name, "FakeQuant") == 0) { MS_LOG(DEBUG) << "parse TfliteFakeQuantParser"; } - std::unique_ptr<schema::FullConnectionT> attr(new schema::FullConnectionT()); + std::unique_ptr<schema::FullConnectionT> attr = std::make_unique<schema::FullConnectionT>(); const auto &tflite_attr = tflite_op->builtin_options.AsFullyConnectedOptions(); if (tflite_attr == nullptr) { @@ -55,7 +55,9 @@ STATUS TfliteFullyConnectedParser::Parse(const std::unique_ptr<tflite::OperatorT return RET_NULL_PTR; } - attr->hasBias = true; + bool hasBias = tflite_op->inputs.size() > 2 && tflite_op->inputs[2] != -1; + + attr->hasBias = hasBias; attr->axis = 1; attr->useAxis = false; attr->activationType = GetActivationFunctionType(tflite_attr->fused_activation_function); @@ -67,8 +69,10 @@ STATUS TfliteFullyConnectedParser::Parse(const std::unique_ptr<tflite::OperatorT tflite_op->inputs[0], tensors_id->size(), tflite_tensors.size(), schema::Format_NHWC); AddOpInput(op, tensors_id, tensors_format, tensors_id_map, tflite_op->inputs[1], tensors_id->size(), tflite_tensors.size(), schema::Format_KHWC); - AddOpInput(op, tensors_id, tensors_format, tensors_id_map, - tflite_op->inputs[2], tensors_id->size(), tflite_tensors.size(), schema::Format_NHWC); + if (hasBias) { + AddOpInput(op, tensors_id, tensors_format, tensors_id_map, + tflite_op->inputs[2], tensors_id->size(), tflite_tensors.size(), schema::Format_NHWC); + } AddOpOutput(op, tensors_id, tensors_format, tensors_id_map, tflite_op->outputs[0], tensors_id->size(), tflite_tensors.size(), schema::Format_NHWC); return RET_OK; diff --git a/mindspore/lite/tools/converter/parser/tflite/tflite_gather_nd_parser.cc b/mindspore/lite/tools/converter/parser/tflite/tflite_gather_nd_parser.cc index e8218bb4318216f0caf7246077bdf57260d937a0..d9f9b6815214eb617b20473647c74075feaeea16 100644 --- a/mindspore/lite/tools/converter/parser/tflite/tflite_gather_nd_parser.cc +++ b/mindspore/lite/tools/converter/parser/tflite/tflite_gather_nd_parser.cc @@ -40,7 +40,7 @@ STATUS TfliteGatherNdParser::Parse(const std::unique_ptr<tflite::OperatorT> &tfl return RET_NULL_PTR; } - std::unique_ptr<schema::GatherNdT> attr(new schema::GatherNdT()); + std::unique_ptr<schema::GatherNdT> attr = std::make_unique<schema::GatherNdT>(); attr->batchDims = 0; op->primitive->value.type = schema::PrimitiveType_GatherNd; diff --git a/mindspore/lite/tools/converter/parser/tflite/tflite_gather_parser.cc b/mindspore/lite/tools/converter/parser/tflite/tflite_gather_parser.cc index cf388e94d89128678f764d9f689f06a57600ca2d..662c5c5c847c671389b518153b4ee5e4a09e231e 100644 --- a/mindspore/lite/tools/converter/parser/tflite/tflite_gather_parser.cc +++ b/mindspore/lite/tools/converter/parser/tflite/tflite_gather_parser.cc @@ -41,7 +41,7 @@ STATUS TfliteGatherParser::Parse(const std::unique_ptr<tflite::OperatorT> &tflit return RET_NULL_PTR; } - std::unique_ptr<schema::GatherT> attr(new schema::GatherT()); + std::unique_ptr<schema::GatherT> attr = std::make_unique<schema::GatherT>(); const auto &tflite_attr = tflite_op->builtin_options.AsGatherOptions(); if (tflite_attr == nullptr) { 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 8ef185d907499e30cc67504d5655ae1ca9a07124..b66f59a7cd4c11bfd1a0e76b55aa93e24914260f 100644 --- a/mindspore/lite/tools/converter/parser/tflite/tflite_l2norm_parser.cc +++ b/mindspore/lite/tools/converter/parser/tflite/tflite_l2norm_parser.cc @@ -42,8 +42,16 @@ STATUS TfliteL2NormParser::Parse(const std::unique_ptr<tflite::OperatorT> &tflit return RET_NULL_PTR; } - std::unique_ptr<schema::L2NormT> attr(new schema::L2NormT()); + std::unique_ptr<schema::L2NormT> attr = std::make_unique<schema::L2NormT>(); + if (tflite_op->inputs.empty()) { + MS_LOG(ERROR) << "the input is null"; + return RET_NULL_PTR; + } auto data_index = tflite_op->inputs[0]; + if (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_logical_parser.cc b/mindspore/lite/tools/converter/parser/tflite/tflite_logical_parser.cc index c6677327664e92d4a1cd5b1ea6021b573b74635d..7c755c54e4c201da0b0e945f1642cadd5fc85f90 100644 --- a/mindspore/lite/tools/converter/parser/tflite/tflite_logical_parser.cc +++ b/mindspore/lite/tools/converter/parser/tflite/tflite_logical_parser.cc @@ -44,17 +44,17 @@ STATUS TfliteLogicalParser::Parse(const std::unique_ptr<tflite::OperatorT> &tfli const char *node_name = node_name_str.data()->c_str(); if (std::strcmp(node_name, "LogicalAnd") == 0) { MS_LOG(DEBUG) << "parse TfliteLogicalAndParser"; - std::unique_ptr<schema::LogicalAndT> attr(new schema::LogicalAndT()); + std::unique_ptr<schema::LogicalAndT> attr = std::make_unique<schema::LogicalAndT>(); op->primitive->value.type = schema::PrimitiveType_LogicalAnd; op->primitive->value.value = attr.release(); } else if (std::strcmp(node_name, "LogicalNot") == 0) { MS_LOG(DEBUG) << "parse TfliteLogicalNotParser"; - std::unique_ptr<schema::LogicalNotT> attr(new schema::LogicalNotT()); + std::unique_ptr<schema::LogicalNotT> attr = std::make_unique<schema::LogicalNotT>(); op->primitive->value.type = schema::PrimitiveType_LogicalNot; op->primitive->value.value = attr.release(); } else if (std::strcmp(node_name, "LogicalOr") == 0) { MS_LOG(DEBUG) << "parse TfliteLogicalOrParser"; - std::unique_ptr<schema::LogicalOrT> attr(new schema::LogicalOrT()); + std::unique_ptr<schema::LogicalOrT> attr = std::make_unique<schema::LogicalOrT>(); op->primitive->value.type = schema::PrimitiveType_LogicalOr; op->primitive->value.value = attr.release(); } diff --git a/mindspore/lite/tools/converter/parser/tflite/tflite_lrn_parser.cc b/mindspore/lite/tools/converter/parser/tflite/tflite_lrn_parser.cc index 8986729d72ec9f15003ded0961522fa3808bbaa8..d47f6f7fbed209e9443f02cda1352ad67e1c338a 100644 --- a/mindspore/lite/tools/converter/parser/tflite/tflite_lrn_parser.cc +++ b/mindspore/lite/tools/converter/parser/tflite/tflite_lrn_parser.cc @@ -41,7 +41,7 @@ STATUS TfliteLRNParser::Parse(const std::unique_ptr<tflite::OperatorT> &tflite_o return RET_NULL_PTR; } - std::unique_ptr<schema::LocalResponseNormalizationT> attr(new schema::LocalResponseNormalizationT()); + std::unique_ptr<schema::LocalResponseNormalizationT> attr = std::make_unique<schema::LocalResponseNormalizationT>(); const auto &tflite_attr = tflite_op->builtin_options.AsLocalResponseNormalizationOptions(); if (tflite_attr == nullptr) { 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 2e6d754184edc92ff28990bacdebc69921ac5b98..452f44d84d730702c802605bac7d6edaddcd988f 100644 --- a/mindspore/lite/tools/converter/parser/tflite/tflite_model_parser.cc +++ b/mindspore/lite/tools/converter/parser/tflite/tflite_model_parser.cc @@ -43,7 +43,8 @@ std::unique_ptr<tflite::ModelT> TfliteModelParser::ReadTfliteModel(const char *m } STATUS TfliteModelParser::CopyConstTensorData(const std::vector<std::unique_ptr<tflite::BufferT>> &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)); @@ -91,7 +92,8 @@ void TfliteModelParser::SetTensorQuantParam(const std::unique_ptr<tflite::Tensor STATUS TfliteModelParser::ConvertOp(const std::unique_ptr<tflite::ModelT> &tflite_model, const std::unique_ptr<tflite::SubGraphT> &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; @@ -293,7 +295,8 @@ STATUS TfliteModelParser::ConvertGroupDepthwiseOp(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<schema::MetaGraphT> sub_graph(new schema::MetaGraphT); sub_graph->name = "MS_model converted by TF-Lite"; diff --git a/mindspore/lite/tools/converter/parser/tflite/tflite_model_parser.h b/mindspore/lite/tools/converter/parser/tflite/tflite_model_parser.h index 833ef1cbec91b5c881e0c4cb24e803046c0b2f8f..2d95500213b29cbee9fe1f02758e90e14fb11829 100644 --- a/mindspore/lite/tools/converter/parser/tflite/tflite_model_parser.h +++ b/mindspore/lite/tools/converter/parser/tflite/tflite_model_parser.h @@ -58,14 +58,14 @@ class TfliteModelParser : public ModelParser { STATUS ConvertOp(const std::unique_ptr<tflite::ModelT> &tflite_model, const std::unique_ptr<tflite::SubGraphT> &tflite_subgraph, const QuantType &quant_type, - schema::MetaGraphT* sub_graph); + schema::MetaGraphT *sub_graph); STATUS ConvertTensor(const std::unique_ptr<tflite::SubGraphT> &tflite_subgraph, const std::vector<std::unique_ptr<tflite::BufferT>> &tflite_model_buffer, - schema::MetaGraphT* sub_graph); + schema::MetaGraphT *sub_graph); STATUS GetGraphInfo(const std::unique_ptr<tflite::SubGraphT> &tflite_subgraph, - schema::MetaGraphT* sub_graph); + schema::MetaGraphT *sub_graph); STATUS ConvertGroupDepthwiseOp(schema::MetaGraphT* sub_graph); diff --git a/mindspore/lite/tools/converter/parser/tflite/tflite_one_hot_parser.cc b/mindspore/lite/tools/converter/parser/tflite/tflite_one_hot_parser.cc index 4f8b7261611b5eb465400ebabb52b3ffcf186a20..71cc518c6f664a9539957b52b198aabeaafe90d0 100644 --- a/mindspore/lite/tools/converter/parser/tflite/tflite_one_hot_parser.cc +++ b/mindspore/lite/tools/converter/parser/tflite/tflite_one_hot_parser.cc @@ -40,7 +40,7 @@ STATUS TfliteOneHotParser::Parse(const std::unique_ptr<tflite::OperatorT> &tflit return RET_NULL_PTR; } - std::unique_ptr<schema::OneHotT> attr(new schema::OneHotT()); + std::unique_ptr<schema::OneHotT> attr = std::make_unique<schema::OneHotT>(); const auto &tflite_attr = tflite_op->builtin_options.AsOneHotOptions(); if (tflite_attr == nullptr) { diff --git a/mindspore/lite/tools/converter/parser/tflite/tflite_pad_parser.cc b/mindspore/lite/tools/converter/parser/tflite/tflite_pad_parser.cc index db828d1fcf156b5f4e28dab745da94dabc45f4ca..7a09b81a700b7e904cbd1f7e020b7f87b1216044 100644 --- a/mindspore/lite/tools/converter/parser/tflite/tflite_pad_parser.cc +++ b/mindspore/lite/tools/converter/parser/tflite/tflite_pad_parser.cc @@ -40,7 +40,7 @@ STATUS TflitePadParser::Parse(const std::unique_ptr<tflite::OperatorT> &tflite_o return RET_NULL_PTR; } - std::unique_ptr<schema::PadT> attr(new schema::PadT()); + std::unique_ptr<schema::PadT> attr = std::make_unique<schema::PadT>(); const auto &tflite_attr = tflite_op->builtin_options.AsPadOptions(); if (tflite_attr == nullptr) { diff --git a/mindspore/lite/tools/converter/parser/tflite/tflite_pooling_parser.cc b/mindspore/lite/tools/converter/parser/tflite/tflite_pooling_parser.cc index 1d7db44adb5f9371281ad132c657b59696095fc1..8a33f4a720d35ae4edf1e1b0afb96c07212ee291 100644 --- a/mindspore/lite/tools/converter/parser/tflite/tflite_pooling_parser.cc +++ b/mindspore/lite/tools/converter/parser/tflite/tflite_pooling_parser.cc @@ -39,7 +39,7 @@ STATUS TflitePoolingParser::Parse(const std::unique_ptr<tflite::OperatorT> &tfli return RET_NULL_PTR; } - std::unique_ptr<schema::PoolingT> attr(new schema::PoolingT()); + std::unique_ptr<schema::PoolingT> attr = std::make_unique<schema::PoolingT>(); std::vector<std::string> node_name_str; Split(op->name, &node_name_str, "-"); diff --git a/mindspore/lite/tools/converter/parser/tflite/tflite_range_parser.cc b/mindspore/lite/tools/converter/parser/tflite/tflite_range_parser.cc index 519b5c243ba590b2e25dde1ffdcc867012f293bc..9a33a174dee327d3e969c1068f4e4a1e14d489a9 100644 --- a/mindspore/lite/tools/converter/parser/tflite/tflite_range_parser.cc +++ b/mindspore/lite/tools/converter/parser/tflite/tflite_range_parser.cc @@ -40,7 +40,7 @@ STATUS TfliteRangeParser::Parse(const std::unique_ptr<tflite::OperatorT> &tflite return RET_NULL_PTR; } - std::unique_ptr<schema::RangeT> attr(new schema::RangeT()); + std::unique_ptr<schema::RangeT> attr = std::make_unique<schema::RangeT>(); attr->dType = 0; // attr->start diff --git a/mindspore/lite/tools/converter/parser/tflite/tflite_rank_parser.cc b/mindspore/lite/tools/converter/parser/tflite/tflite_rank_parser.cc index d4fcac5371ce1a9dba573adac517cc16af1ebd02..4a135a5bb1edb92c7b56815255886275cdf9e1d0 100644 --- a/mindspore/lite/tools/converter/parser/tflite/tflite_rank_parser.cc +++ b/mindspore/lite/tools/converter/parser/tflite/tflite_rank_parser.cc @@ -40,7 +40,7 @@ STATUS TfliteRankParser::Parse(const std::unique_ptr<tflite::OperatorT> &tflite_ return RET_NULL_PTR; } - std::unique_ptr<schema::RankT> attr(new schema::RankT()); + std::unique_ptr<schema::RankT> attr = std::make_unique<schema::RankT>(); op->primitive->value.type = schema::PrimitiveType_Rank; op->primitive->value.value = attr.release(); diff --git a/mindspore/lite/tools/converter/parser/tflite/tflite_reduce_parser.cc b/mindspore/lite/tools/converter/parser/tflite/tflite_reduce_parser.cc index 690ec75fd344bb79cf59d5c78768d43c618bd3d5..b9dc8e9da7fd0235e26eb7b38b1adafee7b5a13f 100644 --- a/mindspore/lite/tools/converter/parser/tflite/tflite_reduce_parser.cc +++ b/mindspore/lite/tools/converter/parser/tflite/tflite_reduce_parser.cc @@ -40,7 +40,7 @@ STATUS TfliteReduceParser::Parse(const std::unique_ptr<tflite::OperatorT> &tflit return RET_NULL_PTR; } - std::unique_ptr<schema::ReduceT> attr(new schema::ReduceT()); + std::unique_ptr<schema::ReduceT> attr = std::make_unique<schema::ReduceT>(); // auto tflite_tensors = tflite_subgraph->tensors; const auto &tflite_attr = tflite_op->builtin_options.AsReducerOptions(); 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 3aa06063dc6d23384633e6ed62faa2489a28039d..626383532d0f65b31bb258311765c42764c43f18 100644 --- a/mindspore/lite/tools/converter/parser/tflite/tflite_reshape_parser.cc +++ b/mindspore/lite/tools/converter/parser/tflite/tflite_reshape_parser.cc @@ -40,7 +40,7 @@ STATUS TfliteReshapeParser::Parse(const std::unique_ptr<tflite::OperatorT> &tfli return RET_NULL_PTR; } - std::unique_ptr<schema::ReshapeT> attr(new schema::ReshapeT()); + std::unique_ptr<schema::ReshapeT> attr = std::make_unique<schema::ReshapeT>(); const auto &tfliteAttr = tflite_op->builtin_options.AsReshapeOptions(); if (tfliteAttr == nullptr) { diff --git a/mindspore/lite/tools/converter/parser/tflite/tflite_resize_parser.cc b/mindspore/lite/tools/converter/parser/tflite/tflite_resize_parser.cc index 3c5516b49744f83b6d9f8aecc88bcf413078b119..0fc846465911ea8612bde46881012944f671cd75 100644 --- a/mindspore/lite/tools/converter/parser/tflite/tflite_resize_parser.cc +++ b/mindspore/lite/tools/converter/parser/tflite/tflite_resize_parser.cc @@ -39,7 +39,7 @@ STATUS TfliteResizeParser::Parse(const std::unique_ptr<tflite::OperatorT> &tflit return RET_NULL_PTR; } - std::unique_ptr<schema::ResizeT> attr(new schema::ResizeT()); + std::unique_ptr<schema::ResizeT> attr = std::make_unique<schema::ResizeT>(); std::vector<std::string> node_name_str; Split(op->name.data(), &node_name_str, "-"); diff --git a/mindspore/lite/tools/converter/parser/tflite/tflite_reverse_parser.cc b/mindspore/lite/tools/converter/parser/tflite/tflite_reverse_parser.cc index 7e449a3588a903d3e2949d38e871ab3e152306f3..cfcabbd5a33a451251a7cb221ba642d5e23ff1fd 100644 --- a/mindspore/lite/tools/converter/parser/tflite/tflite_reverse_parser.cc +++ b/mindspore/lite/tools/converter/parser/tflite/tflite_reverse_parser.cc @@ -40,7 +40,7 @@ STATUS TfliteReverseParser::Parse(const std::unique_ptr<tflite::OperatorT> &tfli return RET_NULL_PTR; } - std::unique_ptr<schema::ReverseT> attr(new schema::ReverseT()); + std::unique_ptr<schema::ReverseT> attr = std::make_unique<schema::ReverseT>(); if (GetTfliteData(tflite_op->inputs[1], tflite_tensors, tflite_model_buffer, attr->axis)) { MS_LOG(ERROR) << "get reverse -> axis failed"; diff --git a/mindspore/lite/tools/converter/parser/tflite/tflite_reverse_sequence_parser.cc b/mindspore/lite/tools/converter/parser/tflite/tflite_reverse_sequence_parser.cc index 3d996a4feff725469390d3dcd9691ab7b7007c06..da7b4f8ae857c8be6888379a3bd4dfb5cce6aa96 100644 --- a/mindspore/lite/tools/converter/parser/tflite/tflite_reverse_sequence_parser.cc +++ b/mindspore/lite/tools/converter/parser/tflite/tflite_reverse_sequence_parser.cc @@ -42,7 +42,7 @@ STATUS TfliteReverseSequenceParser::Parse(const std::unique_ptr<tflite::Operator return RET_NULL_PTR; } - std::unique_ptr<schema::ReverseSequenceT> attr(new schema::ReverseSequenceT()); + std::unique_ptr<schema::ReverseSequenceT> attr = std::make_unique<schema::ReverseSequenceT>(); const auto &tflite_attr = tflite_op->builtin_options.AsReverseSequenceOptions(); if (tflite_attr == nullptr) { diff --git a/mindspore/lite/tools/converter/parser/tflite/tflite_scatter_nd_parser.cc b/mindspore/lite/tools/converter/parser/tflite/tflite_scatter_nd_parser.cc index 39568e47105060ec3865f0831019fb45fd460825..535ef54e8b142de0dace41553e2bac066b8e7153 100644 --- a/mindspore/lite/tools/converter/parser/tflite/tflite_scatter_nd_parser.cc +++ b/mindspore/lite/tools/converter/parser/tflite/tflite_scatter_nd_parser.cc @@ -41,7 +41,7 @@ STATUS TfliteScatterNdParser::Parse(const std::unique_ptr<tflite::OperatorT> &tf return RET_NULL_PTR; } - std::unique_ptr<schema::ScatterNDT> attr(new schema::ScatterNDT()); + std::unique_ptr<schema::ScatterNDT> attr = std::make_unique<schema::ScatterNDT>(); const auto &tflite_attr = tflite_op->builtin_options.AsScatterNdOptions(); if (tflite_attr == nullptr) { diff --git a/mindspore/lite/tools/converter/parser/tflite/tflite_shape_parser.cc b/mindspore/lite/tools/converter/parser/tflite/tflite_shape_parser.cc index eae6cdb35270e9db6438f45134164a27777c0c15..582270eda673802bcddd506e1ab3ec65bccc60f9 100644 --- a/mindspore/lite/tools/converter/parser/tflite/tflite_shape_parser.cc +++ b/mindspore/lite/tools/converter/parser/tflite/tflite_shape_parser.cc @@ -40,7 +40,7 @@ STATUS TfliteShapeParser::Parse(const std::unique_ptr<tflite::OperatorT> &tflite return RET_NULL_PTR; } - std::unique_ptr<schema::ShapeT> attr(new schema::ShapeT()); + std::unique_ptr<schema::ShapeT> attr = std::make_unique<schema::ShapeT>(); op->primitive->value.type = schema::PrimitiveType_Shape; op->primitive->value.value = attr.release(); diff --git a/mindspore/lite/tools/converter/parser/tflite/tflite_slice_parser.cc b/mindspore/lite/tools/converter/parser/tflite/tflite_slice_parser.cc index 14d31067235ac3292e19c19913685cfffe3ab223..583d656b32abaf1d7a90cfe83154d1b085c3db2a 100644 --- a/mindspore/lite/tools/converter/parser/tflite/tflite_slice_parser.cc +++ b/mindspore/lite/tools/converter/parser/tflite/tflite_slice_parser.cc @@ -41,7 +41,7 @@ STATUS TfliteSliceParser::Parse(const std::unique_ptr<tflite::OperatorT> &tflite return RET_NULL_PTR; } - std::unique_ptr<schema::SliceT> attr(new schema::SliceT()); + std::unique_ptr<schema::SliceT> attr = std::make_unique<schema::SliceT>(); attr->format = schema::Format_NHWC; diff --git a/mindspore/lite/tools/converter/parser/tflite/tflite_softmax_parser.cc b/mindspore/lite/tools/converter/parser/tflite/tflite_softmax_parser.cc index 5c25d4837a519fa4afd2a1a4bd21845fd7989540..c925e006fb180adadb398ecc285b9bb14cd4742c 100644 --- a/mindspore/lite/tools/converter/parser/tflite/tflite_softmax_parser.cc +++ b/mindspore/lite/tools/converter/parser/tflite/tflite_softmax_parser.cc @@ -40,7 +40,7 @@ STATUS TfliteSoftmaxParser::Parse(const std::unique_ptr<tflite::OperatorT> &tfli return RET_NULL_PTR; } - std::unique_ptr<schema::SoftMaxT> attr(new schema::SoftMaxT()); + std::unique_ptr<schema::SoftMaxT> attr = std::make_unique<schema::SoftMaxT>(); attr->axis = -1; diff --git a/mindspore/lite/tools/converter/parser/tflite/tflite_space_to_batch_nd_parser.cc b/mindspore/lite/tools/converter/parser/tflite/tflite_space_to_batch_nd_parser.cc index bfd9e8248f4b75c38a01bf029c84de333a894258..304dd095147838edd479ba78a90d915d5ca5c5b5 100644 --- a/mindspore/lite/tools/converter/parser/tflite/tflite_space_to_batch_nd_parser.cc +++ b/mindspore/lite/tools/converter/parser/tflite/tflite_space_to_batch_nd_parser.cc @@ -41,7 +41,7 @@ STATUS TfliteSpaceToBatchNDParser::Parse(const std::unique_ptr<tflite::OperatorT return RET_NULL_PTR; } - std::unique_ptr<schema::SpaceToBatchNDT> attr(new schema::SpaceToBatchNDT()); + std::unique_ptr<schema::SpaceToBatchNDT> attr = std::make_unique<schema::SpaceToBatchNDT>(); if (GetTfliteData(tflite_op->inputs[1], tflite_tensors, tflite_model_buffer, attr->blockShape)) { MS_LOG(ERROR) << "get spaceToBatchND -> blockShape failed"; diff --git a/mindspore/lite/tools/converter/parser/tflite/tflite_space_to_depth_parser.cc b/mindspore/lite/tools/converter/parser/tflite/tflite_space_to_depth_parser.cc index b9dca6927d0c20eac7f6f2b688c7c98cf26da6c6..9c71770e25501a98cee5448429c38e04ed024c2c 100644 --- a/mindspore/lite/tools/converter/parser/tflite/tflite_space_to_depth_parser.cc +++ b/mindspore/lite/tools/converter/parser/tflite/tflite_space_to_depth_parser.cc @@ -41,7 +41,7 @@ STATUS TfliteSpaceToDepthParser::Parse(const std::unique_ptr<tflite::OperatorT> return RET_NULL_PTR; } - std::unique_ptr<schema::SpaceToDepthT> attr(new schema::SpaceToDepthT()); + std::unique_ptr<schema::SpaceToDepthT> attr = std::make_unique<schema::SpaceToDepthT>(); const auto &tflite_attr = tflite_op->builtin_options.AsSpaceToDepthOptions(); if (tflite_attr == nullptr) { diff --git a/mindspore/lite/tools/converter/parser/tflite/tflite_sparse_to_dense_parser.cc b/mindspore/lite/tools/converter/parser/tflite/tflite_sparse_to_dense_parser.cc index 8859377b96f54025d8a2da748cda882e09647d0b..2b1228a412952827a9ee03d0c4954ad20a0c1abe 100644 --- a/mindspore/lite/tools/converter/parser/tflite/tflite_sparse_to_dense_parser.cc +++ b/mindspore/lite/tools/converter/parser/tflite/tflite_sparse_to_dense_parser.cc @@ -41,7 +41,7 @@ STATUS TfliteSparseToDenseParser::Parse(const std::unique_ptr<tflite::OperatorT> return RET_NULL_PTR; } - std::unique_ptr<schema::SparseToDenseT> attr(new schema::SparseToDenseT()); + std::unique_ptr<schema::SparseToDenseT> attr = std::make_unique<schema::SparseToDenseT>(); attr->validateIndices = false; diff --git a/mindspore/lite/tools/converter/parser/tflite/tflite_split_parser.cc b/mindspore/lite/tools/converter/parser/tflite/tflite_split_parser.cc index cf3695eeb1031a4c94d8492786bb28f92bc022c1..48df14fb93b2f5ee71f33e05c92408c2ff137eb7 100644 --- a/mindspore/lite/tools/converter/parser/tflite/tflite_split_parser.cc +++ b/mindspore/lite/tools/converter/parser/tflite/tflite_split_parser.cc @@ -41,7 +41,7 @@ STATUS TfliteSplitParser::Parse(const std::unique_ptr<tflite::OperatorT> &tflite return RET_NULL_PTR; } - std::unique_ptr<schema::SplitT> attr(new schema::SplitT()); + std::unique_ptr<schema::SplitT> attr = std::make_unique<schema::SplitT>(); const auto &tflite_attr = tflite_op->builtin_options.AsSplitOptions(); if (tflite_attr == nullptr) { diff --git a/mindspore/lite/tools/converter/parser/tflite/tflite_split_v_parser.cc b/mindspore/lite/tools/converter/parser/tflite/tflite_split_v_parser.cc index f134e085cd4a9ef25bd2c79a150d7bd96fd6ba0b..df4e35b76f28f8ab9e5e43b9795245c3a2e0afff 100644 --- a/mindspore/lite/tools/converter/parser/tflite/tflite_split_v_parser.cc +++ b/mindspore/lite/tools/converter/parser/tflite/tflite_split_v_parser.cc @@ -39,7 +39,7 @@ STATUS TfliteSplitVParser::Parse(const std::unique_ptr<tflite::OperatorT> &tflit } MS_LOG(DEBUG) << "parse TfliteSplitVParser"; - std::unique_ptr<schema::SplitT> attr(new schema::SplitT()); + std::unique_ptr<schema::SplitT> attr = std::make_unique<schema::SplitT>(); const auto &tflite_attr = tflite_op->builtin_options.AsSplitVOptions(); if (tflite_attr == nullptr) { diff --git a/mindspore/lite/tools/converter/parser/tflite/tflite_squeeze_parser.cc b/mindspore/lite/tools/converter/parser/tflite/tflite_squeeze_parser.cc index a5720e4a089fe3ac30aae0fb3edeed5b41659b50..30985814859d4d512ad3f305096469608275c4fa 100644 --- a/mindspore/lite/tools/converter/parser/tflite/tflite_squeeze_parser.cc +++ b/mindspore/lite/tools/converter/parser/tflite/tflite_squeeze_parser.cc @@ -40,7 +40,7 @@ STATUS TfliteSqueezeParser::Parse(const std::unique_ptr<tflite::OperatorT> &tfli return RET_NULL_PTR; } - std::unique_ptr<schema::SqueezeT> attr(new schema::SqueezeT()); + std::unique_ptr<schema::SqueezeT> attr = std::make_unique<schema::SqueezeT>(); const auto &tflite_attr = tflite_op->builtin_options.AsSqueezeOptions(); if (tflite_attr == nullptr) { diff --git a/mindspore/lite/tools/converter/parser/tflite/tflite_stack_parser.cc b/mindspore/lite/tools/converter/parser/tflite/tflite_stack_parser.cc index 63d4f0fbfb3e789a025448ec810a4d49c5f70183..308f1492a65f8035a891fb1c5f30fc51b5ead2e7 100644 --- a/mindspore/lite/tools/converter/parser/tflite/tflite_stack_parser.cc +++ b/mindspore/lite/tools/converter/parser/tflite/tflite_stack_parser.cc @@ -40,7 +40,7 @@ STATUS TfliteStackParser::Parse(const std::unique_ptr<tflite::OperatorT> &tflite return RET_NULL_PTR; } - std::unique_ptr<schema::StackT> attr(new schema::StackT()); + std::unique_ptr<schema::StackT> attr = std::make_unique<schema::StackT>(); const auto &tflite_attr = tflite_op->builtin_options.AsPackOptions(); if (tflite_attr == nullptr) { MS_LOG(ERROR) << "get op: " << op->name.c_str() << " attr failed"; diff --git a/mindspore/lite/tools/converter/parser/tflite/tflite_strided_slice_parser.cc b/mindspore/lite/tools/converter/parser/tflite/tflite_strided_slice_parser.cc index 123e458665b7a46b29f312ff0048992b06d3ab89..dc74b2f8971833559dbbd11dd407c240195674a9 100644 --- a/mindspore/lite/tools/converter/parser/tflite/tflite_strided_slice_parser.cc +++ b/mindspore/lite/tools/converter/parser/tflite/tflite_strided_slice_parser.cc @@ -39,7 +39,7 @@ STATUS TfliteStridedSliceParser::Parse(const std::unique_ptr<tflite::OperatorT> } MS_LOG(DEBUG) << "parse TfliteStridedSliceParser"; - std::unique_ptr<schema::StridedSliceT> attr(new schema::StridedSliceT()); + std::unique_ptr<schema::StridedSliceT> attr = std::make_unique<schema::StridedSliceT>(); const auto &tflite_attr = tflite_op->builtin_options.AsStridedSliceOptions(); if (tflite_attr == nullptr) { MS_LOG(ERROR) << "get op: %s attr failed", op->name.c_str(); diff --git a/mindspore/lite/tools/converter/parser/tflite/tflite_tile_parser.cc b/mindspore/lite/tools/converter/parser/tflite/tflite_tile_parser.cc index 6b618829b0571af52676598ea01ddc45233f438e..356f2b83af15c23d292da174d09994fd4234f82f 100644 --- a/mindspore/lite/tools/converter/parser/tflite/tflite_tile_parser.cc +++ b/mindspore/lite/tools/converter/parser/tflite/tflite_tile_parser.cc @@ -41,7 +41,7 @@ STATUS TfliteTileParser::Parse(const std::unique_ptr<tflite::OperatorT> &tflite_ return RET_NULL_PTR; } - std::unique_ptr<schema::TileT> attr(new schema::TileT()); + std::unique_ptr<schema::TileT> attr = std::make_unique<schema::TileT>(); if (GetTfliteData(tflite_op->inputs[1], tflite_tensors, tflite_model_buffer, attr->multiples)) { MS_LOG(ERROR) << "get tile -> multiples failed"; diff --git a/mindspore/lite/tools/converter/parser/tflite/tflite_topk_v2_parser.cc b/mindspore/lite/tools/converter/parser/tflite/tflite_topk_v2_parser.cc index fc90e1ead88d34fa89d80e196e168313fc0db584..c9fb1f48d87fdd5d07daa858f5c464e339f3778c 100644 --- a/mindspore/lite/tools/converter/parser/tflite/tflite_topk_v2_parser.cc +++ b/mindspore/lite/tools/converter/parser/tflite/tflite_topk_v2_parser.cc @@ -41,7 +41,7 @@ STATUS TfliteTopKV2Parser::Parse(const std::unique_ptr<tflite::OperatorT> &tflit return RET_NULL_PTR; } - std::unique_ptr<schema::TopKT> attr(new schema::TopKT()); + std::unique_ptr<schema::TopKT> attr = std::make_unique<schema::TopKT>(); attr->sorted = true; std::vector<int32_t> k; diff --git a/mindspore/lite/tools/converter/parser/tflite/tflite_transpose_parser.cc b/mindspore/lite/tools/converter/parser/tflite/tflite_transpose_parser.cc index 759c3d8fc52dd6c274f178e1581c1150e2ff0883..3cefb780a6456d118beaf0d94cdf72b1b240850a 100644 --- a/mindspore/lite/tools/converter/parser/tflite/tflite_transpose_parser.cc +++ b/mindspore/lite/tools/converter/parser/tflite/tflite_transpose_parser.cc @@ -39,7 +39,7 @@ STATUS TfliteTransposeParser::Parse(const std::unique_ptr<tflite::OperatorT> &tf return RET_NULL_PTR; } - std::unique_ptr<schema::TransposeT> attr(new schema::TransposeT()); + std::unique_ptr<schema::TransposeT> attr = std::make_unique<schema::TransposeT>(); if (GetTfliteData(tflite_op->inputs[1], tflite_tensors, tflite_model_buffer, attr->perm)) { MS_LOG(ERROR) << "get transpose -> perm failed"; diff --git a/mindspore/lite/tools/converter/parser/tflite/tflite_unique_parser.cc b/mindspore/lite/tools/converter/parser/tflite/tflite_unique_parser.cc index aa052c250d2def38dc23a58163526fa7942712e3..c7e04c7b29b85cf21f9c450570425e08b6d6c320 100644 --- a/mindspore/lite/tools/converter/parser/tflite/tflite_unique_parser.cc +++ b/mindspore/lite/tools/converter/parser/tflite/tflite_unique_parser.cc @@ -41,7 +41,7 @@ STATUS TfliteUniqueParser::Parse(const std::unique_ptr<tflite::OperatorT> &tflit return RET_NULL_PTR; } - std::unique_ptr<schema::UniqueT> attr(new schema::UniqueT()); + std::unique_ptr<schema::UniqueT> attr = std::make_unique<schema::UniqueT>(); const auto &tflite_attr = tflite_op->builtin_options.AsUniqueOptions(); if (tflite_attr == nullptr) { diff --git a/mindspore/lite/tools/converter/parser/tflite/tflite_unstack_parser.cc b/mindspore/lite/tools/converter/parser/tflite/tflite_unstack_parser.cc index b78f4fe799159381c7d6730ada45864abbe63cd0..0b03d27b552dbcc6fa0e09d25154c4f619b3cc5e 100644 --- a/mindspore/lite/tools/converter/parser/tflite/tflite_unstack_parser.cc +++ b/mindspore/lite/tools/converter/parser/tflite/tflite_unstack_parser.cc @@ -42,7 +42,7 @@ STATUS TfliteUnstackParser::Parse(const std::unique_ptr<tflite::OperatorT> &tfli return RET_NULL_PTR; } - std::unique_ptr<schema::UnstackT> attr(new schema::UnstackT()); + std::unique_ptr<schema::UnstackT> attr = std::make_unique<schema::UnstackT>(); const auto &tflite_attr = tflite_op->builtin_options.AsUnpackOptions(); if (tflite_attr == nullptr) { diff --git a/mindspore/lite/tools/converter/parser/tflite/tflite_where_parser.cc b/mindspore/lite/tools/converter/parser/tflite/tflite_where_parser.cc index 88d027e41a20b87a6b75803d105c8c2a7e79293d..61e0bfcfa9a7af996e8dfe64ee0beccbb737522b 100644 --- a/mindspore/lite/tools/converter/parser/tflite/tflite_where_parser.cc +++ b/mindspore/lite/tools/converter/parser/tflite/tflite_where_parser.cc @@ -41,7 +41,7 @@ STATUS TfliteWhereParser::Parse(const std::unique_ptr<tflite::OperatorT> &tflite return RET_NULL_PTR; } - std::unique_ptr<schema::WhereT> attr(new schema::WhereT()); + std::unique_ptr<schema::WhereT> attr = std::make_unique<schema::WhereT>(); if (GetTfliteData(tflite_op->inputs[0], tflite_tensors, tflite_model_buffer, attr->condition)) { MS_LOG(ERROR) << "get where -> condition failed"; diff --git a/mindspore/lite/tools/converter/parser/tflite/tflite_zeros_like_parser.cc b/mindspore/lite/tools/converter/parser/tflite/tflite_zeros_like_parser.cc index d5c1750d5989f54076401602f64768cd095c0c10..36170b7d93cb12834974cfe9056e8541366a64cb 100644 --- a/mindspore/lite/tools/converter/parser/tflite/tflite_zeros_like_parser.cc +++ b/mindspore/lite/tools/converter/parser/tflite/tflite_zeros_like_parser.cc @@ -41,7 +41,7 @@ STATUS TfliteZerosLikeParser::Parse(const std::unique_ptr<tflite::OperatorT> &tf return RET_NULL_PTR; } - std::unique_ptr<schema::ZerosLikeT> attr(new schema::ZerosLikeT()); + std::unique_ptr<schema::ZerosLikeT> attr = std::make_unique<schema::ZerosLikeT>(); op->primitive->value.type = schema::PrimitiveType_ZerosLike; op->primitive->value.value = attr.release();