| @@ -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"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with 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; | 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, | Status Message2Operator::ParseField(const google::protobuf::Reflection *reflection, | ||||
| const google::protobuf::Message *message, | const google::protobuf::Message *message, | ||||
| const google::protobuf::FieldDescriptor *field, int depth, ge::Operator &ops) { | const google::protobuf::FieldDescriptor *field, int depth, ge::Operator &ops) { | ||||
| GELOGD("Start to parse field: %s.", field->name().c_str()); | GELOGD("Start to parse field: %s.", field->name().c_str()); | ||||
| ParseBaseTypeField(reflection, message, field, ops); | |||||
| switch (field->cpp_type()) { | 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: { | case google::protobuf::FieldDescriptor::CPPTYPE_ENUM: { | ||||
| GE_CHECK_NOTNULL(reflection->GetEnum(*message, field)); | GE_CHECK_NOTNULL(reflection->GetEnum(*message, field)); | ||||
| int value = reflection->GetEnum(*message, field)->number(); | int value = reflection->GetEnum(*message, field)->number(); | ||||
| @@ -108,6 +135,70 @@ Status Message2Operator::ParseField(const google::protobuf::Reflection *reflecti | |||||
| return SUCCESS; | 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<int32_t> 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<uint32_t> 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<int64_t> 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<float> 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<bool> 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<string> 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, | Status Message2Operator::ParseRepeatedField(const google::protobuf::Reflection *reflection, | ||||
| const google::protobuf::Message *message, | const google::protobuf::Message *message, | ||||
| const google::protobuf::FieldDescriptor *field, | const google::protobuf::FieldDescriptor *field, | ||||
| @@ -120,24 +211,8 @@ Status Message2Operator::ParseRepeatedField(const google::protobuf::Reflection * | |||||
| return FAILED; | return FAILED; | ||||
| } | } | ||||
| ParseRepeatedBaseTypeField(reflection, message, field, ops); | |||||
| switch (field->cpp_type()) { | switch (field->cpp_type()) { | ||||
| #define CASE_FIELD_TYPE_REPEATED(cpptype, method, valuetype) \ | |||||
| case google::protobuf::FieldDescriptor::CPPTYPE_##cpptype: { \ | |||||
| std::vector<valuetype> 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: { | case google::protobuf::FieldDescriptor::CPPTYPE_MESSAGE: { | ||||
| nlohmann::json message_json; | nlohmann::json message_json; | ||||
| Pb2Json::RepeatedMessage2Json(*message, field, reflection, std::set<string>(), message_json[field->name()], | Pb2Json::RepeatedMessage2Json(*message, field, reflection, std::set<string>(), message_json[field->name()], | ||||
| @@ -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"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with 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, | static Status ParseRepeatedField(const google::protobuf::Reflection *reflection, | ||||
| const google::protobuf::Message *message, | const google::protobuf::Message *message, | ||||
| const google::protobuf::FieldDescriptor *field, ge::Operator &ops); | 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 | } // namespace ge | ||||
| #endif // PARSER_MESSAGE2OPERATOR_H | #endif // PARSER_MESSAGE2OPERATOR_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"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with 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()) { | switch (field->type()) { | ||||
| case ProtobufFieldDescriptor::TYPE_MESSAGE: { | case ProtobufFieldDescriptor::TYPE_MESSAGE: { | ||||
| const ProtobufMsg &tmp_message = reflection->GetMessage(message, field); | 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); | Message2Json(tmp_message, black_fields, json[field->name()], enum2str, depth + 1); | ||||
| } | } | ||||
| break; | break; | ||||
| @@ -155,10 +155,8 @@ string Pb2Json::TypeBytes2String(string &field_name, string &type_bytes) { | |||||
| } | } | ||||
| string result = ""; | string result = ""; | ||||
| for (char temp_value : type_bytes) { | for (char temp_value : type_bytes) { | ||||
| uint8_t *value = 0; | |||||
| value = reinterpret_cast<uint8_t *>(&temp_value); | |||||
| char str[kSignificantDigits]; | 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()); | GELOGW("Convert bytes to string fail, filed name:%s", field_name.c_str()); | ||||
| continue; | continue; | ||||
| } | } | ||||
| @@ -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"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -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"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -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"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -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"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -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"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -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"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -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"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -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"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -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"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -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"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -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"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -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"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -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"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with 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_ | #ifndef DOMI_OP_NO_OP_OP_H_ | ||||
| #define DOMI_OP_NO_OP_OP_H_ | #define DOMI_OP_NO_OP_OP_H_ | ||||
| #include "parser/common/op_def/operator.h" | #include "parser/common/op_def/operator.h" | ||||
| #include "framework/omg/parser/parser_types.h" | |||||
| namespace ge { | namespace ge { | ||||
| class NoOpOperator : public ParserOperator { | class NoOpOperator : public ParserOperator { | ||||
| @@ -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"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -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"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -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"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -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"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -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"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -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"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -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"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -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"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -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"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -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"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -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"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -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"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with 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 "proto/tensorflow/graph.pb.h" | ||||
| #include "register/register_error_codes.h" | #include "register/register_error_codes.h" | ||||
| namespace ge { | |||||
| using domi::tensorflow::AttrValue; | using domi::tensorflow::AttrValue; | ||||
| using domi::tensorflow::AttrValue_ListValue; | using domi::tensorflow::AttrValue_ListValue; | ||||
| using domi::tensorflow::DataType; | using domi::tensorflow::DataType; | ||||
| @@ -39,7 +40,6 @@ using std::string; | |||||
| using std::to_string; | using std::to_string; | ||||
| using std::vector; | using std::vector; | ||||
| namespace ge { | |||||
| class GraphToFunctionDef { | class GraphToFunctionDef { | ||||
| public: | public: | ||||
| static domi::Status RecordArg(ge::ComputeGraphPtr graph, | static domi::Status RecordArg(ge::ComputeGraphPtr graph, | ||||
| @@ -65,6 +65,16 @@ class GraphToFunctionDef { | |||||
| static void AddNodeAttr(const string &attr_name, | static void AddNodeAttr(const string &attr_name, | ||||
| const domi::tensorflow::AttrValue &value, | const domi::tensorflow::AttrValue &value, | ||||
| domi::tensorflow::NodeDef *node_def); | domi::tensorflow::NodeDef *node_def); | ||||
| private: | |||||
| static domi::Status DataOpToFunctionDef(const ge::NodePtr &node, FunctionDef *fdef, | |||||
| std::map<string, string> &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 { | class NameMapHelper { | ||||
| @@ -202,9 +202,9 @@ Status ParserGraphOptimizer::UpdateGraph(vector<NodePtr> &nodes) { | |||||
| "insert node to sub_graph failed."); | "insert node to sub_graph failed."); | ||||
| GE_CHK_STATUS_RET(LinkInnerAnchor(node_map), "Link inner anchor failed."); | GE_CHK_STATUS_RET(LinkInnerAnchor(node_map), "Link inner anchor failed."); | ||||
| std::unique_ptr<NodeDef> node_def(new (std::nothrow) NodeDef()); // tensorflow NodeDef | |||||
| std::unique_ptr<NodeDef> node_def = std::make_unique<NodeDef>(); // tensorflow NodeDef | |||||
| GE_CHECK_NOTNULL(node_def); | GE_CHECK_NOTNULL(node_def); | ||||
| std::unique_ptr<FunctionDefLibrary> func_def_lib(new (std::nothrow) FunctionDefLibrary()); | |||||
| std::unique_ptr<FunctionDefLibrary> func_def_lib = std::make_unique<FunctionDefLibrary>(); | |||||
| GE_CHECK_NOTNULL(func_def_lib); | GE_CHECK_NOTNULL(func_def_lib); | ||||
| // convert graph to FunctionDef | // convert graph to FunctionDef | ||||
| if (nodes.size() == 0) { | if (nodes.size() == 0) { | ||||
| @@ -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"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -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"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -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"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -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"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -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"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -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"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -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"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -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"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||