From 44202c9b9da350b015a235ab30360204fae95dcb Mon Sep 17 00:00:00 2001 From: 13291271729 Date: Mon, 29 Aug 2022 21:47:31 +0800 Subject: [PATCH] clean code --- parser/common/convert/message2operator.cc | 137 ++++++++++++++---- parser/common/convert/message2operator.h | 11 +- parser/common/convert/pb2json.cc | 8 +- parser/common/convert/pb2json.h | 2 +- parser/common/op_def/arg_op.cc | 2 +- parser/common/op_def/arg_op.h | 2 +- parser/common/op_def/constant_op.cc | 2 +- parser/common/op_def/constant_op.h | 2 +- parser/common/op_def/fill_op.cc | 2 +- parser/common/op_def/fill_op.h | 2 +- parser/common/op_def/frameworkop_op.cc | 2 +- parser/common/op_def/frameworkop_op.h | 2 +- parser/common/op_def/ir_pb_converter.cc | 2 +- parser/common/op_def/ir_pb_converter.h | 2 +- parser/common/op_def/no_op_op.cc | 2 +- parser/common/op_def/no_op_op.h | 3 +- parser/common/op_def/operator.cc | 2 +- parser/common/op_def/operator.h | 2 +- parser/common/op_def/ref_switch_op.cc | 2 +- parser/common/op_def/ref_switch_op.h | 2 +- parser/common/op_def/shape_n_op.cc | 2 +- parser/common/op_def/shape_n_op.h | 2 +- .../common/op_def/var_is_initialized_op_op.cc | 2 +- .../common/op_def/var_is_initialized_op_op.h | 2 +- parser/common/op_def/variable_op.cc | 2 +- parser/common/op_def/variable_op.h | 2 +- parser/tensorflow/graph_functiondef.cc | 2 +- parser/tensorflow/graph_functiondef.h | 14 +- parser/tensorflow/graph_optimizer.cc | 4 +- parser/tensorflow/graph_optimizer.h | 2 +- parser/tensorflow/iterator_fusion_pass.cc | 2 +- parser/tensorflow/iterator_fusion_pass.h | 2 +- parser/tensorflow/scope/scope_pass_manager.cc | 2 +- parser/tensorflow/scope/scope_pass_manager.h | 2 +- parser/tensorflow/tensorflow_arg_parser.cc | 2 +- .../tensorflow_auto_mapping_parser_adapter.cc | 2 +- .../tensorflow_auto_mapping_parser_adapter.h | 2 +- 37 files changed, 165 insertions(+), 74 deletions(-) diff --git a/parser/common/convert/message2operator.cc b/parser/common/convert/message2operator.cc index d58762f..866a78a 100644 --- a/parser/common/convert/message2operator.cc +++ b/parser/common/convert/message2operator.cc @@ -1,5 +1,5 @@ /** - * Copyright 2021 Huawei Technologies Co., Ltd + * Copyright (c) Huawei Technologies Co., Ltd. 2022. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -58,24 +58,51 @@ Status Message2Operator::ParseOperatorAttrs(const google::protobuf::Message *mes return SUCCESS; } +void Message2Operator::ParseBaseTypeField(const google::protobuf::Reflection *reflection, + const google::protobuf::Message *message, + const google::protobuf::FieldDescriptor *field, ge::Operator &ops) { + switch (field->cpp_type()) { + case google::protobuf::FieldDescriptor::CPPTYPE_INT32: { + int32_t value = reflection->GetInt32(*message, field); + GELOGD("Parse result(%s : %d)", field->name().c_str(), value); + (void)ops.SetAttr(field->name().c_str(), value); + break; + } + case google::protobuf::FieldDescriptor::CPPTYPE_UINT32: { + uint32_t value = reflection->GetUInt32(*message, field); + GELOGD("Parse result(%s : %u)", field->name().c_str(), value); + (void)ops.SetAttr(field->name().c_str(), value); + break; + } + case google::protobuf::FieldDescriptor::CPPTYPE_INT64: { + int64_t value = reflection->GetInt64(*message, field); + GELOGD("Parse result(%s : %ld)", field->name().c_str(), value); + (void)ops.SetAttr(field->name().c_str(), value); + break; + } + case google::protobuf::FieldDescriptor::CPPTYPE_FLOAT: { + float value = reflection->GetFloat(*message, field); + GELOGD("Parse result(%s : %f)", field->name().c_str(), value); + (void)ops.SetAttr(field->name().c_str(), value); + break; + } + case google::protobuf::FieldDescriptor::CPPTYPE_BOOL: { + bool value = reflection->GetBool(*message, field); + GELOGD("Parse result(%s : %d)", field->name().c_str(), value); + (void)ops.SetAttr(field->name().c_str(), value); + break; + } + default: { + break; + } +} + Status Message2Operator::ParseField(const google::protobuf::Reflection *reflection, const google::protobuf::Message *message, const google::protobuf::FieldDescriptor *field, int depth, ge::Operator &ops) { GELOGD("Start to parse field: %s.", field->name().c_str()); + ParseBaseTypeField(reflection, message, field, ops); switch (field->cpp_type()) { -#define CASE_FIELD_TYPE(cpptype, method, valuetype, logtype) \ - case google::protobuf::FieldDescriptor::CPPTYPE_##cpptype: { \ - valuetype value = reflection->Get##method(*message, field); \ - GELOGD("Parse result(%s : %" #logtype ")", field->name().c_str(), value); \ - (void)ops.SetAttr(field->name().c_str(), value); \ - break; \ - } - CASE_FIELD_TYPE(INT32, Int32, int32_t, d); - CASE_FIELD_TYPE(UINT32, UInt32, uint32_t, u); - CASE_FIELD_TYPE(INT64, Int64, int64_t, ld); - CASE_FIELD_TYPE(FLOAT, Float, float, f); - CASE_FIELD_TYPE(BOOL, Bool, bool, d); -#undef CASE_FIELD_TYPE case google::protobuf::FieldDescriptor::CPPTYPE_ENUM: { GE_CHECK_NOTNULL(reflection->GetEnum(*message, field)); int value = reflection->GetEnum(*message, field)->number(); @@ -108,6 +135,70 @@ Status Message2Operator::ParseField(const google::protobuf::Reflection *reflecti return SUCCESS; } +void Message2Operator::ParseRepeatedBaseTypeField(const google::protobuf::Reflection *reflection, + const google::protobuf::Message *message, + const google::protobuf::FieldDescriptor *field, + ge::Operator &ops) { + switch (field->cpp_type()) { + case google::protobuf::FieldDescriptor::CPPTYPE_INT32: { + std::vector attr_value; + for (int i = 0; i < field_size; i++) { + int32_t value = reflection->GetRepeatedInt32(*message, field, i); + attr_value.push_back(value); + } + (void)ops.SetAttr(field->name().c_str(), attr_value); + break; + } + case google::protobuf::FieldDescriptor::CPPTYPE_UINT32: { + std::vector attr_value; + for (int i = 0; i < field_size; i++) { + uint32_t value = reflection->GetRepeatedUInt32(*message, field, i); + attr_value.push_back(value); + } + (void)ops.SetAttr(field->name().c_str(), attr_value); + break; + } + case google::protobuf::FieldDescriptor::CPPTYPE_INT64: { + std::vector attr_value; + for (int i = 0; i < field_size; i++) { + int64_t value = reflection->GetRepeatedInt64(*message, field, i); + attr_value.push_back(value); + } + (void)ops.SetAttr(field->name().c_str(), attr_value); + break; + } + case google::protobuf::FieldDescriptor::CPPTYPE_FLOAT: { + std::vector attr_value; + for (int i = 0; i < field_size; i++) { + float value = reflection->GetRepeatedFloat(*message, field, i); + attr_value.push_back(value); + } + (void)ops.SetAttr(field->name().c_str(), attr_value); + break; + } + case google::protobuf::FieldDescriptor::CPPTYPE_BOOL: { + std::vector attr_value; + for (int i = 0; i < field_size; i++) { + bool value = reflection->GetRepeatedBool(*message, field, i); + attr_value.push_back(value); + } + (void)ops.SetAttr(field->name().c_str(), attr_value); + break; + } + case google::protobuf::FieldDescriptor::CPPTYPE_STRING: { + std::vector attr_value; + for (int i = 0; i < field_size; i++) { + string value = reflection->GetRepeatedString(*message, field, i); + attr_value.push_back(value); + } + (void)ops.SetAttr(field->name().c_str(), attr_value); + break; + } + default: { + break; + } +} + Status Message2Operator::ParseRepeatedField(const google::protobuf::Reflection *reflection, const google::protobuf::Message *message, const google::protobuf::FieldDescriptor *field, @@ -120,24 +211,8 @@ Status Message2Operator::ParseRepeatedField(const google::protobuf::Reflection * return FAILED; } + ParseRepeatedBaseTypeField(reflection, message, field, ops); switch (field->cpp_type()) { -#define CASE_FIELD_TYPE_REPEATED(cpptype, method, valuetype) \ - case google::protobuf::FieldDescriptor::CPPTYPE_##cpptype: { \ - std::vector attr_value; \ - for (int i = 0; i < field_size; i++) { \ - valuetype value = reflection->GetRepeated##method(*message, field, i); \ - attr_value.push_back(value); \ - } \ - (void)ops.SetAttr(field->name().c_str(), attr_value); \ - break; \ - } - CASE_FIELD_TYPE_REPEATED(INT32, Int32, int32_t); - CASE_FIELD_TYPE_REPEATED(UINT32, UInt32, uint32_t); - CASE_FIELD_TYPE_REPEATED(INT64, Int64, int64_t); - CASE_FIELD_TYPE_REPEATED(FLOAT, Float, float); - CASE_FIELD_TYPE_REPEATED(BOOL, Bool, bool); - CASE_FIELD_TYPE_REPEATED(STRING, String, string); -#undef CASE_FIELD_TYPE_REPEATED case google::protobuf::FieldDescriptor::CPPTYPE_MESSAGE: { nlohmann::json message_json; Pb2Json::RepeatedMessage2Json(*message, field, reflection, std::set(), message_json[field->name()], diff --git a/parser/common/convert/message2operator.h b/parser/common/convert/message2operator.h index b8610e9..c65d92b 100644 --- a/parser/common/convert/message2operator.h +++ b/parser/common/convert/message2operator.h @@ -1,5 +1,5 @@ /** - * Copyright 2021 Huawei Technologies Co., Ltd + * Copyright (c) Huawei Technologies Co., Ltd. 2022. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,6 +33,15 @@ class Message2Operator { static Status ParseRepeatedField(const google::protobuf::Reflection *reflection, const google::protobuf::Message *message, const google::protobuf::FieldDescriptor *field, ge::Operator &ops); + + void ParseBaseTypeField(const google::protobuf::Reflection *reflection, + const google::protobuf::Message *message, + const google::protobuf::FieldDescriptor *field, ge::Operator &ops); + + void ParseRepeatedBaseTypeField(const google::protobuf::Reflection *reflection, + const google::protobuf::Message *message, + const google::protobuf::FieldDescriptor *field, + ge::Operator &ops) }; } // namespace ge #endif // PARSER_MESSAGE2OPERATOR_H diff --git a/parser/common/convert/pb2json.cc b/parser/common/convert/pb2json.cc index 66097b8..2f01c92 100644 --- a/parser/common/convert/pb2json.cc +++ b/parser/common/convert/pb2json.cc @@ -1,5 +1,5 @@ /** - * Copyright 2020 Huawei Technologies Co., Ltd + * Copyright (c) Huawei Technologies Co., Ltd. 2022. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -82,7 +82,7 @@ void Pb2Json::OneField2Json(const ProtobufMsg &message, const ProtobufFieldDescr switch (field->type()) { case ProtobufFieldDescriptor::TYPE_MESSAGE: { const ProtobufMsg &tmp_message = reflection->GetMessage(message, field); - if (0UL != tmp_message.ByteSizeLong()) { + if (tmp_message.ByteSizeLong() != 0UL) { Message2Json(tmp_message, black_fields, json[field->name()], enum2str, depth + 1); } break; @@ -155,10 +155,8 @@ string Pb2Json::TypeBytes2String(string &field_name, string &type_bytes) { } string result = ""; for (char temp_value : type_bytes) { - uint8_t *value = 0; - value = reinterpret_cast(&temp_value); char str[kSignificantDigits]; - if (sprintf_s(str, kSignificantDigits, "%d", *value) == -1){ + if (sprintf_s(str, kSignificantDigits, "%c", temp_value) == -1) { GELOGW("Convert bytes to string fail, filed name:%s", field_name.c_str()); continue; } diff --git a/parser/common/convert/pb2json.h b/parser/common/convert/pb2json.h index 28e796d..9e48d06 100644 --- a/parser/common/convert/pb2json.h +++ b/parser/common/convert/pb2json.h @@ -1,5 +1,5 @@ /** - * Copyright 2020 Huawei Technologies Co., Ltd + * Copyright (c) Huawei Technologies Co., Ltd. 2022. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/parser/common/op_def/arg_op.cc b/parser/common/op_def/arg_op.cc index 2eb0ff6..e9c4243 100644 --- a/parser/common/op_def/arg_op.cc +++ b/parser/common/op_def/arg_op.cc @@ -1,5 +1,5 @@ /** - * Copyright 2020 Huawei Technologies Co., Ltd + * Copyright (c) Huawei Technologies Co., Ltd. 2022. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/parser/common/op_def/arg_op.h b/parser/common/op_def/arg_op.h index 7258422..3746471 100644 --- a/parser/common/op_def/arg_op.h +++ b/parser/common/op_def/arg_op.h @@ -1,5 +1,5 @@ /** - * Copyright 2020 Huawei Technologies Co., Ltd + * Copyright (c) Huawei Technologies Co., Ltd. 2022. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/parser/common/op_def/constant_op.cc b/parser/common/op_def/constant_op.cc index ce9d249..cecb1d5 100644 --- a/parser/common/op_def/constant_op.cc +++ b/parser/common/op_def/constant_op.cc @@ -1,5 +1,5 @@ /** - * Copyright 2020 Huawei Technologies Co., Ltd + * Copyright (c) Huawei Technologies Co., Ltd. 2022. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/parser/common/op_def/constant_op.h b/parser/common/op_def/constant_op.h index e329ac1..6f809b3 100644 --- a/parser/common/op_def/constant_op.h +++ b/parser/common/op_def/constant_op.h @@ -1,5 +1,5 @@ /** - * Copyright 2020 Huawei Technologies Co., Ltd + * Copyright (c) Huawei Technologies Co., Ltd. 2022. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/parser/common/op_def/fill_op.cc b/parser/common/op_def/fill_op.cc index 2228d26..e3d5927 100644 --- a/parser/common/op_def/fill_op.cc +++ b/parser/common/op_def/fill_op.cc @@ -1,5 +1,5 @@ /** - * Copyright 2020 Huawei Technologies Co., Ltd + * Copyright (c) Huawei Technologies Co., Ltd. 2022. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/parser/common/op_def/fill_op.h b/parser/common/op_def/fill_op.h index 4040b49..b556067 100644 --- a/parser/common/op_def/fill_op.h +++ b/parser/common/op_def/fill_op.h @@ -1,5 +1,5 @@ /** - * Copyright 2020 Huawei Technologies Co., Ltd + * Copyright (c) Huawei Technologies Co., Ltd. 2022. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/parser/common/op_def/frameworkop_op.cc b/parser/common/op_def/frameworkop_op.cc index 7810147..81010ae 100644 --- a/parser/common/op_def/frameworkop_op.cc +++ b/parser/common/op_def/frameworkop_op.cc @@ -1,5 +1,5 @@ /** - * Copyright 2020 Huawei Technologies Co., Ltd + * Copyright (c) Huawei Technologies Co., Ltd. 2022. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/parser/common/op_def/frameworkop_op.h b/parser/common/op_def/frameworkop_op.h index 9a1a54c..eafc1a5 100644 --- a/parser/common/op_def/frameworkop_op.h +++ b/parser/common/op_def/frameworkop_op.h @@ -1,5 +1,5 @@ /** - * Copyright 2020 Huawei Technologies Co., Ltd + * Copyright (c) Huawei Technologies Co., Ltd. 2022. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/parser/common/op_def/ir_pb_converter.cc b/parser/common/op_def/ir_pb_converter.cc index 9dd7f64..87c56ac 100644 --- a/parser/common/op_def/ir_pb_converter.cc +++ b/parser/common/op_def/ir_pb_converter.cc @@ -1,5 +1,5 @@ /** - * Copyright 2020 Huawei Technologies Co., Ltd + * Copyright (c) Huawei Technologies Co., Ltd. 2022. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/parser/common/op_def/ir_pb_converter.h b/parser/common/op_def/ir_pb_converter.h index bbc8e03..fea9dd2 100644 --- a/parser/common/op_def/ir_pb_converter.h +++ b/parser/common/op_def/ir_pb_converter.h @@ -1,5 +1,5 @@ /** - * Copyright 2020 Huawei Technologies Co., Ltd + * Copyright (c) Huawei Technologies Co., Ltd. 2022. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/parser/common/op_def/no_op_op.cc b/parser/common/op_def/no_op_op.cc index d9706ef..c427bd2 100644 --- a/parser/common/op_def/no_op_op.cc +++ b/parser/common/op_def/no_op_op.cc @@ -1,5 +1,5 @@ /** - * Copyright 2020 Huawei Technologies Co., Ltd + * Copyright (c) Huawei Technologies Co., Ltd. 2022. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/parser/common/op_def/no_op_op.h b/parser/common/op_def/no_op_op.h index f3bfea8..56338c2 100644 --- a/parser/common/op_def/no_op_op.h +++ b/parser/common/op_def/no_op_op.h @@ -1,5 +1,5 @@ /** - * Copyright 2020 Huawei Technologies Co., Ltd + * Copyright (c) Huawei Technologies Co., Ltd. 2022. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,6 @@ #ifndef DOMI_OP_NO_OP_OP_H_ #define DOMI_OP_NO_OP_OP_H_ #include "parser/common/op_def/operator.h" -#include "framework/omg/parser/parser_types.h" namespace ge { class NoOpOperator : public ParserOperator { diff --git a/parser/common/op_def/operator.cc b/parser/common/op_def/operator.cc index 8db5a75..15296e9 100644 --- a/parser/common/op_def/operator.cc +++ b/parser/common/op_def/operator.cc @@ -1,5 +1,5 @@ /** - * Copyright 2020 Huawei Technologies Co., Ltd + * Copyright (c) Huawei Technologies Co., Ltd. 2022. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/parser/common/op_def/operator.h b/parser/common/op_def/operator.h index a97580f..28fce69 100644 --- a/parser/common/op_def/operator.h +++ b/parser/common/op_def/operator.h @@ -1,5 +1,5 @@ /** - * Copyright 2020 Huawei Technologies Co., Ltd + * Copyright (c) Huawei Technologies Co., Ltd. 2022. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/parser/common/op_def/ref_switch_op.cc b/parser/common/op_def/ref_switch_op.cc index 5331676..933e05b 100644 --- a/parser/common/op_def/ref_switch_op.cc +++ b/parser/common/op_def/ref_switch_op.cc @@ -1,5 +1,5 @@ /** - * Copyright 2020 Huawei Technologies Co., Ltd + * Copyright (c) Huawei Technologies Co., Ltd. 2022. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/parser/common/op_def/ref_switch_op.h b/parser/common/op_def/ref_switch_op.h index 6a09bea..becbf28 100644 --- a/parser/common/op_def/ref_switch_op.h +++ b/parser/common/op_def/ref_switch_op.h @@ -1,5 +1,5 @@ /** - * Copyright 2020 Huawei Technologies Co., Ltd + * Copyright (c) Huawei Technologies Co., Ltd. 2022. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/parser/common/op_def/shape_n_op.cc b/parser/common/op_def/shape_n_op.cc index d5d64dc..d75818d 100644 --- a/parser/common/op_def/shape_n_op.cc +++ b/parser/common/op_def/shape_n_op.cc @@ -1,5 +1,5 @@ /** - * Copyright 2020 Huawei Technologies Co., Ltd + * Copyright (c) Huawei Technologies Co., Ltd. 2022. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/parser/common/op_def/shape_n_op.h b/parser/common/op_def/shape_n_op.h index e60c70c..ce9aa2e 100644 --- a/parser/common/op_def/shape_n_op.h +++ b/parser/common/op_def/shape_n_op.h @@ -1,5 +1,5 @@ /** - * Copyright 2020 Huawei Technologies Co., Ltd + * Copyright (c) Huawei Technologies Co., Ltd. 2022. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/parser/common/op_def/var_is_initialized_op_op.cc b/parser/common/op_def/var_is_initialized_op_op.cc index ad3013d..9f7e9c2 100644 --- a/parser/common/op_def/var_is_initialized_op_op.cc +++ b/parser/common/op_def/var_is_initialized_op_op.cc @@ -1,5 +1,5 @@ /** - * Copyright 2020 Huawei Technologies Co., Ltd + * Copyright (c) Huawei Technologies Co., Ltd. 2022. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/parser/common/op_def/var_is_initialized_op_op.h b/parser/common/op_def/var_is_initialized_op_op.h index 1c8ac5e..a0c2a32 100644 --- a/parser/common/op_def/var_is_initialized_op_op.h +++ b/parser/common/op_def/var_is_initialized_op_op.h @@ -1,5 +1,5 @@ /** - * Copyright 2020 Huawei Technologies Co., Ltd + * Copyright (c) Huawei Technologies Co., Ltd. 2022. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/parser/common/op_def/variable_op.cc b/parser/common/op_def/variable_op.cc index 5be9600..d1d0c7b 100644 --- a/parser/common/op_def/variable_op.cc +++ b/parser/common/op_def/variable_op.cc @@ -1,5 +1,5 @@ /** - * Copyright 2020 Huawei Technologies Co., Ltd + * Copyright (c) Huawei Technologies Co., Ltd. 2022. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/parser/common/op_def/variable_op.h b/parser/common/op_def/variable_op.h index 3326657..76d60a1 100644 --- a/parser/common/op_def/variable_op.h +++ b/parser/common/op_def/variable_op.h @@ -1,5 +1,5 @@ /** - * Copyright 2020 Huawei Technologies Co., Ltd + * Copyright (c) Huawei Technologies Co., Ltd. 2022. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/parser/tensorflow/graph_functiondef.cc b/parser/tensorflow/graph_functiondef.cc index 983d8a6..94e3d2e 100644 --- a/parser/tensorflow/graph_functiondef.cc +++ b/parser/tensorflow/graph_functiondef.cc @@ -1,5 +1,5 @@ /** - * Copyright 2020 Huawei Technologies Co., Ltd +* Copyright (c) Huawei Technologies Co., Ltd. 2022. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/parser/tensorflow/graph_functiondef.h b/parser/tensorflow/graph_functiondef.h index ae27885..4a7a017 100644 --- a/parser/tensorflow/graph_functiondef.h +++ b/parser/tensorflow/graph_functiondef.h @@ -1,5 +1,5 @@ /** - * Copyright 2020 Huawei Technologies Co., Ltd + * Copyright (c) Huawei Technologies Co., Ltd. 2022. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,6 +28,7 @@ #include "proto/tensorflow/graph.pb.h" #include "register/register_error_codes.h" +namespace ge { using domi::tensorflow::AttrValue; using domi::tensorflow::AttrValue_ListValue; using domi::tensorflow::DataType; @@ -39,7 +40,6 @@ using std::string; using std::to_string; using std::vector; -namespace ge { class GraphToFunctionDef { public: static domi::Status RecordArg(ge::ComputeGraphPtr graph, @@ -65,6 +65,16 @@ class GraphToFunctionDef { static void AddNodeAttr(const string &attr_name, const domi::tensorflow::AttrValue &value, domi::tensorflow::NodeDef *node_def); + private: + static domi::Status DataOpToFunctionDef(const ge::NodePtr &node, FunctionDef *fdef, + std::map &tensor_renaming, NameMapHelper &node_names); + + + static domi::Status NetoutputOpToFunctionDef(const ge::NodePtr &node, FunctionDef *fdef, + NameMapHelper &node_names); + + static domi::Status UpdateFunctionDef(const ge::NodePtr &node, NodeDef *node_def, + NameMapHelper &node_names); }; class NameMapHelper { diff --git a/parser/tensorflow/graph_optimizer.cc b/parser/tensorflow/graph_optimizer.cc index e9c8799..3346364 100644 --- a/parser/tensorflow/graph_optimizer.cc +++ b/parser/tensorflow/graph_optimizer.cc @@ -202,9 +202,9 @@ Status ParserGraphOptimizer::UpdateGraph(vector &nodes) { "insert node to sub_graph failed."); GE_CHK_STATUS_RET(LinkInnerAnchor(node_map), "Link inner anchor failed."); - std::unique_ptr node_def(new (std::nothrow) NodeDef()); // tensorflow NodeDef + std::unique_ptr node_def = std::make_unique(); // tensorflow NodeDef GE_CHECK_NOTNULL(node_def); - std::unique_ptr func_def_lib(new (std::nothrow) FunctionDefLibrary()); + std::unique_ptr func_def_lib = std::make_unique(); GE_CHECK_NOTNULL(func_def_lib); // convert graph to FunctionDef if (nodes.size() == 0) { diff --git a/parser/tensorflow/graph_optimizer.h b/parser/tensorflow/graph_optimizer.h index 728230e..6fee699 100644 --- a/parser/tensorflow/graph_optimizer.h +++ b/parser/tensorflow/graph_optimizer.h @@ -1,5 +1,5 @@ /** - * Copyright 2020 Huawei Technologies Co., Ltd + * Copyright (c) Huawei Technologies Co., Ltd. 2022. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/parser/tensorflow/iterator_fusion_pass.cc b/parser/tensorflow/iterator_fusion_pass.cc index 14fcf9a..734d9a3 100644 --- a/parser/tensorflow/iterator_fusion_pass.cc +++ b/parser/tensorflow/iterator_fusion_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2020 Huawei Technologies Co., Ltd + * Copyright (c) Huawei Technologies Co., Ltd. 2022. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/parser/tensorflow/iterator_fusion_pass.h b/parser/tensorflow/iterator_fusion_pass.h index 268613f..0756bb9 100644 --- a/parser/tensorflow/iterator_fusion_pass.h +++ b/parser/tensorflow/iterator_fusion_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2020 Huawei Technologies Co., Ltd + * Copyright (c) Huawei Technologies Co., Ltd. 2022. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/parser/tensorflow/scope/scope_pass_manager.cc b/parser/tensorflow/scope/scope_pass_manager.cc index b4a3a65..d715e20 100644 --- a/parser/tensorflow/scope/scope_pass_manager.cc +++ b/parser/tensorflow/scope/scope_pass_manager.cc @@ -1,5 +1,5 @@ /** - * Copyright 2020 Huawei Technologies Co., Ltd + * Copyright (c) Huawei Technologies Co., Ltd. 2022. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/parser/tensorflow/scope/scope_pass_manager.h b/parser/tensorflow/scope/scope_pass_manager.h index d661003..2f24b28 100644 --- a/parser/tensorflow/scope/scope_pass_manager.h +++ b/parser/tensorflow/scope/scope_pass_manager.h @@ -1,5 +1,5 @@ /** - * Copyright 2020 Huawei Technologies Co., Ltd + * Copyright (c) Huawei Technologies Co., Ltd. 2022. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/parser/tensorflow/tensorflow_arg_parser.cc b/parser/tensorflow/tensorflow_arg_parser.cc index afa6097..32a1943 100644 --- a/parser/tensorflow/tensorflow_arg_parser.cc +++ b/parser/tensorflow/tensorflow_arg_parser.cc @@ -1,5 +1,5 @@ /** - * Copyright 2020 Huawei Technologies Co., Ltd + * Copyright (c) Huawei Technologies Co., Ltd. 2022. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/parser/tensorflow/tensorflow_auto_mapping_parser_adapter.cc b/parser/tensorflow/tensorflow_auto_mapping_parser_adapter.cc index 3fc99de..89a2ee8 100644 --- a/parser/tensorflow/tensorflow_auto_mapping_parser_adapter.cc +++ b/parser/tensorflow/tensorflow_auto_mapping_parser_adapter.cc @@ -1,5 +1,5 @@ /** - * Copyright 2020 Huawei Technologies Co., Ltd + * Copyright (c) Huawei Technologies Co., Ltd. 2022. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/parser/tensorflow/tensorflow_auto_mapping_parser_adapter.h b/parser/tensorflow/tensorflow_auto_mapping_parser_adapter.h index 9b4cf52..f7bc8f5 100644 --- a/parser/tensorflow/tensorflow_auto_mapping_parser_adapter.h +++ b/parser/tensorflow/tensorflow_auto_mapping_parser_adapter.h @@ -1,5 +1,5 @@ /** - * Copyright 2020 Huawei Technologies Co., Ltd + * Copyright (c) Huawei Technologies Co., Ltd. 2022. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.