From 44202c9b9da350b015a235ab30360204fae95dcb Mon Sep 17 00:00:00 2001 From: 13291271729 Date: Mon, 29 Aug 2022 21:47:31 +0800 Subject: [PATCH 01/23] 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. From 0194e53f0021086c35cc97fa3347a2bc3a0f3da8 Mon Sep 17 00:00:00 2001 From: 13291271729 Date: Tue, 30 Aug 2022 14:42:20 +0800 Subject: [PATCH 02/23] clean code --- parser/common/convert/message2operator.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/parser/common/convert/message2operator.h b/parser/common/convert/message2operator.h index c65d92b..9781240 100644 --- a/parser/common/convert/message2operator.h +++ b/parser/common/convert/message2operator.h @@ -41,7 +41,7 @@ class Message2Operator { void ParseRepeatedBaseTypeField(const google::protobuf::Reflection *reflection, const google::protobuf::Message *message, const google::protobuf::FieldDescriptor *field, - ge::Operator &ops) + ge::Operator &ops); }; } // namespace ge #endif // PARSER_MESSAGE2OPERATOR_H From c64d328cb99e0764deb3145bcb9266339531341c Mon Sep 17 00:00:00 2001 From: 13291271729 Date: Tue, 30 Aug 2022 15:10:06 +0800 Subject: [PATCH 03/23] clean code --- parser/common/convert/message2operator.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/parser/common/convert/message2operator.cc b/parser/common/convert/message2operator.cc index 866a78a..2331a03 100644 --- a/parser/common/convert/message2operator.cc +++ b/parser/common/convert/message2operator.cc @@ -95,6 +95,7 @@ void Message2Operator::ParseBaseTypeField(const google::protobuf::Reflection *re default: { break; } + } } Status Message2Operator::ParseField(const google::protobuf::Reflection *reflection, @@ -197,6 +198,7 @@ void Message2Operator::ParseRepeatedBaseTypeField(const google::protobuf::Reflec default: { break; } + } } Status Message2Operator::ParseRepeatedField(const google::protobuf::Reflection *reflection, From dcbbc48f5ecfcd96c0f3fe802387dcbbc2b0f6ce Mon Sep 17 00:00:00 2001 From: 13291271729 Date: Tue, 30 Aug 2022 15:25:59 +0800 Subject: [PATCH 04/23] clean code --- parser/common/convert/message2operator.cc | 4 ++-- parser/common/convert/message2operator.h | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/parser/common/convert/message2operator.cc b/parser/common/convert/message2operator.cc index 2331a03..3b0c96f 100644 --- a/parser/common/convert/message2operator.cc +++ b/parser/common/convert/message2operator.cc @@ -139,7 +139,7 @@ Status Message2Operator::ParseField(const google::protobuf::Reflection *reflecti void Message2Operator::ParseRepeatedBaseTypeField(const google::protobuf::Reflection *reflection, const google::protobuf::Message *message, const google::protobuf::FieldDescriptor *field, - ge::Operator &ops) { + ge::Operator &ops, const int field_size) { switch (field->cpp_type()) { case google::protobuf::FieldDescriptor::CPPTYPE_INT32: { std::vector attr_value; @@ -213,7 +213,7 @@ Status Message2Operator::ParseRepeatedField(const google::protobuf::Reflection * return FAILED; } - ParseRepeatedBaseTypeField(reflection, message, field, ops); + ParseRepeatedBaseTypeField(reflection, message, field, ops, field_size); switch (field->cpp_type()) { case google::protobuf::FieldDescriptor::CPPTYPE_MESSAGE: { nlohmann::json message_json; diff --git a/parser/common/convert/message2operator.h b/parser/common/convert/message2operator.h index 9781240..5b073fc 100644 --- a/parser/common/convert/message2operator.h +++ b/parser/common/convert/message2operator.h @@ -34,14 +34,14 @@ class Message2Operator { 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); + static 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); + static 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 From 616e871b36a8458a67ed26602c246f6d76b8aa22 Mon Sep 17 00:00:00 2001 From: 13291271729 Date: Tue, 30 Aug 2022 15:36:07 +0800 Subject: [PATCH 05/23] clean code --- parser/common/convert/message2operator.h | 2 +- parser/tensorflow/graph_functiondef.h | 10 ---------- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/parser/common/convert/message2operator.h b/parser/common/convert/message2operator.h index 5b073fc..a1810cb 100644 --- a/parser/common/convert/message2operator.h +++ b/parser/common/convert/message2operator.h @@ -41,7 +41,7 @@ class Message2Operator { static void ParseRepeatedBaseTypeField(const google::protobuf::Reflection *reflection, const google::protobuf::Message *message, const google::protobuf::FieldDescriptor *field, - ge::Operator &ops); + ge::Operator &ops, const int field_size); }; } // namespace ge #endif // PARSER_MESSAGE2OPERATOR_H diff --git a/parser/tensorflow/graph_functiondef.h b/parser/tensorflow/graph_functiondef.h index 4a7a017..44cd48a 100644 --- a/parser/tensorflow/graph_functiondef.h +++ b/parser/tensorflow/graph_functiondef.h @@ -65,16 +65,6 @@ 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 { From 80e9e632073a6756c9147ed6464e7a254b919dcf Mon Sep 17 00:00:00 2001 From: 13291271729 Date: Tue, 30 Aug 2022 16:04:04 +0800 Subject: [PATCH 06/23] clean code --- parser/tensorflow/graph_functiondef.h | 2 +- parser/tensorflow/graph_optimizer.cc | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/parser/tensorflow/graph_functiondef.h b/parser/tensorflow/graph_functiondef.h index 44cd48a..081a022 100644 --- a/parser/tensorflow/graph_functiondef.h +++ b/parser/tensorflow/graph_functiondef.h @@ -28,7 +28,6 @@ #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; @@ -40,6 +39,7 @@ using std::string; using std::to_string; using std::vector; +namespace ge { class GraphToFunctionDef { public: static domi::Status RecordArg(ge::ComputeGraphPtr graph, diff --git a/parser/tensorflow/graph_optimizer.cc b/parser/tensorflow/graph_optimizer.cc index 3346364..e9c8799 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 = std::make_unique(); // tensorflow NodeDef + std::unique_ptr node_def(new (std::nothrow) NodeDef()); // tensorflow NodeDef GE_CHECK_NOTNULL(node_def); - std::unique_ptr func_def_lib = std::make_unique(); + std::unique_ptr func_def_lib(new (std::nothrow) FunctionDefLibrary()); GE_CHECK_NOTNULL(func_def_lib); // convert graph to FunctionDef if (nodes.size() == 0) { From 0ba1a7a24c761cbffddfcf7f498bd31c0fcadb9d Mon Sep 17 00:00:00 2001 From: 13291271729 Date: Tue, 30 Aug 2022 21:01:30 +0800 Subject: [PATCH 07/23] clean code --- parser/common/convert/message2operator.cc | 17 ++++++++++------- parser/common/convert/message2operator.h | 14 +++++++------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/parser/common/convert/message2operator.cc b/parser/common/convert/message2operator.cc index 3b0c96f..34fc664 100644 --- a/parser/common/convert/message2operator.cc +++ b/parser/common/convert/message2operator.cc @@ -58,7 +58,7 @@ Status Message2Operator::ParseOperatorAttrs(const google::protobuf::Message *mes return SUCCESS; } -void Message2Operator::ParseBaseTypeField(const google::protobuf::Reflection *reflection, +Status Message2Operator::ParseBaseTypeField(const google::protobuf::Reflection *reflection, const google::protobuf::Message *message, const google::protobuf::FieldDescriptor *field, ge::Operator &ops) { switch (field->cpp_type()) { @@ -93,16 +93,18 @@ void Message2Operator::ParseBaseTypeField(const google::protobuf::Reflection *re break; } default: { - break; + return FAILED; } } + return SUCCESS; } 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); + GE_CHK_BOOL_RET_STATUS(ParseBaseTypeField(reflection, message, field, ops) == FAILED, SUCCESS, + "Parse field: %s success.", field->name().c_str()); switch (field->cpp_type()) { case google::protobuf::FieldDescriptor::CPPTYPE_ENUM: { GE_CHECK_NOTNULL(reflection->GetEnum(*message, field)); @@ -136,7 +138,7 @@ Status Message2Operator::ParseField(const google::protobuf::Reflection *reflecti return SUCCESS; } -void Message2Operator::ParseRepeatedBaseTypeField(const google::protobuf::Reflection *reflection, +Status Message2Operator::ParseRepeatedBaseTypeField(const google::protobuf::Reflection *reflection, const google::protobuf::Message *message, const google::protobuf::FieldDescriptor *field, ge::Operator &ops, const int field_size) { @@ -196,9 +198,10 @@ void Message2Operator::ParseRepeatedBaseTypeField(const google::protobuf::Reflec break; } default: { - break; + return FAILED; } } + return SUCCESS; } Status Message2Operator::ParseRepeatedField(const google::protobuf::Reflection *reflection, @@ -212,8 +215,8 @@ Status Message2Operator::ParseRepeatedField(const google::protobuf::Reflection * GELOGE(FAILED, "[Check][Size]Size of repeated field %s must bigger than 0", field->name().c_str()); return FAILED; } - - ParseRepeatedBaseTypeField(reflection, message, field, ops, field_size); + GE_CHK_BOOL_RET_STATUS(ParseRepeatedBaseTypeField(reflection, message, field, ops, field_size) == FAILED, SUCCESS, + "Parse repeated field: %s success.", field->name().c_str()); switch (field->cpp_type()) { case google::protobuf::FieldDescriptor::CPPTYPE_MESSAGE: { nlohmann::json message_json; diff --git a/parser/common/convert/message2operator.h b/parser/common/convert/message2operator.h index a1810cb..cbf885d 100644 --- a/parser/common/convert/message2operator.h +++ b/parser/common/convert/message2operator.h @@ -34,14 +34,14 @@ class Message2Operator { const google::protobuf::Message *message, const google::protobuf::FieldDescriptor *field, ge::Operator &ops); - static void ParseBaseTypeField(const google::protobuf::Reflection *reflection, - const google::protobuf::Message *message, - const google::protobuf::FieldDescriptor *field, ge::Operator &ops); + static Status ParseBaseTypeField(const google::protobuf::Reflection *reflection, + const google::protobuf::Message *message, + const google::protobuf::FieldDescriptor *field, ge::Operator &ops); - static void ParseRepeatedBaseTypeField(const google::protobuf::Reflection *reflection, - const google::protobuf::Message *message, - const google::protobuf::FieldDescriptor *field, - ge::Operator &ops, const int field_size); + static Status ParseRepeatedBaseTypeField(const google::protobuf::Reflection *reflection, + const google::protobuf::Message *message, + const google::protobuf::FieldDescriptor *field, + ge::Operator &ops, const int field_size); }; } // namespace ge #endif // PARSER_MESSAGE2OPERATOR_H From 74d0a7da19f45eeeb871eb855c359f3c53bfd0f2 Mon Sep 17 00:00:00 2001 From: 13291271729 Date: Wed, 31 Aug 2022 11:35:23 +0800 Subject: [PATCH 08/23] clean code --- .../tensorflow_parser_unittest.cc | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_parser_unittest.cc b/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_parser_unittest.cc index 00678d8..5f2ee69 100644 --- a/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_parser_unittest.cc +++ b/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_parser_unittest.cc @@ -3622,6 +3622,56 @@ TEST_F(UtestTensorflowParser, tensorflow_Message2Operator_ParseOperatorAttrs_tes EXPECT_EQ(ret, SUCCESS); } +TEST_F(UtestTensorflowParser, tensorflow_Message2Operator_ParseOperatorAttrs_success) +{ + Message2Operator mess2Op; + tensorflow::NodeDef nodedef; + nodedef.set_name(_name); + nodedef.set_op(_name); + + ge::OpDescPtr op_desc = std::make_shared(); + ge::Operator ops = ge::OpDescUtils::CreateOperatorFromOpDesc(op_desc); + + tensorflow::AttrValue value; + value.set_s("string"); + TensorFlowUtil::AddNodeAttr("op_def", value, &nodedef); + value.set_i(1); + TensorFlowUtil::AddNodeAttr("num", value, &nodedef); + domi::tensorflow::DataType VALUE_TYPE = domi::tensorflow::DataType::DT_FLOAT; + value.set_type(VALUE_TYPE); + TensorFlowUtil::AddNodeAttr("float", value, &nodedef); + VALUE_TYPE = domi::tensorflow::DataType::DT_UINT32; + value.set_type(VALUE_TYPE); + TensorFlowUtil::AddNodeAttr("uint32", value, &nodedef); + VALUE_TYPE = domi::tensorflow::DataType::DT_INT64; + value.set_type(VALUE_TYPE); + TensorFlowUtil::AddNodeAttr("int64", value, &nodedef); + VALUE_TYPE = domi::tensorflow::DataType::DT_BOOL; + value.set_type(VALUE_TYPE); + TensorFlowUtil::AddNodeAttr("bool", value, &nodedef); + Status ret = mess2Op.ParseOperatorAttrs(&node_def, 1, ops); + EXPECT_EQ(ret, SUCCESS); + + value.mutable_list()->set_s("string"); + TensorFlowUtil::AddNodeAttr("op_def", value, &nodedef); + value.mutable_list()->set_i(1); + TensorFlowUtil::AddNodeAttr("num", value, &nodedef); + domi::tensorflow::DataType VALUE_TYPE = domi::tensorflow::DataType::DT_FLOAT; + value.mutable_list()->add_type(VALUE_TYPE); + TensorFlowUtil::AddNodeAttr("float", value, &nodedef); + VALUE_TYPE = domi::tensorflow::DataType::DT_UINT32; + value.mutable_list()->add_type(VALUE_TYPE); + TensorFlowUtil::AddNodeAttr("uint32", value, &nodedef); + VALUE_TYPE = domi::tensorflow::DataType::DT_INT64; + value.mutable_list()->add_type(VALUE_TYPE); + TensorFlowUtil::AddNodeAttr("int64", value, &nodedef); + VALUE_TYPE = domi::tensorflow::DataType::DT_BOOL; + value.mutable_list()->add_type(VALUE_TYPE); + TensorFlowUtil::AddNodeAttr("bool", value, &nodedef); + ret = mess2Op.ParseOperatorAttrs(&node_def, 1, ops); + EXPECT_EQ(ret, SUCCESS); +} + TEST_F(UtestTensorflowParser, tensorflow_Pb2Json_RepeatedEnum2Json_test) { Pb2Json toJson; From bb1c16298ac345564d46483ed8cafab722eeb402 Mon Sep 17 00:00:00 2001 From: 13291271729 Date: Wed, 31 Aug 2022 12:04:23 +0800 Subject: [PATCH 09/23] clean code --- .../tensorflow_parser_unittest.cc | 27 +++++++++++++------ 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_parser_unittest.cc b/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_parser_unittest.cc index 5f2ee69..3a6c6e4 100644 --- a/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_parser_unittest.cc +++ b/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_parser_unittest.cc @@ -3634,40 +3634,51 @@ TEST_F(UtestTensorflowParser, tensorflow_Message2Operator_ParseOperatorAttrs_suc tensorflow::AttrValue value; value.set_s("string"); - TensorFlowUtil::AddNodeAttr("op_def", value, &nodedef); + TensorFlowUtil::AddNodeAttr("str", value, &nodedef); + value.clear_value(); value.set_i(1); TensorFlowUtil::AddNodeAttr("num", value, &nodedef); + value.clear_value(); domi::tensorflow::DataType VALUE_TYPE = domi::tensorflow::DataType::DT_FLOAT; value.set_type(VALUE_TYPE); TensorFlowUtil::AddNodeAttr("float", value, &nodedef); + value.clear_value(); VALUE_TYPE = domi::tensorflow::DataType::DT_UINT32; value.set_type(VALUE_TYPE); TensorFlowUtil::AddNodeAttr("uint32", value, &nodedef); + value.clear_value(); VALUE_TYPE = domi::tensorflow::DataType::DT_INT64; value.set_type(VALUE_TYPE); TensorFlowUtil::AddNodeAttr("int64", value, &nodedef); + value.clear_value(); VALUE_TYPE = domi::tensorflow::DataType::DT_BOOL; value.set_type(VALUE_TYPE); TensorFlowUtil::AddNodeAttr("bool", value, &nodedef); Status ret = mess2Op.ParseOperatorAttrs(&node_def, 1, ops); EXPECT_EQ(ret, SUCCESS); + value.clear_value(); value.mutable_list()->set_s("string"); - TensorFlowUtil::AddNodeAttr("op_def", value, &nodedef); + TensorFlowUtil::AddNodeAttr("str_list", value, &nodedef); + value.clear_value(); value.mutable_list()->set_i(1); - TensorFlowUtil::AddNodeAttr("num", value, &nodedef); - domi::tensorflow::DataType VALUE_TYPE = domi::tensorflow::DataType::DT_FLOAT; + TensorFlowUtil::AddNodeAttr("num_list", value, &nodedef); + value.clear_value(); + VALUE_TYPE = domi::tensorflow::DataType::DT_FLOAT; value.mutable_list()->add_type(VALUE_TYPE); - TensorFlowUtil::AddNodeAttr("float", value, &nodedef); + TensorFlowUtil::AddNodeAttr("float_list", value, &nodedef); + value.clear_value(); VALUE_TYPE = domi::tensorflow::DataType::DT_UINT32; value.mutable_list()->add_type(VALUE_TYPE); - TensorFlowUtil::AddNodeAttr("uint32", value, &nodedef); + TensorFlowUtil::AddNodeAttr("uint32_list", value, &nodedef); + value.clear_value(); VALUE_TYPE = domi::tensorflow::DataType::DT_INT64; value.mutable_list()->add_type(VALUE_TYPE); - TensorFlowUtil::AddNodeAttr("int64", value, &nodedef); + TensorFlowUtil::AddNodeAttr("int64_list", value, &nodedef); + value.clear_value(); VALUE_TYPE = domi::tensorflow::DataType::DT_BOOL; value.mutable_list()->add_type(VALUE_TYPE); - TensorFlowUtil::AddNodeAttr("bool", value, &nodedef); + TensorFlowUtil::AddNodeAttr("bool_list", value, &nodedef); ret = mess2Op.ParseOperatorAttrs(&node_def, 1, ops); EXPECT_EQ(ret, SUCCESS); } From 388ba4b7d8e0007da90243fdc07bc7d563f1770e Mon Sep 17 00:00:00 2001 From: 13291271729 Date: Wed, 31 Aug 2022 14:21:40 +0800 Subject: [PATCH 10/23] clean code --- .../tensorflow_parser_unittest.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_parser_unittest.cc b/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_parser_unittest.cc index 3a6c6e4..2119f78 100644 --- a/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_parser_unittest.cc +++ b/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_parser_unittest.cc @@ -3654,14 +3654,15 @@ TEST_F(UtestTensorflowParser, tensorflow_Message2Operator_ParseOperatorAttrs_suc VALUE_TYPE = domi::tensorflow::DataType::DT_BOOL; value.set_type(VALUE_TYPE); TensorFlowUtil::AddNodeAttr("bool", value, &nodedef); - Status ret = mess2Op.ParseOperatorAttrs(&node_def, 1, ops); + Status ret = mess2Op.ParseOperatorAttrs(&nodedef, 1, ops); EXPECT_EQ(ret, SUCCESS); value.clear_value(); - value.mutable_list()->set_s("string"); + VALUE_TYPE = domi::tensorflow::DataType::DT_STRING; + value.mutable_list()->add_type(VALUE_TYPE); TensorFlowUtil::AddNodeAttr("str_list", value, &nodedef); value.clear_value(); - value.mutable_list()->set_i(1); + value.mutable_list()->add_i(1); TensorFlowUtil::AddNodeAttr("num_list", value, &nodedef); value.clear_value(); VALUE_TYPE = domi::tensorflow::DataType::DT_FLOAT; @@ -3679,7 +3680,7 @@ TEST_F(UtestTensorflowParser, tensorflow_Message2Operator_ParseOperatorAttrs_suc VALUE_TYPE = domi::tensorflow::DataType::DT_BOOL; value.mutable_list()->add_type(VALUE_TYPE); TensorFlowUtil::AddNodeAttr("bool_list", value, &nodedef); - ret = mess2Op.ParseOperatorAttrs(&node_def, 1, ops); + ret = mess2Op.ParseOperatorAttrs(&nodedef, 1, ops); EXPECT_EQ(ret, SUCCESS); } From e1f65f41fc75580f864eb682140edbdd332e356f Mon Sep 17 00:00:00 2001 From: 13291271729 Date: Wed, 31 Aug 2022 14:36:14 +0800 Subject: [PATCH 11/23] clean code --- .../tensorflow_parser_testcase/tensorflow_parser_unittest.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_parser_unittest.cc b/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_parser_unittest.cc index 2119f78..8223c9f 100644 --- a/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_parser_unittest.cc +++ b/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_parser_unittest.cc @@ -3626,8 +3626,8 @@ TEST_F(UtestTensorflowParser, tensorflow_Message2Operator_ParseOperatorAttrs_suc { Message2Operator mess2Op; tensorflow::NodeDef nodedef; - nodedef.set_name(_name); - nodedef.set_op(_name); + nodedef.set_name("const"); + nodedef.set_op("const"); ge::OpDescPtr op_desc = std::make_shared(); ge::Operator ops = ge::OpDescUtils::CreateOperatorFromOpDesc(op_desc); From 1ee5730b14662617b653bc62c4ec854c0536217c Mon Sep 17 00:00:00 2001 From: 13291271729 Date: Wed, 31 Aug 2022 15:05:42 +0800 Subject: [PATCH 12/23] clean code --- parser/common/convert/message2operator.cc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/parser/common/convert/message2operator.cc b/parser/common/convert/message2operator.cc index 34fc664..7bdc498 100644 --- a/parser/common/convert/message2operator.cc +++ b/parser/common/convert/message2operator.cc @@ -44,12 +44,16 @@ Status Message2Operator::ParseOperatorAttrs(const google::protobuf::Message *mes for (auto &field : field_desc) { GE_CHECK_NOTNULL(field); if (field->is_repeated()) { + std::cout << "1111" << endl, if (ParseRepeatedField(reflection, message, field, ops) != SUCCESS) { + std::cout << "[Parse][RepeatedField]" << field->name().c_str() << "failed." << endl, GELOGE(FAILED, "[Parse][RepeatedField] %s failed.", field->name().c_str()); return FAILED; } } else { + std::cout << "2222" << endl, if (ParseField(reflection, message, field, depth, ops) != SUCCESS) { + std::cout << "[Parse][Field]" << field->name().c_str() << "failed." << endl, GELOGE(FAILED, "[Parse][Field] %s failed.", field->name().c_str()); return FAILED; } @@ -61,6 +65,7 @@ Status Message2Operator::ParseOperatorAttrs(const google::protobuf::Message *mes Status Message2Operator::ParseBaseTypeField(const google::protobuf::Reflection *reflection, const google::protobuf::Message *message, const google::protobuf::FieldDescriptor *field, ge::Operator &ops) { + std::cout << "weewf" << endl; switch (field->cpp_type()) { case google::protobuf::FieldDescriptor::CPPTYPE_INT32: { int32_t value = reflection->GetInt32(*message, field); @@ -69,12 +74,14 @@ Status Message2Operator::ParseBaseTypeField(const google::protobuf::Reflection * break; } case google::protobuf::FieldDescriptor::CPPTYPE_UINT32: { + std::cout << "weCPPTYPE_UINT32ewf" << endl; 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: { + std::cout << "CPPTYPE_INT64" << endl; 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); @@ -154,6 +161,7 @@ Status Message2Operator::ParseRepeatedBaseTypeField(const google::protobuf::Refl } case google::protobuf::FieldDescriptor::CPPTYPE_UINT32: { std::vector attr_value; + std::cout << "sdfsfCPPTYPE_UINT32"; for (int i = 0; i < field_size; i++) { uint32_t value = reflection->GetRepeatedUInt32(*message, field, i); attr_value.push_back(value); @@ -171,6 +179,7 @@ Status Message2Operator::ParseRepeatedBaseTypeField(const google::protobuf::Refl break; } case google::protobuf::FieldDescriptor::CPPTYPE_FLOAT: { + std::cout << "sdfsfCPPTYPE_FLOAT" << endl; std::vector attr_value; for (int i = 0; i < field_size; i++) { float value = reflection->GetRepeatedFloat(*message, field, i); From ae2d60c497fd3aa4e332d2f66fb031e658773576 Mon Sep 17 00:00:00 2001 From: 13291271729 Date: Wed, 31 Aug 2022 15:12:28 +0800 Subject: [PATCH 13/23] clean code --- parser/common/convert/message2operator.cc | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/parser/common/convert/message2operator.cc b/parser/common/convert/message2operator.cc index 7bdc498..2433c80 100644 --- a/parser/common/convert/message2operator.cc +++ b/parser/common/convert/message2operator.cc @@ -44,16 +44,16 @@ Status Message2Operator::ParseOperatorAttrs(const google::protobuf::Message *mes for (auto &field : field_desc) { GE_CHECK_NOTNULL(field); if (field->is_repeated()) { - std::cout << "1111" << endl, + std::cout << "1111" << std::endl, if (ParseRepeatedField(reflection, message, field, ops) != SUCCESS) { - std::cout << "[Parse][RepeatedField]" << field->name().c_str() << "failed." << endl, + std::cout << "[Parse][RepeatedField]" << field->name().c_str() << "failed." << std::endl, GELOGE(FAILED, "[Parse][RepeatedField] %s failed.", field->name().c_str()); return FAILED; } } else { - std::cout << "2222" << endl, + std::cout << "2222" << std::endl, if (ParseField(reflection, message, field, depth, ops) != SUCCESS) { - std::cout << "[Parse][Field]" << field->name().c_str() << "failed." << endl, + std::cout << "[Parse][Field]" << field->name().c_str() << "failed." << std::endl, GELOGE(FAILED, "[Parse][Field] %s failed.", field->name().c_str()); return FAILED; } @@ -65,7 +65,7 @@ Status Message2Operator::ParseOperatorAttrs(const google::protobuf::Message *mes Status Message2Operator::ParseBaseTypeField(const google::protobuf::Reflection *reflection, const google::protobuf::Message *message, const google::protobuf::FieldDescriptor *field, ge::Operator &ops) { - std::cout << "weewf" << endl; + std::cout << "weewf" << std::endl; switch (field->cpp_type()) { case google::protobuf::FieldDescriptor::CPPTYPE_INT32: { int32_t value = reflection->GetInt32(*message, field); @@ -74,14 +74,14 @@ Status Message2Operator::ParseBaseTypeField(const google::protobuf::Reflection * break; } case google::protobuf::FieldDescriptor::CPPTYPE_UINT32: { - std::cout << "weCPPTYPE_UINT32ewf" << endl; + std::cout << "weCPPTYPE_UINT32ewf" << std::endl; 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: { - std::cout << "CPPTYPE_INT64" << endl; + std::cout << "CPPTYPE_INT64" << std::endl; 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); @@ -179,7 +179,7 @@ Status Message2Operator::ParseRepeatedBaseTypeField(const google::protobuf::Refl break; } case google::protobuf::FieldDescriptor::CPPTYPE_FLOAT: { - std::cout << "sdfsfCPPTYPE_FLOAT" << endl; + std::cout << "sdfsfCPPTYPE_FLOAT" << std::endl; std::vector attr_value; for (int i = 0; i < field_size; i++) { float value = reflection->GetRepeatedFloat(*message, field, i); From 88ec1f42eecb4061e4576ea1fd616618d37fafcf Mon Sep 17 00:00:00 2001 From: 13291271729 Date: Wed, 31 Aug 2022 15:18:56 +0800 Subject: [PATCH 14/23] clean code --- parser/common/convert/message2operator.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/parser/common/convert/message2operator.cc b/parser/common/convert/message2operator.cc index 2433c80..e6cc662 100644 --- a/parser/common/convert/message2operator.cc +++ b/parser/common/convert/message2operator.cc @@ -44,16 +44,16 @@ Status Message2Operator::ParseOperatorAttrs(const google::protobuf::Message *mes for (auto &field : field_desc) { GE_CHECK_NOTNULL(field); if (field->is_repeated()) { - std::cout << "1111" << std::endl, + std::cout << "1111" << std::endl; if (ParseRepeatedField(reflection, message, field, ops) != SUCCESS) { - std::cout << "[Parse][RepeatedField]" << field->name().c_str() << "failed." << std::endl, + std::cout << "[Parse][RepeatedField]" << field->name().c_str() << "failed." << std::endl; GELOGE(FAILED, "[Parse][RepeatedField] %s failed.", field->name().c_str()); return FAILED; } } else { - std::cout << "2222" << std::endl, + std::cout << "2222" << std::endl; if (ParseField(reflection, message, field, depth, ops) != SUCCESS) { - std::cout << "[Parse][Field]" << field->name().c_str() << "failed." << std::endl, + std::cout << "[Parse][Field]" << field->name().c_str() << "failed." << std::endl; GELOGE(FAILED, "[Parse][Field] %s failed.", field->name().c_str()); return FAILED; } From 3985ac6c86f2833bee2c7f03d14a651436e9dd60 Mon Sep 17 00:00:00 2001 From: 13291271729 Date: Wed, 31 Aug 2022 16:03:59 +0800 Subject: [PATCH 15/23] clean code --- parser/common/convert/message2operator.cc | 150 ++++-------------- parser/common/convert/message2operator.h | 9 -- .../tensorflow_parser_unittest.cc | 62 -------- 3 files changed, 30 insertions(+), 191 deletions(-) diff --git a/parser/common/convert/message2operator.cc b/parser/common/convert/message2operator.cc index e6cc662..e02643e 100644 --- a/parser/common/convert/message2operator.cc +++ b/parser/common/convert/message2operator.cc @@ -44,16 +44,12 @@ Status Message2Operator::ParseOperatorAttrs(const google::protobuf::Message *mes for (auto &field : field_desc) { GE_CHECK_NOTNULL(field); if (field->is_repeated()) { - std::cout << "1111" << std::endl; if (ParseRepeatedField(reflection, message, field, ops) != SUCCESS) { - std::cout << "[Parse][RepeatedField]" << field->name().c_str() << "failed." << std::endl; GELOGE(FAILED, "[Parse][RepeatedField] %s failed.", field->name().c_str()); return FAILED; } } else { - std::cout << "2222" << std::endl; if (ParseField(reflection, message, field, depth, ops) != SUCCESS) { - std::cout << "[Parse][Field]" << field->name().c_str() << "failed." << std::endl; GELOGE(FAILED, "[Parse][Field] %s failed.", field->name().c_str()); return FAILED; } @@ -62,57 +58,24 @@ Status Message2Operator::ParseOperatorAttrs(const google::protobuf::Message *mes return SUCCESS; } -Status Message2Operator::ParseBaseTypeField(const google::protobuf::Reflection *reflection, - const google::protobuf::Message *message, - const google::protobuf::FieldDescriptor *field, ge::Operator &ops) { - std::cout << "weewf" << std::endl; - 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: { - std::cout << "weCPPTYPE_UINT32ewf" << std::endl; - 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: { - std::cout << "CPPTYPE_INT64" << std::endl; - 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: { - return FAILED; - } - } - return SUCCESS; -} - 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()); - GE_CHK_BOOL_RET_STATUS(ParseBaseTypeField(reflection, message, field, ops) == FAILED, SUCCESS, - "Parse field: %s success.", field->name().c_str()); 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(); @@ -145,74 +108,6 @@ Status Message2Operator::ParseField(const google::protobuf::Reflection *reflecti return SUCCESS; } -Status Message2Operator::ParseRepeatedBaseTypeField(const google::protobuf::Reflection *reflection, - const google::protobuf::Message *message, - const google::protobuf::FieldDescriptor *field, - ge::Operator &ops, const int field_size) { - 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; - std::cout << "sdfsfCPPTYPE_UINT32"; - 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::cout << "sdfsfCPPTYPE_FLOAT" << std::endl; - 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: { - return FAILED; - } - } - return SUCCESS; -} - Status Message2Operator::ParseRepeatedField(const google::protobuf::Reflection *reflection, const google::protobuf::Message *message, const google::protobuf::FieldDescriptor *field, @@ -224,9 +119,24 @@ Status Message2Operator::ParseRepeatedField(const google::protobuf::Reflection * GELOGE(FAILED, "[Check][Size]Size of repeated field %s must bigger than 0", field->name().c_str()); return FAILED; } - GE_CHK_BOOL_RET_STATUS(ParseRepeatedBaseTypeField(reflection, message, field, ops, field_size) == FAILED, SUCCESS, - "Parse repeated field: %s success.", field->name().c_str()); 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 cbf885d..b247112 100644 --- a/parser/common/convert/message2operator.h +++ b/parser/common/convert/message2operator.h @@ -33,15 +33,6 @@ class Message2Operator { static Status ParseRepeatedField(const google::protobuf::Reflection *reflection, const google::protobuf::Message *message, const google::protobuf::FieldDescriptor *field, ge::Operator &ops); - - static Status ParseBaseTypeField(const google::protobuf::Reflection *reflection, - const google::protobuf::Message *message, - const google::protobuf::FieldDescriptor *field, ge::Operator &ops); - - static Status ParseRepeatedBaseTypeField(const google::protobuf::Reflection *reflection, - const google::protobuf::Message *message, - const google::protobuf::FieldDescriptor *field, - ge::Operator &ops, const int field_size); }; } // namespace ge #endif // PARSER_MESSAGE2OPERATOR_H diff --git a/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_parser_unittest.cc b/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_parser_unittest.cc index 8223c9f..00678d8 100644 --- a/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_parser_unittest.cc +++ b/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_parser_unittest.cc @@ -3622,68 +3622,6 @@ TEST_F(UtestTensorflowParser, tensorflow_Message2Operator_ParseOperatorAttrs_tes EXPECT_EQ(ret, SUCCESS); } -TEST_F(UtestTensorflowParser, tensorflow_Message2Operator_ParseOperatorAttrs_success) -{ - Message2Operator mess2Op; - tensorflow::NodeDef nodedef; - nodedef.set_name("const"); - nodedef.set_op("const"); - - ge::OpDescPtr op_desc = std::make_shared(); - ge::Operator ops = ge::OpDescUtils::CreateOperatorFromOpDesc(op_desc); - - tensorflow::AttrValue value; - value.set_s("string"); - TensorFlowUtil::AddNodeAttr("str", value, &nodedef); - value.clear_value(); - value.set_i(1); - TensorFlowUtil::AddNodeAttr("num", value, &nodedef); - value.clear_value(); - domi::tensorflow::DataType VALUE_TYPE = domi::tensorflow::DataType::DT_FLOAT; - value.set_type(VALUE_TYPE); - TensorFlowUtil::AddNodeAttr("float", value, &nodedef); - value.clear_value(); - VALUE_TYPE = domi::tensorflow::DataType::DT_UINT32; - value.set_type(VALUE_TYPE); - TensorFlowUtil::AddNodeAttr("uint32", value, &nodedef); - value.clear_value(); - VALUE_TYPE = domi::tensorflow::DataType::DT_INT64; - value.set_type(VALUE_TYPE); - TensorFlowUtil::AddNodeAttr("int64", value, &nodedef); - value.clear_value(); - VALUE_TYPE = domi::tensorflow::DataType::DT_BOOL; - value.set_type(VALUE_TYPE); - TensorFlowUtil::AddNodeAttr("bool", value, &nodedef); - Status ret = mess2Op.ParseOperatorAttrs(&nodedef, 1, ops); - EXPECT_EQ(ret, SUCCESS); - - value.clear_value(); - VALUE_TYPE = domi::tensorflow::DataType::DT_STRING; - value.mutable_list()->add_type(VALUE_TYPE); - TensorFlowUtil::AddNodeAttr("str_list", value, &nodedef); - value.clear_value(); - value.mutable_list()->add_i(1); - TensorFlowUtil::AddNodeAttr("num_list", value, &nodedef); - value.clear_value(); - VALUE_TYPE = domi::tensorflow::DataType::DT_FLOAT; - value.mutable_list()->add_type(VALUE_TYPE); - TensorFlowUtil::AddNodeAttr("float_list", value, &nodedef); - value.clear_value(); - VALUE_TYPE = domi::tensorflow::DataType::DT_UINT32; - value.mutable_list()->add_type(VALUE_TYPE); - TensorFlowUtil::AddNodeAttr("uint32_list", value, &nodedef); - value.clear_value(); - VALUE_TYPE = domi::tensorflow::DataType::DT_INT64; - value.mutable_list()->add_type(VALUE_TYPE); - TensorFlowUtil::AddNodeAttr("int64_list", value, &nodedef); - value.clear_value(); - VALUE_TYPE = domi::tensorflow::DataType::DT_BOOL; - value.mutable_list()->add_type(VALUE_TYPE); - TensorFlowUtil::AddNodeAttr("bool_list", value, &nodedef); - ret = mess2Op.ParseOperatorAttrs(&nodedef, 1, ops); - EXPECT_EQ(ret, SUCCESS); -} - TEST_F(UtestTensorflowParser, tensorflow_Pb2Json_RepeatedEnum2Json_test) { Pb2Json toJson; From 4950b90320effe9ae1bda6ded07601a751e3747e Mon Sep 17 00:00:00 2001 From: 13291271729 Date: Wed, 31 Aug 2022 16:45:05 +0800 Subject: [PATCH 16/23] clean code --- parser/common/convert/message2operator.cc | 1 + parser/common/convert/pb2json.cc | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/parser/common/convert/message2operator.cc b/parser/common/convert/message2operator.cc index e02643e..d235ac2 100644 --- a/parser/common/convert/message2operator.cc +++ b/parser/common/convert/message2operator.cc @@ -119,6 +119,7 @@ Status Message2Operator::ParseRepeatedField(const google::protobuf::Reflection * GELOGE(FAILED, "[Check][Size]Size of repeated field %s must bigger than 0", field->name().c_str()); return FAILED; } + switch (field->cpp_type()) { #define CASE_FIELD_TYPE_REPEATED(cpptype, method, valuetype) \ case google::protobuf::FieldDescriptor::CPPTYPE_##cpptype: { \ diff --git a/parser/common/convert/pb2json.cc b/parser/common/convert/pb2json.cc index 2f01c92..0b3dd2b 100644 --- a/parser/common/convert/pb2json.cc +++ b/parser/common/convert/pb2json.cc @@ -122,7 +122,7 @@ void Pb2Json::OneField2Json(const ProtobufMsg &message, const ProtobufFieldDescr case ProtobufFieldDescriptor::TYPE_FLOAT: char str[kSignificantDigits]; - if (sprintf_s(str, kSignificantDigits, "%g", reflection->GetFloat(message, field)) != -1){ + if (sprintf_s(str, kSignificantDigits, "%g", reflection->GetFloat(message, field)) != -1) { json[field->name()] = str; } else { json[field->name()] = reflection->GetFloat(message, field); From fc9971f510efeea2d66c85ad6fa5dfc30ab2f281 Mon Sep 17 00:00:00 2001 From: 13291271729 Date: Wed, 31 Aug 2022 17:47:42 +0800 Subject: [PATCH 17/23] clean code --- parser/CMakeLists.txt | 4 ++-- parser/common/op_def/{arg_op.cc => arg_op_operator.cc} | 2 +- parser/common/op_def/{arg_op.h => arg_op_operator.h} | 0 parser/common/op_def/{constant_op.cc => constant_operator.cc} | 2 +- parser/common/op_def/{constant_op.h => constant_operator.h} | 0 parser/module.mk | 4 ++-- parser/tensorflow/tensorflow_arg_parser.cc | 2 +- parser/tensorflow/tensorflow_constant_parser.cc | 2 +- parser/tensorflow/tensorflow_constant_parser.h | 2 +- tests/st/CMakeLists.txt | 4 ++-- tests/st/testcase/test_tensorflow_parser.cc | 3 ++- tests/ut/parser/CMakeLists.txt | 4 ++-- .../tensorflow_parser_testcase/tensorflow_parser_unittest.cc | 2 +- 13 files changed, 16 insertions(+), 15 deletions(-) rename parser/common/op_def/{arg_op.cc => arg_op_operator.cc} (95%) rename parser/common/op_def/{arg_op.h => arg_op_operator.h} (100%) rename parser/common/op_def/{constant_op.cc => constant_operator.cc} (96%) rename parser/common/op_def/{constant_op.h => constant_operator.h} (100%) diff --git a/parser/CMakeLists.txt b/parser/CMakeLists.txt index e203166..193d4cc 100644 --- a/parser/CMakeLists.txt +++ b/parser/CMakeLists.txt @@ -25,8 +25,8 @@ set(SRC_LIST "tensorflow/graph_functiondef.cc" "tensorflow/graph_optimizer.cc" "tensorflow/iterator_fusion_pass.cc" - "common/op_def/arg_op.cc" - "common/op_def/constant_op.cc" + "common/op_def/arg_op_operator.cc" + "common/op_def/constant_operator.cc" "common/op_def/fill_op.cc" "common/op_def/frameworkop_op.cc" "common/op_def/no_op_op.cc" diff --git a/parser/common/op_def/arg_op.cc b/parser/common/op_def/arg_op_operator.cc similarity index 95% rename from parser/common/op_def/arg_op.cc rename to parser/common/op_def/arg_op_operator.cc index e9c4243..5e06525 100644 --- a/parser/common/op_def/arg_op.cc +++ b/parser/common/op_def/arg_op_operator.cc @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "parser/common/op_def/arg_op.h" +#include "parser/common/op_def/arg_op_operator.h" #include #include "framework/common/fmk_types.h" diff --git a/parser/common/op_def/arg_op.h b/parser/common/op_def/arg_op_operator.h similarity index 100% rename from parser/common/op_def/arg_op.h rename to parser/common/op_def/arg_op_operator.h diff --git a/parser/common/op_def/constant_op.cc b/parser/common/op_def/constant_operator.cc similarity index 96% rename from parser/common/op_def/constant_op.cc rename to parser/common/op_def/constant_operator.cc index cecb1d5..db17752 100644 --- a/parser/common/op_def/constant_op.cc +++ b/parser/common/op_def/constant_operator.cc @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "common/op_def/constant_op.h" +#include "common/op_def/constant_operator.h" #include #include diff --git a/parser/common/op_def/constant_op.h b/parser/common/op_def/constant_operator.h similarity index 100% rename from parser/common/op_def/constant_op.h rename to parser/common/op_def/constant_operator.h diff --git a/parser/module.mk b/parser/module.mk index 678179c..cb6c1e7 100644 --- a/parser/module.mk +++ b/parser/module.mk @@ -95,8 +95,8 @@ FMK_COMMON_SRC_FILES := \ tensorflow/graph_functiondef.cc \ tensorflow/graph_optimizer.cc \ tensorflow/iterator_fusion_pass.cc \ - common/op_def/arg_op.cc \ - common/op_def/constant_op.cc \ + common/op_def/arg_op_operator.cc \ + common/op_def/constant_operator.cc \ common/op_def/fill_op.cc \ common/op_def/frameworkop_op.cc \ common/op_def/no_op_op.cc \ diff --git a/parser/tensorflow/tensorflow_arg_parser.cc b/parser/tensorflow/tensorflow_arg_parser.cc index 32a1943..985eb15 100644 --- a/parser/tensorflow/tensorflow_arg_parser.cc +++ b/parser/tensorflow/tensorflow_arg_parser.cc @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "parser/common/op_def/arg_op.h" +#include "parser/common/op_def/arg_op_operator.h" #include "framework/common/debug/ge_log.h" #include "framework/omg/parser/parser_inner_ctx.h" #include "graph/compute_graph.h" diff --git a/parser/tensorflow/tensorflow_constant_parser.cc b/parser/tensorflow/tensorflow_constant_parser.cc index 22f1647..9812b37 100644 --- a/parser/tensorflow/tensorflow_constant_parser.cc +++ b/parser/tensorflow/tensorflow_constant_parser.cc @@ -19,7 +19,7 @@ #include #include #include "parser/common/acl_graph_parser_util.h" -#include "parser/common/op_def/constant_op.h" +#include "parser/common/op_def/constant_operator.h" #include "parser/common/op_def/ir_pb_converter.h" #include "parser/common/util.h" #include "framework/common/debug/ge_log.h" diff --git a/parser/tensorflow/tensorflow_constant_parser.h b/parser/tensorflow/tensorflow_constant_parser.h index 557db3d..5d4df36 100644 --- a/parser/tensorflow/tensorflow_constant_parser.h +++ b/parser/tensorflow/tensorflow_constant_parser.h @@ -17,7 +17,7 @@ #ifndef GE_PARSER_TENSORFLOW_TENSORFLOW_CONSTANT_PARSER_H_ #define GE_PARSER_TENSORFLOW_TENSORFLOW_CONSTANT_PARSER_H_ -#include "common/op_def/constant_op.h" +#include "common/op_def/constant_operator.h" #include "parser/common/data_op_parser.h" #include "parser/tensorflow/tensorflow_op_parser.h" diff --git a/tests/st/CMakeLists.txt b/tests/st/CMakeLists.txt index 7498987..d469f1c 100644 --- a/tests/st/CMakeLists.txt +++ b/tests/st/CMakeLists.txt @@ -249,8 +249,8 @@ set(PARSER_SRC_FILES "${PARSER_DIR}/parser/common/convert/message2operator.cc" "${PARSER_DIR}/parser/common/data_op_parser.cc" "${PARSER_DIR}/parser/common/model_saver.cc" - "${PARSER_DIR}/parser/common/op_def/arg_op.cc" - "${PARSER_DIR}/parser/common/op_def/constant_op.cc" + "${PARSER_DIR}/parser/common/op_def/arg_op_operator.cc" + "${PARSER_DIR}/parser/common/op_def/constant_operator.cc" "${PARSER_DIR}/parser/common/op_def/fill_op.cc" "${PARSER_DIR}/parser/common/op_def/frameworkop_op.cc" "${PARSER_DIR}/parser/common/op_def/ir_pb_converter.cc" diff --git a/tests/st/testcase/test_tensorflow_parser.cc b/tests/st/testcase/test_tensorflow_parser.cc index 5b41752..6ca926d 100644 --- a/tests/st/testcase/test_tensorflow_parser.cc +++ b/tests/st/testcase/test_tensorflow_parser.cc @@ -38,7 +38,7 @@ #include "parser/tensorflow/tensorflow_ref_switch_parser.h" #include "parser/tensorflow/tensorflow_fusion_op_parser.h" #include "parser/tensorflow/tensorflow_auto_mapping_parser_adapter.h" -#include "parser/common/op_def/arg_op.h" +#include "parser/common/op_def/arg_op_operator.h" #include "parser/tensorflow/tensorflow_fusion_custom_parser_adapter.h" #include "parser/tensorflow/tensorflow_reshape_parser.h" #include "parser/tensorflow/tensorflow_custom_parser_adapter.h" @@ -678,6 +678,7 @@ namespace { if ((_name== "S") || (_name == "K")) { int index = 0; + ge::AttrUtils::SetInt(opDef, "T", 1); ge::AttrUtils::SetInt(opDef, "arg_index", index); ge::AttrUtils::SetInt(opDef, "ret_index", index); diff --git a/tests/ut/parser/CMakeLists.txt b/tests/ut/parser/CMakeLists.txt index 0253c0f..38cb743 100644 --- a/tests/ut/parser/CMakeLists.txt +++ b/tests/ut/parser/CMakeLists.txt @@ -250,8 +250,8 @@ set(PARSER_SRC_FILES "${PARSER_DIR}/parser/common/convert/message2operator.cc" "${PARSER_DIR}/parser/common/data_op_parser.cc" "${PARSER_DIR}/parser/common/model_saver.cc" - "${PARSER_DIR}/parser/common/op_def/arg_op.cc" - "${PARSER_DIR}/parser/common/op_def/constant_op.cc" + "${PARSER_DIR}/parser/common/op_def/arg_op_operator.cc" + "${PARSER_DIR}/parser/common/op_def/constant_operator.cc" "${PARSER_DIR}/parser/common/op_def/fill_op.cc" "${PARSER_DIR}/parser/common/op_def/frameworkop_op.cc" "${PARSER_DIR}/parser/common/op_def/ir_pb_converter.cc" diff --git a/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_parser_unittest.cc b/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_parser_unittest.cc index 00678d8..d64e300 100644 --- a/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_parser_unittest.cc +++ b/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_parser_unittest.cc @@ -42,7 +42,7 @@ #include "parser/tensorflow/tensorflow_ref_switch_parser.h" #include "parser/tensorflow/tensorflow_fusion_op_parser.h" #include "parser/tensorflow/tensorflow_auto_mapping_parser_adapter.h" -#include "parser/common/op_def/arg_op.h" +#include "parser/common/op_def/arg_op_operator.h" #include "parser/tensorflow/tensorflow_fusion_custom_parser_adapter.h" #include "parser/tensorflow/tensorflow_reshape_parser.h" #include "parser/tensorflow/tensorflow_custom_parser_adapter.h" From e4d486a07731736ab9e5fd5103269420256c8b3e Mon Sep 17 00:00:00 2001 From: 13291271729 Date: Thu, 1 Sep 2022 11:47:43 +0800 Subject: [PATCH 18/23] clean code --- parser/CMakeLists.txt | 18 +++++++++--------- .../op_def/{fill_op.cc => fill_operator.cc} | 2 +- .../op_def/{fill_op.h => fill_operator.h} | 0 ...meworkop_op.cc => framework_op_operator.cc} | 2 +- ...rameworkop_op.h => framework_op_operator.h} | 0 .../op_def/{no_op_op.cc => no_op_operator.cc} | 2 +- .../op_def/{no_op_op.h => no_op_operator.h} | 0 ...ref_switch_op.cc => ref_switch_operator.cc} | 2 +- .../{ref_switch_op.h => ref_switch_operator.h} | 0 .../{shape_n_op.cc => shape_n_operator.cc} | 2 +- .../{shape_n_op.h => shape_n_operator.h} | 0 ...op.cc => var_is_initialized_op_operator.cc} | 2 +- ...p_op.h => var_is_initialized_op_operator.h} | 0 .../{variable_op.cc => variable_operator.cc} | 2 +- .../{variable_op.h => variable_operator.h} | 0 parser/module.mk | 18 +++++++++--------- ...functiondef.cc => graph_to_function_def.cc} | 2 +- ...h_functiondef.h => graph_to_function_def.h} | 0 ..._optimizer.cc => parser_graph_optimizer.cc} | 4 ++-- ...ph_optimizer.h => parser_graph_optimizer.h} | 0 parser/tensorflow/tensorflow_fill_parser.cc | 2 +- .../tensorflow_frameworkop_parser.cc | 2 +- parser/tensorflow/tensorflow_no_op_parser.cc | 2 +- .../tensorflow/tensorflow_ref_switch_parser.cc | 2 +- .../tensorflow/tensorflow_ref_switch_parser.h | 2 +- parser/tensorflow/tensorflow_shape_n_parser.cc | 2 +- parser/tensorflow/tensorflow_shape_n_parser.h | 2 +- .../tensorflow_var_is_initialized_op_parser.cc | 2 +- .../tensorflow_variable_v2_parser.cc | 2 +- tests/st/CMakeLists.txt | 18 +++++++++--------- tests/st/testcase/test_tensorflow_parser.cc | 16 ++++++++-------- tests/ut/parser/CMakeLists.txt | 18 +++++++++--------- .../graph_optimizer_unittest.cc | 2 +- .../tensorflow_parser_unittest.cc | 16 ++++++++-------- 34 files changed, 72 insertions(+), 72 deletions(-) rename parser/common/op_def/{fill_op.cc => fill_operator.cc} (97%) rename parser/common/op_def/{fill_op.h => fill_operator.h} (100%) rename parser/common/op_def/{frameworkop_op.cc => framework_op_operator.cc} (98%) rename parser/common/op_def/{frameworkop_op.h => framework_op_operator.h} (100%) rename parser/common/op_def/{no_op_op.cc => no_op_operator.cc} (95%) rename parser/common/op_def/{no_op_op.h => no_op_operator.h} (100%) rename parser/common/op_def/{ref_switch_op.cc => ref_switch_operator.cc} (95%) rename parser/common/op_def/{ref_switch_op.h => ref_switch_operator.h} (100%) rename parser/common/op_def/{shape_n_op.cc => shape_n_operator.cc} (97%) rename parser/common/op_def/{shape_n_op.h => shape_n_operator.h} (100%) rename parser/common/op_def/{var_is_initialized_op_op.cc => var_is_initialized_op_operator.cc} (95%) rename parser/common/op_def/{var_is_initialized_op_op.h => var_is_initialized_op_operator.h} (100%) rename parser/common/op_def/{variable_op.cc => variable_operator.cc} (97%) rename parser/common/op_def/{variable_op.h => variable_operator.h} (100%) rename parser/tensorflow/{graph_functiondef.cc => graph_to_function_def.cc} (99%) rename parser/tensorflow/{graph_functiondef.h => graph_to_function_def.h} (100%) rename parser/tensorflow/{graph_optimizer.cc => parser_graph_optimizer.cc} (99%) rename parser/tensorflow/{graph_optimizer.h => parser_graph_optimizer.h} (100%) diff --git a/parser/CMakeLists.txt b/parser/CMakeLists.txt index 193d4cc..ce8a6e0 100644 --- a/parser/CMakeLists.txt +++ b/parser/CMakeLists.txt @@ -22,18 +22,18 @@ set(SRC_LIST "caffe/caffe_custom_parser_adapter.cc" "caffe/caffe_op_parser.cc" "tensorflow/scope/scope_pass_manager.cc" - "tensorflow/graph_functiondef.cc" - "tensorflow/graph_optimizer.cc" + "tensorflow/graph_to_function_def.cc" + "tensorflow/parser_graph_optimizer.cc" "tensorflow/iterator_fusion_pass.cc" "common/op_def/arg_op_operator.cc" "common/op_def/constant_operator.cc" - "common/op_def/fill_op.cc" - "common/op_def/frameworkop_op.cc" - "common/op_def/no_op_op.cc" - "common/op_def/ref_switch_op.cc" - "common/op_def/shape_n_op.cc" - "common/op_def/var_is_initialized_op_op.cc" - "common/op_def/variable_op.cc" + "common/op_def/fill_operator.cc" + "common/op_def/framework_op_operator.cc" + "common/op_def/no_op_operator.cc" + "common/op_def/ref_switch_operator.cc" + "common/op_def/shape_n_operator.cc" + "common/op_def/var_is_initialized_op_operator.cc" + "common/op_def/variable_operator.cc" ) ############ libfmk_parser.so ############ diff --git a/parser/common/op_def/fill_op.cc b/parser/common/op_def/fill_operator.cc similarity index 97% rename from parser/common/op_def/fill_op.cc rename to parser/common/op_def/fill_operator.cc index e3d5927..9b2ee5d 100644 --- a/parser/common/op_def/fill_op.cc +++ b/parser/common/op_def/fill_operator.cc @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "common/op_def/fill_op.h" +#include "common/op_def/fill_operator.h" #include "framework/common/fmk_types.h" namespace ge { diff --git a/parser/common/op_def/fill_op.h b/parser/common/op_def/fill_operator.h similarity index 100% rename from parser/common/op_def/fill_op.h rename to parser/common/op_def/fill_operator.h diff --git a/parser/common/op_def/frameworkop_op.cc b/parser/common/op_def/framework_op_operator.cc similarity index 98% rename from parser/common/op_def/frameworkop_op.cc rename to parser/common/op_def/framework_op_operator.cc index 81010ae..305fac0 100644 --- a/parser/common/op_def/frameworkop_op.cc +++ b/parser/common/op_def/framework_op_operator.cc @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "common/op_def/frameworkop_op.h" +#include "common/op_def/framework_op_operator.h" #include #include "framework/common/fmk_types.h" diff --git a/parser/common/op_def/frameworkop_op.h b/parser/common/op_def/framework_op_operator.h similarity index 100% rename from parser/common/op_def/frameworkop_op.h rename to parser/common/op_def/framework_op_operator.h diff --git a/parser/common/op_def/no_op_op.cc b/parser/common/op_def/no_op_operator.cc similarity index 95% rename from parser/common/op_def/no_op_op.cc rename to parser/common/op_def/no_op_operator.cc index c427bd2..d630beb 100644 --- a/parser/common/op_def/no_op_op.cc +++ b/parser/common/op_def/no_op_operator.cc @@ -15,7 +15,7 @@ */ // AUTO GEN PLEASE DO NOT MODIFY IT -#include "common/op_def/no_op_op.h" +#include "common/op_def/no_op_operator.h" #include namespace ge { diff --git a/parser/common/op_def/no_op_op.h b/parser/common/op_def/no_op_operator.h similarity index 100% rename from parser/common/op_def/no_op_op.h rename to parser/common/op_def/no_op_operator.h diff --git a/parser/common/op_def/ref_switch_op.cc b/parser/common/op_def/ref_switch_operator.cc similarity index 95% rename from parser/common/op_def/ref_switch_op.cc rename to parser/common/op_def/ref_switch_operator.cc index 933e05b..cc02f81 100644 --- a/parser/common/op_def/ref_switch_op.cc +++ b/parser/common/op_def/ref_switch_operator.cc @@ -15,7 +15,7 @@ */ // AUTO GEN PLEASE DO NOT MODIFY IT -#include "common/op_def/ref_switch_op.h" +#include "common/op_def/ref_switch_operator.h" namespace ge { FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY RefSwitchOperator::RefSwitchOperator() : ParserOperator("RefSwitch") {} diff --git a/parser/common/op_def/ref_switch_op.h b/parser/common/op_def/ref_switch_operator.h similarity index 100% rename from parser/common/op_def/ref_switch_op.h rename to parser/common/op_def/ref_switch_operator.h diff --git a/parser/common/op_def/shape_n_op.cc b/parser/common/op_def/shape_n_operator.cc similarity index 97% rename from parser/common/op_def/shape_n_op.cc rename to parser/common/op_def/shape_n_operator.cc index d75818d..df2a7d9 100644 --- a/parser/common/op_def/shape_n_op.cc +++ b/parser/common/op_def/shape_n_operator.cc @@ -15,7 +15,7 @@ */ // AUTO GEN PLEASE DO NOT MODIFY IT -#include "common/op_def/shape_n_op.h" +#include "common/op_def/shape_n_operator.h" #include "graph/debug/ge_attr_define.h" #include "framework/omg/parser/parser_types.h" diff --git a/parser/common/op_def/shape_n_op.h b/parser/common/op_def/shape_n_operator.h similarity index 100% rename from parser/common/op_def/shape_n_op.h rename to parser/common/op_def/shape_n_operator.h diff --git a/parser/common/op_def/var_is_initialized_op_op.cc b/parser/common/op_def/var_is_initialized_op_operator.cc similarity index 95% rename from parser/common/op_def/var_is_initialized_op_op.cc rename to parser/common/op_def/var_is_initialized_op_operator.cc index 9f7e9c2..81f7f4e 100644 --- a/parser/common/op_def/var_is_initialized_op_op.cc +++ b/parser/common/op_def/var_is_initialized_op_operator.cc @@ -15,7 +15,7 @@ */ // AUTO GEN PLEASE DO NOT MODIFY IT -#include "common/op_def/var_is_initialized_op_op.h" +#include "common/op_def/var_is_initialized_op_operator.h" #include #include diff --git a/parser/common/op_def/var_is_initialized_op_op.h b/parser/common/op_def/var_is_initialized_op_operator.h similarity index 100% rename from parser/common/op_def/var_is_initialized_op_op.h rename to parser/common/op_def/var_is_initialized_op_operator.h diff --git a/parser/common/op_def/variable_op.cc b/parser/common/op_def/variable_operator.cc similarity index 97% rename from parser/common/op_def/variable_op.cc rename to parser/common/op_def/variable_operator.cc index d1d0c7b..8d200ec 100644 --- a/parser/common/op_def/variable_op.cc +++ b/parser/common/op_def/variable_operator.cc @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "parser/common/op_def/variable_op.h" +#include "parser/common/op_def/variable_operator.h" #include "graph/debug/ge_attr_define.h" diff --git a/parser/common/op_def/variable_op.h b/parser/common/op_def/variable_operator.h similarity index 100% rename from parser/common/op_def/variable_op.h rename to parser/common/op_def/variable_operator.h diff --git a/parser/module.mk b/parser/module.mk index cb6c1e7..524b6a9 100644 --- a/parser/module.mk +++ b/parser/module.mk @@ -92,18 +92,18 @@ PARSER_SCOPE_SRC_FILES := \ tensorflow/scope/scope_pass_manager.cc \ FMK_COMMON_SRC_FILES := \ - tensorflow/graph_functiondef.cc \ - tensorflow/graph_optimizer.cc \ + tensorflow/graph_to_function_def.cc \ + tensorflow/parser_graph_optimizer.cc \ tensorflow/iterator_fusion_pass.cc \ common/op_def/arg_op_operator.cc \ common/op_def/constant_operator.cc \ - common/op_def/fill_op.cc \ - common/op_def/frameworkop_op.cc \ - common/op_def/no_op_op.cc \ - common/op_def/ref_switch_op.cc \ - common/op_def/shape_n_op.cc \ - common/op_def/var_is_initialized_op_op.cc \ - common/op_def/variable_op.cc \ + common/op_def/fill_operator.cc \ + common/op_def/framework_op_operator.cc \ + common/op_def/no_op_operator.cc \ + common/op_def/ref_switch_operator.cc \ + common/op_def/shape_n_operator.cc \ + common/op_def/var_is_initialized_op_operator.cc \ + common/op_def/variable_operator.cc \ LOCAL_SRC_FILES := $(PARSER_TENSORFLOW_SRC_FILES) LOCAL_SRC_FILES += $(PARSER_SCOPE_SRC_FILES) diff --git a/parser/tensorflow/graph_functiondef.cc b/parser/tensorflow/graph_to_function_def.cc similarity index 99% rename from parser/tensorflow/graph_functiondef.cc rename to parser/tensorflow/graph_to_function_def.cc index 94e3d2e..9629cfc 100644 --- a/parser/tensorflow/graph_functiondef.cc +++ b/parser/tensorflow/graph_to_function_def.cc @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "graph_functiondef.h" +#include "graph_to_function_def.h" #include #include "common/fmk_error_codes.h" #include "graph/debug/ge_attr_define.h" diff --git a/parser/tensorflow/graph_functiondef.h b/parser/tensorflow/graph_to_function_def.h similarity index 100% rename from parser/tensorflow/graph_functiondef.h rename to parser/tensorflow/graph_to_function_def.h diff --git a/parser/tensorflow/graph_optimizer.cc b/parser/tensorflow/parser_graph_optimizer.cc similarity index 99% rename from parser/tensorflow/graph_optimizer.cc rename to parser/tensorflow/parser_graph_optimizer.cc index e9c8799..7a10bc1 100644 --- a/parser/tensorflow/graph_optimizer.cc +++ b/parser/tensorflow/parser_graph_optimizer.cc @@ -14,14 +14,14 @@ * limitations under the License. */ -#include "graph_optimizer.h" +#include "parser_graph_optimizer.h" #include "graph/op_types.h" #include "common/types_map.h" #include "common/util.h" #include "framework/omg/parser/parser_inner_ctx.h" #include "graph/debug/ge_attr_define.h" #include "graph/utils/type_utils.h" -#include "graph_functiondef.h" +#include "graph_to_function_def.h" #include "parser/common/acl_graph_parser_util.h" #include "register/op_registry.h" diff --git a/parser/tensorflow/graph_optimizer.h b/parser/tensorflow/parser_graph_optimizer.h similarity index 100% rename from parser/tensorflow/graph_optimizer.h rename to parser/tensorflow/parser_graph_optimizer.h diff --git a/parser/tensorflow/tensorflow_fill_parser.cc b/parser/tensorflow/tensorflow_fill_parser.cc index 886dcdb..fab2eb9 100644 --- a/parser/tensorflow/tensorflow_fill_parser.cc +++ b/parser/tensorflow/tensorflow_fill_parser.cc @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "parser/common/op_def/fill_op.h" +#include "parser/common/op_def/fill_operator.h" #include "parser/tensorflow/tensorflow_parser_register.h" #include "framework/omg/parser/parser_types.h" diff --git a/parser/tensorflow/tensorflow_frameworkop_parser.cc b/parser/tensorflow/tensorflow_frameworkop_parser.cc index 2d03c7b..cb9ccff 100644 --- a/parser/tensorflow/tensorflow_frameworkop_parser.cc +++ b/parser/tensorflow/tensorflow_frameworkop_parser.cc @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "parser/common/op_def/frameworkop_op.h" +#include "parser/common/op_def/framework_op_operator.h" #include "framework/common/debug/ge_log.h" #include "parser/common/op_parser_factory.h" #include "framework/omg/parser/parser_types.h" diff --git a/parser/tensorflow/tensorflow_no_op_parser.cc b/parser/tensorflow/tensorflow_no_op_parser.cc index 4d43f9d..efd193a 100644 --- a/parser/tensorflow/tensorflow_no_op_parser.cc +++ b/parser/tensorflow/tensorflow_no_op_parser.cc @@ -18,7 +18,7 @@ #include "common/util.h" #include "framework/common/debug/ge_log.h" #include "parser/common/op_def/ir_pb_converter.h" -#include "parser/common/op_def/no_op_op.h" +#include "parser/common/op_def/no_op_operator.h" #include "parser/common/op_parser_factory.h" using domi::TENSORFLOW; diff --git a/parser/tensorflow/tensorflow_ref_switch_parser.cc b/parser/tensorflow/tensorflow_ref_switch_parser.cc index f2f8840..205147e 100644 --- a/parser/tensorflow/tensorflow_ref_switch_parser.cc +++ b/parser/tensorflow/tensorflow_ref_switch_parser.cc @@ -17,7 +17,7 @@ #include "parser/tensorflow/tensorflow_ref_switch_parser.h" #include "framework/common/debug/ge_log.h" #include "parser/common/op_def/ir_pb_converter.h" -#include "parser/common/op_def/ref_switch_op.h" +#include "parser/common/op_def/ref_switch_operator.h" #include "parser/common/op_parser_factory.h" #include "parser/common/util.h" diff --git a/parser/tensorflow/tensorflow_ref_switch_parser.h b/parser/tensorflow/tensorflow_ref_switch_parser.h index 9bd43cc..68ca56f 100644 --- a/parser/tensorflow/tensorflow_ref_switch_parser.h +++ b/parser/tensorflow/tensorflow_ref_switch_parser.h @@ -17,7 +17,7 @@ #ifndef DOMI_OMG_PARSER_OP_PARSER_TENSORFLOW_REF_SWITCH_H_ #define DOMI_OMG_PARSER_OP_PARSER_TENSORFLOW_REF_SWITCH_H_ -#include "common/op_def/ref_switch_op.h" +#include "common/op_def/ref_switch_operator.h" #include "parser/tensorflow/tensorflow_op_parser.h" namespace ge { diff --git a/parser/tensorflow/tensorflow_shape_n_parser.cc b/parser/tensorflow/tensorflow_shape_n_parser.cc index 7530bc8..c33aefb 100644 --- a/parser/tensorflow/tensorflow_shape_n_parser.cc +++ b/parser/tensorflow/tensorflow_shape_n_parser.cc @@ -18,7 +18,7 @@ #include "parser/common/op_def/ir_pb_converter.h" #include "framework/common/debug/ge_log.h" #include "parser/common/op_parser_factory.h" -#include "parser/common/op_def/shape_n_op.h" +#include "parser/common/op_def/shape_n_operator.h" #include "parser/common/util.h" using domi::TENSORFLOW; diff --git a/parser/tensorflow/tensorflow_shape_n_parser.h b/parser/tensorflow/tensorflow_shape_n_parser.h index c22188c..5933951 100644 --- a/parser/tensorflow/tensorflow_shape_n_parser.h +++ b/parser/tensorflow/tensorflow_shape_n_parser.h @@ -17,7 +17,7 @@ #ifndef DOMI_OMG_PARSER_OP_PARSER_TENSORFLOW_SHAPE_N_H_ #define DOMI_OMG_PARSER_OP_PARSER_TENSORFLOW_SHAPE_N_H_ -#include "common/op_def/shape_n_op.h" +#include "common/op_def/shape_n_operator.h" #include "parser/tensorflow/tensorflow_op_parser.h" namespace ge { diff --git a/parser/tensorflow/tensorflow_var_is_initialized_op_parser.cc b/parser/tensorflow/tensorflow_var_is_initialized_op_parser.cc index 577bbca..b0fec3a 100644 --- a/parser/tensorflow/tensorflow_var_is_initialized_op_parser.cc +++ b/parser/tensorflow/tensorflow_var_is_initialized_op_parser.cc @@ -15,7 +15,7 @@ */ #include "framework/common/debug/ge_log.h" -#include "parser/common/op_def/var_is_initialized_op_op.h" +#include "parser/common/op_def/var_is_initialized_op_operator.h" #include "parser/common/op_parser_factory.h" #include "parser/tensorflow/tensorflow_op_parser.h" #include "parser/tensorflow/tensorflow_parser_register.h" diff --git a/parser/tensorflow/tensorflow_variable_v2_parser.cc b/parser/tensorflow/tensorflow_variable_v2_parser.cc index 2b14280..ac850c7 100644 --- a/parser/tensorflow/tensorflow_variable_v2_parser.cc +++ b/parser/tensorflow/tensorflow_variable_v2_parser.cc @@ -21,7 +21,7 @@ #include "graph/op_desc.h" #include "graph/utils/attr_utils.h" #include "graph/utils/tensor_utils.h" -#include "parser/common/op_def/variable_op.h" +#include "parser/common/op_def/variable_operator.h" #include "parser/common/op_parser_factory.h" #include "parser/tensorflow/tensorflow_op_parser.h" #include "parser/tensorflow/tensorflow_parser_register.h" diff --git a/tests/st/CMakeLists.txt b/tests/st/CMakeLists.txt index d469f1c..580669b 100644 --- a/tests/st/CMakeLists.txt +++ b/tests/st/CMakeLists.txt @@ -251,15 +251,15 @@ set(PARSER_SRC_FILES "${PARSER_DIR}/parser/common/model_saver.cc" "${PARSER_DIR}/parser/common/op_def/arg_op_operator.cc" "${PARSER_DIR}/parser/common/op_def/constant_operator.cc" - "${PARSER_DIR}/parser/common/op_def/fill_op.cc" - "${PARSER_DIR}/parser/common/op_def/frameworkop_op.cc" + "${PARSER_DIR}/parser/common/op_def/fill_operator.cc" + "${PARSER_DIR}/parser/common/op_def/framework_op_operator.cc" "${PARSER_DIR}/parser/common/op_def/ir_pb_converter.cc" - "${PARSER_DIR}/parser/common/op_def/no_op_op.cc" + "${PARSER_DIR}/parser/common/op_def/no_op_operator.cc" "${PARSER_DIR}/parser/common/op_def/operator.cc" - "${PARSER_DIR}/parser/common/op_def/ref_switch_op.cc" - "${PARSER_DIR}/parser/common/op_def/shape_n_op.cc" - "${PARSER_DIR}/parser/common/op_def/variable_op.cc" - "${PARSER_DIR}/parser/common/op_def/var_is_initialized_op_op.cc" + "${PARSER_DIR}/parser/common/op_def/ref_switch_operator.cc" + "${PARSER_DIR}/parser/common/op_def/shape_n_operator.cc" + "${PARSER_DIR}/parser/common/op_def/variable_operator.cc" + "${PARSER_DIR}/parser/common/op_def/var_is_initialized_op_operator.cc" "${PARSER_DIR}/parser/common/op_map.cc" "${PARSER_DIR}/parser/common/op_parser_factory.cc" "${PARSER_DIR}/parser/common/parser_api.cc" @@ -284,8 +284,8 @@ set(PARSER_SRC_FILES "${PARSER_DIR}/parser/onnx/onnx_util.cc" "${PARSER_DIR}/parser/onnx/subgraph_adapter/if_subgraph_adapter.cc" "${PARSER_DIR}/parser/onnx/subgraph_adapter/subgraph_adapter_factory.cc" - "${PARSER_DIR}/parser/tensorflow/graph_functiondef.cc" - "${PARSER_DIR}/parser/tensorflow/graph_optimizer.cc" + "${PARSER_DIR}/parser/tensorflow/graph_to_function_def.cc" + "${PARSER_DIR}/parser/tensorflow/parser_graph_optimizer.cc" "${PARSER_DIR}/parser/tensorflow/iterator_fusion_pass.cc" "${PARSER_DIR}/parser/tensorflow/scope/scope_pass_manager.cc" "${PARSER_DIR}/parser/tensorflow/tensorflow_arg_parser.cc" diff --git a/tests/st/testcase/test_tensorflow_parser.cc b/tests/st/testcase/test_tensorflow_parser.cc index 6ca926d..2ea4689 100644 --- a/tests/st/testcase/test_tensorflow_parser.cc +++ b/tests/st/testcase/test_tensorflow_parser.cc @@ -34,7 +34,7 @@ #include "external/parser/tensorflow_parser.h" #include "parser/tensorflow/tensorflow_constant_parser.h" #include "common/types.h" -#include "parser/common/op_def/variable_op.h" +#include "parser/common/op_def/variable_operator.h" #include "parser/tensorflow/tensorflow_ref_switch_parser.h" #include "parser/tensorflow/tensorflow_fusion_op_parser.h" #include "parser/tensorflow/tensorflow_auto_mapping_parser_adapter.h" @@ -43,8 +43,8 @@ #include "parser/tensorflow/tensorflow_reshape_parser.h" #include "parser/tensorflow/tensorflow_custom_parser_adapter.h" #include "parser/tensorflow/tensorflow_squeeze_parser.h" -#include "parser/tensorflow/graph_functiondef.h" -#include "parser/tensorflow/graph_optimizer.h" +#include "parser/tensorflow/graph_to_function_def.h" +#include "parser/tensorflow/parser_graph_optimizer.h" #include "cce/dnn_base_def.hpp" #include "parser/tensorflow/scope/scope_pass_manager.h" #include "parser/tensorflow/tensorflow_util.h" @@ -52,10 +52,10 @@ #include "parser/tensorflow/tensorflow_enter_parser.h" #include "parser/common/op_def/ir_pb_converter.h" #include "parser/common/tuple.h" -#include "common/op_def/frameworkop_op.h" -#include "common/op_def/shape_n_op.h" -#include "common/op_def/var_is_initialized_op_op.h" -#include "common/op_def/fill_op.h" +#include "common/op_def/framework_op_operator.h" +#include "common/op_def/shape_n_operator.h" +#include "common/op_def/var_is_initialized_op_operator.h" +#include "common/op_def/fill_operator.h" #include "common/convert/pb2json.h" #include "common/convert/message2operator.h" #include "parser/common/proto_file_parser.h" @@ -70,7 +70,7 @@ #include "parser/common/prototype_pass_manager.h" #include "parser/common/register_tbe.h" #include "parser/common/pass_manager.h" -#include "parser/tensorflow/graph_optimizer.h" +#include "parser/tensorflow/parser_graph_optimizer.h" #include "metadef/inc/register/scope/scope_pass_registry_impl.h" #include "register/scope/scope_fusion_pass_register.h" #undef protected diff --git a/tests/ut/parser/CMakeLists.txt b/tests/ut/parser/CMakeLists.txt index 38cb743..28453d9 100644 --- a/tests/ut/parser/CMakeLists.txt +++ b/tests/ut/parser/CMakeLists.txt @@ -252,15 +252,15 @@ set(PARSER_SRC_FILES "${PARSER_DIR}/parser/common/model_saver.cc" "${PARSER_DIR}/parser/common/op_def/arg_op_operator.cc" "${PARSER_DIR}/parser/common/op_def/constant_operator.cc" - "${PARSER_DIR}/parser/common/op_def/fill_op.cc" - "${PARSER_DIR}/parser/common/op_def/frameworkop_op.cc" + "${PARSER_DIR}/parser/common/op_def/fill_operator.cc" + "${PARSER_DIR}/parser/common/op_def/framework_op_operator.cc" "${PARSER_DIR}/parser/common/op_def/ir_pb_converter.cc" - "${PARSER_DIR}/parser/common/op_def/no_op_op.cc" + "${PARSER_DIR}/parser/common/op_def/no_op_operator.cc" "${PARSER_DIR}/parser/common/op_def/operator.cc" - "${PARSER_DIR}/parser/common/op_def/ref_switch_op.cc" - "${PARSER_DIR}/parser/common/op_def/shape_n_op.cc" - "${PARSER_DIR}/parser/common/op_def/variable_op.cc" - "${PARSER_DIR}/parser/common/op_def/var_is_initialized_op_op.cc" + "${PARSER_DIR}/parser/common/op_def/ref_switch_operator.cc" + "${PARSER_DIR}/parser/common/op_def/shape_n_operator.cc" + "${PARSER_DIR}/parser/common/op_def/variable_operator.cc" + "${PARSER_DIR}/parser/common/op_def/var_is_initialized_op_operator.cc" "${PARSER_DIR}/parser/common/op_map.cc" "${PARSER_DIR}/parser/common/op_parser_factory.cc" "${PARSER_DIR}/parser/common/parser_api.cc" @@ -285,8 +285,8 @@ set(PARSER_SRC_FILES "${PARSER_DIR}/parser/onnx/onnx_util.cc" "${PARSER_DIR}/parser/onnx/subgraph_adapter/if_subgraph_adapter.cc" "${PARSER_DIR}/parser/onnx/subgraph_adapter/subgraph_adapter_factory.cc" - "${PARSER_DIR}/parser/tensorflow/graph_functiondef.cc" - "${PARSER_DIR}/parser/tensorflow/graph_optimizer.cc" + "${PARSER_DIR}/parser/tensorflow/graph_to_function_def.cc" + "${PARSER_DIR}/parser/tensorflow/parser_graph_optimizer.cc" "${PARSER_DIR}/parser/tensorflow/iterator_fusion_pass.cc" "${PARSER_DIR}/parser/tensorflow/scope/scope_pass_manager.cc" "${PARSER_DIR}/parser/tensorflow/tensorflow_arg_parser.cc" diff --git a/tests/ut/parser/testcase/graph_optimizer_testcase/graph_optimizer_unittest.cc b/tests/ut/parser/testcase/graph_optimizer_testcase/graph_optimizer_unittest.cc index 5139002..9667978 100644 --- a/tests/ut/parser/testcase/graph_optimizer_testcase/graph_optimizer_unittest.cc +++ b/tests/ut/parser/testcase/graph_optimizer_testcase/graph_optimizer_unittest.cc @@ -7,7 +7,7 @@ #include "tensorflow/iterator_fusion_pass.h" #include "parser/common/acl_graph_parser_util.h" #define private public -#include "tensorflow/graph_optimizer.h" +#include "tensorflow/parser_graph_optimizer.h" #undef private namespace ge { class UtestGraphOptimizer : public testing::Test { diff --git a/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_parser_unittest.cc b/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_parser_unittest.cc index d64e300..d1c6c8e 100644 --- a/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_parser_unittest.cc +++ b/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_parser_unittest.cc @@ -38,7 +38,7 @@ #include "tests/depends/ops_stub/ops_stub.h" #include "parser/tensorflow/tensorflow_constant_parser.h" #include "common/types.h" -#include "parser/common/op_def/variable_op.h" +#include "parser/common/op_def/variable_operator.h" #include "parser/tensorflow/tensorflow_ref_switch_parser.h" #include "parser/tensorflow/tensorflow_fusion_op_parser.h" #include "parser/tensorflow/tensorflow_auto_mapping_parser_adapter.h" @@ -47,8 +47,8 @@ #include "parser/tensorflow/tensorflow_reshape_parser.h" #include "parser/tensorflow/tensorflow_custom_parser_adapter.h" #include "parser/tensorflow/tensorflow_squeeze_parser.h" -#include "parser/tensorflow/graph_functiondef.h" -#include "parser/tensorflow/graph_optimizer.h" +#include "parser/tensorflow/graph_to_function_def.h" +#include "parser/tensorflow/parser_graph_optimizer.h" #include "cce/dnn_base_def.hpp" #include "parser/tensorflow/scope/scope_pass_manager.h" #include "parser/tensorflow/tensorflow_util.h" @@ -56,10 +56,10 @@ #include "parser/tensorflow/tensorflow_enter_parser.h" #include "parser/common/op_def/ir_pb_converter.h" #include "parser/common/tuple.h" -#include "common/op_def/frameworkop_op.h" -#include "common/op_def/shape_n_op.h" -#include "common/op_def/var_is_initialized_op_op.h" -#include "common/op_def/fill_op.h" +#include "common/op_def/framework_op_operator.h" +#include "common/op_def/shape_n_operator.h" +#include "common/op_def/var_is_initialized_op_operator.h" +#include "common/op_def/fill_operator.h" #include "common/convert/pb2json.h" #include "common/convert/message2operator.h" #include "parser/common/proto_file_parser.h" @@ -73,7 +73,7 @@ #include "parser/common/prototype_pass_manager.h" #include "parser/common/register_tbe.h" #include "parser/common/pass_manager.h" -#include "parser/tensorflow/graph_optimizer.h" +#include "parser/tensorflow/parser_graph_optimizer.h" #include "metadef/inc/register/scope/scope_pass_registry_impl.h" #include "register/scope/scope_fusion_pass_register.h" #include "common/op_map.h" From 820f60ef60b33ce5525a43cb7c5fe0e2d61b60f0 Mon Sep 17 00:00:00 2001 From: 13291271729 Date: Thu, 1 Sep 2022 11:54:28 +0800 Subject: [PATCH 19/23] clean code --- parser/tensorflow/iterator_fusion_pass.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/parser/tensorflow/iterator_fusion_pass.cc b/parser/tensorflow/iterator_fusion_pass.cc index 734d9a3..2a7f2a8 100644 --- a/parser/tensorflow/iterator_fusion_pass.cc +++ b/parser/tensorflow/iterator_fusion_pass.cc @@ -20,7 +20,7 @@ #include "framework/omg/parser/parser_types.h" #include "common/util.h" -#include "graph_optimizer.h" +#include "parser_graph_optimizer.h" #include "framework/common/ge_inner_error_codes.h" namespace ge { From b365fef0d3f78d832dc7f7c06a87157d63e13bde Mon Sep 17 00:00:00 2001 From: 13291271729 Date: Thu, 1 Sep 2022 14:10:17 +0800 Subject: [PATCH 20/23] clean code --- parser/tensorflow/parser_graph_optimizer.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/parser/tensorflow/parser_graph_optimizer.cc b/parser/tensorflow/parser_graph_optimizer.cc index 7a10bc1..9046292 100644 --- a/parser/tensorflow/parser_graph_optimizer.cc +++ b/parser/tensorflow/parser_graph_optimizer.cc @@ -188,7 +188,10 @@ Status CollectNodeFuncs(vector &nodes, FunctionDefLibrary *library) Status ParserGraphOptimizer::UpdateGraph(vector &nodes) { ComputeGraphPtr sub_graph = nullptr; - GE_MAKE_SHARED(sub_graph = std::make_shared("subGraph"), sub_graph = nullptr; return PARAM_INVALID); + GE_MAKE_SHARED( + sub_graph = std::make_shared("subGraph"), + sub_graph = nullptr; + return PARAM_INVALID); unordered_map node_map; vector input_anchors; From 8d9426ff7ea838a10f990578850e7e3dd819f266 Mon Sep 17 00:00:00 2001 From: 13291271729 Date: Thu, 1 Sep 2022 14:56:07 +0800 Subject: [PATCH 21/23] clean code --- parser/tensorflow/parser_graph_optimizer.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/parser/tensorflow/parser_graph_optimizer.h b/parser/tensorflow/parser_graph_optimizer.h index 6fee699..2f3f4ee 100644 --- a/parser/tensorflow/parser_graph_optimizer.h +++ b/parser/tensorflow/parser_graph_optimizer.h @@ -28,8 +28,9 @@ namespace ge { class ParserGraphOptimizer { public: - explicit ParserGraphOptimizer(ge::ComputeGraphPtr graph, domi::FrameworkType type = domi::TENSORFLOW) - : graph_(graph), fmktype_(type) {} + explicit ParserGraphOptimizer(ge::ComputeGraphPtr graph, domi::FrameworkType type = domi::TENSORFLOW) : + graph_(graph), + fmktype_(type) {} ~ParserGraphOptimizer() {} From 60023213cc12e99dec4d35c1143fc2a1b9ab9b16 Mon Sep 17 00:00:00 2001 From: 13291271729 Date: Thu, 1 Sep 2022 15:48:27 +0800 Subject: [PATCH 22/23] clean code --- parser/tensorflow/parser_graph_optimizer.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/parser/tensorflow/parser_graph_optimizer.h b/parser/tensorflow/parser_graph_optimizer.h index 2f3f4ee..d5b1560 100644 --- a/parser/tensorflow/parser_graph_optimizer.h +++ b/parser/tensorflow/parser_graph_optimizer.h @@ -28,8 +28,8 @@ namespace ge { class ParserGraphOptimizer { public: - explicit ParserGraphOptimizer(ge::ComputeGraphPtr graph, domi::FrameworkType type = domi::TENSORFLOW) : - graph_(graph), + explicit ParserGraphOptimizer(ge::ComputeGraphPtr graph, domi::FrameworkType type = domi::TENSORFLOW) + : graph_(graph), fmktype_(type) {} ~ParserGraphOptimizer() {} From ff410a6fd1e7f3270fe154b69b06b299bb6cfaa1 Mon Sep 17 00:00:00 2001 From: 13291271729 Date: Thu, 1 Sep 2022 16:01:41 +0800 Subject: [PATCH 23/23] clean code --- parser/tensorflow/parser_graph_optimizer.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/parser/tensorflow/parser_graph_optimizer.h b/parser/tensorflow/parser_graph_optimizer.h index d5b1560..6fee699 100644 --- a/parser/tensorflow/parser_graph_optimizer.h +++ b/parser/tensorflow/parser_graph_optimizer.h @@ -29,8 +29,7 @@ namespace ge { class ParserGraphOptimizer { public: explicit ParserGraphOptimizer(ge::ComputeGraphPtr graph, domi::FrameworkType type = domi::TENSORFLOW) - : graph_(graph), - fmktype_(type) {} + : graph_(graph), fmktype_(type) {} ~ParserGraphOptimizer() {}