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 0fa8b0f6da4..675d8f82a70 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 b5babf04ce9..0e495cfca45 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 &t MS_LOG(ERROR) << "op->primitive is null"; return RET_NULL_PTR; } - std::unique_ptr attr(new schema::ActivationT()); + std::unique_ptr attr = std::make_unique(); std::vector node_name_str; Split(op->name, &node_name_str, "-"); @@ -89,7 +89,7 @@ STATUS TflitePreluParser::Parse(const std::unique_ptr &tflite MS_LOG(ERROR) << "op->primitive is null"; return RET_NULL_PTR; } - std::unique_ptr attr(new schema::PreluT()); + std::unique_ptr attr = std::make_unique(); 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 &tf return RET_NULL_PTR; } - std::unique_ptr attr(new schema::LeakyReLUT()); + std::unique_ptr attr = std::make_unique(); 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 b88666fca93..130e9eb53e2 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_ return RET_NULL_PTR; } - std::unique_ptr attr(new schema::AddNT()); + std::unique_ptr attr = std::make_unique(); 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 1ccf2ea4651..d1aedeea20d 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 &tflit return RET_NULL_PTR; } - std::unique_ptr attr(new schema::ArgMaxT()); + std::unique_ptr attr = std::make_unique(); 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 1ce77d5ebac..998db501d9f 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 &tflit return RET_NULL_PTR; } - std::unique_ptr attr(new schema::ArgMinT()); + std::unique_ptr attr = std::make_unique(); 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 2ebaa61131d..914391c5561 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 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 attr(new schema::AddT()); + std::unique_ptr attr = std::make_unique(); 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 op->primitive->value.value = attr.release(); } else if (std::strcmp(node_name, "Sub") == 0) { MS_LOG(DEBUG) << "parse TfliteSubParser"; - std::unique_ptr attr(new schema::SubT()); + std::unique_ptr attr = std::make_unique(); 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 op->primitive->value.value = attr.release(); } else if (std::strcmp(node_name, "Mul") == 0) { MS_LOG(DEBUG) << "parse TfliteMulParser"; - std::unique_ptr attr(new schema::MulT()); + std::unique_ptr attr = std::make_unique(); 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 op->primitive->value.value = attr.release(); } else if (std::strcmp(node_name, "Div") == 0) { MS_LOG(DEBUG) << "parse TfliteDivParser"; - std::unique_ptr attr(new schema::DivT()); + std::unique_ptr attr = std::make_unique(); 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 op->primitive->value.value = attr.release(); } else if (std::strcmp(node_name, "FloorDiv") == 0) { MS_LOG(DEBUG) << "parse TfliteFloorDivParser"; - std::unique_ptr attr(new schema::FloorDivT()); + std::unique_ptr attr = std::make_unique(); 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 attr(new schema::FloorModT()); + std::unique_ptr attr = std::make_unique(); 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 attr(new schema::RealDivT()); + std::unique_ptr attr = std::make_unique(); 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 attr(new schema::SquaredDifferenceT()); + std::unique_ptr attr = std::make_unique(); 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 attr(new schema::PowerT()); + std::unique_ptr attr = std::make_unique(); attr->power = 0.0f; attr->scale = 1.0f; attr->shift = 0.0f; @@ -116,12 +116,12 @@ STATUS TfliteDoubleInputOpParser::Parse(const std::unique_ptr op->primitive->value.value = attr.release(); } else if (std::strcmp(node_name, "Maximum") == 0) { MS_LOG(DEBUG) << "parse TfliteMaximumParser"; - std::unique_ptr attr(new schema::MaximumT()); + std::unique_ptr attr = std::make_unique(); 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 attr(new schema::MinimumT()); + std::unique_ptr attr = std::make_unique(); op->primitive->value.type = schema::PrimitiveType_Minimum; op->primitive->value.value = attr.release(); } @@ -158,57 +158,57 @@ STATUS TfliteSingleInputOpParser::Parse(const std::unique_ptr 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 attr(new schema::AbsT()); + std::unique_ptr attr = std::make_unique(); 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 attr(new schema::ExpT()); + std::unique_ptr attr = std::make_unique(); 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 attr(new schema::SqrtT()); + std::unique_ptr attr = std::make_unique(); 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 attr(new schema::RsqrtT()); + std::unique_ptr attr = std::make_unique(); 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 attr(new schema::SquareT()); + std::unique_ptr attr = std::make_unique(); 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 attr(new schema::SinT()); + std::unique_ptr attr = std::make_unique(); 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 attr(new schema::CosT()); + std::unique_ptr attr = std::make_unique(); 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 attr(new schema::LogT()); + std::unique_ptr attr = std::make_unique(); 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 attr(new schema::RoundT()); + std::unique_ptr attr = std::make_unique(); 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 attr(new schema::CeilT()); + std::unique_ptr attr = std::make_unique(); 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 attr(new schema::FloorT()); + std::unique_ptr attr = std::make_unique(); op->primitive->value.type = schema::PrimitiveType_Floor; op->primitive->value.value = attr.release(); } @@ -242,32 +242,32 @@ STATUS TfliteCompareOpParser::Parse(const std::unique_ptr &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 attr(new schema::EqualT()); + std::unique_ptr attr = std::make_unique(); 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 attr(new schema::NotEqualT()); + std::unique_ptr attr = std::make_unique(); 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 attr(new schema::GreaterT()); + std::unique_ptr attr = std::make_unique(); 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 attr(new schema::GreaterEqualT()); + std::unique_ptr attr = std::make_unique(); 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 attr(new schema::LessT()); + std::unique_ptr attr = std::make_unique(); 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 attr(new schema::LessEqualT()); + std::unique_ptr attr = std::make_unique(); 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 3c490ac4e44..adc8f2f105f 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 MS_LOG(DEBUG) << "parse TfliteBatchToSpaceNDParser"; } - std::unique_ptr attr(new schema::BatchToSpaceT()); + std::unique_ptr attr = std::make_unique(); 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 199aff567b2..0a4d36decb3 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 & return RET_NULL_PTR; } - std::unique_ptr attr(new schema::BroadcastToT()); + std::unique_ptr attr = std::make_unique(); 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 ee5120ddec8..7ff446973e2 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_ return RET_NULL_PTR; } - std::unique_ptr attr(new schema::CastT()); + std::unique_ptr attr = std::make_unique(); 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 86c4d98b89a..cc17a473d28 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 &tflit return RET_NULL_PTR; } - std::unique_ptr attr(new schema::ConcatT()); + std::unique_ptr attr = std::make_unique(); 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 8de26527b25..fec5f76d5a2 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_ return RET_NULL_PTR; } - std::unique_ptr attr(new schema::Conv2DT()); + std::unique_ptr attr = std::make_unique(); 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 565bceb8a45..cf9d55d830a 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 &tflit return RET_NULL_PTR; } - std::unique_ptr attr(new schema::DeConv2DT()); + std::unique_ptr attr = std::make_unique(); 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 b8fceaed9a7..d37f17ed3b0 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 return RET_NULL_PTR; } - std::unique_ptr attr(new schema::DepthToSpaceT()); + std::unique_ptr attr = std::make_unique(); 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 5ebe2583730..f6ff3eab711 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 attr(new schema::DepthwiseConv2DT()); + std::unique_ptr attr = std::make_unique(); 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 5854166fd32..3e7f4129cb8 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 &t return RET_NULL_PTR; } - std::unique_ptr attr(new schema::CastT); + std::unique_ptr attr = std::make_unique(); // 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 0d3c91528f9..191c3bff984 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 &t std::vector *tensors_id, std::vector *tensors_format, std::map *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 &t return RET_NULL_PTR; } - MS_LOG(DEBUG) << "parse TfliteExpandDimsParser"; - std::unique_ptr attr(new schema::ExpandDimsT()); + std::unique_ptr attr = std::make_unique(); 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 70405dbf1e1..a563bcc7c73 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_ return RET_NULL_PTR; } - std::unique_ptr attr(new schema::FillT()); + std::unique_ptr attr = std::make_unique(); 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 f84bff6bdf7..447fb7ae74f 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 attr(new schema::FullConnectionT()); + std::unique_ptr attr = std::make_unique(); const auto &tflite_attr = tflite_op->builtin_options.AsFullyConnectedOptions(); if (tflite_attr == nullptr) { @@ -55,7 +55,9 @@ STATUS TfliteFullyConnectedParser::Parse(const std::unique_ptrhasBias = 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_ptrinputs[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 e8218bb4318..d9f9b681521 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 &tfl return RET_NULL_PTR; } - std::unique_ptr attr(new schema::GatherNdT()); + std::unique_ptr attr = std::make_unique(); 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 cf388e94d89..662c5c5c847 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 &tflit return RET_NULL_PTR; } - std::unique_ptr attr(new schema::GatherT()); + std::unique_ptr attr = std::make_unique(); 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 8ef185d9074..b66f59a7cd4 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 &tflit return RET_NULL_PTR; } - std::unique_ptr attr(new schema::L2NormT()); + std::unique_ptr attr = std::make_unique(); + 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 c6677327664..7c755c54e4c 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 &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 attr(new schema::LogicalAndT()); + std::unique_ptr attr = std::make_unique(); 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 attr(new schema::LogicalNotT()); + std::unique_ptr attr = std::make_unique(); 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 attr(new schema::LogicalOrT()); + std::unique_ptr attr = std::make_unique(); 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 8986729d72e..d47f6f7fbed 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_o return RET_NULL_PTR; } - std::unique_ptr attr(new schema::LocalResponseNormalizationT()); + std::unique_ptr attr = std::make_unique(); 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 2e6d754184e..452f44d84d7 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 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)); @@ -91,7 +92,8 @@ 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; @@ -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 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 833ef1cbec9..2d95500213b 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_model, const std::unique_ptr &tflite_subgraph, const QuantType &quant_type, - schema::MetaGraphT* sub_graph); + schema::MetaGraphT *sub_graph); STATUS ConvertTensor(const std::unique_ptr &tflite_subgraph, const std::vector> &tflite_model_buffer, - schema::MetaGraphT* sub_graph); + schema::MetaGraphT *sub_graph); STATUS GetGraphInfo(const std::unique_ptr &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 4f8b7261611..71cc518c6f6 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 &tflit return RET_NULL_PTR; } - std::unique_ptr attr(new schema::OneHotT()); + std::unique_ptr attr = std::make_unique(); 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 db828d1fcf1..7a09b81a700 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_o return RET_NULL_PTR; } - std::unique_ptr attr(new schema::PadT()); + std::unique_ptr attr = std::make_unique(); 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 1d7db44adb5..8a33f4a720d 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 &tfli return RET_NULL_PTR; } - std::unique_ptr attr(new schema::PoolingT()); + std::unique_ptr attr = std::make_unique(); std::vector 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 519b5c243ba..9a33a174dee 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 return RET_NULL_PTR; } - std::unique_ptr attr(new schema::RangeT()); + std::unique_ptr attr = std::make_unique(); 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 d4fcac5371c..4a135a5bb1e 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_ return RET_NULL_PTR; } - std::unique_ptr attr(new schema::RankT()); + std::unique_ptr attr = std::make_unique(); 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 690ec75fd34..b9dc8e9da7f 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 &tflit return RET_NULL_PTR; } - std::unique_ptr attr(new schema::ReduceT()); + std::unique_ptr attr = std::make_unique(); // 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 3aa06063dc6..626383532d0 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 &tfli return RET_NULL_PTR; } - std::unique_ptr attr(new schema::ReshapeT()); + std::unique_ptr attr = std::make_unique(); 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 3c5516b4974..0fc84646591 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 &tflit return RET_NULL_PTR; } - std::unique_ptr attr(new schema::ResizeT()); + std::unique_ptr attr = std::make_unique(); std::vector 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 7e449a3588a..cfcabbd5a33 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 &tfli return RET_NULL_PTR; } - std::unique_ptr attr(new schema::ReverseT()); + std::unique_ptr attr = std::make_unique(); 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 3d996a4feff..da7b4f8ae85 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 attr(new schema::ReverseSequenceT()); + std::unique_ptr attr = std::make_unique(); 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 39568e47105..535ef54e8b1 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 &tf return RET_NULL_PTR; } - std::unique_ptr attr(new schema::ScatterNDT()); + std::unique_ptr attr = std::make_unique(); 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 eae6cdb3527..582270eda67 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 return RET_NULL_PTR; } - std::unique_ptr attr(new schema::ShapeT()); + std::unique_ptr attr = std::make_unique(); 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 14d31067235..583d656b32a 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 return RET_NULL_PTR; } - std::unique_ptr attr(new schema::SliceT()); + std::unique_ptr attr = std::make_unique(); 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 5c25d4837a5..c925e006fb1 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 &tfli return RET_NULL_PTR; } - std::unique_ptr attr(new schema::SoftMaxT()); + std::unique_ptr attr = std::make_unique(); 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 bfd9e8248f4..304dd095147 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 attr(new schema::SpaceToBatchNDT()); + std::unique_ptr attr = std::make_unique(); 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 b9dca6927d0..9c71770e255 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 return RET_NULL_PTR; } - std::unique_ptr attr(new schema::SpaceToDepthT()); + std::unique_ptr attr = std::make_unique(); 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 8859377b96f..2b1228a4129 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 return RET_NULL_PTR; } - std::unique_ptr attr(new schema::SparseToDenseT()); + std::unique_ptr attr = std::make_unique(); 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 cf3695eeb10..48df14fb93b 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 return RET_NULL_PTR; } - std::unique_ptr attr(new schema::SplitT()); + std::unique_ptr attr = std::make_unique(); 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 f134e085cd4..df4e35b76f2 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 &tflit } MS_LOG(DEBUG) << "parse TfliteSplitVParser"; - std::unique_ptr attr(new schema::SplitT()); + std::unique_ptr attr = std::make_unique(); 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 a5720e4a089..30985814859 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 &tfli return RET_NULL_PTR; } - std::unique_ptr attr(new schema::SqueezeT()); + std::unique_ptr attr = std::make_unique(); 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 63d4f0fbfb3..308f1492a65 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 return RET_NULL_PTR; } - std::unique_ptr attr(new schema::StackT()); + std::unique_ptr attr = std::make_unique(); 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 123e458665b..dc74b2f8971 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 } MS_LOG(DEBUG) << "parse TfliteStridedSliceParser"; - std::unique_ptr attr(new schema::StridedSliceT()); + std::unique_ptr attr = std::make_unique(); 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 6b618829b05..356f2b83af1 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_ return RET_NULL_PTR; } - std::unique_ptr attr(new schema::TileT()); + std::unique_ptr attr = std::make_unique(); 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 fc90e1ead88..c9fb1f48d87 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 &tflit return RET_NULL_PTR; } - std::unique_ptr attr(new schema::TopKT()); + std::unique_ptr attr = std::make_unique(); attr->sorted = true; std::vector 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 759c3d8fc52..3cefb780a64 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 &tf return RET_NULL_PTR; } - std::unique_ptr attr(new schema::TransposeT()); + std::unique_ptr attr = std::make_unique(); 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 aa052c250d2..c7e04c7b29b 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 &tflit return RET_NULL_PTR; } - std::unique_ptr attr(new schema::UniqueT()); + std::unique_ptr attr = std::make_unique(); 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 b78f4fe7991..0b03d27b552 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 &tfli return RET_NULL_PTR; } - std::unique_ptr attr(new schema::UnstackT()); + std::unique_ptr attr = std::make_unique(); 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 88d027e41a2..61e0bfcfa9a 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 return RET_NULL_PTR; } - std::unique_ptr attr(new schema::WhereT()); + std::unique_ptr attr = std::make_unique(); 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 d5c1750d598..36170b7d93c 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 &tf return RET_NULL_PTR; } - std::unique_ptr attr(new schema::ZerosLikeT()); + std::unique_ptr attr = std::make_unique(); op->primitive->value.type = schema::PrimitiveType_ZerosLike; op->primitive->value.value = attr.release();