From 0d68018dbb39f64fa5187d9b8f944cf6187de5ab Mon Sep 17 00:00:00 2001 From: Gleb Kazantaev Date: Mon, 16 Nov 2020 10:25:52 +0300 Subject: [PATCH 001/116] Double serialization --- model-optimizer/mo/back/ie_ir_ver_2/emitter.py | 4 ++++ model-optimizer/mo/main.py | 11 +++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/model-optimizer/mo/back/ie_ir_ver_2/emitter.py b/model-optimizer/mo/back/ie_ir_ver_2/emitter.py index d37f3d8164d389..0ce76bf08ab061 100644 --- a/model-optimizer/mo/back/ie_ir_ver_2/emitter.py +++ b/model-optimizer/mo/back/ie_ir_ver_2/emitter.py @@ -42,6 +42,8 @@ def serialize_constants(graph: Graph, bin_file_name:str, data_type=np.float32): bin_hashes = {} with open(bin_file_name, 'wb') as bin_file: serialize_constants_recursively(graph, bin_file, data_type, bin_hashes) + from shutil import copyfile + copyfile(bin_file_name, bin_file_name + "2") def update_offset_size_in_const_node(node: Node): @@ -433,6 +435,8 @@ def generate_ie_ir(graph: Graph, file_name: str, input_names: tuple = (), mean_o refer_to_faq_msg(24)) with open(file_name, 'wb') as file: file.write(bytes(pretty_xml_as_string, "UTF-8")) + with open(file_name + "2", 'wb') as file: + file.write(bytes(pretty_xml_as_string, "UTF-8")) def port_renumber(graph: Graph): diff --git a/model-optimizer/mo/main.py b/model-optimizer/mo/main.py index 59c4fe1c98c455..a0828bd4a0cc68 100644 --- a/model-optimizer/mo/main.py +++ b/model-optimizer/mo/main.py @@ -249,9 +249,16 @@ def emit_ir(graph: Graph, argv: argparse.Namespace): if not (argv.framework == 'tf' and argv.tensorflow_custom_operations_config_update): output_dir = argv.output_dir if argv.output_dir != '.' else os.getcwd() + + orig_model_name = os.path.join(output_dir, argv.model_name) + from openvino.inference_engine import IECore + ie = IECore() + net = ie.read_network(model=orig_model_name + ".xml", weights=orig_model_name + ".bin") + # net.serialize(orig_model_name + "_s.xml", orig_model_name + "_s.bin") + print('\n[ SUCCESS ] Generated IR version {} model.'.format(get_ir_version(argv))) - print('[ SUCCESS ] XML file: {}.xml'.format(os.path.join(output_dir, argv.model_name))) - print('[ SUCCESS ] BIN file: {}.bin'.format(os.path.join(output_dir, argv.model_name))) + print('[ SUCCESS ] XML file: {}.xml'.format(orig_model_name)) + print('[ SUCCESS ] BIN file: {}.bin'.format(orig_model_name)) return 0 From d10048a012e58df33b7d426ebdeb065c9ccd023d Mon Sep 17 00:00:00 2001 From: Gleb Kazantaev Date: Mon, 16 Nov 2020 19:45:01 +0300 Subject: [PATCH 002/116] Serialize-Read-Serialize --- .../src/transformations/serialize.cpp | 47 ++++++++++++++++++- .../mo/back/ie_ir_ver_2/emitter.py | 4 -- model-optimizer/mo/main.py | 2 +- 3 files changed, 47 insertions(+), 6 deletions(-) diff --git a/inference-engine/src/transformations/src/transformations/serialize.cpp b/inference-engine/src/transformations/src/transformations/serialize.cpp index 9bf24e8441ebed..ce64d363dbb7b5 100644 --- a/inference-engine/src/transformations/src/transformations/serialize.cpp +++ b/inference-engine/src/transformations/src/transformations/serialize.cpp @@ -8,6 +8,7 @@ #include #include +#include #include "ngraph/ops.hpp" #include "ngraph/opsets/opset.hpp" #include "pugixml.hpp" @@ -298,6 +299,47 @@ bool is_exec_graph(const ngraph::Function& f) { return false; } +void resolve_dynamic_shapes(const ngraph::Function& f) { + auto f_clone = ngraph::clone_function(f); + + auto f_ops = f.get_ordered_ops(); + auto f_clone_ops = f_clone->get_ordered_ops(); + assert(f_ops.size() == f_clone_ops.size()); + + for (size_t id = 0; id < f_ops.size(); ++id) { + auto & op = f_ops[id]; + auto & clone_op = f_clone_ops[id]; + + if (auto op_subgraph = std::dynamic_pointer_cast(op)) { + resolve_dynamic_shapes(*op_subgraph->get_function()); + } + + op->validate_and_infer_types(); + clone_op->validate_and_infer_types(); + + OutputVector replacements(clone_op->get_output_size()); + if (!clone_op->constant_fold(replacements, clone_op->input_values())) { + for (size_t output_id = 0; output_id < clone_op->get_output_size(); ++output_id) { + op->set_output_type(output_id, clone_op->output(output_id).get_element_type(), + clone_op->output(output_id).get_partial_shape()); + } + } else { + for (size_t output_id = 0; output_id < clone_op->get_output_size(); ++output_id) { + op->set_output_type(output_id, replacements[output_id].get_element_type(), + replacements[output_id].get_partial_shape()); + } + + for (size_t i = 0; i < replacements.size(); ++i) { + auto node_output = clone_op->output(i); + auto replacement = replacements.at(i); + if (replacement.get_node_shared_ptr() && (node_output != replacement)) { + node_output.replace(replacement); + } + } + } + } +} + void ngfunction_2_irv10( pugi::xml_document& doc, std::vector& bin, const ngraph::Function& f, @@ -313,6 +355,9 @@ void ngfunction_2_irv10( create_layer_ids(f); std::unordered_set unique_names; + // Dynamic to Static + resolve_dynamic_shapes(f); + for (const auto& n : f.get_ordered_ops()) { ngraph::Node* node = n.get(); @@ -330,7 +375,7 @@ void ngfunction_2_irv10( // pugi::xml_node data = layer.append_child("data"); - // general atributes + // general attributes std::string node_type_name{node->get_type_name()}; if (exec_graph) { visit_exec_graph_node(data, node_type_name, node); diff --git a/model-optimizer/mo/back/ie_ir_ver_2/emitter.py b/model-optimizer/mo/back/ie_ir_ver_2/emitter.py index 0ce76bf08ab061..d37f3d8164d389 100644 --- a/model-optimizer/mo/back/ie_ir_ver_2/emitter.py +++ b/model-optimizer/mo/back/ie_ir_ver_2/emitter.py @@ -42,8 +42,6 @@ def serialize_constants(graph: Graph, bin_file_name:str, data_type=np.float32): bin_hashes = {} with open(bin_file_name, 'wb') as bin_file: serialize_constants_recursively(graph, bin_file, data_type, bin_hashes) - from shutil import copyfile - copyfile(bin_file_name, bin_file_name + "2") def update_offset_size_in_const_node(node: Node): @@ -435,8 +433,6 @@ def generate_ie_ir(graph: Graph, file_name: str, input_names: tuple = (), mean_o refer_to_faq_msg(24)) with open(file_name, 'wb') as file: file.write(bytes(pretty_xml_as_string, "UTF-8")) - with open(file_name + "2", 'wb') as file: - file.write(bytes(pretty_xml_as_string, "UTF-8")) def port_renumber(graph: Graph): diff --git a/model-optimizer/mo/main.py b/model-optimizer/mo/main.py index a0828bd4a0cc68..941dd53dc6e5b2 100644 --- a/model-optimizer/mo/main.py +++ b/model-optimizer/mo/main.py @@ -254,7 +254,7 @@ def emit_ir(graph: Graph, argv: argparse.Namespace): from openvino.inference_engine import IECore ie = IECore() net = ie.read_network(model=orig_model_name + ".xml", weights=orig_model_name + ".bin") - # net.serialize(orig_model_name + "_s.xml", orig_model_name + "_s.bin") + net.serialize(orig_model_name + ".xml", orig_model_name + ".bin") print('\n[ SUCCESS ] Generated IR version {} model.'.format(get_ir_version(argv))) print('[ SUCCESS ] XML file: {}.xml'.format(orig_model_name)) From 68635cd15301937d6c9acf7165be6881d9d15641 Mon Sep 17 00:00:00 2001 From: Gleb Kazantaev Date: Mon, 16 Nov 2020 19:49:03 +0300 Subject: [PATCH 003/116] Added loging --- model-optimizer/mo/main.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/model-optimizer/mo/main.py b/model-optimizer/mo/main.py index 941dd53dc6e5b2..8eaba053727fc1 100644 --- a/model-optimizer/mo/main.py +++ b/model-optimizer/mo/main.py @@ -256,7 +256,8 @@ def emit_ir(graph: Graph, argv: argparse.Namespace): net = ie.read_network(model=orig_model_name + ".xml", weights=orig_model_name + ".bin") net.serialize(orig_model_name + ".xml", orig_model_name + ".bin") - print('\n[ SUCCESS ] Generated IR version {} model.'.format(get_ir_version(argv))) + print('\n[ SUCCESS ] Serialize-Read-Serialize') + print('[ SUCCESS ] Generated IR version {} model.'.format(get_ir_version(argv))) print('[ SUCCESS ] XML file: {}.xml'.format(orig_model_name)) print('[ SUCCESS ] BIN file: {}.bin'.format(orig_model_name)) From a85d90fd3c14e3ae8fcc8d3283a54b48cff5efa3 Mon Sep 17 00:00:00 2001 From: Gleb Kazantaev Date: Wed, 18 Nov 2020 14:04:48 +0300 Subject: [PATCH 004/116] Fixed attribute visitors for AvgPool,MaxPool,NormalizeL2,PriorBoxClustered --- ngraph/core/src/op/avg_pool.cpp | 3 ++- ngraph/core/src/op/prior_box_clustered.cpp | 9 +++++---- ngraph/core/src/op/util/attr_types.cpp | 4 ++-- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/ngraph/core/src/op/avg_pool.cpp b/ngraph/core/src/op/avg_pool.cpp index dfb411977dbdf3..404897a5a886af 100644 --- a/ngraph/core/src/op/avg_pool.cpp +++ b/ngraph/core/src/op/avg_pool.cpp @@ -69,7 +69,8 @@ bool op::v1::AvgPool::visit_attributes(AttributeVisitor& visitor) visitor.on_attribute("strides", m_strides); visitor.on_attribute("pads_begin", m_pads_begin); visitor.on_attribute("pads_end", m_pads_end); - visitor.on_attribute("exclude_pad", m_exclude_pad); + // TODO: discuss final attr name + visitor.on_attribute("exclude-pad", m_exclude_pad); visitor.on_attribute("auto_pad", m_auto_pad); visitor.on_attribute("rounding_type", m_rounding_type); return true; diff --git a/ngraph/core/src/op/prior_box_clustered.cpp b/ngraph/core/src/op/prior_box_clustered.cpp index 4b173c6a007774..bf52a219699aa8 100644 --- a/ngraph/core/src/op/prior_box_clustered.cpp +++ b/ngraph/core/src/op/prior_box_clustered.cpp @@ -96,13 +96,14 @@ shared_ptr op::PriorBoxClustered::clone_with_new_inputs(const OutputVector bool op::PriorBoxClustered::visit_attributes(AttributeVisitor& visitor) { - visitor.on_attribute("widths", m_attrs.widths); - visitor.on_attribute("heights", m_attrs.heights); - visitor.on_attribute("clip", m_attrs.clip); + int clip = (m_attrs.clip ? 1 : 0); + visitor.on_attribute("width", m_attrs.widths); + visitor.on_attribute("height", m_attrs.heights); + visitor.on_attribute("clip", clip); visitor.on_attribute("step_widths", m_attrs.step_widths); visitor.on_attribute("step_heights", m_attrs.step_heights); visitor.on_attribute("offset", m_attrs.offset); - visitor.on_attribute("variances", m_attrs.variances); + visitor.on_attribute("variance", m_attrs.variances); return true; } diff --git a/ngraph/core/src/op/util/attr_types.cpp b/ngraph/core/src/op/util/attr_types.cpp index 64e3416e838cad..470d27adc10844 100644 --- a/ngraph/core/src/op/util/attr_types.cpp +++ b/ngraph/core/src/op/util/attr_types.cpp @@ -66,7 +66,7 @@ namespace ngraph { static auto enum_names = EnumNames( "op::RoundingType", - {{"FLOOR", op::RoundingType::FLOOR}, {"CEIL", op::RoundingType::CEIL}}); + {{"floor", op::RoundingType::FLOOR}, {"ceil", op::RoundingType::CEIL}}); return enum_names; } @@ -118,7 +118,7 @@ namespace ngraph NGRAPH_API EnumNames& EnumNames::get() { static auto enum_names = EnumNames( - "op::EpsMode", {{"ADD", op::EpsMode::ADD}, {"MAX", op::EpsMode::MAX}}); + "op::EpsMode", {{"add", op::EpsMode::ADD}, {"max", op::EpsMode::MAX}}); return enum_names; } From 319ad6d77c6abec632aa68785bb44dc0cb74d57f Mon Sep 17 00:00:00 2001 From: Gleb Kazantaev Date: Wed, 18 Nov 2020 17:06:11 +0300 Subject: [PATCH 005/116] Added interval propaation for MS5 --- ngraph/core/src/op/non_max_suppression.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/ngraph/core/src/op/non_max_suppression.cpp b/ngraph/core/src/op/non_max_suppression.cpp index 3b5e92be0faf8e..cba1845e95577b 100644 --- a/ngraph/core/src/op/non_max_suppression.cpp +++ b/ngraph/core/src/op/non_max_suppression.cpp @@ -902,6 +902,23 @@ void op::v5::NonMaxSuppression::validate_and_infer_types() validate(); + if (boxes_ps.rank().is_static() && scores_ps.rank().is_static()) + { + const auto num_boxes_boxes = boxes_ps[1]; + const auto max_output_boxes_per_class_node = input_value(2).get_node_shared_ptr(); + if (num_boxes_boxes.is_static() && scores_ps[0].is_static() && scores_ps[1].is_static() && + op::is_constant(max_output_boxes_per_class_node)) + { + const auto num_boxes = num_boxes_boxes.get_length(); + const auto num_classes = scores_ps[1].get_length(); + const auto max_output_boxes_per_class = max_boxes_output_from_input(); + + out_shape[0] = Dimension(0, + std::min(num_boxes, max_output_boxes_per_class) * num_classes * + scores_ps[0].get_length()); + } + } + set_output_type(0, m_output_type, out_shape); set_output_type(1, element::f32, out_shape); set_output_type(2, m_output_type, Shape{1}); From 1a98f0fac27af0790fbdb9723e55b0eec7f41043 Mon Sep 17 00:00:00 2001 From: Gleb Kazantaev Date: Wed, 18 Nov 2020 17:08:56 +0300 Subject: [PATCH 006/116] Added interaval based dynamic shape propagation --- .../src/transformations/serialize.cpp | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/inference-engine/src/transformations/src/transformations/serialize.cpp b/inference-engine/src/transformations/src/transformations/serialize.cpp index ce64d363dbb7b5..8ff345cbd3e726 100644 --- a/inference-engine/src/transformations/src/transformations/serialize.cpp +++ b/inference-engine/src/transformations/src/transformations/serialize.cpp @@ -302,8 +302,8 @@ bool is_exec_graph(const ngraph::Function& f) { void resolve_dynamic_shapes(const ngraph::Function& f) { auto f_clone = ngraph::clone_function(f); - auto f_ops = f.get_ordered_ops(); - auto f_clone_ops = f_clone->get_ordered_ops(); + const auto & f_ops = f.get_ordered_ops(); + const auto & f_clone_ops = f_clone->get_ordered_ops(); assert(f_ops.size() == f_clone_ops.size()); for (size_t id = 0; id < f_ops.size(); ++id) { @@ -317,16 +317,29 @@ void resolve_dynamic_shapes(const ngraph::Function& f) { op->validate_and_infer_types(); clone_op->validate_and_infer_types(); + auto dynamic_to_static = [](const PartialShape & shape) -> PartialShape { + if (shape.is_static() || shape.rank().is_dynamic()) { + return shape; + } + auto out_shape = PartialShape::dynamic(shape.rank()); + for (size_t i = 0; i < shape.rank().get_length(); ++i) { + const auto & in_dim = shape[i]; + out_shape[i] = (in_dim.is_dynamic() ? Dimension(in_dim.get_max_length()) : in_dim); + } + return out_shape; + }; + OutputVector replacements(clone_op->get_output_size()); if (!clone_op->constant_fold(replacements, clone_op->input_values())) { for (size_t output_id = 0; output_id < clone_op->get_output_size(); ++output_id) { + clone_op->set_output_type(output_id, clone_op->output(output_id).get_element_type(), + dynamic_to_static(clone_op->output(output_id).get_partial_shape())); op->set_output_type(output_id, clone_op->output(output_id).get_element_type(), - clone_op->output(output_id).get_partial_shape()); + clone_op->output(output_id).get_partial_shape()); } } else { for (size_t output_id = 0; output_id < clone_op->get_output_size(); ++output_id) { - op->set_output_type(output_id, replacements[output_id].get_element_type(), - replacements[output_id].get_partial_shape()); + op->set_output_type(output_id, replacements[output_id].get_element_type(), replacements[output_id].get_partial_shape()); } for (size_t i = 0; i < replacements.size(); ++i) { From 6354f8ba88274a1b08b7d008da0dac499d3a4eeb Mon Sep 17 00:00:00 2001 From: Gleb Kazantaev Date: Wed, 18 Nov 2020 17:09:59 +0300 Subject: [PATCH 007/116] Boolean attributes support --- .../src/inference_engine/xml_parse_utils.cpp | 43 ++++++++++++++----- 1 file changed, 33 insertions(+), 10 deletions(-) diff --git a/inference-engine/src/inference_engine/xml_parse_utils.cpp b/inference-engine/src/inference_engine/xml_parse_utils.cpp index 1a5cfd8a266d63..3dc8da1b17c543 100644 --- a/inference-engine/src/inference_engine/xml_parse_utils.cpp +++ b/inference-engine/src/inference_engine/xml_parse_utils.cpp @@ -13,6 +13,23 @@ #include "details/ie_exception.hpp" #include "ie_precision.hpp" +template +bool is_bool_value(const std::string & str, T & val) { + std::string tmp; + for (const auto ch : str) { + tmp += std::tolower(ch); + } + if (tmp == "true") { + val = 1; + return true; + } + if (tmp == "false") { + val = 0; + return true; + } + return false; +} + int XMLParseUtils::GetIntAttr(const pugi::xml_node& node, const char* str) { auto attr = node.attribute(str); if (attr.empty()) @@ -20,11 +37,14 @@ int XMLParseUtils::GetIntAttr(const pugi::xml_node& node, const char* str) { << node.offset_debug(); std::string str_value = std::string(attr.value()); std::size_t idx = 0; - int int_value = std::stoi(str_value, &idx, 10); - if (idx != str_value.length()) - THROW_IE_EXCEPTION << "node <" << node.name() << "> has attribute \"" << str << "\" = \"" << str_value - << "\" which is not an integer" - << " at offset " << node.offset_debug(); + int int_value; + if (!is_bool_value(str_value, int_value)) { + int_value = std::stoi(str_value, &idx, 10); + } +// if (idx != str_value.length()) +// THROW_IE_EXCEPTION << "node <" << node.name() << "> has attribute \"" << str << "\" = \"" << str_value +// << "\" which is not an integer" +// << " at offset " << node.offset_debug(); return int_value; } @@ -65,11 +85,14 @@ unsigned int XMLParseUtils::GetUIntAttr(const pugi::xml_node& node, const char* << node.offset_debug(); std::string str_value = std::string(attr.value()); std::size_t idx = 0; - long long int_value = std::stoll(str_value, &idx, 10); - if (idx != str_value.length() || int_value < 0 || int_value > (std::numeric_limits::max)()) - THROW_IE_EXCEPTION << "node <" << node.name() << "> has attribute \"" << str << "\" = \"" << str_value - << "\" which is not an unsigned integer" - << " at offset " << node.offset_debug(); + long long int_value; + if (!is_bool_value(str_value, int_value)) { + int_value = std::stoll(str_value, &idx, 10); + } +// if (idx != str_value.length() || int_value < 0 || int_value > (std::numeric_limits::max)()) +// THROW_IE_EXCEPTION << "node <" << node.name() << "> has attribute \"" << str << "\" = \"" << str_value +// << "\" which is not an unsigned integer" +// << " at offset " << node.offset_debug(); return static_cast(int_value); } From 0d7280e89ed62212bde9e22b2de509b922fdd57d Mon Sep 17 00:00:00 2001 From: "Lyalin, Sergey" Date: Thu, 26 Nov 2020 16:47:59 +0300 Subject: [PATCH 008/116] Quick integration of ONNX importer to MO frontend instead of regular one. Shapes are hard-coded --- model-optimizer/mo/main.py | 46 +++++++++++++++----------- model-optimizer/mo/utils/cli_parser.py | 6 ++++ 2 files changed, 33 insertions(+), 19 deletions(-) diff --git a/model-optimizer/mo/main.py b/model-optimizer/mo/main.py index 8eaba053727fc1..73ad184ad5dafd 100644 --- a/model-optimizer/mo/main.py +++ b/model-optimizer/mo/main.py @@ -227,36 +227,44 @@ def prepare_ir(argv: argparse.Namespace): elif is_kaldi: from mo.front.kaldi.register_custom_ops import get_front_classes import_extensions.load_dirs(argv.framework, extensions, get_front_classes) - elif is_onnx: + elif is_onnx and argv.use_legacy_frontend: from mo.front.onnx.register_custom_ops import get_front_classes import_extensions.load_dirs(argv.framework, extensions, get_front_classes) - graph = unified_pipeline(argv) + + if not(is_onnx and not argv.use_legacy_frontend): + graph = unified_pipeline(argv) + else: + from openvino.inference_engine import IECore + ie = IECore() + graph = ie.read_network(model=argv.input_model) + #TODO: provide real shapes here + print('Placeholder shapes:' + str(argv.placeholder_shapes)) + print('Placeholder shapes:' + str(argv.user_shapes)) + graph.reshape({'input:0': [1, 3, 224, 224]}) return graph -def emit_ir(graph: Graph, argv: argparse.Namespace): - NormalizeTI().find_and_replace_pattern(graph) - for_graph_and_each_sub_graph_recursively(graph, RemoveConstOps().find_and_replace_pattern) - for_graph_and_each_sub_graph_recursively(graph, CreateConstNodesReplacement().find_and_replace_pattern) +def emit_ir(graph, argv: argparse.Namespace): + if argv.use_legacy_frontend: + NormalizeTI().find_and_replace_pattern(graph) + for_graph_and_each_sub_graph_recursively(graph, RemoveConstOps().find_and_replace_pattern) + for_graph_and_each_sub_graph_recursively(graph, CreateConstNodesReplacement().find_and_replace_pattern) - prepare_emit_ir(graph=graph, - data_type=graph.graph['cmd_params'].data_type, - output_dir=argv.output_dir, - output_model_name=argv.model_name, - mean_data=graph.graph['mf'] if 'mf' in graph.graph else None, - input_names=graph.graph['input_names'] if 'input_names' in graph.graph else [], - meta_info=get_meta_info(argv)) + prepare_emit_ir(graph=graph, + data_type=graph.graph['cmd_params'].data_type, + output_dir=argv.output_dir, + output_model_name=argv.model_name, + mean_data=graph.graph['mf'] if 'mf' in graph.graph else None, + input_names=graph.graph['input_names'] if 'input_names' in graph.graph else [], + meta_info=get_meta_info(argv)) if not (argv.framework == 'tf' and argv.tensorflow_custom_operations_config_update): output_dir = argv.output_dir if argv.output_dir != '.' else os.getcwd() - orig_model_name = os.path.join(output_dir, argv.model_name) - from openvino.inference_engine import IECore - ie = IECore() - net = ie.read_network(model=orig_model_name + ".xml", weights=orig_model_name + ".bin") - net.serialize(orig_model_name + ".xml", orig_model_name + ".bin") + if not argv.use_legacy_frontend: + graph.serialize(orig_model_name + ".xml", orig_model_name + ".bin") + print('[ SUCCESS ] Converted with ONNX Importer') - print('\n[ SUCCESS ] Serialize-Read-Serialize') print('[ SUCCESS ] Generated IR version {} model.'.format(get_ir_version(argv))) print('[ SUCCESS ] XML file: {}.xml'.format(orig_model_name)) print('[ SUCCESS ] BIN file: {}.bin'.format(orig_model_name)) diff --git a/model-optimizer/mo/utils/cli_parser.py b/model-optimizer/mo/utils/cli_parser.py index bb2918db4625f9..c214d31ef17cf4 100644 --- a/model-optimizer/mo/utils/cli_parser.py +++ b/model-optimizer/mo/utils/cli_parser.py @@ -616,6 +616,12 @@ def get_onnx_cli_parser(parser: argparse.ArgumentParser = None): onnx_group = parser.add_argument_group('ONNX*-specific parameters') + onnx_group.add_argument("--use_legacy_frontend", + help="Switch back to the original (legacy) frontend for ONNX model conversion. " + + "By default, ONNX Importer is used as a converter.", + default=False, + action='store_true') + return parser From c47c1c18fb68d668ed3424cc1fd11c6ee028b9c4 Mon Sep 17 00:00:00 2001 From: "Lyalin, Sergey" Date: Thu, 3 Dec 2020 11:31:09 +0300 Subject: [PATCH 009/116] Allow generating upper bounds for dynamic shapes in IR serialization instead of raising, moved temporary code for network load to new function moc_pipeline --- .../src/transformations/serialize.cpp | 25 +++++++++---------- model-optimizer/mo/main.py | 10 ++------ model-optimizer/mo/pipeline/unified.py | 10 ++++++++ 3 files changed, 24 insertions(+), 21 deletions(-) diff --git a/inference-engine/src/transformations/src/transformations/serialize.cpp b/inference-engine/src/transformations/src/transformations/serialize.cpp index 8ff345cbd3e726..bc906e9fa37c7e 100644 --- a/inference-engine/src/transformations/src/transformations/serialize.cpp +++ b/inference-engine/src/transformations/src/transformations/serialize.cpp @@ -179,10 +179,15 @@ const std::vector create_edge_mapping( // TODO: refactor to Vistor API when Constant will be supporting it ConstantAtributes dump_constant_data(std::vector& bin, const ngraph::op::Constant& c) { - NGRAPH_CHECK(c.get_output_partial_shape(0.).is_static(), - "Unsupported dynamic output shape in ", c); - ConstantAtributes attr; + if (!c.get_output_partial_shape(0).is_static()) { + std::cerr << "[ WARNING ] Constant with dynamic shape (really???), name = " + << c.get_friendly_name() << ", shape = " << c.get_output_partial_shape(0) << "\n"; + attr.size = 0; + attr.offset = bin.size(); + return attr; + } + const uint8_t* p = reinterpret_cast(c.get_data_ptr()); attr.size = ngraph::shape_size(c.get_shape()) * c.get_element_type().size(); attr.offset = bin.size(); @@ -412,15 +417,12 @@ void ngfunction_2_irv10( if (node->get_input_size() > 0) { pugi::xml_node input = layer.append_child("input"); for (auto i : node->inputs()) { - NGRAPH_CHECK(i.get_partial_shape().is_static(), - "Unsupported dynamic input shape in ", node); - pugi::xml_node port = input.append_child("port"); port.append_attribute("id").set_value(port_id++); - for (auto d : i.get_shape()) { + for (auto d : std::vector(i.get_partial_shape())) { pugi::xml_node dim = port.append_child("dim"); dim.append_child(pugi::xml_node_type::node_pcdata) - .set_value(std::to_string(d).c_str()); + .set_value(std::to_string(d.get_max_length()).c_str()); } } } @@ -428,17 +430,14 @@ void ngfunction_2_irv10( if ((node->get_output_size() > 0) && !ngraph::op::is_output(node)) { pugi::xml_node output = layer.append_child("output"); for (auto o : node->outputs()) { - NGRAPH_CHECK(o.get_partial_shape().is_static(), - "Unsupported dynamic output shape in ", node); - pugi::xml_node port = output.append_child("port"); port.append_attribute("id").set_value(port_id++); port.append_attribute("precision") .set_value(get_output_precision_name(o).c_str()); - for (auto d : o.get_shape()) { + for (auto d : std::vector(o.get_partial_shape())) { pugi::xml_node dim = port.append_child("dim"); dim.append_child(pugi::xml_node_type::node_pcdata) - .set_value(std::to_string(d).c_str()); + .set_value(std::to_string(d.get_max_length()).c_str()); } } } diff --git a/model-optimizer/mo/main.py b/model-optimizer/mo/main.py index 73ad184ad5dafd..2e433f38ec7b8a 100644 --- a/model-optimizer/mo/main.py +++ b/model-optimizer/mo/main.py @@ -29,7 +29,7 @@ from mo.graph.graph import Graph from mo.middle.pattern_match import for_graph_and_each_sub_graph_recursively, for_each_sub_graph_recursively from mo.pipeline.common import prepare_emit_ir, get_ir_version -from mo.pipeline.unified import unified_pipeline +from mo.pipeline.unified import unified_pipeline, moc_pipeline from mo.utils import import_extensions from mo.utils.cli_parser import get_placeholder_shapes, get_tuple_values, get_model_name, \ get_common_cli_options, get_caffe_cli_options, get_tf_cli_options, get_mxnet_cli_options, get_kaldi_cli_options, \ @@ -234,13 +234,7 @@ def prepare_ir(argv: argparse.Namespace): if not(is_onnx and not argv.use_legacy_frontend): graph = unified_pipeline(argv) else: - from openvino.inference_engine import IECore - ie = IECore() - graph = ie.read_network(model=argv.input_model) - #TODO: provide real shapes here - print('Placeholder shapes:' + str(argv.placeholder_shapes)) - print('Placeholder shapes:' + str(argv.user_shapes)) - graph.reshape({'input:0': [1, 3, 224, 224]}) + graph = moc_pipeline(argv) return graph diff --git a/model-optimizer/mo/pipeline/unified.py b/model-optimizer/mo/pipeline/unified.py index ca06da6ffc39c3..3e12e9ffef6f9f 100644 --- a/model-optimizer/mo/pipeline/unified.py +++ b/model-optimizer/mo/pipeline/unified.py @@ -29,3 +29,13 @@ def unified_pipeline(argv: argparse.Namespace): class_registration.ClassType.BACK_REPLACER ]) return graph + +def moc_pipeline(argv: argparse.Namespace): + from openvino.inference_engine import IECore + ie = IECore() + graph = ie.read_network(model=argv.input_model) + #TODO: provide real shapes here + print('Placeholder shapes:' + str(argv.placeholder_shapes)) + #print('Placeholder shapes:' + str(argv.user_shapes)) + graph.reshape({'image': argv.placeholder_shapes}) + return graph \ No newline at end of file From 1ec4df62dc89d2188c5c4e41e4f5e33916f85691 Mon Sep 17 00:00:00 2001 From: "Lyalin, Sergey" Date: Fri, 11 Dec 2020 14:24:57 +0300 Subject: [PATCH 010/116] Hacks to reshape onnx-imported model without cuts --- model-optimizer/mo/front/extractor.py | 16 ++++++++++++++- model-optimizer/mo/graph/graph.py | 10 ++++++++- model-optimizer/mo/main.py | 2 +- model-optimizer/mo/pipeline/unified.py | 28 +++++++++++++++++++++----- 4 files changed, 48 insertions(+), 8 deletions(-) diff --git a/model-optimizer/mo/front/extractor.py b/model-optimizer/mo/front/extractor.py index b94badaa45ef3c..681f8bd52645e7 100644 --- a/model-optimizer/mo/front/extractor.py +++ b/model-optimizer/mo/front/extractor.py @@ -548,7 +548,7 @@ def input_user_data_repack(graph: Graph, input_user_shapes: [None, list, dict, n # freeze placeholder restructure # Replaces placeholder name with placeholder id. Raises if there is no placeholder with such ID - placeholders_ids = graph.get_nodes_with_attributes(op='Parameter') + placeholders_ids = graph.get_input_ids() if freeze_placeholder is None: _freeze_placeholder = None else: @@ -923,6 +923,20 @@ def add_input_ops(graph: Graph, user_defined_inputs: dict, before_infer: bool): For case with before_infer=False data nodes are added to this schemes. """ + + # Limited implementation for nGraph + # Support reshape only, no model cutting is available + #print('--- USER DEFINED INPUTS ---:' + str(user_defined_inputs)) + if 'network' in graph.graph: + # warning connection through node name + #print(user_defined_inputs) + # temporary we handle only 0th index + if user_defined_inputs: + reshape_request = {k.get_friendly_name(): user_defined_inputs[k][0]['shape'] for k in user_defined_inputs} + #print('RESHAPE REQUEST: ' + str(reshape_request)) + graph.graph['network'].reshape(reshape_request) + return + inputs = [] set_is_input(graph, graph.get_nodes_with_attributes(op='Parameter'), False) if user_defined_inputs is None: diff --git a/model-optimizer/mo/graph/graph.py b/model-optimizer/mo/graph/graph.py index a27cbe45773aaf..a65e9871a01c39 100644 --- a/model-optimizer/mo/graph/graph.py +++ b/model-optimizer/mo/graph/graph.py @@ -746,7 +746,7 @@ def unique_id(self, prefix: str = ""): return prefix + str(self.unique_id_count) def check_empty_graph(self, description: str): - if len(self.nodes()) <= 1: + if len(self.nodes()) <= 1 and self.graph['network'] is None: raise Error( "Graph contains {} node after executing {}. It considered as error because resulting IR will be " "empty which is not usual".format(len(self.nodes()), description)) @@ -1008,6 +1008,14 @@ def clean_up(self, undead_node_types: list = None): # Add Const op for constant data nodes add_constant_operations(self) + def get_input_ids(self): + if 'network' in self.graph: + import ngraph as ng + func = ng.function_from_cnn(self.graph['network']) + return func.get_parameters() + else: + return self.get_nodes_with_attributes(op='Parameter') + def fill_graph_with_nodes(graph, src_nodes, get_id: callable, get_attrs: callable): """ diff --git a/model-optimizer/mo/main.py b/model-optimizer/mo/main.py index 2e433f38ec7b8a..a67222bcd66a0e 100644 --- a/model-optimizer/mo/main.py +++ b/model-optimizer/mo/main.py @@ -256,7 +256,7 @@ def emit_ir(graph, argv: argparse.Namespace): output_dir = argv.output_dir if argv.output_dir != '.' else os.getcwd() orig_model_name = os.path.join(output_dir, argv.model_name) if not argv.use_legacy_frontend: - graph.serialize(orig_model_name + ".xml", orig_model_name + ".bin") + graph.graph['network'].serialize(orig_model_name + ".xml", orig_model_name + ".bin") print('[ SUCCESS ] Converted with ONNX Importer') print('[ SUCCESS ] Generated IR version {} model.'.format(get_ir_version(argv))) diff --git a/model-optimizer/mo/pipeline/unified.py b/model-optimizer/mo/pipeline/unified.py index 3e12e9ffef6f9f..da233912eefd0d 100644 --- a/model-optimizer/mo/pipeline/unified.py +++ b/model-optimizer/mo/pipeline/unified.py @@ -19,6 +19,11 @@ from mo.pipeline.common import get_ir_version from mo.utils import class_registration +from extensions.front.user_data_repack import UserDataRepack +from extensions.front.input_cut import InputCut +from extensions.front.output_cut import OutputCut +from mo.utils.class_registration import apply_replacements_list + def unified_pipeline(argv: argparse.Namespace): graph = Graph(cmd_params=argv, name=argv.model_name, ir_version=get_ir_version(argv)) @@ -32,10 +37,23 @@ def unified_pipeline(argv: argparse.Namespace): def moc_pipeline(argv: argparse.Namespace): from openvino.inference_engine import IECore + import openvino ie = IECore() - graph = ie.read_network(model=argv.input_model) - #TODO: provide real shapes here - print('Placeholder shapes:' + str(argv.placeholder_shapes)) - #print('Placeholder shapes:' + str(argv.user_shapes)) - graph.reshape({'image': argv.placeholder_shapes}) + network = ie.read_network(model=argv.input_model) + + # Wrap nGraph network to Graph for smoothly pass through the legacy code in MO. + # This trick doesn't mean that we will hold Graph forever as a wrapper, it is derived from + # NX graph and this is not required. But Graph has several methods that can be implemented for nGraph + # and probably they should be kept at least for transition period where some existing transformations + # that manipulate Graph object really translate those modifications directly to nGraph representation. + graph = Graph(network=network, cmd_params=argv, name=argv.model_name, ir_version=get_ir_version(argv)) + + transforms = [ + UserDataRepack, + InputCut, + #OutputCut + ] + + apply_replacements_list(graph, transforms) + return graph \ No newline at end of file From fb5c077813a1c5761307e57150bc31492bce5ac1 Mon Sep 17 00:00:00 2001 From: "Lyalin, Sergey" Date: Mon, 14 Dec 2020 20:16:59 +0300 Subject: [PATCH 011/116] Fix problematic string literal --- .../src/transformations/src/transformations/serialize.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inference-engine/src/transformations/src/transformations/serialize.cpp b/inference-engine/src/transformations/src/transformations/serialize.cpp index 0449d74d6b5fad..482e271c41877f 100644 --- a/inference-engine/src/transformations/src/transformations/serialize.cpp +++ b/inference-engine/src/transformations/src/transformations/serialize.cpp @@ -181,7 +181,7 @@ ConstantAtributes dump_constant_data(std::vector& bin, const ngraph::op::Constant& c) { ConstantAtributes attr; if (!c.get_output_partial_shape(0).is_static()) { - std::cerr << "[ WARNING ] Constant with dynamic shape (really???), name = " + std::cerr << "[ WARNING ] Constant with dynamic shape, name = " << c.get_friendly_name() << ", shape = " << c.get_output_partial_shape(0) << "\n"; attr.size = 0; attr.offset = bin.size(); From dcbb0b6c739cc527a436c17284658600cee1e590 Mon Sep 17 00:00:00 2001 From: "Lyalin, Sergey" Date: Mon, 14 Dec 2020 23:39:10 +0300 Subject: [PATCH 012/116] Robust detection of new front-end mode --- model-optimizer/mo/main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/model-optimizer/mo/main.py b/model-optimizer/mo/main.py index a67222bcd66a0e..0c4abfd62524c4 100644 --- a/model-optimizer/mo/main.py +++ b/model-optimizer/mo/main.py @@ -239,7 +239,7 @@ def prepare_ir(argv: argparse.Namespace): def emit_ir(graph, argv: argparse.Namespace): - if argv.use_legacy_frontend: + if 'network' not in graph.graph: NormalizeTI().find_and_replace_pattern(graph) for_graph_and_each_sub_graph_recursively(graph, RemoveConstOps().find_and_replace_pattern) for_graph_and_each_sub_graph_recursively(graph, CreateConstNodesReplacement().find_and_replace_pattern) @@ -255,7 +255,7 @@ def emit_ir(graph, argv: argparse.Namespace): if not (argv.framework == 'tf' and argv.tensorflow_custom_operations_config_update): output_dir = argv.output_dir if argv.output_dir != '.' else os.getcwd() orig_model_name = os.path.join(output_dir, argv.model_name) - if not argv.use_legacy_frontend: + if 'network' in graph.graph: graph.graph['network'].serialize(orig_model_name + ".xml", orig_model_name + ".bin") print('[ SUCCESS ] Converted with ONNX Importer') From e6f450caaebac349ee2b134953734ce7abaeb0e5 Mon Sep 17 00:00:00 2001 From: "Vafin, Maxim" Date: Wed, 13 Jan 2021 12:02:20 +0300 Subject: [PATCH 013/116] Add PDPD python API POC --- tools/pdpd_poc/cat3.bmp | Bin 0 -> 155406 bytes tools/pdpd_poc/framework.proto | 216 ++++++++++++++++++++++++++ tools/pdpd_poc/generate_proto.sh | 3 + tools/pdpd_poc/pdpd2ir.py | 255 +++++++++++++++++++++++++++++++ tools/pdpd_poc/pdpd2ir_test.py | 106 +++++++++++++ tools/pdpd_poc/requirements.txt | 4 + 6 files changed, 584 insertions(+) create mode 100644 tools/pdpd_poc/cat3.bmp create mode 100644 tools/pdpd_poc/framework.proto create mode 100644 tools/pdpd_poc/generate_proto.sh create mode 100644 tools/pdpd_poc/pdpd2ir.py create mode 100644 tools/pdpd_poc/pdpd2ir_test.py create mode 100644 tools/pdpd_poc/requirements.txt diff --git a/tools/pdpd_poc/cat3.bmp b/tools/pdpd_poc/cat3.bmp new file mode 100644 index 0000000000000000000000000000000000000000..2de8516d2099b6be682aec629573e6951b89d5f5 GIT binary patch literal 155406 zcmcG%*K-_MmgZSIwr^{;5Bs!#&%Er@+S-iSj@it#bx&7KRc2MCVkT8m3s3+g2m&Ao zfY4fN1c1<5Ypuh>J;Fn44UpNr-*pEfkz{6eRdsFI$y+x(903CO#dps=;>LgczyJ4t z`VYS$|Lenlcko~0{J;O@H~%MQzxhqiKmLc`{2%|@Z@B-s3*7LpzxfSsbs z%X-HSpO5YjFNjB1qyy83uO<(0f8W^l+Xd0`zG-@0H8gYFJGOtLcj3;!>YHWx)UI)6 z&osO&e>T4VeBy9?L-Te`HLy9T-AFDaBdEQ)r(SI%m07C);SJ zYpq=Klvv{|Q$J&C9j4l*D(zUM9WA$l`I;wHbhCv(rV=eQY%C4~tI1%P^7w)_hu3UV zh?INV!ikCXXMGb-Ud;6LFFts&^ki_WXK)J~zL}T2U6l2WAKdO+yz=nfSNF!h>zVn! zZ{_am%||1AnKji z@0-{kUKCGmX(l$+L-WEXquURM)?Q2=j4VsXH$bdNwN|Wp+mCO{;uqr8lMargW~P+D^+Yl-L|OF@=vz;bU{;*cKI7qar6Q z_oXy}tlF1WxDsMZ?8F$>1u~{+&K57a6O~Y=5ihja%4w$dK36-<)!SKElUN2LaBZGu z8l80g6b4We)izUU(UlfeZqn6uoG@7rEom6)!itM&nM-@P+ttShCiE zv5ig&FWx-MHaqx6xz=gEO$_f8p4Ce0w9@QUn;lTvXq~m%@7tXZ9a#H)v(e&>2d|6b z&rUk6&il?8Z)csePWu#wI{|9@^sIGy*65t_#8w(j7+5Vg+B~Z~sQ-Red0e}?8noG6 zCYw^M+1faHGd%zJ$=j!Wlh67WdR{K}z1?{>ymSBM>fIO1k6v%~PaM6T5k4E)y8dMH zvm1kdxHrY1ad*2COOdj=32!`gxZx+RU@Ae)It=)Y&f4g_)?u)r6!)t@H zN29B<;YA^AY)v-3qn$r6z;N;T`1Zi8U}RZ5zAm5GR8DTIXZLiITk026hY#OuTz@|E z&Et39J(;}sdIhKt%$;C-JhFLrVEK0c;{CzZr(-*>=Y?ad@~JiD#FBJkK{7fg92nnw z{ceADOTDk~ZU`-~BW=Lo&sn1-P^xq?dT&~5r&XrN3B*?J+?3h3m98DVf6pA=w?vK{ zafz2z1+u_ZNtaa~SGIAQYMiB-XPMS1-Vp@X_9+awmO4aN z&slAq{>W@ujp^=A?7UcAgIi0!gUZa6)I@vIVQZ8XcAt`=*}zay)>0{~r3 zM`G{+qAri$VsjcSYN>8x?dVni)ZKdn_aDD~+&BBUf3bID`{nrIvp2gBUadbI*m(AK z7fbo0!L@5W6IY*1fBkUsch?91cxUwC(AL`()#$3a_ub*+H=D1f4&N?I2WF1$yqN#y z-kTdwCZ50D1gk>}Cjj-$k_aPDCYYSt*H3M$r*|}%EFGCwg*F%_3x^O)nxwdf#sL46Z=cCsw6(TTLTud-TecO>ePi&*7TY(61-6*jolyDHxL8oK(ktilZd zsIAj_>kPWugtWHK+Qd$IIsHgfc?f@YV>HCtnxlUq1yQWiB-lQ zj5yt1lf|YpsigX?P2s@6^o{TPuHJlkw`T&ZKI~tCuJ(-`z8Dw0e0PM&qrr`vPiMcp zJ@WPa@hgvKzJ5IY-P5_d1M4rRPR7?Y3x~FmCE3f#gYh-R;M~c*{)Ov3<9GUIpT1dt zF|qq<=J560(ct_sZ#=OxyV?zj6K?0a*s-JV3UuK^IF@qHy4blP^=wGo7`GKZtotV> zTIRrtoRv9J5*rI=K%kG|`mQRtqww#@y<1|}rpUQ=Y@6HBjV_8_PaO=+2;QwowBe@C$_Geke z#V)SI2jE$4{35HozY1p+tP)(|2{ccejSj5KDleWt%je~bzr-r<+;&~o3sJ3?>gWFI z-^B+g&3xw=Wx4~pl>*XTN&bD}DWbxXK-p{{$c>V71gTA?&JyY0Z-RWJv z^K$L!+x?+A>6>}!li{te?~Q$VckGLMrVhb&? zGBSHo=}K$7IenmL43#lTZ3$c#n&JR^SLp}p`0^!z8D8$H(2mzxKDJ=PwJb2LotUxu zuLukRh381+**-DtOKfT@rFSM2hM>{Gn4L+O#ho&EQV?66FRk^Z#nza_MuA(6Hw8+~ zft)3fGY2x~tj6*`vRe8#SWP$I^Q>O>1bAHqqCCmK4>bOYuJWw%B7E)!5L`Ry#?R|& zwe!Al`hje(xQ$i4(Wzl$Rckfst;_3vmq}hW|ILx-lh;*#^#`jEReobttkq$aM(6LS zt6&udmldqWy?z7%99q3msXaN6uC541MwV~h?*GG|?|*gm{7wXYSia zGvD_v_l*hO%*zI*P7n?F=F!xb4<;b0Uq71q{f(jDT^;!5;pEfNJ@~5tbz(yWX??RG zL_h$B?N#sCHb8}I3Uz(EB7vMP92#NZ3R`s;Kt0d|0V-@?9RP<4CmclPSgysEPScgs>@VnQru81Ic5wxhmpy?Cg**j*;IQi${F1bG)s=i276 zerR+)@T>yVYPDIdH0m{M=Fj)_JgEOBpOGxq4^gaBOt>#fz!C4~D<^_Q_}8Jp1nM=q-e;dgiY7%prJn`{mlhq3x&G zMvWi#O&mQNKYaXl@Aj*;Zyrx$lLb~kyE*jL{qb9U3(rQkvB3wf6YB~@0EXv|C)X8o zyIT0Au*oeI3=S&95a5AHkO}-wjIl0|5LM0%aDX=wbdq~;1vdjxjJytGUxru1UJN@j zVw);}IxnuZ%pa{0-f8 zp9htQYO9Ta6+G2^y`HPpz-q2o{X6RFWmXYf1*Xf=j}oNw77p-ge^aaMKtNb@bAg$d1#@}ctQ9TJ)@h0E0W<2`QWOgfAM5&Q?@L! zKv%b=Hmv@~YOhS^SDPb%Q*Vx9G+HUUGhuTu7S605*5S{1!Ub=%^49Eq~>>40u702u)|01#C;tI$>6Uxg2Fup@l>^vxGvKDhVr?W;HI zw|gf4bnW%kN7G;5oBZ9?;s1Gkgzel^LGM7R-ba}`fzx=XJq%; z*nZE*&XbYtr*F4Ne6@e^UjHKe)tB#(O%M*v9lxC3hnormT6g;AZ#BzKtVqO*)7xuMtyXu*3)y%eXc1Jb8r&$sh)`Wz^1C@7Q<=vJ# z;g`-I>fdh4$M-a|C#F@oYhM>QHbo?sC`@b!N(@1zF{Czy^_Gaq9k}9<`l@5ac#2PJxt@xN#uJc2#^Dm&3mr$Nk{t7RoAC1u4u5;TJVSE+uA@CUU zo2-vmCE;8WXzdhQol>)dm=$qW`Mp*16#iD~Y>iaIz z-8;#bBM8tr1*@f2i)S@ct7R+obm1@3)xU~WWC1R*YBVS`yIaT4d&mFu<%4go_4f46 zJ?dM$djH)Qw?_YbYy9`uNB;Th@aMP2zj-u!_37fB{`KB*0a$%LarAOV)H`|HJ8?8H zD;{2y56(+oO&=p#h4?C1{qoN6@2))i?AnX(9*#bFvkn0SsH3Y=#8)u~q9FEW?=&>_ z{_7=-u*YxK5G%m?z9zDP($!Y_2)Jqd8DGlyVi2j%c4ojw*L zE*c$_&K^};LV8!+&a>*GWcG;CLt7$Q#8<&;2yQ^8M(65j!fHERZT`qAhbvgkwtx7P zRp=`327EN)&R=4+tG7S0T5osvR$W%}9IIsnte~zJtajr7^=1d4BH7ek#Jl+Y(xeM2 z)R?~qUt8l?#aM2ivkC_wU9F}o^<3pIidp@ItilK2brk_C?5&`y*js6(%FWfoXV1q! z|MR`yetze>TZ8v|7asN_n7{VT{pmkkAN}pMkw1Jt{>8niuO3Wac|3cwZ{_|F9Du_Y z(?XtADDB9yVt7%8m=$(ah_Cif9o~Pn^zDPUpI?6oVt;?N_fNN9fBSe0Ktfls!-Dlq z>_S(sKb!o%ZwB0gSi}l|E39u~XKGV6x2swa=r=`{9jSds=D@fsa~!I?2r#E2MBTDqlwGPKs<4GEgv)B`UYal@3~i(5O3M_ObRr%I0Uy9>(B^YHeYQn=v`# z298Y73u!f4!YaK_Zwc#dxFG^FxZ)61OE{zTGD1rbrgBlHP}-lUz+X)i+R0*z)75tB zf>lUss@aBR+8=lyfRjNIYXYU9m%oVlNA_>B%7e=Jt3TOWeZ(rStCwR|O~kB7e^{sz(fA+Im6TiDY`af@sLS4VSKXvu#!oAm< z@KpPzPKe7oe%L=PB%(Sad^K~7jTKT?u-7vJ1gx(2yaTTP@aKpB<+D5g@a3b=ZuaxU z!e7PG4}-vhSg?Bc)dD5}6=U!C*5baF2NiiGL`P3_0g)jjHiqSv7`EzUlkPtceri3e z#>47^1+70z(ozWBBgKy^*bw>C8W#g^6UaHjSz90lsZ>}35`#zQq>Qe(#ltxKDOWIK z_a^nGpiJe|7z0{Mn6T=I>D{z3m@+OO%+?|ato{y zt2eu>BEAY5yHd%ch$~#GJ;0Ew9E3-l+6$m%ik6yi= z`|8S*fBfC8|Nh%s|MhqG{^5^Le}8rO`m>dreH&jsm;ag zt2xQ*1sU9czR6?6R|n^%VD;rB(ySy1FukpPyCiurw*7c;<q=# z1`5QQ0y$$Khv+DBOvYf&6w1Slfh<7Pd0Dk9uJa~L!IUM4n-eN~Sfs~`*wv1x&P~~Z zDIZk`(q&I1YqUpX8mHReQ=9w{UcHObdTCuCp%14_v8*o0!Us^gD6r~|7sBZ}e1LGW zl*~5>tCdTvHd-vKPPCLq^s;9DwX8x&LFpw?z|(g;pW)4Jxf=5mcDv8|JB2}Z=WvR=v%q|eCff^ z_DiVfoP@Xm6GyzR_D`P-%$y(>Fu!kH6FSyT>?;EE@}X(<$g(5z@Bvb6!PC)AI0-jfkE@5Z4-}3p z?_i*-;1f*3AHXPudti>Ltdz=5s~vH*g9fWGP^$AMw0=h8qg5VC>WoNiL9sQU4ZnS-wRgeaGyx@%hdD$*&??zjjryf*O1 z>q9r6FMe@n;_c+ zcz_(e%)276EbQu_t2!|S~d3;dEFZvKq zP>Pa2vY=yG|EZx+Faa&)iw7{_tFus`#n%&ZqKf%B=bSQgWr19Ll?zxQ2vBHtiilaY z&l(7>a=0RUMce?+>Masw`m1#HBUVY|zlpF|8}+)dY^{mCKipKT{&cY%%a!c$G-0(` zYgVeQN);n;ZE)qR^-{TBEY*r7G8T%kD#m;PR_BVYn;H00*?KBdXH&H#3oBCbJc_Ks zQOe^F+C6TQLoe40_QZq3i&t(9{Pxd}KfBU94lckUh;k0f@vE@*TnUBQBns`}`f zCtkAzb2@KQ;Xu$SrgAY_AFK1FFzQ1YY?>_LJn>^aNsTouR5*5yv`12#MC(>rBG~dP zTyeRF)`YW`WW|?m1k(*)vgV2vY@rm)M;GI{MxxkGlv+%&32zOC@IEh|(Oi|(rk0us zEZMCeU~J<(T|14HTd{JJs&?r587yAyL`uy-z7{IfF+pi7?nyMx@Ku<^QQ3k!Yo}df zYNxP7?KIs$&FUG-R`bnH4tW8NoOHQ{Nw?^_+J2An0A#XYsA)m{)u)DtLG$dxrv}<9 zjW!HbsjyO`U4+#;Fx2aklHF=M1D6Kx$8s}?_h6|>l}V1Z#j#32tyBRjZ(tRm@&-zI ztKWXAnnN&nE|^@pQZ?vC8- znSAgP6;?|RUM@WzSh?4?K)8MM?wh+KS09e|yk31XD@0ZE!mfVh&Zzxgngrvaz{-uWlsDoX3Jh%$$8CpXzcF*7{e+BdB zZ?|5I?}F!nsl(AF@!An6HKFok7U04pnYYF8Hu7pJAKa^Pa zPK;u;M}gJ=co8mCc2OcHB?sP-99Rt_3y`e2!D^7O>ZOa(Y=bFw=wh47H=?;3j1*3n zTgmDv&uXmL1X^tK11ten>u2Z-0F#k&D~gKiN}GUMtb6lSf36B#@oXG4Hr~T9K_3AO zV1Hx)7%pqEeO5%Rb%O|9rrLnYA#j8VE|y?izW}%`cit1@N?U)H)pHT%rTEgw-;By_ zuv(}Q%U4^lQtJm;q46PKe~(JDRJp^J+IY`KawKN;*RxvYSS|cAs{xddQag{xxu+btzM4(17vwK5mhw3iu8Bnk{wV@hYmJZDx zLtUSZY~FjhaKC>M#9|Ig$5&*y2XBN;p?y2Q1>UQE~;n?XKdj#B3F?t z%1$~|u@x;eBKaB`PcVs>Ti`RAuM>1jXawj$B$K>~;(ECiMx#oh4lVU%D==@a;sLAq zb5^^OiwSQ21ytI^>pUZt7TA%qUE>qqOnB@YM2*y4Jf=v zV+h3d(ZKS9SM!et7hg~BO{_`gchyS=Iq$81k}pw( zx#K15$Y9df41UI6`jev zi!Hb_B~PvbR?&wAnFX9sR9;lUDvv8JUN*c`qSnqdU@gGOTMAK#S_5+c3_I^_;c(@N zJ#TXP1lLbN#TBrMx&oAJ0oO|N6mkksQ-x}>P(hv!+ew0Gx`IfEkIJ~BtUZjX3Honi zwMO0pKeBr6ufhk2$8!-1ta{8YlgfOuCz+kuymI~dfBEMd|Ia^s`~Uv-=0AP$`15No zzPAqSh0b2zZeKCHKQ<& zJ%}pg6reg1IcFm8N*BSZFINqqB@p+QTl|WT3Go&#zKZ`^euUFYSDHzprA=-_NA`5Q zrAg-(X>Z|F7rlyS`8Mo*vCX*wpMVObg-`pb0oUe-e{H<~7fi|*tR{<9CSOh#>U6Fe zO_c$vhe|uc30sgh`)PBK{cBl;%UaLEaUratcIEQkst}`!U^Nz}JR!H)sh1lLHjl^0 zmcZ(N`~9u|^iS9R(?4GQ&;N7{_TN6g``OjL2mK4^1c5vHc0stfrx&OKGBYhPQpZ{Z zqp-NUAg421gxj}^$Kxv^I0N8HYL02#DV+y7BRGn*%t9&cC-4&U4geJToOsMsq z=>1Y_RO4e!a22SMg({KC)i{w>;Ob#Yus{k8QxMfQdQrm{tU_9WC4>|KD|GxpS3xf? zx!{mz53E90J?Rppl^Cb1-fRUI@f0tuP*F_qCEc&$zm^|?J%vqNxsfQ>&*KkO!YV*T zPhz&gwPKwUOK^o@BL+9%Qzn1qO8x8yfC`wg{m(QO|Qw<1?Ce?NMT{5#+bxF(w!1x_(1MlKG06C ziN_X?CRRiXJIXDgS)>c7?Tpr$R9GOD{?%ji)P@p`rN|C!OOS*@RG*Sr7$~hRQZon3 zJhaeTC@P%WwPP#BO*FQ^2T-^LYCp7E%;i||%A66Rglf-`!f`0G9LlUGN;kSx)&zRQ zvQQ(92!JzIL9zgpBB(`t08a{O0!z4ni)vQ_lp^=4_aw30%h9)@b_!Z7^FQ1}A~@Q~_l0!r-;SUv+28o=nM?DRkllM}8t95zAQ$J^*6qPUl6%hck@vmVAN3tFO zmCo0wY&DWDhf}3svfyJ7aL&Om`WslS=6<59=d7}99<0)ImZD=m!YXMAT;6;AYU1J3 zu`9O+Kfl`d?cL#rFXwv(mTo_t#Qf`9ufMrHc>Uqnlh@0`(}$BQ(uHl!y1=w6wqr$> znIe!Z&AzCh};36L=d1sK;u7D`#2*xR+3=V`o;Qy#2AzsL+}BxY9Ff{`!ehD zz6RgrSmQ%Sl`T}T1oOxjpo9RsDipeqAb^|YO9-&Zf=ctCA`FY=UTO|YO(C%%aIEu* zxbaBm>#}O4%a&*n=_&+c5nn}3AdU!t1u_k=8Y#9z`9>gDgDS%KbsTGSvUUbs!73>A zr%M5F2qys#`S27rP1O!8Tx$CARad6uP8WGr!6d)XW5VBjnbPh&QiL;%m{=9(1~6c? zj$|2O6?~o(OWJ8UTrXHHaXYN@u)rl&yC)2MG$BDM&Jb$A0SGYk>Y|)1oGJv_JP?Jb z`k5TeLuZ}wtjZDjB~}r+A|Y1JJ`P^x%GGSCnkiJ$*-9#1X4!HgSxzK!F;oHsX@AIP zbL-?Z|^D-`(iF@_qlEr|)|D=byb^8k*Q0ofAACT)y$(%@^1E{`l>)uWr1! zc5nE0&p0klE{j(7G&>MajSs7>1jV9CH-emUQ$%JAA1U1kE6s1o$L0?Q-fcb~T72+w zYG863)qOZSLg`3IE#wdhshN^l;iE!zkvs71E4@eBAg+syQGq6~tMH&XWmn# z&UK*$MXH-(%a+83T)?5y4OU69pEW8og@iiKfx@=1r`}Vzc>TnPu2q1F5tQN~__Rez znDCV_sMk{2DQy2W_Bav;hf3$3%(ky^2sEBUwR;afu*xMg2GyRVHHPh26^2qkbXvi@ zY%Q3@%HDy6a;;Fl8OYYW>9RL{E{wnlD>YN;Fy(e6Uk9bWR1xOqWE1#-XXq-p1*ou4 zsTnLc1BeXZIu5enU?$poY0eAmWGgG5*jNrX5?es1ihBxI%AF6T(;v!b|5EIHi05l@_y7oWWU<-I+d_=i z6_QzeLcJTT@{!d~AT*c<)Mk4u{ps6s_O}^OSt~+?SVgEeg229AAf%3$(<+T6N|?i0{xM~ zrE@Sgq~m=V^x7ksiRMt!c84NoT>xEp%e$)4xr5%}rMu7HJ$yBX{nyl{9BVqfSv7WB z{+x?$IOBDAwlG{#*cqvX5*Z_?M?Kbu&?bO9ELu_aR4B3v3Jswngg`Z3F1Fwo>HS!& z1uDb};4SD^jxjtaPPC|saY0nY=J1IjAkgBC*xAjb+^1DSJH0WCoFXR44y zu<8Yq9FP!362mXG5Xb_nUbf(43t$yA@2j@rQWj-&@qi8FrBTc|r zy~ET`c|#rnpe8tCyCb+oo{QgJb#;|z6%PRfDSu`l&A{J;6ySlHQ-INT^?mrz_ z>3g^FZcV%?u^qwZ#75qMio2X6jv!J4dvkNRfI>d>?`u4uH!U<#yDHzN)PW;jT`M5^sb z{S*TG5vARSml5sGdG&^XpGO8rW&y!i5<}oKVwXpTl)Dg@6@4zeL1Vkd$GAwC3yE4T zFpGN%@E;JZt=35#3`sFKt0?g146Ks!?@|kKIs9C<7_0S0Go=*K)nX!1U>I0Fk%*xZz~=Tid`g*aVSaOTY++{UaC${JG`an1Y<*(+cxguo z!-jfpLkei$&K3&kiOuC*C4!vTi~~yq&(W6zN}b_?3o*=a z0fvX@R3gG!9aZ-d9y?CUlIfqz1O8e04taPzx ztUiK2pbH)w!Xk4_Y>q+kAgyRi5gJ2StoIa-O|g0P7-?D6;-PB(P`h|+SeM!et^gIS z(_9Y=ULUN&L50jBCcqyJB-RCxpOWkRYD*NXB1?tSDikgTK`OP6Rk%rH6>}XbU;`Pg zCyDr#F-Y12^#K;RIuoD{G17)NU9&TJH})4?7|PCM%`p}sQ?QB>=n|i^&eTR+mA*bJcqZiFfh9Mc6w)e`54KgV}(;| zqs$)G>P=bE6Y9@kG=mdV=38UOYR@LZo=Vr6&@{Oz1*>y=s^ug7>WOh%WY~A_ z#*ZrN99DnSz@T6obu3z60tGO}P};#jBoTKatXkt)XR_eOYM3cox-%ZPU8V7w`?G~ipOD>g1~b$RLU zVu{IL$ZFw&)j~3vh(=h7rX#dTXAujP2m6w-@x`&}t&M%n5zZ(R+YUrl6fB*{U8n=m zS<&UeXf2ci%}r__E^Z49fcfdG**iTWeM1Wq3x`_*olNVucvwGG3C3#}VZK<|4fgyQ zlPdv+v2)**JE5gO6uSEK?aDK7zI;5pt6UQ3Ag~bC^VBCopz*3R(X>(xeYmXlXO*6m z!kLuV;!w*&t#4oDhS$pLDnxa1Lp(UQ{bF)`WKA@ApkBlN2%CB*BX?spPrx9mczx`u z5U@gg01;P=?np@kS61goBleNP3BUIcLalLcshmPvRP3O@Dh{whzQ7r;AYWkgrNAmc zAH^q~us3azNZUt{1s2 zpa{GC6m9^_MX2s6kzzbV*cPDjg=DB4gGT{M@qUDd<4NY7bjB7yqyuy%$~I!@7H^mbnW`sR za0IhB4g%p#=pjf0oWQkreEs$8-ss8+?+;*c$5ZPfGlX{^QBy-`N9o(b$!T)us>HT* zVp=#dz$0BgF+!YSJ2Kmv&^W)R99rG z7p$sLRp?8go7Kry0(mH5Cs=6P5_v0~wK7=?oi zWKO6JRMcRnUBSF3QbKW^KUN9T4Ntg;vve#-siU^p8dsY_3Zq}Db&J(bsn(-12le)t z$xR#30cwkwTydK(=?taa;j9aP*CEtjS5s zv|c2<)(+L1Lc^ZQA<%ga^7yh&hARZk-jJ0iMq;wEX0wnm`st+1I=GF4#M9Ft6hsi4c}b9l^p zi^b@4SbcJd?oc2*Jl3GnSb;FR$|cwM3^vN?%lM-ucOd5p<%3w(ama%&V|6F(9@Yt8 z)XktV87<5R}@Qd){G_9 z#V9Nhk=83vI*(N-pmOerO-p;qiIt<_85~Hs_Hb}M* z8M&Q4RD0p>j<1SdO>I9JS$+hB31t*2bdCs4z1T!^vqF{@r@x7o?;R4DD%8^1PT&zTjRnCwFtA|U7#9kP;f#P>k z{0PSt$uAgjCpf2q_`qD`Hq4bD@WqEQoRv{WFt(N8My?%<6lQMpht2OHX!9dV;AMjmpV_2^9|=R&w>JhXejFk|)5 z?jReaapenX&H6X>?34#25$CIKe`uyPyCM_-Z2LSA5OMbtOG@$mJ+{a3RXpO3At3QcfL z-H8Sc_k;Gj5WtTURz(IMRMCbEX)GT|R$|#!B;CNT+Q;OrL4*auT4zXQN1cOPY4amg z=tMCFm3GB5-b6l_#$TuGW%77t8BKK%$1mPR^!2VKADgBqeiV+e4-GaDD76C-5xkP(e4Q}CsK=0 zW<3-dwhvTm+tT@!BaE2Cb_E(-KbDwr18*XkRYIiLqtbg-2CqWrMiZ#Y;L%$HI*VU# z^P8L@yN~jOlK~3Cn{|aUu29w)%%I2F>PbMBwbro86jbPa3Ij2v(XTOw(6DcE(d1Am ze@^eq0#vOh4PpT*as)W?7v%wy8#3_u^}RvZ{a14%i^n+K0*(Q%=x?*mA8JPjb-@eI<1xQHvb&Oa4Q5i!9< zSO5p7W7T7exY#wm${MeRuf@xvyb1}OSgsz)5JM$4Q|d(UO%ugHvJ_;?sL+mP>#kVV zt2hK3>Ix}OeV*qGju8$O|UT*kyWeNp^)mf)(?co3cbO(z9m{* zJK;rj|5&$oqy?GlJF=bLOJ!mN2SJ5jDzVYleguvR5Kwcy>qmU|{}>JN;Mg4?$hmPE0ae9HmpB z)Sak9QBgo8wT9&O2!4T%7}N|WQ6nMPh~*kozKLFG9Pblki^#cvNn}D{U<@b%KOl#T zh;qYl5m@3OsYK;!r$H|+;tBycRpP0}o#2zdh&f&jHv`Uax(W!%X91uVD_ci3GC;*Y z0OqChD5A3j7|@G{kqqtxqQuaJM)RHgAT0VPyzA(%iuJAk(^1e0hcSE-dMB47(e z1*qT?n=hy+M*blWHh&S<5%29PYIj0dtznOU#v6#uHQwi&A9%~wK4hw-pqj<6sMw6> z8&tLq1FKZN<4aahtYY$`Y&D_xFgWf*ML>*KadnmardaU(e={Ne5C^1FjNi++6z;Bxvjn9(E;TK-R zFQ1eN0ZTrwO=nSx>BnY)$>BPZ-SE)BGp^ts8tCE*Z>aX?o{d3pay4=%XSfHiiIGf7 zt!M^iNL31-f&p~`u6U1R>ycCibBqr7!=Yp_QN+V|z8PXm(G0pl%S^GtphmO=t0i!x za0%{iot)NA4s6Hq*Br5A(gLwkED%g^>rhK9oKsq$bz1$U;P{W zRrmm?U&Y?4e2LW}Dkz)*v%w}hk!^1ZkO){=-r3m^8ZG`^fogPWeSTGNAk>KzRx}{H z0<0U2ML5LC1s@f@Xet1g53TV?+~BYs2cxWy&AJeYw;QE zpfu_ZC;U`8nkYq+RZk>m@scBYj4sL^U~z~^mQjT6-@244bl z8sQH1$GT7F(Zbe&F#svwNS4~U#t%HMd|{i9&Z254maU=4Et-K_Tg8Y{A{ZuwRSrw6 ziI}4qFj;QH*h(jX1{U~rnF=1JYiD>CbMnfm3JlGIgw=c#?MO_a#Y;LIKTkA+HdvgB ziKo!J9Z8kxJkBktB#GfVYD8;^QXTEF@EfrKr%)El^>anhCX*v;L?~NDsNu(?Ef?AX zu7DO^0dWZ~d94vt(*9Iec}lyi5?rhJOc}EJVpHCAWXhY%CKqdjV}g`Hjm42m>crxKMYU5e7>NW2t^6@t-xFq*^Y@+B>fn8_N} zn*$o7S8ed94Q`FmqtH5}DvMle)0kXlXTTkzBTSBg%baf}bIl}x!O`XUb`l5d@pL_oqs-V!m?`?vdLK^P5g@WhB?j+-)Vy)5**?(;ls1(mtaDLnE9$7(Fk5G< zKja$!nyUT_L^zbHqZQg2N26cL97v)enkt}l$ z01U8qh-E7%#l!>{=b9gq$Wa0ee40-h(3a!5DpLg8O^mPvdaKLW9peBiXc0bUm=M^2@M87k!N$ZLOFJXUFk9lToRW73TSDD3itX7#HC2Sw zQpI|zgu><~4FAY@whE^ai!YS9Ympr13~)(@bH{*p4?ro35BX#S90TYrd;`*C+9Dm? z7sgWx2Y{y(KTZl*;zz&_h@ZDmXYeD?nLs@4qf(w|(ivv#!MN2IxA@~0j6O77GS*O`^*|nJE*@U4#4+ZgVjnZTT15giAN=5>xXKS1hU-3tS_XxG*5)E)= z5x*swTyz$2tuz=(;*86h@l7=7SiG#IA1Nw+OkTtB3yEjSRJs&Fsv^WVgKD5Wk*hqKdGXuE?;Ozby@B0&fNsF*qbTb~F{@e@m8-c@GF@Ub zl~lf*E)-JvY$6knFkW}iWU%S=R=v({v3h-hxYZs|YwZ?W$QMXDJ#oF!D^*xT5`#=> z70XO=mCa-gI$SZUJ*+c$lxn*|Wz(B{c4yS%PlRJRI#EurRVG=ECyL=%CJ;`Ba8w4? zeL53MWGNg>h{yxHKCG}QkXfbCHIG&uI_HhBz9@@H2zwkl7sM(Y%Xp)#CxnBhDV5oy zFuJ8$$FbbFFVyTDD|e4o0+~T;@yqm1q0)l6P+^uEoCbT??8WZhf~S+>^3oF7wY{Dq;RxOtYVcd`{6)X+rZMjoxr z4Sa$XX$(Q0F@po8aZYa)5{e3W1j(^c0+3a#*BIk@ZckKz|4@Q5LsSz*2qW)x;K+*> z+>Zz%S}Djik$SAEbRISK4Jc(|#4{0={0Q)2;L^kp)5z4Zi-Z%4 z$Ohs7-Tc%?lWs=fGOOf>fNTMj<{37hNR?7~6F-9ASqmYIjEP6dqdbA(sb-4b%Q0 zPR7C^E}2Ly6ON{%R2H91$goAcMbf!yn$z_}x=6z^WxQt-`5H#NZNrJ2pGv`-#XI*S za|LO{2bl3pSa~rqnw$X1C3Qkb+-rbjkI0jnQp(hkX$?gcuaI_6Q0w z1(d0y1IQaoyOH&aBt4O2AfAe)5UZ+8>m5)vkV!1#BVi7RR`Dhy= zX}F>LER98kXB7ufTr3cT(hGxk3d>c{TYYX^hcy%)D^Z>090TGT;2&0O!Apnx&Aa09 z9Eohei}upQ2lxol?!#YV6}nnZWpl_?B~ryyu9PVj*j$Q9yX;<_#-vi}^+ub?;@0SF zYMssM2n54PUw{F7V3keR=tL_+Z0o3zn}ma-~`Z>l#`WiKaC%!XHcI%JFm|%w&8K#uxqA{INtZ&IV#h ze2E&ABtozYaHOykKR|&Cj zSFq7*Q@IxK;BoCT2{JJUt9;0pzs@s^a?=Fq0&64M4H2UVWA->BEqM|rV_6PTuBtGhKNTvg?|_c!2S)aR&yMyiBuNS%4UfJkjygiq{kKT zxFMlFlhtK&20$r9)!`0@qp4Ut2Vn$iWFUl zAu~ngAf&jTqVr6$n8fG4rprXgvlS$G^ANFeBU^$SRt6{ddAXmxg^@oM0nO%Y9?@R} zDn2%_T}2%`)@c0svLz-}pi_B_kmz)t$TddXlPfg}6}%~+kRAAS__Ja$rLc>~UOttN zuvok@5hhKga%{eY7BqaY9rqbG_&`Q{)Lpv_O6#3U_wLx z8s*XzxD8F-Fi(~1==9{8J#o|(`OA_&F6VY)gfzi$1)FQm$g`Xgzm!N8S#)X)C$kV+ zEc#^KC$TS(P(dz(wM{_+VM?td(4q(;5C>4qv^@g|HBjK(raj5iDmk>A?D1Sj`tp z=^R8Atmcy0JVcdFQBj79C49b!MsHDRO=g=zU_E9k`-*g^KdVO)wm`Iku zs?`>NqPo455735^fSJRR5X+{>iEe0)fw8GdDpSqm>u`|ci7b=KV@rpPT_#_Ks3$Xd zppvaX{UEI{w1Y!tiQyqGerkDq%ngqF!0!rbOkD3W3=`sp=gV0fgM_n@Ad(fZigyH# zM1oLbQ&6F>uTK>@FDnyf(%}St?i_-4_=u2VwGL4E&$`9OhgItMKxUlR)FB_O3u}@O zg*^YH-R{MU3C_tuJ11H>xC42}nLOz4Af?DvgcQyXBID8J59+~LJr^8)jOzuc+{x|d ztP(E~?=^%Yxc3_TKoT)SC=3x=WDt%tv2vuy;5YEE(jW<5( z%ZGg92=>BZ2B?rh7&&-~r1)XjMZ(BG28h;9iE*sv%k6W6oR%B-#0vhe15W^(J}ihV z{v!BVoGk-Ug`%>h0E6^v#uH1!oBbPDtrbcvc zRPYCFW-3HNd1$-p+GUu(!iy~e4%lrGKL0=F-m|%_G|Th+CL8-^V_)t@Y;1JT^h|Vb zchyvNnXJsJtn?|D^4?37L`tG4krci6-a8N^Km!_pAP5lNd+)usq@=3Z|AQ+bnaWIc zPjC0cW}LYB;Nk)zi672A&#`Y2MUWzHMp)BNl4sD10If5y%a&sxtUZddFI0RR{Y2lw z;f9w0S8z^_MPiFyGVJw=QHfZN@&?1D238@&F;x_b)eu}C=|c#`YH?(Gad0~B`>`~N z_DJ1cEJ@u2$$b!aL-_9S&B7O|*v`U;Z8BohjsW%u{{~hw(L^GMjlVzO_6FSnAC#)y zZ8q7oS~FOMvAVXwS!HpdS7mBMD*5Wxml;P@nj~38+Rg=NKuo-FkTsRaPp88X4I20^;uj-u1x2#Gm7S3Mbj|4 z;1)wSFVGAB53G?yB$0}zGoTbh$uT`ImCa%_*-wJ{v#dhN7b`vAsn)k-0#^#)()kj@ zMZ*9E^}v;~^lF@nk9*Pe5XcWHOy8POdLtND~%#h-WFm zIstC;XuR+WUBY6SLIk!k_H@w9@l+&{jHS|;#f)yE`GbRO9;jzi(6N+WeWyYxrTTNM zLbYOM1e))m!6~UkM!h@~Dat(4Ih>)+Q%{x7!@vWsA+So!TG*~{k6z4O4I`cfw-pgb zDDEH*t^}xq7DbK$Ni*;z^oV2P*6&Sd+-MdTmD$4Rz$r2ZC63O+|Ie{XGyvI$<{%OL zvMI93f@iO|5g?8%ix-Zpuo2=SN4O=yYQEUVk~-$7UctrYt60M)fFp24(_kDk#YU`& z5HuH<2w+za?doxOEGC;yYZCBfI~?J@P>nmj-r!N8VZO>HQCg*Hn^1|06{ApLmZ+>^ zrCF-7s`W0j4F+%0hHknVyFvl;)x_PEZ*B?a7S<*v>C2355UWs`O%{*c8FaeCE-!54 zh!2}?&=^fdiyb#{godQ_WHbT%k~qe3Q%=KZ%%z|te=J02W)dm9@GX#71F$rZ%K^5x z&*CHmS0-V9W-%KyU&KB~{>Vhx5|xXmFflKk%VS~=(W_YGa(D-v!PLi09@9yPphbDM zK%{gAqst(;CY>dc%3(}iAwi}(5{W}HWRHfEsXV4i9TcBMt5WKGJ_^rmG9OMr$>)Q_ zZ;4G75p4YsBZDn!BHeYu2v}efZS*D7&IqtXqYSjmklO(#QgLvM0#1R!$I~O)9+03y z!4gJs4UVt`OoUP-Ex?+MA_vACfMpAXjKmvMnC6^OOeHS3V(6@eXc`s>Iv{$R@+A<$ zD_SX(y`9R%GSI8guEa+dOCQA3heWXJMCak+?~7kEnufbC6G{@Z%@K&$zn7>zfG{*U zxn+!4@OgK2;ju67jRN*(&_qLkLzqS23(_le>C8a1%n_q$V$f>c7E9P@3MthdWTkS&WHbp|q~l7ByHb?P>2^eVfgHrzEzYP5If{CZL}pQ_ z>`IjbQ3KYdV1d4|yux1J*xT8ah@@Jz)(T>6PQMeju{Y@Th5Ug?FcgbK647W9L+i4* z1!wb6j_GtZmBPqHOtMR1LC*hJ$c>&5MHFCB2#`f7oq2CTa3uoxDgKLm5;8v|pqCPA z{v(d1Gt>*IAA|fPKO%<$diUJ=QY-on&Y6mx;e2+Kq=kVyFB2pmV>6G!okFItST7C|ks znlF+`daW1HCB(iv16Co)P$&UV{lT!;?{&CsCOfLDlyW_SsuHO|CMSVZ{=QMA^{Y`R zisB~ZtZoX|_LSQQT8VUoTcK`OV&sbSBBjlQNhP)jf~xx>gGT2;01LS;66jvUQdMT9 z#;VmjjAjoUUk-N=dew{V6(kUaY7YjZp-?OiQy_~`%ehP%Lu`q$2rUW08s~p3pqhfD z1mwTSYU#=nT_2{DdbUL7zsPFoZQomz-r*?QsZ2heEC5u(Y7}Wi0F`7!c#x?Ar;~@c zNwr|i62z=GIsUdLKl&I8O<{>Wv2O~qQLbAYw~ZqUMY~cP&Y*UTZwTU9BB*CKhtOXO zrmV~w6q|f7Xi-7}da>=I7Fa_J{xrlGNLfN8+t3@2A7K?v3}VJmRt=Qu4_O7MlwO4m zkclMGcZy;)?v6xC;)+Bd&f*#WJ63;;oPk`*itFW6pv#}JOmerEKz|mxT|p?WmIAbKrq?>qHsje z4o>e+qxKnV93e`y--N#l!JPnd4wIgE(wBhmH%&Yh#NkG~8I&vICs{4JqY*$MtfGL= zACE&kkw{4>R&m6cK#|oSgG%YopF5w6px7!J_lEp-uia?ZDGgGQnvaA%fqH8P*{2dF zCPZw=7S?4fzFA?3qnX1pM>@aGC+SRblFo!VWpaZL$@~gE+V2OP0eIV9`_RY98MnKW zHcZSxAOLFqVCN(Y@nk+mtdgSbOtyMS=+%-U1*McCJqqW0>m0Ea z$-TP--iP@-`fTYXKZ(|RCrhOLi+c6F7nUBD-hnzp{p%&Y3Z;rKvJc^>V9Ei@-)h-C1h$p*&7syzwJ@(`MQ80R50qIN7Gv%|QJ8T@f)F*DXvv{w;vL+A|w zIQWOD7{`xUElvu6O`fF;0I(W}#r-k391*a7i)%^2;>=N2sT(~->4#a(!Zj9v#*YLY z0lVIzlIr<9+2*EjeN)6_iRdgb8v2c6D#{FJY|aY^-F ztu2Cb5{xdDsNE2U559{xcI1oNqa=&fhT_41$>ujZkfVZ#5$UTD+0|X63-0i5l31W!B>FJFvV5|u3e22f;AXc5?0Bq zG?W`4iyH|H$YelP1L^$pAy&!A^^&m~jKzadQy*>4&K#PevWd5Vh!} zK`gj+d7~JwjUg}*L_g739=kv|TH(J+W|D~%aHR}X@Ci^~9lpjW<@YFk$12(5lyp}K zzkdy`rHe~1|G=U|-M^?;OIQBf;yqUJg^eZNvg-CHZQhvK88JBEhm0W4T%fY;%FR16 z^Onf4DK^3eK+7z&;acD*=eFgG=z+k~Lcl6z34q}eu2|#b%D!QFPqWBXup}mtC8TgA zgq9FnX@~5=sL;4Ln98AY@Gvvc8djnsH*&O)3L8ti;u$mAUK=ntET0+PqxE?wB!;#R>unLP5@^h@l-GL-5B!3dS zJ`Ylt#d_AdU}kP(YJojGz0o$bRNqHy8C&mP+8=>P*AKAzleqqzIxU_5{|Bpu_z_lJ$ozMsbUma; z(xW{r(|dL#25ewAg*uclY>LtJ07})hxT8i_F31eJcXE`p9Tk)+Y*)&B1*@=H0V;(t zE|}U7qgM><0l71Yu`*i<`?}bSmT^42A1%4CfS@S{T63$sq@xjr8lWGn6RrNK*;^@+ z5l?;6=s#r zsnFUWI+NRI@mL)Jrw5K!WCb90Pi)sjECp6!22eHtrB`wM3EMSWz~1VpGA!YT#Shh2 z_9y)VrR#Aqr3OpyR(h)RR;6p8T1z^!bUhZ-m3Zpt1*Nxr?eL%Tf=SpH zLPFj55)6eQks_;<{w&$6pfnwhK+v+1bgc}Au50T$k)S0L8c!6#}3f{zbj|V^+V%H4;b0a5fN+xg#NXmJBXAN}_g=&##=A+jvslbHB2^ zrgOSsV5zcw_T>O$V1Y;5kYV&5M_?4l95P)%ruB2hRt(&svBZlTl4T4+&$p!$fID?1F zdphXSp`~4bin~AT0d!F0o1$w{$Mm*xYE!YWt6SVNtcYz}O7FVN31P`xn+gvHeVC0A zp*10OCY5N-jUZP51zE5M@=nBFQ>Y7g6+#7T<`5Z}$Umndsxd^Vl1NYtyC9*ED;RW< zlKp_o=Xd)9(5QhB0zLRlBjI3Cupl4qhggM1EeTkqBpr$nKL8?EHm}d>4IoKgY36M2 zZ*Pm&Hbng+OSj7#&)r{FD$djh=_Mzq3Wj;CtZtm*PferoE4Bz3aJt_Pp6>W4wa7crJZ z;#u5-6cn=;e*uHV%a>>oyq2PjQcv|eXKxyy%HuNoe$_b1imefw?n-=#>)7$FFP30_lfbSaca2ey6MRtbJ zj^mmX^SS(7JsNx^#CAwj=8S<@oj-$)+_or^S`SDe7>ogu#6rUTNLGPF;Z4Q#>TuXu zWYrmjKPlk!2b^HlhX_*yf=`nupHL)Lk`J;9I7_TzL747Ol$}m<6z{m|YjG?P_E?pV1kIs8IlGL5@uXC8$<+%oEIbf@wHieIYc` z$OOWuP|SoPsc<-cRH;IF;--%yYyhZP*apzIkhcsY7n%z6zYDFtr#2}LaV(+x-UT4` z-oKSlyC*2F`pkT0ZCUtpC74KuoQiEx6k2q+dXQzp2wB+_D$3`^^Hz4XBIj2En{ac zKR$i=@wIy|D{K4fTE^?!Ci_NLFwqQME4TQD9f=L|OfjH`4!z1ztzy{9o(}h^!9~s# zV{enMg;Psy389!&h5(8N1&=Rqqz{zF@{z)HB>9~Dn4<1?msEOl41kcl+@jSG^^CV^t1wfc zQK4gjF4mwFIu_6lGxp|pG&5}N08>1;BALV_ah_>WV4VfJJ9;c=d<%rWZ)1p^YjW?F zI>^=ri`_o`0&_^}h^f8BIWp*7fQ*`=UPV4w7>Voe^eUWGzF5pt6n8XA0##wMrGkVb zQMe|NoJ8`IAjnaM;NicHRe(zMt_-_9ka!@FMyx0j^E=&6v(0L->Qn}qL_?=8=--o=_%gH7;L%$HMtjKWia1d+KtftMgc{*% zMUui%Rw)-N#VXV(KrPzmVXRB6mXfUATL1|PSCE7IG8|x#{|T(V2kLv2mOw=kV;BjL zXxV4-p!^5f=}4TAsxA9+qXG}DL9n_jGokmOP>YF0<~4z4fi0O>;ZLoL7SQc;TMimK zr&)aqZ2Yw;TmdjV0H7CU0F><xHdIzuED==jVRn`2u}veK(z)luVJr7GH>nGVu~6`Rtct3en=9z zE^oa7$m~Ek0E#6RL0T{h*if59QtC-sd>EhNzo1v4TB*B#j5MzFqK-6(tW%_{TFh>% zHQ@5tj25j@Czq&q*!vqS-r5>(WMuK#v$me@=|%d^$SCtsMazjZ_b*(1`l4aDsdEOb z5(PWHM%$2*AyyI_nnE*p+Hod-WSIw0#~6D9vzue{+i2*AA!tICQ)7vsQ59k(KrN&#rSR0NKHneQSnHzN|FHIB~!iiuVSAWj${!LfEf@BC*iz8 z4T;+uMHZ>kh2kiO$z;@M4QidmXjiL@Y_@QDWrw-SLX-q|46u<#0!*%uFB~2mye=HP!oxJY znk3Vp~`M>#&nJt53RR& z>SeZk5ffxMDkf%zGWWa2RyxL3Fvbf54$x_KX;(YS6m-pPcg$}0E$t1hiUwANL{>!I zbU_!5-@7F0r16`lIGqdp5tedh$FL}XUbQXot#i93Je=D#16_s$+SRtEa9|EH-xQQ0 zCjs5LgJ`LdLmR6wsw%RirVP~+={&Kla7-33ejN=Ha`9|7p2-kN6RRwSytx=M;PJI2 z0#=EFMSJQo9;#2V?ZkawZ*-Zhc9T^l*X->{ zcXp+lJJRL#eVD1s>%v{3i7zrQGxr7u7TTIeX!F}E>!SWq#-pnCN6*?@duE4cSQrY> zIY93iTAHBmj$!P@vS3GS-xQdqF)x6&J2cPj7-h8%u5^zBSMCZ&t1v{&?yMX`e}sCT zP{$W)q#zcWL}N9Y+z1WWoY3)MryF&z0k{g@7msz^JN%@7e_EtEWitK^0)zO))O};^CiHY>V z=~YqN*jm@@cJCsuYmwK#A{u1LyO|a z%yG>SJe+157I@ZGsgI@ftw?Mvg@c168Bi9hVFsd0mfp7@Bt+x^(s`z_ufomcTHy8Y|Z&?M66oe&K-+Pt<^#iQFhbsjt^_~>2 zN$AfcNpB#6EHaWvM&&#d;)#PeDLTs`6cfgd5>`4YQavGfmCZJAq<0EkyXl>i8+{AA-3z;& zwB63dy$-sdV@c4pyx%&@Z5Z2Xo7rud+G!l$2DIZF8VXMESrQNndYNMPiqyr#XfTDH zt#R*R&a6G6M)!|E5*4qg!Un6TQi%b`9K|Y(t2|*fpMy%kUm8|hiuh!pS5p+K3H-0f zDsV+UJ>=iOD(*dgvklQBolGMU$kx`l!()pr-BS%+(|r@`Opa!0Q!&24U1O^`e4|w1 zS;b#zdSi;lW^4%8*fPe3cz9~Pt#5v8Zfga36l=mc3@hK&PA~CB=eFS=5GXyYJ@dq} zsAXuCjBB4^!yXu!-9|LQV2@i|Nxs;)!G`7F_yTZac!B|c*h4(dVMq{W1L6q5D7Xc&6tt9T1&x_B^0W^q zorwh=;v_IGkxZT~5RF<=sz>oFX;+-2gi@`ghouX!APHkdi6bWmQR7&Kl6Wkih!=2- zMRT!8E(*IWoPprZ;PN665K?KaxZUZDZgh!}Y3vfUgRvInJ!4*koHcl!xHG5-Rha%Y8+xV46ig#ZZu79HcV``%k&% zvp_6V>(sU$pbo9b2bnT}3U0?(YMi9)*_QU5OZyHwTv%eu8fMI?T|5Kn>8C=Q8h;Ya z1dgx@6@@;?7fdKIjqFNp(f zE5vHyu9QaGXlWa%c;5M_x~JmhU`@w7Mys#$&Et!EQ*{3FhC*eG@}>6C8P?F`%I2TgSbe*TD6;ymu~*--0pbo1!bl#i&4^y; z9Le+~^F?jXtp^R)A2!{1+)>dmQQkP&JG(oB--RKWToz3;gnXG3b4j*%>WTTy89HZI zWJIrN`kJ6;coDL+zK=EZEq#4|Vt%V@aB*y&Qyj}~pIem<&vJUlRtG0p#Ku?`V%7lW z3!p>h#wD~7)t=b6!`EyfTVqGg-i64(uta7wn!IrAz(R1kpiv_( z#Aj_@ht1=(dtDBn*B$hGfon7rh=qf&Z-Hwf8cro*nH0YBX>bJy53xum^GPVZXc~e= zCIt=;3c1&ieD)P}4bI^FdxDb?>U~P@_TH6%5IVD@HlaDgp)>?%N_dggs+(5TO>dv!0nzzg3$SdOVAqXo zbkp{sPDj^O!>bC4Rp?dVS~OqvO9(57%^R5Mi5~bE+wF*;J`080MOH~aoVTo!2p!7M zP}q+9J~2>H7#A;URB(#_piwD-Ql$#0K`ABwqxNc%Ri{T|Gl+E}j+D8`Y44i3QP%j` zsr$#TzPME0b@RpW?b^}n&jz}tc{H}Ee-?%lUm&+D4FSH?y1?8Uo?2UA@>aGakiiLN z=fM2TB71IWXK{6Jp26)MS!(TD=$T+KI9h?yw}lPYGQVqhsdtnCk_W~aGjz5>>r!c5 zE9*SQDtDK!WUTWi=QnrwI@BSuc`DYHgw0j1Z;6&xxM-)T);iJo&1CkWDS_J)bs(L< z;|bUGN42&tPLW9!|M zTip|zU6Whw;~T9b>&-)}_5F;NvCSc-Y+_T}zbt_z@T_MUY8Klo=+yy+6s!Vc7z49A zCddrOFw2FGH7uj+vdoU^1C%17UH}z^=$JuRMRnNwtQM%96uI>m)#*`<3RYpZLa82Q zmGW8r5AChMYQ*gHYaM2ZLA)d1Sm6(iGVeTU{q<*8{{G{O|MdB-llR+hy_~rAeB^vZ z?}Mhf@l_RlTRpcTfKiGGl@hg=xhWl*T%B9yas)cs%HGHny0UNfk1P(3FO5twhbNgG zgS3XOxwd}#1Z{VNXW)pes~ly=0IjmNr>S$IduU;Do+Xl5v2XOr%sQGl_AQs9-gBeI9kbW!v zRM?-2hBC2mCLYNqqq$VPkVzb7Q?GLASFmZ*MehLuJ4lB>Hm_1`85qV$@$QDU!S=o> z`Z^yi=#i*4$J`sI?+h)l2j;d%=({aLOBD@6)g4pKgY^2|h30|f&N1v^SL?cI^*!{q z;q~qbxDEHlSLI+8d#e}yD^EHXt9lvOVZk8))e2%Mr3zMI2EZhkX6q4+rR^D)_D#sh zVyj#Nn5@GxmX{=a{9>i_!n>EE2J zI9=X*yMFF^^>|qmt)gwQV`7uODQ97dC0Dz>XB1&Ns>TPCb!={9cA3jW?knb5(6&Hn zbLUt~_hk3TQghGzi^kDs^+PSa^O(<$S(ey^HMEac)%Cq>9_r|ur7^g26}C}flp*3nN)63s;m}kz-|w_-EpTQY`6N&2B*d7Fd6KC z)@pXSodIIXx2fEeT_fI zfOAIF1NTesT=NhebLi@N=8y&VxM2vYwYF=vv7g>Nz^Lz8tZJQV=%EkI@urzl+6D$O zD>`O*xbHvipq01HKks9L)sDG6fC|HvVill5@j}5)Y-(n9baa7v6`-oU0uzd7;~1}? zabh4s0{!9rC}RYxY0~2hEfL^fMKL_oDbc7!A@}}wn<>ghO-J7nU6lS{S7%X%(9AHQ8U_q=z#ad54+b8dpp7pVLjJmbQem?N|ZRUWp$I7#Ec zBv=Psdm7AV!PJ%h(WUyfv06-(Y8q|soIzN&x@n|mWSNZO6&SD`tE%g*X&UV4pTnRQ znHu#1ehy{_(|1SUAM2PLn_3fy&>!2VL?xHZvd7mbRdySiX1L>?q6BnKzW=(y#F> zP68)D1);8?US8CMuS-`_7vm`i^^#QVARa!51`6@eVKVY6VZ|< z`ft^a-hPR(iE9+7eM@4>5`f`~Jr|s-bb$lH6g$~SVlhy;tSOZ%t#l?-_NdkoLCaq^ z@{1Cr&nML_2O*Utk};0_S29pxqf(|R#plr@wYMs; zxP~>Jk-n)As1OsxNN5wh0kB2awlVX<#O7(kn`Nf@%&dHv>nT;)pU|-L{$ay1r!8vSJ zZ1z*3U^e7W1^vmOkK9`WNH0VUmkt?XdYKp#sTS11gjaanu-y4pzHGKH;}jNB@Uq;$y3ohFvc1j;+9R}ifhQlnK!u%w3xRu7?DMzC@U)W|t zqgsc_iUu`dq_S-7O5wkfYFvwJ{EmUS+SZ}U`o8+EnT`<#yjAVP%e5U-b=`B#1N8ox z?P;cXW>q@H6pzsO!w62%1pTwzx_;)(>fsZ2n@-(txm!O0Zks1LuvBs12cp19Mcl{Kl2-H!6heug0feIVogRHs&2D49RMmE13!zNh!?OoFsu2+3}>i+MKm;Ljx z2cMjKar{olnFoCrDh4k<89r0ief#-%RohZk`(kD5LTxvrwhQ;2m1Q>at38ZujY#81 zQ2@%c$LF^fSNB)9-mro3mA+A^)BcB*ZS`&A^fe)_K@nnI>ljYL zOyvm-djj1aU%S4(KRd@-TH+`%jYXu}-&Z^BVZa&3#~nXNgtM_wIu^r__BzFI6$88i;ub|JvngPz8&C}ln3VaS(+e#<0Y;Z@)~5y|5r*7@{baw*{VCYyYn zjvqoj66zwrIFB{XK=3L&OI?QRv4-Fzbv^ZxWb_~zI*j`ck5)L@y z$#6a$Eu>@lOdMYpxXue`#|bz3VIG!17C9bB%LyR5;YYHFZt(kFU1%)7l3XJBOCqhn5g7gt}PXQq3^Mt%J;mHG>aphF*3rVtYk) zSR1^E0o_!b6R4IOI_9Kv7SJ+y>i!3I~w z;wWYocc4Pct2)4BOZQB5;}Gb*dglcw1+L31N%s)Fp>=#}W5zPRT>Fjyvk%Z zv<#iUUitO8@-w&UPuyrYb*tsfz0Q+2Tfe*2e&yl7rH6gz9t>QqoUCYDsc2PYoFR=ro1u&_S89AGRZPuQMue6(eI0J@3Bc27NcnBB zXIRan;0g`A4hsi|FkO+WfR2c0vPT9eB-J__lf~^DnXPWvhe2S8hK)bL08d@{Su%`)^hbUM=rGd%OM2&9Czn=D}iGHb~|1#VKRYMo=w_dp0bfco9>_s2ks%u;wTC(_~hf1A$eOrvd!5FbR zHoNh(ru+K6nu|A|-FegiQx+M9b*&S_QyZH+-SVnnW^#ESS({p?h_CQDQCJ>_n)W#Y zeg~2OkTIS_&RH5o6tVQ{%)zT7s}yEH&a8LA4A^Ch_*|)0X|b8mPA-b`kdQ9{O0j^Z z1zkW9tO8W8GlKJA^(cD)50nCI2!$f0T5%1fT0txY@KI3ll2|aG48BSF-h}Kqmm%gc z#Uid;+*b&@)2UD)6Dh%GVyO8vS8!K2v6H9l9y(1c% zqW2BY)VK6CcaBccHijpd>l+fK(xZ^Oce%QaO$BGqu(quln%ZpYp;b1H->vGs`LyfI z-TE&tSDw04f4!>r+VlQPm3`P%J!+kUAK*dD3>Htj7J(}j&w}#`zE;sN!ih;9JeG=SDHt%F~Y|r-`{JEFUDSJ{-PYz3{YWyAsm1QQ5HuliEC2mDNhQ@^{z%%rn%9nkYZ$H0u^ZC=-K9Z?5 zKp&mmNcXUOLWI?*c!<2?{y3gJ&fTKyu(m%#u46gI-XhqE-E&!%3( zhy{&qdkB2OaD_3j&yy=L4-DHecid$Qd7aUa7bXFL6M%t6unLm#5-ccIfgkl0rBneb zv@x#4$)l>3!j-!C==Frv0QBmc6j-%po!YR+5RH2Znc%CaJChFOv(W-17b7Wjg(Qii zqeUz!x-K02_4Vrmcq7uNG)JyNE)a_AO-^_N=*+E^4IYalWN}36+alWX&eAe(Zk9bi z%dW2*x_GhT?1l1E=N_HBP=4~#(^J=;pT1dh>SoP%cj}Jato`cRi*x1e*Pahte%goa z)y?XW8`Zecqv~#g;%bYxQkyUfh zo);!7NsI@pIieboAXH@as76I^Xb8pXQ5%3{n7v~)8$l}*2(nd?ZWzfTv8pI! zU9?vz|0>A|#QX`D$E`&?Pm4)Eg57=E;(Bdk-?{5gzdT!Z{%-w~CRDJlHT134wA0I~ zMlRiMxp=$v^xe)2PeyOmE!?i7-Kkr6+`js}oAs!9@z#s6led~r-EO{6)_&qz?a8aP zup%y(wH&+f^JJG7%*OoCqK7f}q2HWx z=_5W%JQ+C1gkMEH>2$b|g+`6#bLh>Q%#%K?X~HTpun)7jzaGAMoj*j^%Ul{B-E1V1 zRBMdLz`zh3<~nC;o;fl}>lv6F99@{4Vs&-ScXrHIRrOuFUVZUO)pr-3UcCA8=A({_ z_nJ>!eR1qs^*7gQzPSA2+neH{72zyfJ;%||xH=}^xFxXzSBVLp_=LriB$M)@P!&0(P9q)# z4+hCl{b6K^qV(vIy312XoG0~GNL4LS8o&-Y1UMnMsZhxP)ERhLAqWaM)Ox*CsT9ij zTrqN2Y8nSlUV8M)Kb`&T%%dx~mDi0uX`ZR?h5wmZQ9E+=LEEwGbzfYq`}S7z>9Vfx z?suKI-FE(A@59Eq2lX@8pAKGp(0#tFTvHZ!DdTrc#kqGLnQ~7DW<~sc0%5PR2sXXdoGdFUym37y>GhMJI6v zY?+wnwa=V!=~F&y%4-Yb8sbTSBP*Cmh4Zi^qds)FJ4{CoQsF`(SO9WSUpDN4shLU= zU(;Jj!-WNpD{ken14s(Y2Xhd-3X%-w@xq`Z?XkpN#)#J%k9zUcA$foDb->2Ixc8?@ zT(YDS2eP^`d*Ds(;ID-@uXC^PeN5q3Ls>`?fwrtcZ&_Gij8D!jF0Zn-xC=`wU43Ic z*jx21zpS5n@@(KvS;x7{HOJ0Yp1An@yQ?pcU#$M>T-7(1s*m4jIDWI~+nY_N?zCak z@y(^$uP)YnbNS_&J8d_g4V5>|J?~;vbu%iv8BODy-bL{sQ$DaF>tjgzmc>J>k{PyY zVOO)Tr(fXdXuH~FfpJUb!yp{eaaXsD)e>8nuA56*7?s zP2LNyvWEw7v!mOmFYL6tRZ1;~v$wg;-Qw`pHrTVYrNOb8?*94urs;t8XD6;UUVhMf z_xbq4y6K9>x$>s@`!A<%RgYHnFgxc2!>h^>mTG8CF|Z;XUXx61$>%t#Ij&}Q2Vnvg zji*}|S$9+(nI)Qv z`El>Lvi4h5L${s{9=lrm&6S!9_uFn%^j^H*e*9AP*XN$$YkuWH*YPX$e>z$D>B-8E zzkT$FukL^H&HazRy#1SxFZ}BF-~IOE?@pY$U0d6;z9z6);IWU{%wCC5!P(qVN>!M$ zQPQig@~__w5xvizTdSP+i0|6^Gw7K=h&89IXVHp04sG0P%6cuS zfFtQN`rVcg_)G+H@Fs!YfD>~Q3W>l$+)qIL0johk2!Z;2t3Qic^dRC*#RK_l>`gxL zR~(@~@el%5K`A8YOc7R#Y=ib};sAP;Fz>*=d? zpMUq{v(ryM`u4%Ezr6SRV-+8NSNYpx<-hpz?caa>@a(O&2h~&Mb+dP0jNN=TeEY@N ztrw#=tA?L;EFv_37#2ymT34bbYji_4$l#By3CB02kjX9iJQp>ymJ+LIVhmP8Wae@B^$;)+q%lW=#4q|Bn<;V%ne8B-QM1@6U}dKB=fbefIu?r|mNg z(ZYsmZbLP?DC(W$_D^$r#aRI{&O~;Zgn6-RDDhpAD8(k9>Ed z{>!sZj$e9l=0@GgE7gBK@$loX?|yc&{My5wi+4MJ|7F=PKEC?PkFWg0Z_fVXZ%+U5 zi|bz;yNxo#8@HZcy!i0cshdxpG%%OhCX6FQU4T+&M2lfK!BN(Wn|{#}C?HMroiRW@ z?sNfXAbFITz%7a738G_xE6mF@6ejNJ9&6NRi#rWbz03_lUFsNQGc9yh?@+a0ZKP>@S(f zYuF6L?e9niT`3StbTZ6?NS+uB!~i&W`;(LMZvrYdQ?GJ)YF5@^I{!L*@EV0SY3$>W zpcO?LxzT9V8muZbaMoJ{V&&G3V3V`oKSY20toQDN_B&#tr{Oxbf|Cirg`t;P(OZU6(KOevGWbpLumQy#IEK%Lg3Km`e^;A7_?QYA-3suL?Ri3_Dd-_`4 zv5VDTo~!!9@kjsg@s+>*)#<Eg1djfY{i6BCx-l~bYNA^7Ou{$^fnK)HVzCAEe(vUR5wjDbkgfO zm&&WhZawO{SJ6{mHPqNfo1qDpw{^>CgRm~|8sDhxTBvTHeNsPm?P1G>+jUpVnr=L7 z#qrv`#vAvWFWr3k?RSrU_3_2O`Nw1b<-eW!_^Z2Lepm6EKVJT)-<cZ+32uwZRgw)_Ame=IZjAR47AN4VbJDjGUyjE42o_6tTt6y?~lhlI)u$ z)xQ+3a0`&F5HTzdzzkGtzz(&UFe$yF9UXT~zQ3h6D?&a~)}>3@)KRY~6>&kk9tQ1M zNXYS)Sg;!N9>jdbBNpBRZ19Qr4-)=Y3I72u0LHig-hQ_!V$%g2h7fRtIRUL+q_jZo z%Me_9m3woLeMQ|1@ckm7=HU7#@+N=q*Mryp{q^KS?F{x=7puYQx0h-z+-tv6HS`c$vzGaqUS{hAyN@m$VoK5MqMsq^ zXNvlk`JJ;{eRS^73i7cf(`@Auy6P!C7(D=1Rd$qi#?et9!x@XLqLk`;=YJ^*KrKF? zV?Ur*sl62}0jO5k05AYt_^zsS(kP00LRUlY{oBvZohiEx6S8?~f+n0=mJLkq zw)L$yv@bq-HhArJ)13$HWtBZQDq8Qu)jzqx*wHa}w2K>xl^yNa{BAFDeTP?Tn#b=v zYQA#2=4M&rqss2<_ghY0toq{QqmMqn`ODv(`}_ZP;x`|kKYr%H!zb7(A1&lYu=!d`34V~(kWR?doqyQ13PG^+S6qcmh!$KCoAc3wey-fzu7 z0=8^X!R9Ge0cX?$EQx?;NRilAI6__HE8sLlteSvX<-^fqj)&bD?9}j2PyhJsuRgi_>G22OoO^bq zti7sfzGs3r#ZWG+=_Z#HeUp3LW8BUWPUk46cN#S>;t8f=lp!0Uizn8V@cd72YsS{) z!>f{^H3{_UJi55-p@WcVS!ia8t(!{szA+-T#U-Y&%0^gq6#=ow}8 zPHpy1Z=!axdu**^nAthZ>=|99tw~s19Wq)4QoC5?7Ra1zo{`1Y&eDbb56YJ6V((Zu`063`) zJ{Ct=g*^aeOGZ&*vQ*Lhd&erVZ=qU~=-G*szbL#<*!V{fk%#pNXcYo0pQYPgQg9e5 z`L5HZin(+tC|Hj%4PpZ}A|XeC5bJOPFR4kJY&YY!n70{53gABL;Jpm1Xo z2X4bI;y1t-BoRhu)kCP$3{n>`;3|Fa=HM@sF$2|lgjL{rfR+Rp7l+;fgkBUU<_=M? zfNHcw`g-5MM0@A((CEV4;wFv39voe)YZ`n}HwYzg<>t$?m#a>kd;I%9U-_HA|MLI% z+duv7|MSf+KDq#hz#qRY`{e8UpL|{Rr(=&kJzoBYukL;H<=rp7dvff;i<4Js&)#mn zUeR;!#qi_C>DoR<nY%-*P z*sFHft4Y|a(5qpza{T|mD&?)B99EPrrCh1lRh0xLtIueL4PaAf)VpH-DtB>|*3&f9 z+A!SHJ>NID(%#2x?qN3etkiWaS2r&_dpT8AH{H;>*wM2xzQCVc5)939ddAn=2A1mD zr=Qdg-hbM0>p|1?dv)ioRDSX8%|Cs9<(rdtFJ7y&d%|k?#aRaiOI1UxB^@@H}oo{NGThDIzn@P zFR1cG18gLvk-RiYke-TE5E!mm${|4fSH#_#2)W^#O8RXny~L;7bBngke3pKH!=T_f zOtKJg^_nsf=c}Nt5cmAWu8BGIF~2pN3j8(fJP11uL-s<@4)qI|k&%)?QVQM*$Dk9j z{xr5=u#JgL8$d?QA@QRov6Ff$g$%SMoB(fq#l(8SEVn$`${)Tyc=hJ+HNugookvp` zjMzkBqt)W1EigK}hU)4&@7}LGdFJ}p$1k6~c)z@|xxHt0W^s3ZSva+@hrefY_u{FG zPk;Hl(;t6vI{kGec z{TIvH&faajRn_~Teypl%0p)~U^W4!j>B254wpzrP42*XHr84wnb8f4=0z+78!x*@f z!Gn~5j1O6?*jpj8N;<2&EunhP0KmhavjOlFY=EC*6+SCUDAfv+6?-e#0O;~>Q&<$c z%IV?7iU;*)&pteU`r)y2PrrtH`Et#L+s#+*cU->Hdj4AdnM*aNFI8W>U4Q;o&6(>j zu9h`EYZ&WBY3l6G=-kfG%VT#w{`2LJKE3qm zSJ%Gy_Qt1QUH$6#&CAy+pV##E57Ors*h@>?v9aaG#(~PpmS^}ZTKiD4MY*joYzwU7 zBZd}*4S@STZmx-*w+zd8N%cYnU|hp+B_b>`_Gk3E1d z@%p2#3wN8pIQ!(YGZiPUS6_bA_OO1mrgyP!kWoL(Y?<5~Wb6;G?sv{?45G!*7V2JA zGiaQ(gQ)~Mme~5eAAqs}{$p5$j->>|Lcx|;6|s0*^sULhnI{iko;!2@{Kdx)9(PtZ z&pv!HdhhvY*^9BemBUxdy3XHdI&-z|?6ta6m!BWI`1IQgPrtqR^carkD!w>b_UYHR zK0kKvixc;cpQ*TUuj%QFq33mDwT)A)or^DrBF7m5z6W5=$ZJbClN#j=|>Djt?SYisFTXR_d8g*U)yb-@@2deLuZ_mYn|?UG2QYz=2F_{7JSpkW=W40XHl6NMz?8Y&m z7b@zZs>(ZkBmexZ%^|;9LH3XktOTD)(Q_0se7Z z{j+HWy(*vrptc%pZR>s3Qg`Kc<>@Q=IY&bR5_mjUCReRg#{xkbxB2LXoO8Phs`eG# z%067RDeFx9#v>4B!;^DE6ZiNb+JJ0ItU)0yP)z`Oz zV70#PaqX>pHB~p^02=@eEP(6e=oA1ILhDjt^(Peozk0|4-e~)Le?R}P3me#+Y1>(s8mg~ug&6zjX7|&&!E0w9m6z1l zUvGc@VDLr5P{)(e-j+!Ss!%{dLb*8c1>7zH^?!W=s=xm7_1AA8TmhFY?J7^uT5B}`*K47q%GjQ}Y3shCk}FrM8_!;> z1vk;Km~AA6%G8!=gA-byxF$9%63bQY5<%s<+v221g2EOnLlKn%Sx9u!{=yTtZ`Afx z-ReGhq2X}JowUpoUZEKPRR5Tr{;@m#<95Yv&EL4EWM{#p-N(vz!2lO1x6j@@T7Iwi z>VuP25MW_)unF1$m+IT0#|r%F{npXPup+8|dH_~D%*@Zs&Hrop>OaP+b{KH6uL?~o zNLGhlw0A#w*4Fr>;m)ITCoiTaZgW!liDlku-^AeftkC5BQHyGaz?4J2vHN{v_eP{0 z-jZ`Zujp1z!L)Axyp>M;s)ShY4jN zLWv(==phifJ17HO+``}~mHRlV0zEvVf`SsGqBbTaWu~WRZ{3;;MOJop;l90x_wUKu zpObs|K*81WYtNswbhLKD+D%Abq3sCe6(AOH`v(uOh>9hCRqMw7$N7W5(l%Z}0}R^- zz|jJHEx_Occ7RPSXxUe76JOiAhg1_9Ort%pFA2nZpCJe6ZJup!m~4G8eyOW-k$WVzCxBhW-A>^OJ% z{`rcBDVy>H3V$mM-^iM7iRK}Q5)?^>#7oHxR~Fyfp6*JZI1#BX6o$J%9HjPK9~P6H zyt#1a{tG8AJgNZ6-_<9(50}SmJQ%)yU+T`|oA;Jx=AYYr^fD|lIehMR$@RvwFzE@a z2WlPzVFl;Zt!H4{zKGR{C9HzkCM=7AE#%WL!M5^W;Q{_JRv}FVtitWT6jb}4w{|u? zX?f6a?ZUN_1*bNp?s9Vt<_I-1*T|5>?DbhC&@WEidpqj*$D?go0zyQC3(xv?b$_z#ivWoz`1np za_!B#kPkqB1zG@-0l*tz4>AF54zP&TMf1KtT9!-wAbqv_vAO_R!Jk+K!~&@W zT_m6gfc%`FdI#Ai1W6#EK;Ht%>QvvS@vcupt?z0p+AbE=bw8d3iU3s8Q1xpoDQFoi zCa8-IR$%+J*#+bn@ONsz9=PJ+-v4|5RNI+a;!(8)zV^T$!Kw`6Dtz)%*nbNKZQu?7 zeb;wy!2+qT4^(duMcSJlx8)a<28AZclsF5=33 zArmk|u&pry0!2w-sqqvQ0F@^O20PiyZ=;(>ipn)!tO%!Yya-HphB(mGFAe0HS^1aC zt~6b#>%36&yrl9`!MWQ9Pu)0lx~2e(hA!QOOyFeIBj^PHN|(;L+Lo&ix^6ukfE=K? zcN%g4SQZ0u6|f2pt8;&KZMDP+EEQG|S0MrDY?W{m6!$ zr?&6CxHbD+@|L2|*u5IR%`)dWjwF=M^W_M=9YM9F4wor>nJguXAPPMkPa2Kj39IY{Pjr77@BGr)ICtY*bKkR9Q+*$&phqzLeyOVk?NMByY9mWzos9Z3|YZ$AvKO}T~TGM6wroY)e< z!;u|@@<12&cu(I{SC2#)h%Tf-Qbo8_87Xy&R=OuTXyPQ!kz$u9N6$ppfK=b;?de&? z`KNA{*R@qQ_Ep?#KXc;=*kYGeH=c$)FSnkay7{!Ex(PCYQ#DU6-+ciK;FfBu-m!%d z*h&U|>QE1Y#ro_l#L55d`PX=WB^K+?!U_nh?x)XMA2rt3)Rz^Vjf>hK;KQxqC{YG^ zhHmzc&yLx8ECHHUJ5I%9lmxHO_lVl<9JEaZp*1v99k>PBrf^*RHmUM!SfyHC}8y<7`DR5{bGFk03Lzb;zhgIU3^ zM2WEl1x=LDcxnPe1#vYYeSguZ+XcndiD|hmo(UpF5KG`qW4p6>UQ)*}7fqtlC62-M z#!+3_(m;uGl*lQ9>kz_MhRZeaUJ)5_TM81lAKkFGbZ24t;S06rYg@FwKyBkoTQaMf zdMX~Y!)~l=4?Am{2OB#l+J@%3$L0qo7bali^GoownSDaQxrzCak?DT0e&`+V22gsE&Ze1w7oEViR5xVgC zZc>K;7moy$XEJ1@@mq_cHXM!Gblf*S*E@EfCStc|)NV)vR9@?)E^!i+sk-EXi1S4Go}gzkGuW7ZzH8&l2RV z5LrRq0v6MY2G?J-Qg#?M0JmN+cb$DVGx>ISV19b!({RuGnZe&Ddw=VD^0l#gzUK6B z?WN(a#)Zl550kyXTzwqtdp9xsaefxY5PpS;+C^i5FOYL;|99_T6!rti`#);ukij(r zT;4u?fk^unaQpEad`Vxv!lx~XR6!yRrn+;JFX26Swc_f@q7!-h4y31U&f2jrE+%#J z#@)w{UD&hdcwkV9OzxAmabL#H0$2A4nbJ?D@@EP(7_x&kMr2@4|J#pd%U0Pry2TzX z0ei8gt-DUDeb%#tzF2!D9FEA3EApdqJh+kou`*od5-W9y6*`*QoO@=ByK&v zerM^1y=OM$p4oKp?9QT!d~j~BZm6tlx%0HYseAfq-)v*oL|se&?WT@<&pNw6PBJz# z1_pN!QemkI>?WU_nwy#get79Df%g9d(LX;9pQhzk{|{IN#Lf*5PxbWyP)9pE2U=U( z8yg?j)?GPs`Pjjth`?A!sk^%-A}n%C!uoxYiF<=$b3&5x!c+1?lk+{J_PB-ZQio^x z#O?vo)jKo;bbV}Tu+Sk4dVE3!bWVL3JWnFc2}O`$?H!0zC7t7@@lMFhI$j1m)v4>y zNZq(`4Rpwr0_Y4gqXB_+4+YL7U%6hdho!BU0DT*DLXc9-jjFW zL{ahi^B1aa-@4!WynS+XdTelPsJm}^bnGL*br!Vv&>Z>z>knZ4Fzi5_8=qR30<|c3 zRzlQzt!)#43Rr7TJ3p%}0v5m+d>;7N*Rb{V)0;P7g{n14TbTbmH~VR9_|0H9l=i=k z_x#%W;O)bzmlZ`l$FiDAbD!R;7R*l3KjZ3HSJ&U;>b={QH%=ZY z4fBtdi`5?PkrC0`l2UV{lXHV(bG*WLXo54H{kN$@cDe;;LdptaGoX}J9?9+jn?Tqj zbB<#0z1bo^ICQQDh2*UYyNuudkfAeYxjh_2}~lbK||gj`saJ-1lV&x&x!1rp7-_jlLa$-{SP!1y~h2 z1tW8yntuNQMmu5K$jr-k^KU?o0wEMo3iyQ6+u2`xv+l;Vo7Goq%1)fl%G`abJZZXH0^-YN>{-i$2aj&vK39A? zZ}-6DT*9uD^nd;J?dkWkgY8VRe zPSyBtj7i>~yfGiT{F^e1vUAUso~x^SG;ptB@B+BgAFG5@a^`l~xjV(B*N+xoDL7Vs zApcxec2R2j-tdSG!2f%BN2xWTQi;1%>aJD?`}s!s`9w!WZ3qibQ#$!89K7TT524UW zq0spIMMOpf0}GUjH%%<1It;-QANT!>>o6Y1lC{HuQ0B>TBooHakS!ON8XO==K44NZNCn6|2EwFb$a}_$;)@$uqfo z5AE5#KQVrNYRaaKI@Qj0uKj_I79p zN1Z+5`HEn=z?Ulvb<`xeK+N$>bMo2fAG;@J)6w*t(_0Q)$SAnH8`K?O^iVN#vwv+4umsehwzmG3 z762+F08j4Ty?6aa)upRP4;2UdMaiV@8cjraH{Zh zbBk{uEV+BAq&Bap2BZRTfUn!K>*SFWHPyA?zuFSNe!tu)973xFf@fyK0(J#wFSkN) zup}v-tT3^ptzCyTHm4vld=yS-i)0Z$j zFYibvCqJdq3$UtEdU$98B0^(xcJ3)FF1>oGqW)Ix(}#^u9yZk7yj64UYF}r^8!+Tu z98ZH9=QqdrC6eR`&{c(S@|=Ej-nrkamukF@hhu{+Yst1k67)h|4{ zH}j(T%~0PjV}oC&$9|cc{4x#W0R4~wf0!5qOM*F=MuGF?9qcFg`sF=*F+ieyY-)IR z_SEIWhl)0)WyHp;kBv^zsQqM87k7<+_U?lkw*VVUA`ZjGpx8hDu+G$k$meQ|jR^n# zAFBvN!O`QFv-TWAvKvn3NG$D z1$(0Jm0oLt;o}Q8Th8BVzIgjtdEN8tkJ@Tsdr|w~^PZ9J!SSKdDX_W)PDZ;iQwB}M0Qv)9BU-c%$g4PG`C>_ zXfY(2g&oJlf{w(AXlz#&Ps8SE?CFjqij2l^z^>>GwA5S$s9BjPbJ={A7+}C@pX!hlTcE>zqun<>20!am#cEf`wmo8M6U#vQI zq$D+EYh*-{k8e1i?|?#6XjB2op5vtQ%F4>8P{hlAHu?ESlkfhv?x!D2Q3x)VtHBc_ z%a)sb|APTU)bgwKzW#A5SDD$^P$MEYCM0f`NIl^#Po_%A6z##{coeEkEO8f0p#`IM zbqjO%jrR}Vyf^<+*@gQs+z}MH%fT(l#b={;=nl_NNCWmprXNnsEQSgzv#?_Sshb5C z?-f@*It3Ggun_ZB%Z1y|%j;UNH+0^9)_cFD{|Q{nJ)^xtlcOUu6Js;eW7=)j@ZS6j zYbziJfC_+2V0I7;cD2a>MAzpJ8p@8AWp2q)y9CN*o*tetp1vu5AzK2W$C`d5ZbM;E z{C=OP-EM(fAWap!#Bm(LS+d~p#C?UOwR`d_ojsB;_DVR=+QX0>FeC*46%dOd%IxVX zI9QU*4gidoBJpw*US`j5rE=T=vBnnEMHq`P1QC`f20}*T850}7-N!G%+b7n`D~ic< z5KA=B*z)m-6p5T2TG}0(e`?v_haqNzGDTq zx2Bg;@jlDGv;X-Aa_){hEf0QeuKWG*t#9WGN9wP9?tlE-i~8TLl#V(Hx2^esXRIs7 z+Ic7)Qnzj{y>Y$0?rzV;^K~bVmEXJltfOUUYyh^)!yqR}Sm&lkr>4ecMh3@fZ`SY4 zJ{ag19^fD8I9kU|TD08e#d3%%)FHHoI=iM^$cL2SN;C-Q&>B7@^1 zl6vul8Wvjxoq~vnbm$I1q=htKeM;tuq6ly`3F%Q(zhemb~-8!~#wxM`uR*CWm_`hI=MQdZ$Kur+eF{ZdSDx z9=?8Hf91uqPxAAwZ%8gmODK{H5`O%iXlLS9Q3fvGzjZYH-qrN={IS9MYajZaYX8{Y z`0K@!-N8P2d$X!fmo?wHJz8De)j#m5xA*PsThC#qQf0;MhhP`eIn>wLHvD8DN09g5{ZvMPzZPql`1Bag>;6L$x*WSYPoZ$vwN(gTa1fma@_iZM@sINUV5@) z|K->Xg}%|*A<4NgDUf}_QE-sTTpcLc>UeGt_;D`S9p+Oiq z>=^EW4ZL;F%8DuieNt26bBhaaHQXC-XXP)+&Z`sm`4Lyy}VzD;!f-u?Ku z#+nZgs@^@V{W944`{0Y;`(FIs-SXRuXJ1;MeSH4>-SgI0tuN;K2H*A#zG?=qgZgKU zjo=OsPDZnECqfnn%WeBQdXE(pMMuW_`-DbCCObR(ibSqdn#2Y{v#_?eMX?YVu7wTF z*qpRl*UrcUucM3nkN?nNv0T&B58!a3@4q)&y9TYRi?OhzFo7->} zvsn=WCn8cE;Q&w}oB~SeEGHnfa0H>P9Rq=6p^ywbo(Dk{x~_m*eLb61t4!A!*fFRQ zAj_m2+s!eYd+ z!Omeg5AQS->_3{8kg;j~z61NtSCu!nK6%;O_OboxyXOyIH9vUU*6^{f<=649-{B0l z{NCC0Tie5L?Tudt+kYSG{C%L~x89C#Jsn><+TXW#ym`?H`_mUjVAf#bbw~Gbb8~xV zM-ME9TV!(H4s`WDsJ(yw^o1Q6S@0D)D%4~$ABmzH7$SdMX7uB7(=~bsopqSi`lyw< zh@Vzj!Rwz^SS(*<^Zid2|MqVNM51F@=r$5jxq21Kz<^+4Vvok~ZS0suxesthelGQViyiujzQA^z)XhJo+83iBs8uISK`f= z`N6y!PZ}(8h?Kh|I;c}so*R<37MD~!yL_j&@WP|4!m1qbWII=X=uGXw)3@_s=VL`Z z=vXT1U(_^q-D~b^Y#W08n|&kTy$NlU*H9FI{PJIms}NL|;woVEf9+c>jE+JM09^pU zY8Q;1-@gz0R;w>nY~8Rk&_6*SQ1iu}YR@=N|5X35jEKa2;YqnZ;X8ntK6a*l@8K(< z@!1|h8)dH1B$hjl=0;#>NGwkp*9*D;K(2Dc{#=P4ldo+DAaD|3`~a(vl)@9>s$+;Z zv0|X`5(32mGFTi*N@F=gnu;Te*<2T>t+a>hOsC87c)p!2)x;R%=@GGULk^4Sps#1E zv)0Pg1Z!zQgkx@o=W(4pJi^IjkyzyBr1VWn*c2KZ6A~1W5SOw(X~V7^IVX!x0TWwy z>)t@;Kuc50%W)WBne2Sld9n0TVeYY0$1j{bR(|F3!>0R#T`yh@cYhk}`eoq7=dNd; zhTDGwtoAiwm^_j6y*$DZD|-Mz26`{swn z-hdK(X6`){#eIu=j6j+Qt<~wViT38U<41~jZQmUio$Rc1C*T=B|EzCjhF!VF;@|#j z?N2K$^-YOu4RJrLwEl6G^>Q7=vemYFhQuG2+x+L>O#kD*O#bcPjbyU0sK_iU3yy(4 z!O)0kWJExrI9MzPjb_33jzrST&2eZn1BIf?WbVbq7qfRCv9=}{7+7N}TQtk7eHvxL>Y=g&JIKYm(QS9k5&)pHm3?=A=qN?|ZnG=`ItTQnrAexVt`F}wXD zcO`8(cBS!tsvl3{K^!sGZno->cM1UJTmxcWaz`t z(7VBr*MlRk#;0HruGT9Lv?s967)%{uCl)YfuqU_v_C4rE#YZQq9Mm)lZ_OH0T|FyE zO@CTp_MhLcTcL|wXF*wGNceuG?GLN$mg{2R>RD?*Sg{7ZY$bZtTKvjY*q@i7B;pWn z&om@LWMF{Dp!s;5kV=(fv0T6>Il4UF9bRyiB8 z&+I&0arVaZ3%6P->pH3)cHey5d+SNxt*1S;&9HHMu(^A%^M6-RNhMhQ)= zS&*+{cdod2jwX`DH*pTToDTN}U zQbkw{0~)WJHsvVfUdBdf$OKRbhKUhQUk_nof@d<7{{D%Mj{df`^q+n*S-Zy8&JF+! z!PefMC}7Ye7G`LD9diR6Ga8BGqY0Gq6;g;DexZl=AL@MGHa<8!&jWS#=wY;cOxdgz12LvMR`<%No{pa=m+gtj9r z`$=c@YLnG#%$IKeWovEM7~%Cy$vTkO8^qRWstArN#7 zhD|1mMIyCK28@=R%#<_vE&{o?TovNz8m)4RQ>qg*KAVD~_WFfq`-Fn4Lv~1fZgg5f z?53lsJ4+6hR3ANm=gjp+$WiY+?YrLw*4Cp>d&k-aC%Zv*F+MXf1vACaGM=3W%4Kru zU&iX6+7(Dv{{$-3R!foOH00|Pq~Q;eM*1#T!lPYJn}tu?{ZJvb^N1&3jn znPMRgShLz<}=XBG@+8baQjEsVT`oAEmErXQ*$t zPS1vfP^2XwVW6(9|hRwtsoui=J861Xa(DkCHyQL52TW7(5 zqGw^U_wB3kU#EILjCa3>=Vb5u*?|u)M?St92Oog1Fl{|M_W9++=h?|GFQ-4x&U|_K z@{86sY!-S7A7-b)*>&#K%xhTl3|k*22gdHz+|AD19UT_KV(@IO(AL&Cb8`$-{W=Cn zQ!A=1R$z|c8dx&cS+fmo`Fa-YHAd8**I>-7dB)~!-E~wmE55!V9f4BV+DecpS!`^! zt7{B}?8ss|kw{`Bl8Hnz*leX(><-{WqL=_(_z00GgttFPE{_~J2L~X^;i#xoDS^nx z+Y1ml76QjX5`<7A&^a2OI6$Nb7sw-oiWnEKO^139CR@ zfxHSxfTaWg3Mn6Ci2xvEaBpu6`Rt z&QY$u>mAfFQl}6s#nBoovBXGC?SzI_+;tW#BTJU44Hx(*6hXekuRfiX zYr3@^!_1txZXMFXf=D6>fdFK)9pHMxpcr;G_IMn_(hQA7lHu<5R0r5u#nsmH6aLv8X{4&YNgf6mB8UxeD}S9jxOrwWfm(|SOK@QdZpFRKN_!H zVQI1sZL$t&q-Tw@BfBX*(i1mkZ_mo#mv`rS^=NP3FsRGA+TYB~PK}KAc69f&c8~Us z&kirlg6q`Chc^>n=Z8NpjC^@B{>!_mZy#p9z6BGu@%JxB-YzT}S%81V!t~eq*Npg5R%J2SrUX6F5;h0hD)3j;5D59S;Q_6d>+YN{z#{4E_bY0fs_#F&^SHISYp|ntsDEg50+x(VPJ_s50ZOdN$$t&2 zpi^CntAN#|WEF0I!0M7-1^9oE0=7JCXsWHdd+qww3zcc>ck=k!MiNKh<=`BdvAb+< z{uK?VsXf;_`=mR0r*Y(=Y;geG{%nyKfvNPW8W@bv_a$IRt2R-O|ueDpf%GTV1s&9bR)k7Ps!>w3p z^|$}ghq$V{#==0?X2s7&7$lv`QrKEz@o1__=8~S6wm*AMZcfhqJ9qlq+qzqur$>fH zdir|Xy1H6AdZD20otz(g{R$?gN8Zg0yjd9i@NVkMhuL4=O@Dqf4RP`V82oB|*e1V# zZ1vR)xT5{?df}HhufDzoITh@-SopF4s+CDtyAGRFKF^K3?0njhmzB$!6pT-}7E4k?F2NnRakP;us@yj(74%b@SV-3EUPC zos*hbvNOM8=iy7R;1$-rUB2B6Er8oiop+zKKYHHP-Z$DeG&VM_T_5{qb{?F9KQ0xb-tkyvom=M;P5G<`}7G@+p9Xn$q3>w9RLdn*K4CR1@1t_6l_ElS^rY;MK2Ly533>4p{?8IxD6uwAv_ zu{Y4ez*(`}V%d*|D}K_oGDqPtl(nl3fBI2p`7*tgD-71@o3rSAwX5fzU3;#TSKhmI z8{Yn{j~hmMdS-{mrw7NO_41;z1#}*dGVfo6pSCj9w_?-RpVeZTOxkWEl0P6I6 zxcBE@eqEUVI{)$$bZMbuJ39#+?gEgg9~NMIb^hzeuM1P)lQ}WkJA9|=HpEo{Lx{G* z*_dKqU;Hpk^)g(w9Lb)Ped#1B3hL0u)i4++U3qYmd z@LWg+AXDY>T;Li~se-`mVaJX_F3%0{3>|Ht2VqW=L{(vk3JO~zRYl63V_2d%$NSNnI2DqO%jWpWJp>>&sev<;mHa=jFFsZ`^Nx2wU(vhr4=)2m421Qe$pn_U$wv z4Gfw=7B~m4sxX54PaV*&z5@$a5WT_9H4s`aV)gaN;44^H*3&i80fVd0+nzjq{_t_l zmFg1(C--LO2L-2i_$B!SZa8?nDtS{O==}Yob_d4n@r}p=%MK9#i=AUYO3jl7K%0QU zb0^ZAp$(5ugjON(Zq<4+%guH7D!op$ykyiFhFz z$u?St($lqpV`zxb*SB$V3k(X1v$Z8cHylS`SXiO)M5eVZRo8$3<*=>+*#c5HGy3W^ zm^EwA`uccXU96!Y(cF}5X-);W8XFSeEugd7Z0$;YQ$uqLGg|{a6Fprs0|U!dtBuyI zHP+KLbyxePB&KF=&8WFn)!WfF(9t&9)AMR_W~zT|q;sIXsdb>Ee{LL{11G14X6D9U z%}>03J^k)2m;;0H?+h4J!d@ZxLBfwy%LRh;1&lW*My6)Q;QE^ZaTlB=yZiZx>DjTV zx|?@TpE#A1nd2mN#o5`LtwULwf?`U;Vf$KJOV{Yo&^Wa~5+#+#a`-Uq>w_h#%q;m7 zW&lSR%@xJUm8nYCjdEp*KpevrM#vrFJiRx2`E2&~-5eMU-$Y4F++MjdTBS}%j7sQIgV%y3$j@vQGh@&SS*!9;w9igGv#1u>2=5lh-4{_Bq351(1<}1 zqzs;i*dc^1@@MdUs5~Dk-+%cRk6h0`d+%)3ld8Kf>K?T} ze%9U7Ju=ikIyF2sKk*XQvAmyNfb$mM`j=vLysKlN^?6@&OK0=*=7*0Vt`;3Wk(#_M zBsA4KaQ)7lvY?oqYTpfVb)rI(qV!CIr(B&Z0cox(iYpBkJBEtnLC_v0P*f;_0{W_u zqe36b6bb}$nywLPohcc3Du|_P^-*wi*J1PwvBsuQ=`*Y>sm6vlOLJhE@P_M9K$+Uv zQvCd4q*Ar9F%p5WH#0|B+v2f!8X8N*VA)0{_G@&oCT28S1b>|&>4zUJRxGz(r;pXs z(FRphW0Hw6(ZrZwppVwovC~}(X{xocfrajB<8`{`W^m_P;q~>cY;8%FR#+UCA`!|r zrElDov3*y@)}se<=f)={2S%m_#y~VY(AKkf&;=_ zUA&o0sf{%mgAs551`HoSsgb#q&JI(k(z$|YzA%O>h@`Uu7_0z=D#_J-qsDWK#%r^} zDUmA(g&e@eEhQ>uPi)-&l=b=P8;*oW>`YEMkOJPeej5XVw|NI{5<7(QCH^vH2u}hN z?ozzHh|Y2(Q)G5fe4#ne0i@C$kZ3M6XZ`$>_Ut?9;T?;@!3ZJLR&IQ$FJP6*(SZDz zKzD<54n~mRckS$*4&@cB-SJM&58hmqy!XQH9$6c?X#iAy|7 z8pc&b!i@lqsXT`Wwm4Aa7z#5fM4A$=dq@KyO$BBZfs?`?fmVeU01_t#Hr3LOX<&?B zI)GRML!6EdVx0lT%!FWNL5AlK-|M4M3=qB3sFG#N4A-nNx3M9iP*gOA28ts)1PPiu zXbcaJ7sIiGq{7r*UmpwCJ)qP;A7iu*Z)!pUV%!vT#gMYH@9%Js(SzKeS!X=1QLzL7767VuEbp=4*<^u3d`TvN?~a3K%|AJT(-h-Rc8nU zu`E`YNF3$uwFL z@60TYOW5lZv;`*qz=}bvfLS4!9E2=Xgv9b~kZhm_&8#Tq)>Oz1cp`TKgj1pjL_xU+ z&urO#7;*rRy748xT(K`(r0wGn8E)X)CUJ@Zn+x~At!@EZT|;;ItS^Y%d3wv?YkN-I zEI4zgtnz-NKViX5 z2PXln!o3eKKmY(kE0C*$Oa-K>aLlY}5Ki@taPVBMW4l(@PEQZH23m*T8UFCS;s5-% z9tOh=2uK7vMMuYat&Wui)E&Sw*$W6nE}qCnW9fJTm(6w-3fyTFg_RX_XUGUUHb~=a zteIBU3~L*ftt}9<+NY^G&C-HtX-Y-gFo`Ihl?h32jV%_G#y}Ghp}7M=n?`1P zxOuv%oET*L-0WR9D$B?F1|g_IXoZw@q<0A9rqjbyqrD^0haK)71-MQR&w?~-26kg< zH(xBwOv4btmxcK+z)-TYz>BGriMp=v6&tjhu_ze2Tcd}9!O70=kp{aIuB{j zLJ+yO1c41+$`S=B+}4v=K|01#8?>jp*Y2Q@11`>67_?xaAjZWxMdci+bPj?!bcxJc zsSNb;iUlUw!z0SgHO$v1J|tj$Xu$fI@Xb-78@F#hl((-eF=?;bGgamoC6tDUWZJ`% z_%XQd&>6Hv!#s-!rn4=PEK4L44vFDFVJT@$rEfs;-n>(La!-L|2<}Ii;1DW;U=E7| zqgbjaXRlP4@l<)GDZMs02k-DoIjqHMLDgQ^-hScknW{%O?zc2P@9F9t=^q@M7@K-I z1+FVF`nLd+EPu=Z{&iTL>g^tGe*v`>`q80xPAR z8so?#_>R#~^uUuT2`2M=VG7co1%-eM0wctdAlp$`BKg4l8v{vbMqRrO2Q5N4tMyQ; zbP>x}Td!PWvvRHNiq%%D)>!}WgAtVQ=4STae{TS3zn51G9xpI5!T?hZ?JB4RfEl1O zWNeO-K;+TrQs4|(EGMY_=~PE7MuSj3N3B<*0w@x zYaZH$M?#9wHe5?%3Y+dqAvx&jApiD12D)o)AZQEu4qUdt*ULLCIVm*2xAfSN=7)_C zQAfK6p#d}8GuYqJ+uz>T-`?NfJ~-4hGS)W%SOuUih1RLDR}fL>=fAvu^~)=$dZ)D| z6#!LR1;g@@>6v$Puew^=P8Jp)&O3~<#n7od8!T1N0&9k0;TTSK1P2PwPvyRe#0WCC zb)qmr0)qAi2JI2>B53wr3Q4q55g``2^97Cqk)u@Zs!*t<5*G)B8YDUazL6eo0lsh{ zc!ULbMg)3Bh5IM$%R06*^H>Nts(Gb5yCph0$HAnk(j`_X3x=9k&xB%RMYq8T5F{}M zbT_HFs~69wi(15d}#m(Ie4-lm>C2M9ql}_dx}h*Ec4l@ zip=p$ITV*ww)1$^@$&oSwas@LI~rShy81`^7kPl0=~-|FSb$YQ+Vjs-r1r`=>Ax-8z(+84<#)g#`(XW>Y9q21CK&I6-3z z6q^*9lFD$VGu;?0HHGeiBRU|lQX~dUhve2M8Bmet2&n}UB-|hmlVNSdSSumMT7LJ<>c9R=UuUf?bYQt`8ILWF3XSw}caIDS4hsw@%scp`{$bnW=HAwhq3(ef zPg0y_6e1tFNaN)Zkdl&ew6O4c)wS!_s!o-Z9Y1mm#vd-9y_}Yi<}7y>GDS+EN-0pP zW$LZT+Yjz5*}AnbIwm_bY=>{)Rt*?6xFv!Xg~;%raJ-pfe>;-Y3MU}4mG(TPJ;#B< zcAzp8RJtS7Rv^Z3agW)PcQz&|2js+%uhMwlJb9?2dlJlH!OWn@IbNtqk-<8Q*gfIf zj&D0$4srG3ttU4hwmxd^`a4#qr)Oqi-Wn`|mi_^|z<-JafKUDhSe@zbod;^Mz4O_F zhYxSvyL#!$u|q}KyAC=z2P>RIJ$%!v z!E~-Ko~p)C)mVxeNpwMy)HXP0q`le>?}8(^;t>ug3nAK4gt3vLY{VFZR9}|}k`Hq; zGGqc!!3p?sE|aSeOITEj+DR1?5_Yz@S8}8QKzIOfm$|pKY+FIa{?h9wEAC#ad-CuZ zD4$0AheyXICZ}f?vASq!191Iou?lf@yt@d*+8SWVdUDos%IH4?nF$;he zmaV^<`!EfWc6woKU=%KWSSSW#i6ede(7HW)vMePoDJ?18*DILIkvb^6P)LEPDci`1 zjlrlS;z&n_c#$Yn$PY9#rV;UCE>j`kNVcSY)i*DfSCp0=&dQGT^5qc73Z8?vI?O{I85*)FE}_#5anY*2iAhD%KH z9`F+Y@*J?L^&(Rz!chlqa}CLKiOBLu*cY>-czeO6{U@#-J6Ch%R>Pxb?X6w?UHyYY zBO~LJTDZ=D=L!VZxw(H9tFV6lAH-GQtf00UXn6rVK>dwc5CWYnER6_F)ObXS6#jBm zxT7WxasYv2B!%x!V0oLNUq6vdUu_C(t|A@DLHRYhii`=1ar|A18ps-RGX*+~-% zvZ*D-%#v(}WLa2IAg-=nW3_6P`42xBtXOVJB#GD@7fUPJnzeT378H`b42uI{Jl)2Y z1$RA%s|G28ROU}4Dj+Ep2z{K?2|!1PoMMHl7@1pwd*BvmqKTd2_zqDFQ80q!VoPwc z=lH^F65AI|R+Fh75?&CKq`@H^>@0;mwlA0ML%@O9Sg?9EQb)%QiJ+OAB7{7dL?H2S zb@Om>byqp1#>J<{Cl%)(dGVyVx#4l+y+_c->IVx=ZK(x9Z5V_BO{UhX3Jz=}d^rsc zTJONgUkg+)bDNy%ZfR|M)(k+sef?%+Xmn0iu8&s;p1?FTM421YjSX0adQ7yPqf8X3 zQp5?kfn2tyMCe7tvIBgAbNA$&D?3_xe9yg_vZoKrTOZ$e)>!lKZpEX!mA9^)zJB@S zy&IP%``ceM+4_aL?AOJ%dAT9!l5sd>1j2&6I z=V5#vasZHkh9%~Dh3yPZJ`kO8GImEv((bY?xo37Cxp1hY;@p*6cON}#>+0+7A6UZb z)XdBhR_9*6{A;l~+0zMeb)fY{+v6v#4bPezpXKd75F3>$k$KrORKV1!JQICFG8CF5 zo&=TbK}yzm}E5`p+MV7h5P^_US({|Kq5u<_8{%x5D7d2j=`b{FbFIWi*t5xgvrD8 zv2h2ob1KfB?``YsZf);;{sKS?5-gaInwx~NJ}}DyBeg$Vsln$T6vgl6-odQj>zVo2 zV2U#``n;j>{_VS&o3`cULf`Qp1ZXIh#n2D|QbwcKuQsD503^~wEfkMCWpE-%@f92V@M z+_ydL(usoWXHHxxId=MRZrP!Irw{Hc%-XR&B0McN!B68$!Z5fjm5)zyaOe(=*A|gO z0$mV>XLv(s#j)I|Vt1C@oh^6eNL(49V__(nJU0phnpRSfyK8*~nQnYpP*Bv)th`IH zX@|f-FA!$0;`aw9<-x|%EqRx>A1co|cBSazoeS6RSKn=F1U-3AKPYvFM@J{8Cud*I z!1bbawU`4R#(yqf{l{^2ZU}_d?ORv-$ZLKoHAmJa;$ zIwP#571_W50dp3R0N`+J7ZauJMklXh-L0jZcbKKpGrp_c&MgSZB9LiQL~&6|C`yc5(^f@m**%DU824seEKo z4V|JOU}SidoPbfF?8F3|qp=Zv&03tf1qhJ1Bzq|a!=cf{STqHVAn2~vrIE;d1{1J) zx~TZ_=`(;gP+_$_eLmJd1l=gGMghBt53j-F_X|LD>HGpKD8X9*+};-6Ob(BY_6hEw(!=hDR3cYUx{pGo__u0EUo- zb@Q5sC%Wftp1bUwZTrujc>nT;=Rd#l`Q1BrA3XTti-%vsu@Uy5KVudCYyZ{3>OY^Y zfYrO7UAzHj&-0&N`S{}Y4O>TgW*cgUaN_lal-`! zi(dHP>ZfNu`|#w&v&YUHd1uSY1^q2mO{KPv-#>b2$Hcs@#-&4DTbIq-wQA9}<)b^6 zk8K+t-MDCI{i1=1rSmErc3Lu>O5uvdHk-Z2QaB*bY2ir9(H*g%*HGAb@;s(MnU)El z3Lt^Ov4E87nKdvY!%tC}tlOZ0g{u#+3S%^Q zPQLc?g`MxO|Ma^*!8PUIe)n(RJoxI#7hhid@T1APx_I80tI*j{)5vE_3M{U80yR96 z92`#e3!%g%@zOGLSbPhUXHCv9rZV!Rs%l&DpxNH3)Rb#xoT|V!r`@}y{qQ5 zE*`8~JJz>&q|d0-kP~Pb=_<9R#$xX`7W8K4Gz%3K0)cf^v(}f-?{bW z=hwfvcOQFzced(OiZnSjn~*4=(X}FRAsz|%64|9vsY|Vb@k^zEXBYF0Ql8wX)?xfvGH33NHEWJ+ z+k9fzmiPB+Vx>(>p|uj;8-(N)n?eQoREfp#DOQR^7`2uyT(o}WD%?puN5dE2 z0;uquL{Y`_8m@?SgCEupfBM58vHyQ?HK_hrYV_KAXL?x3J2}(d9*C2NM4<5>B_ful(+}R#x}jP zdH3mq2afLCzHjry-VN)P&lxmIc*I~|MOJ!eRq>{!bB=Fcb9CG4-D?+Z9iP2r$?*2& z{mX`{=69EG9G}}-Q$tJ6q^HSbvXUHQn=yZ;%FrrNRpTtq7MnA;5O0c8((yVIk+7{w z6|wn7uE@;dn=n{Ol*KR=w3qZ$w=68Fom0`g5IH8Zm+W7>_C&|vMCZV|vGKjz-Z^{h z#D$BO?%sjM>gN4#zWV0r*N%Ue zIE6z>#kxZnpTv$KFvFtL!S=_73WroYkx|sRI2x78mq?8qt_qro$TVayO?V+{@j;LlLjk8!l?eo(5a)5(MzmfQlS7{^&ma>Ejk;N#Eo^3`c;4EsuE~X6jlT|D;ml&rZy=VffBFpCS(F2=T9@w<}(3TZ@ zCl+m8KC)%JXX~==WwRPKEt|7y(L$L(6&IBu5;`@yX1Tgas;n1em$5vGcrAr4CZ%x` z$eD>`4vH$4tC?IQ`!#Dts&>Oe&sy4NFB?SYRb|VPs4!-e3+M3!s=-(KeTP#qZ=2`9o@Zu!-}I@SMOcBXwRC(TNlmVvS`-Iq0UB! zS;ZHViQE*bnv^WZ!{V5^p5*{;1WMSEq4-am9_{TD2mc2U5i{r_kx-pZ&7AV~i~!#t zrA*n@)H2l52dv)y{MwJ-e*5cJ-~axnUwJ&-e)|VJ$k+CGr^DtKR)jzP1ex)dx9?(U z0Im8v8@G=R&+TsQHs$0oXdH0G!_a0#k|JYMqvGkoQPh}3HW+9L6e%TLlgcn=aI7kQ zW45-Q!F3YII<2YAQ98%&8c}F#<%$w_NykwCl69-!*|Fu|n&lgUo@a|_L<$YU5(4iT35PT zSC+LSU3cxs;%!UT?Af;G^a=Rce0uxV&99$)jj+*I-y*ExDbgID!#&LNy!7~kzk2z1 zXDhtx|K{`Rh39TH>1FZPSVd8N{@~s-tQxN0x_SA=rBAM%diVUUUB~9lTjh3lT5T;w zCB1cxV{P5zaQw5lAX+KssU56r8#z-;NXsT?!2d@}q+obgFtc)FiQM4m)PM-GcTj>~ zP(nyJIXogcIG6~a0N_=YA0q78^l#a=6kETN|BGP7&~p_|Wl zXJt8r!Xk;-#>|j0X>4`2tg6)BP~~u0wUR7Kbl_WTYHV$B-quwM?q5E4@yxM9+c%ut zgSX_mooiR@UcY+ng3$(-Ge;s8vZQpHhM8rdq-Y3V)fsC|NB26loB_Ar_UbU{}OAi%jYgEpTA_uyv2PTeJY8jq^J^xFmZ9osi|yA za#namntuQ#GKvutOpS@-BqoWIDA}nr9h05U6*`z4YaB_zla^YG2VGV3jRjrC{I=Zu z7K5qIT+r0oHnw=tma>wTn24l|l+4bi_8k)wC-?0>xNXD!Eo*nKhco!RofBi5R?XV7 zW^CW~&HHxjtF7pyCd)HuX1TmUZ|u_O+hv+Mj?|IP)2FiKscdOVrZk?siSdOar4U3wlx*q>udWqwhpf!Ubu0^hCRCvy?^?{E1zAt zclXYt$6v#u^Sf71zQxM!6`Cavw+d!=FA#6zdHznn`Zs}!pPcjx{(D$O{L0t2@7=j} z>&k`eADq6hY12MLpOlq#l~)c|H;mP_EQaT5Y2Dm{vRHh2y?|U?Qq$Xe8Aqi0Bta35}&i z6Ed(0h>4+-l6Yj2IGLhgGN4Jx7xHalem*TlNKekxNV6NtU1NhC{Vnc7qa>T1niT1i zL5Xf~+t)0bbN0yIb0-fU+`jqb-rXnn?b)|w%hEY>i}La{B8fq+7IW2Nu|p&+Nlnv5 z#qhxyzy}Hxm#~NoNNB-J^n!N4Cl+!8AOAS?lfj_`A}J#>n#9Q9r6kid3Qbo>2hxjw z_3FD{{}opM_}ky(@nH2gzx&gl{)Fs_?_Yik!)lCRcR#=R{L9BPn>yzYkJh+rjh1@TF8B2}x<*8{Ev zMFUz>v(D5~VDDC_D+EG&PEJLhsX`?$Fly{w7;?tf?b*C@@0M-*HgDd!cFp!RD>p13 z8y_3mxMtaoEn8PF-w3Bxdb*ZMHHah?T4RSHzgul=&Jq_U(dBWeJOY)QDb#Co%T>m5 zv8E(T=3q!1TvbJOe!J4%t19d_xaXRy7T6n>R?eJg9@*J2u&Hri)jT-lZ##7O-SeMZ zymkHNR}bz#{^qOaFCM@A8LJ*=x&K#KMGxTd2)cLw&efY&E?hf%>ip`JTbdgCN=iE% z#XS!9u-!eBU)+auIg7hLr?6e1E9a_9Gep=b>yw!tYqbQj1WzhW4X-NSP%<98<|3j! z-C$%?8g$Scj+V{VgoIMyuNWSc?i-vm-JjqUn23HgDv}x-MI#eA6cQiWVFAy?=jvH> zSvr|TC(-j%IUUuNLoGE6dmBf)syixdt~^b8Vq{F><3rh0!OPKBz z4Xg$RCr+Oc9uWmM9x{{&T#l4RWAQnHww9JH>nHBryx}n)eg!j%AOGz)zy4oXMF{nu z{`Bjgkgxg*y}{G39^Joj`{l!@t<{YqJ;N4*#bqrmEv^y^lrovVsJJF2l@kd{c|=BR zY*t`kN<4uNtfGCwCp{vXo6bNegC&8ijDeDcYn6Z`tZ&HH)N@58>YPSnZd-mqhpn*F zoQqSJ1-m#7L!lNMt$JsTtFEh|b7p;ePeVsrT|;wyZC_7cYg3o4pdv@_mSz_VBqdx? zDOco{>l&2$dSI1ElM`vOEJ>~|ztUXTB-ex9X{B=VXaYM|Q>85E(z}LDWpnc?=bOss z;hVzxCDlFaTZXsvj&51HZujU;R*v&UaOfBpy-*01a8pRwvGr~go0 zg&8|~fL}wh{tRv)|Epg`58&xn@813T_MKaweSYcVOJ`1eIKE_kRaFNV<8mFii_oo% zI;-awl+T8LHS$(?n#wGdn7-AZc zY*wlI8fzEyw2gJttsUuDH_|>(S5lIf!yqLDzWoN1oK#;@GCp?{5IwMS-=aB-OYLR3 zI;&n~(JAuvYMWA)pPg;XG1ap9R&t7xNY19xv^2;Slcf<+4Br3}hzgkgeEkW)s((l~h(!32vY)?#rObtadyXzz}lcW+$xVAW%s@-tT9@Q?8dp#y*X!ykV7{(B_+ z0;?FWa5cDj@!DWVZ%t{nge!5Fi;OuIsYtEUSO7+PWm4{OzOp4`oVgi2r$ zt6fHGL#`d^W0h!Cc=94N077k*EVo%{=~UT!^(C_kY8JX$mbse83+on^G%sx**)q23 z!20b+51#z!lgoGRJb3aDvK@~j=!+Ns9;>)LO}_eH{hbB?|Mu_o0RKmg&1+thM>hnMJh=YrEFh_in20USHa>JilVD+TJb5sbglBP&pPNO&d#+ zM8!0IE+wqJJRK+c$28Z}i*KLf@Ve921)g4Z;ksKnfX*#Egp4ikV$q=vPr! ze|mwiiti9n@rPeyyh4il&sat7&kwJ@`vdHe@1vT3pF-|AWTlv;`dBSQIV+H z)C_Yvt1w&Bkgcv4WmiIGWi++s<+YU-4^+5^ifo;^x*Dsg!I9VGFgKPtJBkWha}4ED zg@Y@~&*Gcqx-zw?nklqmX~PmbAn{A*=BKi9MM}5P)~d^^mubqfb!8H58RSUv+y;%c zLs!_NbM|YU0~+T*u6tHV^LRtwL}UL%^T5Qw*sf(8kM2Hl_S8q8UAy_!mk&M374Wcq z`OQlVRzKHO%vSJSe~ndKSO1d(>)*pF5_A5Ox(esjhc|EEzI^Soa~Dn>J-vDT_TKJU z1=i}~s#&(G1-7b%MUBhRUAtOV;Dcs#&k>tivXqrH0bV7#m?TMfEITX;UTPUZk!k+n zDR2z)0sRl+lsG2X`vgL!hyU-Nh}U0e1eR1(2(SFZlBfC-yuC>gARk`oiOa!IY*(O&HuYN=i{vt>nJ$EMi>n`RF$>FJr*-P=@F!yr)ur}_z)0*l^m zP+PSsTedWxnW2)1?M72wE|LnhRYFM-U*w=?8d0_4iNZuOz6$Wf5jY_jaDqJ&McgUC zRY0@)=G(!zsfC0RNn}QNL_%~FF*B3bSlc)#s zwgOgv`u5d#PoAILe{{>5jb#ou9zmusN1ZF=%1cY@Ue`Kk^hBZIX#^rS5(1oXI^c@Z z8V!+SU}{J>T+^|gU?z~nX&G9Oa+8u3sSFcKBp(k<0hNOLM>_?5X0N=uuzut#4!=%`;*-@mD>ZAD4bVr;9L`_~RE*tvAw zv8{X0o;Z8ylgl@6-+P2*>eI&_8{1b;U;Ti%#wTz>@T3EHu=-lM@=w4jf_479vzqJy zUOjyH&Fwq)uU)_P$wi2*_U_m>HfOQjUad6L3UivW&E0y}?A)?ZUGa#v=SQQFJt`ptS@? zP<=xvZ%&VWdsO0E$-}E z(m8W}NALXJSuGV!tQ1zLcQ_R$LJXOh52l}y%{EGx`1r(lc}J3yGp+Wr>C*zZ(Bnf5{Cb5cGw_kx{_2lUvfBQR(z~EVd0K8-UmbSW9rC3R) zFl_lnI#q5-X&s#|P-|_#s+TVsZU)XD-o7N9Tmjd>V5+Y_B_=*AAQ)aiSWwWYbais7 z90CV2O`FCx)A=?i2pD|a=nK;_%_4c3Qdg_d*XNpBb^3-vM_+mQT(^6+vuH54px01< znDriwrAuvTSLHWb%lmAV{ifnJy|YPcYbdN3tY}(bbq&ZgwNh1$SXIfE6^XPJ*~k#g zZIYRqrMay#bGynm(^4_Fx@#3|tm?X!*LRKg&D}V@?$FNtXFvSp^DEau{(JoB(evl8 z1?E4#_~BPCfAC0F|9M#b$s;X%{^M(`{`k$;Sh0Tp)feA=1&e?O7_X3__~6?0E1z6C ze&G1ntOeGBGNGy@GrOFvs#92d3#u0tHLb8zEz&xNdAeq62NuvGX;0jP-}Uq#VTSFzOuRs+IQeS=e`cvF1>*pV@^Sb`)p zGQ&3rrzNsLC@pe2YAeetT}8$DW{1J#(B&5C@?AMLr_PqE%u@(7>@)!>jz)@SW>BR9 zu1TqIL55Q3L^OGaF1J;rs!3xNre<2xSosiuDM}qQ= zHh{y=2@WOu_{949;)gMW#58u6h(w}xwsm#1w!X7<+gEozSpEL#(?9We#f(Pcrs0#U%h9edX-UV+(4E|g0+vc}qW3(U*<=E4WqVymQQ z$fIHy_`JZQ(m#k26oPV^9v(^e_9fy?go6dx6cCQ#1WZiAwVIonsUwtUyx%}24Sx^U&z^;`G8{PHpERXs_~c%FUt!)w*5=P>%h^LWCl zpyK%!&);66{@n%uzy5U(;Q3EIeF3cg@c1zzlYv#_Fn#~kgBK6(KEHqO$!%D$UcY|f z@_R>4E*V|qDyoL<4^vufC>}tk>TX+Qt6ron9FmwidD^Dz+zxo3bF$rNS>b6D5JC42 zqId<8U~?B4&x|K=6G>d`XZ-z%AQuI^{t7pM$-0WEDl~=`5S~6Gkl`CD43ASp#7q4{ zGo}X+afM7I)0kO2K3^o@3Ir@ZKZDOr=X0n6PO6Yi6*3@lCv*8sg_Lhl%k7rD8oRC4 zoZpg{-XV@4;i@C1Y=fwVgUf%-lVHI%d(24EqHZL7rVpJQ&Z0Vel1?44mjZHH_wX!>F@i&0g zE{f{Z8F6?}V*`SdBV!q0`Nk93ST#pR)1sp3!J)}`D}k|)#!{0q6-0)d#8eU)iZs4~ zt8%cj?E-ZPWKiYxqtz{oZ0A4;NU3SqMT}(sWCgRRbJ4cMGjQ??4rhnWr$^Ra!-~R`!-oNwg-tDh%T*syL^Yfp+f9&0L%T~hvQK5Aza%=KS`yEwt z@?68p{O;`BPL-vXqpTO|niaY52&ziWGRLQ8N09^wR`w4^!K8*n(V(&N4M_6xCQP3m zJ7Zexl(!E9q0k3qLK$E2ZW@&IW_vt zsZpT!_ys^8fnzjfx_2yACGeWS@+3Hfgyo4O+nkWhi%80hN#P~XB&i%V1!jOu1xIPO zxVx<7y*ev2P}MSHjmq4pEojviv}x_V^88+*zFlN!mFBkLwXU)>8J+D2eXi|XQdB*n z$!`*<%7v((n%XRB8C_7skhmDq5|+H2udC0__h8jfGH5OzDQR5L(!U0;{#gsQtXQ{y z-=TA7Kl&V$s_Qpy-@A7o*2mv^U30Cjjes<^P z*Pma#a}kzS=iz6yd*haQBctx}R-?66VW^PhRK3=&){C@_5`CKhHZ__ip{9YOsK}HQ zK^=fyE0Ly%OytB6Az;aXUDX?JMNFL*<257RYkC~8I_1p>;MU6rdKOA(BptObDP5kB zrVUS0`^SjA!?OG$G7-xdn}iEB7mP|48yXfhpQo2e3bdNid~<`-(N$<|H5;o73mVHy zy30zsE#`WCPNhOw$`jf}GM7|Y#+SM%bVD3jnM5-XQZ)YIOmB>J5h;G5XrxoZVrf|X zqM}Y}w&YOf=FVf zUqs3@7$e7L@Ktt8Nt@JA%GVT$_2r_RGQPHqtHKY94 zGd3V}%v##-uA2uYsy4qFqB#QymL&s5XK%KtS*WYyX=>8Nu4JBrCMgx@8x;juSal&? z*I7HKzI(iDc=hbDjhnU|JNwb~>o*_Xy8Y#y+jqZ2%H*R*o=}_Dj#WUZ2dm(rJ$vp6 zU-Rq%umSM=gHZN=tgim>%;VXD9^kL*>JJa^zqotj>7DCee}3i8#ZO_scH#Z^kL}*O zcKI6EN#*3aSONo;sY%YzQ5YtunRrU1cDBh3?J`4~GOt5j&@MOCvE|NGjxm9XSs)uS zmT+v^18}rT4GB*6^@gWkf}b}`{0P%##7*}mpsFM!3z_^}I?qgI8IxH?h&mbET(;0G z5a$cU`H-#{4Q1xMYP+quxVWp--S4g#F0Y#9a`oCQEp}^*&Dv~+ouwGs%a`S~RzN*2uj!AOTq zA`lDmB*!J0XL55IS*lv0snye|R?NvO8_p{ouvH8dR`wTH^|r%W zaL2JLSHF1h;K|)PUwrZ4i$`C5`Rp5D_38J|pZ^3M@9Vw&&sasSr3bF~n|bMp4*f^5 z`u(%-uvPf+$@8DF`sk}4AAa%U!+X!~Tzh`!^T#)@J^1Xx%}>u?`RK#<4(VX^2sk^;iXKEa98e4?jgh6*NO*^3?kzOMi(7%Y%` zgHjtBp6Kfr5grz=)fkKH#Un#QV6h(Fw--wQw5;F*eE;HwClvGB?~z9R=&MIhzWL^x zhY#=Fy8Za8hiF!h?mGyqx^2ZfHf)C%@nF~RaR0o*f>L@0UoJN#l9)kZ$#Fyur0972 zz{(rqof$rH;ZdoOOnP}oO`jeHMtWdCY)mvIAs*h{EXd3`0yB%32UAd_*g)Er#xg_^ zMNklnb(PB8My0t~q_1VGFannYs61T-M^hrum#Yd8tJ+^uHMh_;tTnVMHI0V6&RlDc z!qCK)y9K%`jiWaXGU2AH(SG$`QTFVE_#T|M}wbR|U zblK)l&R>V~83@&n;DY`L=JmkplkcBB`wLb*HSj6C5j-J59;`lp36}ui_51&7%lf)s z1y;c>_$#b_`O|BxKD~AI#og;qZ{K)$?ee`#7p|W_hir>|+jlG)TU1#Ep=C}w4di5A z98m~vFs5v0#h9aFL0<8Qp|D?V=@9Cw*@_Y#9BC9zCeH*{zyy+zm?R_;`H2bK#CT3* z7!7$$G4N7|Vqh)f?MLCzf1v+%!?ri8Uf0!4^>L}IcqAz1*F z21KU#0DiGlzcAvAz&O9KB>%7^AJAq36Mz{anTzv864_(%^ouuweSG5m{NqU!OgE&6 za6)V>(Ppua&Y6R{dgAb*?;aym=r(p%ubzXI@f`vjF#_MaefOKMzkc}T7l-%l2UcM< zymQl5^s9~KwF_r2(8+au?E@}ng+_r$DV0E=jwPf+ED76rk70r@0oHurB|Yeq07i7pizSS%fhlpPht3k_#QMDrqI1=DT$fe;9rL0iq zwQ8(gN=v)Q*vQdT0;v3)VzsT-)iA5FX)M>$&J&dI_->u9Eib>=Ou4nkP&(V$G+x!cwytMw{mfN}*Ri>~Wg4dj`_`dFXHI`|=jIpp zp^`vsDA+2G5etO)x~DMj{_TsGzrja%601)qLoHwYj8&wD|3g^CV&N})fJv*s*L#5b zsHiXQ-h6TI_BS`L!!PLOryqZO@&u0To7b+LJv35RS?{p9p%+FP3pjN;Q-iH&AjjMx zQo((tPHJf6YbqJiBD%=V5Q6Bgg-uW*MT!j}i7bha=i>Gq8j=bZ9#55+Ei0sz0Oo6*Of|?pq^T} z0vk_Q$QRjxQWynfc^pEVv`n2x)JB!Y64~&;Nv25?DZFUNyJD%+0%8Lr!TXAT+dBeZ zeS-|E;&eLB00&i6kb`Vq-}0AdRtjoh_|c) z4HX7gb5X;Pqk0e=REe@us;E|LTBO-^5_!EouiIel$+6EgxcW>L13B(qg}qaj->I_p z8cSz8>KD7)R+Kg`byUxD)sMFJuWsvEYIn6jBI+t>*tF@LJ2xI6X!Ql;R8PUF{ss|N z*yH^Klf;)VfYl#RQ~}gKV-@k?p1S&vV)f5Gu!j#YX&3zJ;g@h>eR}uSv%9z9Xz}$; z59u0FEEmt5`S94$6MJ`WU$=VIf`xPYhwIC0&4vPnM9*cbm`qhlnj({%uQ1d?fu*x| zGv#GuT%0AvugzF&>72Y2rk;>2i;M@Q8JcTud?G)FfK@6KD_Gi4BcVY{WXF@(vBbO09jMW-_rBvnO2n*;eJ-{iFIe8)*Pi%utlSttZ zDhjEYnsDU1B@3wx1QAN&leh?VO{dA?;uwAb1RVN({9|T#M+Sx@f~JTcPMHxt-6zH) zt@R^#4!#L2nbJOGdh|3ej8{n!C~;GQg8d?8B4xHnW;PhlzW46IJ-bdFKlD93aKHZI z%R4uJc>et1-TTO{xP9dsR#l&Ua=xLe`oZlxU)_7KY3+tn$4;#pUu{t3rc;##Y$oCt9lMX1yiL$T{0Ou>eVk|K(TO7jaOKr#vcuHfK!FR!qe7)p3}f}ekc zw|4}H;yOchS>-U~Es=3t?*M9eEH9a+OJ$l;7^XB(v&2qLcBw#Bsm^ahZdyt6SbpVz zG_OviuU1)F%&q}*5qR<)3S+xm-zqn@=RnL-Jftrk&=vJ5Y#rH_c75?sVa)$y{hJRc!GG_0ePez8mu!nktiHBk|MD4@t9S1{ zh7{p-Ap4C^KSgffh12hyJ9hXuqGi{wS-)_>U|VaI)0wB%@tE*5gG+w~9FXMNGCtfS z#IAHvso2yeGBkRaE%MTIzLl7vkEX~%<9Wf+tf&M&Tv$O6#(u!tKPe~#7C;OV34XsG zu{JE)V1~)$>&?A4V%Io|!MPa|HQm3@t36Gx@pc zY#lj65l!ZYCuGG_1O$o@V_gg(3sHJhsx%R2ARKlhl6`%nJ^GPA0`!T#esR;Lg(F`N zSj80p?IM_g2?&QGasKBo{AbLFj*p@eW2jU9bw*5RoJy)FD|YSMwc~?RC*MDH?7`j7 zzkTxX`lV0rT)q12tFK;t^YrqEA0ues#%G_6j?9AL@Vy&%;IMjd&*8et#<(aFAtss4 zl!^p8W=1x+d8H+7uhocxy!?7PQ;l0da0nQ)f+P|b99sOwphi!p37{bG^^HuWX8HJr zdwGSUSAm-iPhy2aQ)8^e-w$3}h^|Y{$f2@KNWT?p$}O(ms@BET$i}UiV=U^;&TnOF zDw%S(&`@u14cMwjae>M$ot5JpP+NPH1w9f|o6yiA&+n4ub;$DCjm3lZs!?~-lDh7d z?Sm5?gX?Nq7rLtYt*%y$u~eZg%rO-eI;y*7&fd50#GTt1tR7J z?Rqkf?b4akpPhd9?7`hf5gWE@`NF}z&f1#N0;@`#oe&L|R0f9+cP1t7RuopgD5uF> zHcwaBD={^4Rpsddds2omHbogllps4GFf!9Wlok|52W=oekw;CJ^Z3SWxm}1u4BwK; zfw`g~m8MN+z`owD&Z*Kv?{BKpnd+3<3W3y_#j|Ab3ItMzREd#4AI8hTY6iy;PZ5R1 zXGM|uamm7XJQM-uYf`d^L>6RZD3egP;}CB_f)~Mz8R2lq^zw?r1J{=sUQw8;!Xi@P zTr|x)E+{M|gQfcATcI<&Vq&ok2ug?!Aq4w|B}OL{+3b6F?Yw;9NWZ!=HDr{Q2aows3qt-m-ZJ#7U8j~)9UpJ4V zE3j0%id)mt5k4gWR^t;mo)bV!25wbon4$Lx2uPSd9aWSD0~l0SR+dyCRE35SAqb)} zJO+#~2!#wvsjpDxRA@{!n%p`#Bw!f@nF*rt@Z>tXp@0+VYO!?6Dejl$w{f&Jc%*1( z3wuFFF_sL2dX!f-M}bKyw@qX3)7bkJ7^w<-&7~uS)pN_57q#@RnK^4?*WlWQj>f(Mqeqje0e`{jWYQ%QBLs?n6bYz;u(tW&Ppb_cg z69sGcNgItRQ$nXs4G#!Pf@Q%BUjnd-0VgS0fMy^pB85WC^qm^&H!UPIAd(bEDtDD` zShM!R`E!T&y>s%&!P{3qJGOt%r)SUJzH;T)FTZ76Wn`DJ)iqe0;xwRj^x10{-~n#+MT0s=zs}KDP%*cx zWxTp$1>XL39pk901M@Zw&YkG&U*fKwsnVfVX!HihoVnwtPJMF!-q$~T`wBG^I0Q-o z&aWSQ@#WonU){Tp>GFTaDyr`PB~~XXtUtG`Uw=J`Rg_i)vLHPWnd~U7pP&2a#<>qJ zp`IMt54q^Z@g?K4XZJL<*o=8>Iy*QZdd7^1@Mt>rq6%Z3BCpj@G=M*~v3NjgY+}jW zbiN~<3o2TE3NshnHaPgf{XXfn?kSn7gt;G$sbglrLJjMtTpBBv!7*byDpr&zbXD1! z3dGiEjI~-55*8}>vLcSCkSBKV;R4M=V!IKpAi!!IQeDWxC=x%6kcF#RJei+B5hRlN zFu&q(awsI8k5|l$=@GCU#)IE2iYf>y{{Dz)iN(1J12`;Su;Ijm97$4&00$#rHIm}9A!Q`S1(HFx{);(dMdcObc}Z{C)X1>5E=*)f0Vw(fzY&XN|ns=!`Y zwPxLpt5@znegxj>D*zQBd=BsA+jnkWy@szq=|3H-e=TDHRwqjPT#JQt~PVCygbIq!WC5z|GoLQW2%}AjK`iA>>M?$hhOp!2n7PR-8g3dhG zkjC20*VLecWeAJ#(75*0Omj+xDVe6HP(7SXa;hpdT?f4?i-RuI%o13|s#3YGQmicH zhzr>wJAz&C6^}w+Ww11BbL;W1vV=A!&w|>Uo}r^<>e0c{ScaG+VMGGzsxT^v9}>$5 zj;4W%fWZpBSQLuD&xi2FFM?)F5BK$rLK`rBdiZN^BJ5E~0f7m?YCtdvQ1J;MPW6ff z?aD&{3n2%?!2k~J(WKb$#30{LtJ$`8#mb`x4#4ef@%+&X=RUf5^~%n2vLKt=uf z?!C*Oe0uTR#~-|V`s4RMSUi8xv4h9qQUKE-uW7+jsUgIpHKW42JKtR8a5lr|5In$C znhNUj1VW z0M0ENF;~pC*NwT`mzT6IwN}q{H7!IS;OMHuOD0Z^Pn=w|=FrH(twW;|!0O28x~8_- z1%=g>RUJEa9(`~h-ap^JeCh$}H(!2r{qmJhKRWl>C!eBOee}hb|6Hv8?&ZtBVD;xT zme*~-Bv2=-E7|}A2%@y&hIQ-wxz9g1b@AP!r}ynTuz6zF+SN;E&8jGLGE!*q(MgdJ zWE?1``4A9u!^R6*SEI9aE6p8zRZW(xj0Z)(s+uD!qjT*UTswnfr?V_+8M&!+1C?e- zryFSuQ##X>$+L>&CBkeMJu8ox3U;xE!GXy`0fUR!MXuWuYU0KWc-2-bl^5%LRAV6i@eFN)W+umGQktPCMBE+slFo=(jeU$}JB z`VH@&e6Opu^`q0L;l#3M`}Y3Mu2aX3-MxO}{MiqVA2@vW-P2bue%4ssaO%XF-tHkL zjTamc!{e#Fy`l&NCh|KJ3VU7sFjtTp8_$l2W`Rr#jd=`#8yueQ7fABn9;#+ zTyN{lv2|wWHOul^B_Nv_o5i`!8b=RMs&!%|HE5}tW3HH$S3Ybg8Nl~t9n0PA{+tm!yf(ma{^n0;H9*vVH)m57uJvwW*6qo3n zMpbUR&eEkcHuL2b;67yui)pL^N}3@l1uSAcjcI0a3t2onTTsZ86tVa=D#J)lL)|d( zrNsa+z7fb=z$${4#0oclhRQUOQq_>6kW*A~i6XxcT3`e-328*>^3eFKSTZk_smwrR zLz*}=99eA9Z@n3eq8c7fijPkx5NQ7Xp!~(om=TGCJB~yk0HCy@LFI{ZfzmgoL|`Wn z5J(L2kDKy_Z*meHyAIzOff;F;LwzITi^dP`-oJj;nu(RG-#dEj(4M{U4Op>c@s$e~ zKmgdcb2or`^2iC3F87@s`}=3kii@U%h9tn)Ejl`lm8C}PCfbss;ZG0Bk?KqBwl5T32YybpacuydtZkX4dG0#o5lp4n*dFZAf&IB%Pfn zP?S)ZMj~Cu6gglpjt2%K@Jq~rP}KffTuz2_E<@*+{JFJ)@ zyKdL{^PgY%^xBCd$M@{mxqZ{-1H1Q}eecv&q|V<&Uii;g#fktO0(#WRp7x*BuTC}q z7_X4Y4*n|Y>SPaqmKEE8`yZFi7Pd~c;;i*rKA3VKx=ix0ISIwW-UR{%?$)P4u zLj$8jQL>`bViS>hr`I6Fv#8fnGL%<5ptW@38=HHU(cUA=X%MTcd9pGZ$4*W+rDr1W z+J>(P7vqXSHt;z8;>i>sOu@yK7Bf7sG{J{iC`WHljYq1kfZ-}BO-mqUrvT4%ePk?u znon{hfuF+Ah9`1E;#f3}jw3Orp-#rpp`Z2fi+$_OAn;MiWEK*i!@`o#ufDFRvFKMZ zbYrkWDf9A)PiLTu7GTIiX`SI6)n#?v?L7zg9GW{a zcj4U8Gbi6g#!$7pY_MnMd&iDm{^SBMeB<)xM-Lt=$g_ap&LBsI+k(CD)Z+>rl>#3!iPcGhY zbj9WqoA!OU@8oCuj$hck>(tiW?`__3Y~|WrtC>n9spRy0qgF? zPwrhf2drWn@c#Z?hqp|u8lBVAQ18q&i?aB!5ea@i5#bS(WU81ifqt|;&)JPPk-^?= zbq`gwE_GJT)#SG;Ow9^o6F9vrQArxh$`+SqiAvL1whRu!K1#V#R|dBL$mB?hU;@k* zJCidEDGVd5fbl&)yF{cc!_NcBz$%%lNzX8llU2ZKPNt%$7jea$qlf%m{NM~ze zld^&$D6#Q$5``TA21r~QqKA<`jwOJ%cN8irj0*8C@b~w~0j7C*yfo3WrqX1nY;R4A zdTUA;uAI}S2L0lHP6yuJe#6_(E2Ico)S`;9xr>MTh8K-4JhK1b{&#jSosGA3bpF!%)e~K9y+ws(xrV}!koaj+Lt){C26%>7Ty!imlbvHNY)PV^fyoY! zhDVKplqx4AfoPFA)hhwq0D&}Lt}XzE3>l8__{iw0mD=y+5mN7&+G1V7C0)l+PP&N z<3-I2@~cJ)8|GE_t!$n>(Y0XP@XCE-6UWB4y|;4b>E+u_EZul`eBgiZFVX7@UDhw$zOp3#a8Qad8$J0Fjd| zK}L2dUtWp^3_jI#9>TH8k1}R%CfCYh7o<>i1fndCC`qC!p`wkY zh~XlV%2Fq!3gbvwBr2c9Q7Y91c>6P%64+-61X`Q}e0-wO10eg=a|`f^#hM7D5wP+m z9W?=3)YUiM4F1J0yuD_Gyzxu#X;T8<_=VThw|(vTE{mzqRam}#)2_~z&eh9TPOM(@ z-m&Ag73CK`KDYm!Jriptwr$!`SJg0g*1}>(xmKNz&_gh$P{6^LhF>>S0PxYuw>G6g znUbasjb@|YPD;rp;;t9R_6tfyKrMWF%WL}BJbhSHN};Q#Z)&LYpKm0#?PkTE4o9tEiCYw&?6Ld74^gc14!5hOP1}sX(9tRtu`< zT5IOo>qjfPm)8xhE$?1hK67cy+=vO&b=@A8u``b~u!LAt^R7DUQNs zNreI}PhgO#90es^?xxYY?(wF+Rkrd$y}cvXi9pPug3>`GxG7Aq8m^JxY%O!sxUd9w z(s_0o*E$)Nf%*VNFkevyQE&#|4*nsD4%>edo&>6vkgB1wu&pXUY;F=+85zTmju)k5 z6Kj#wOl*5DA!3}iA>qp_5fG_qLPQ>Fx?u6i~A0R*hA0)r+M ztnoNnO*+K^tJ8hr-gqly>eN6~)G2TI`*?-L$ECdS%NbmjR3XhVX$yKf24)S-DK9Bs zyJFQl+qbV-vFzGsmrfix)>PMw{eM|WWnFcPM5J;$s-mM)e)$W3OmHEHgagMcnt_-Y zk*pAxVxZJ7gpOrMYyz%q;_#TP;BY#$U?4NJbdAY1&e#N~B6PJ)gG-lhb+}p-Ib|Yc zi8QCWeQ3S8)vO;n!R>l`K~3~PcGZ}?&2*+mu)*fvG4tDhd-X! zb9(W*J$-Xm*S5~8YZ>Y4TQD?hc}K^bii(b!noiW!4Y(s8KY=9x#(zvz04f$%XjA`t zusWF_jJk@20QLZXh1E~*Up#mF<1?4vJ9_@ezIWf*x@GBtIi0O7B&HBz z$gwdg0-?U7yt8@cqLzUb)tw8A>u2TITMDa&E87;^D~9t+2MmsGovlM@Zjr+hQ|_km z9T|cmrpU<@0#7U)c66sm|w;Z-*bteM!`&^E_lsprUw z64SNVpbn1h#4Q!?{WMO2huE*HO<@-Rs}S_*>^)k0kKWm@us{*tEHbu8^V)z_9I!C^ z+v`Sc;9572RrM`znY(`G;%%J^Hn+@M*S})tlI_Qr?L0ZY^pUN z)85moHXRyUwza8aPLaFC<%Z+n%;x5y?yflt$Ce*EbQG&9tW~iMnA}!@yNhP^zZ0uy zStqdyRsh<7FOhh4$%EB9AD_8;`q-z(_Mh3iefx^V^Lsj4+$CxOpAt(5^zwi6U#F3X z8P!#tv*xYp7#uIIA2JlR0XwJ;{+Z|jFkX>JnLsJ(Dp(@GD#!p3Tmz+8 z0$|08uaFA9H6`?yZ+QLkP49pCm#NdIhtSgmEQZw2JKAh=#YZJG(z*0hCQJin56{x7 zRfiAk*|mM^u|vnoTowJj!**-2QejA=W(5VsCnYgMp+pEu`o$Yzxck!>S}dui%t!=J zES+ie4WcI`Bl}x`Z3g^mh$*tf6e*OIoqbEShEnX@QfX3Cer4bA_@d=ISX#;2~@dB_-5pbMucwGGG9UbVePZJ&w3Dz|LdRy)tt zx~Oh&P3yc3D5`DqH_TkJwQt$>S?l&J-Fafw-cu{yIk|M(k%b%fFI>NO>Ba+VwjbND z>*Ts^hZio}GIL;2ee+;r<3M-!=-k=MSFhZ3;_z``6%7EeiXH%Ub@ICU-;7m^SJ+wo zd#rwZ=luKE&K$pZ;@}7SckWs}zHp$c(dEojDAE#%ep9{UA`_5?IXb$sqZ?WCty){H zp{S{(X{31oar4V+x)#^>jF-19v{nw;Yi2wCf8O3Zs_i?^0zLb7cP2BLNpak;O)sYR z-a80^KnM^BkN^pRDw2>;1tEbDNQmBhHMkq&-n$*gvEvpyb`tjxil=6sLN&!FT?r0dW3Q|{+paccp`keV+AJvb>x5<}!hB(cI1nBj>~sAESa zmxsl}MWxt10C6?TBQVDe%YBed^UcC>a8I+ciLtd$@bV#VbVFf6aP~}f^hk1sMUih3 z`T*exIjNZpnYuYWvnY?oqBA%gt_&vcNLiDUa{>b5F>nV^f!KBH!KwEB;3Ef=|JV~m zP+b}Xpv(H9^*{gWqu+h7`XBz`ckjKo(q_FonMAi<=aES)OoAC!3~}X0>jg0k^-TQD?_IzU z3yH{IV-1bOG-%g5x+TK8E+8xm>>ao&Yjk}KmLf7PCp3~2mqevAC0ll#EaT}T!H7s< zqDh6#Yp$#d3X>>ZiBvg;FL|uS@KjE6ZVj-Cpqfe70;_p!b6$lhr`!mYKMVpes4A0o zRH%BS%@fE`HJx*E%cQ1jM%O=Y7~S5z`M|{9GcyOyk1w8TpWLZ74+?9|JcY5QzFlt~ z)aX0w8oC;r`JH|%_r?<>*K7H&s2mp6(eu=ocJYB`Q+204N@7Pukmsl2A!6;bbfLc zj8sH1shp75Qvb+e|A-?0h+?l`soDzbpq2qOEJ{28RS-)xjy*!8ysxKg-!8 zb)7vJR>=X8+0n_gqzp!BrGi-r*XCp{U(V&qNF*9MtH3IOkmunMj;acAb$M>(;1vA+ z2X<%$U{4U!H%P%_!}OyS_P_sN?XQ0IA+Y*S|MZd7nvE1P)5S5^%_WpfVg&lfh6cyk zT01AkC!3mEq}Ae!7ccBy*vG9DiK`T8spNuurk`&la^v^kU$<_9=da&e`%k}KhgQGi z#wB5ME9;=Js640uePR`CzcJC?HF3Q|luvLLb{V|<)8MjHz>w8wI-(M(uulz*%1TM6 z5039P_iV!mdl{=pQzKK@0(oD#s4Y5;6Gsx}F&m@s0p`l6>?WqTvzXVKS8k+nErmQw zeq{>Hq-c`d2)As-zG)dSkv&<;T^|j_MO{u__MkF z=Z5C@HFZzQbZugFi$dEb*O)N~;0iPni5_v)(AeE5Igwf>HYe-o! zY+Y^wyv4@KzcE$*M{28O3D&>N0+!iUNLl}VD*!3$!<*M1T>IkQmCx>6ICK5fkxPg7 zom$wwFgY^bVd>E8>%`R}Hc!Hrs-#+GX_cQ}tc{&ta8y=dg;HGCp*9Yh`nU8>?=$sn zRT_tp#EP`NHHJ~SaU7tfaT|(whJ3c34At>`IU!dD!Zuc7!;@Ixx`$yn8^6>%L;_&% zk>=!0bn(sD=tpw!B)Isbd-!EJxj{iI5fd&KuhjMS;gG6`OvuLyOa`S~S=W}BnwODT zEUB)S%MBhLq24}G#l?cmOgcnX(XB#gMcWGfRcDuwk3O>hc!i^@N2I+&&?l=mVi2%q zt;_GFJ%xvDi zbAK7Ls*EWjW)u|ADq#w+!N&9VAK0u|?fifI^U5WxT6w}c0Zt0eZqZ;_yJMPf7ir@d zyTLx%);Z2QnCuluf+V}U9|42ZI^$?u8W_1*Au+koL!(#Jj?5m1>Rk-60^-c*{QE`G zFrt!bM=}azp-IeK3{s2KXa$fNwMR_Un2N=ODF2T{D6NPoWSM&>R+(B%(wcC=d7{=dp|#8?nnu}DbA`;pl9-CP4YbNe@U*c_nUaH1mpC?q8$n>l zk$B(_hbER_o7>SV4fYvcp%j?D*+WCyE7d22f;pqLbF7^!I#e)zjRUbtYZGlvt{?16);?u&!TJKOk!w z(f4dNk1QDaw>9-|?VUT+H+QIGa!>E{-odH89mrj~W;zG9j-k0av#+yfQ)5%VzM)&E z?=m*^H5qzU3ZqD%k%_cAjk%$&RU>a08JIeC{M@xGHy%ECxGX;NP8Jw~tFL~9>DTwr ztN;F&?|;Dg?*>>z=KmsAm&+?KSRQ|Q>(LTcKL=K?ojms0q5Y>8cI=s*nj0J%Y42=r zY*tHDsd4FRS2(2KgmA|9yi5M z46}upo@;_{SPsrQ$LRHrQ4Xl1oumCiGUAhI(eXLFDjhkS6&{f;lQxRQIxK;@xCFx@ zQ&wXvDV4xo3xn6+e_(61ZfTZ^xQb=`wN~y9j)5>UdVi?{fbOfunibY-Ke1l%;kx&J zz4G_Jw_dr{6T3Fnj$x3Yh8r@0#C-n)d(6Bj6lP^*O*vaSF}=H#EsIH{lygwOe@0LwH6T1UB&xta zJl89jEZ2{w=T}D)SZJa`x(Asmw*GaN%|vQ7J`f-lpG-K`bqVE=Mz7J2ab%q=QEO&l zO=^ya#@2(+U(7Y+vFa$LYL2{9**u{!PyO4OY#Uu1*?O{NaEIDF-qVD^$cxq?cUVhJCCemY-(@+;8v4)q_MFFN3Al6s_Lpm+Io%I+|=7@>;qQi)mmdi z+rp0hU*5a}S*sV%p1pnr3G1Z;9m^lzz@rXv6>$BZ$LcbR6%&EwRsd4gKV$XA_4}7U z|LVfo>!*%iI(*>F;;wyjGh0W7w~mhWw3vBim3|&UYggJkJNU=OWRofEa&E1qXKrlM z!FK$|_G|)T+XuHdcWr7P+SN9+tEqdl$~fB4F{f>v;j20Ys%~_&$|dc^JVb+roH8x3 z00CBnj~xLdI*siYRp1$#6Pmz)+Y2NJ5MZ4Uh$8YZ5XV^D-Yvn&Bhl6++TABPC?boP z$&|`XegVlbvDrf5QiH|IE6U9+92a+u!c@!ta7C7ISf?-3Ctfh{O)mlBl8>Dw-%J^B2!t(*}`}d z`u~Dh2&Pf0Dy1E&rYQv2qRPg!JPE=q04%K^E~{!OVArGlqHdmS>EEI6n5#8SDw;+b zyXJ@Hk4@}2(>}Ue-ZUuD^|TIcpWb~#SWZ2E`uKlM@vbW4+qR8P=YW z84QL*-!y3H+0@c84LVu-z?PwzeYjuR2DbH1?CBm`Y#rF%I=Iu+zrC(?O5QlEY#Nu= zkBDjqx$@$t}~8>8h+kIlh$T`wqbb-^-HodkoDtk_rb{FPK3DWIB4LKuZ&= z99{vCDkTO-W*5*U6}&pXz?8gvZZW-zU7_&wj0^}&3=AeT82afY5>(~btzK5H0MQy) z1&qPThgDo~Xd2oA5V*!-{%?Q1;@AK9!7^5ncEYO#O(&!QtJe9hSmOobPXAyc_^uIA znWW6pYzj-Mv81LK^Q!8@qcb;pMA|q6xO>NZ1QX8{4(~06Ww&*a7Q#M_NR<_DGC9WG_pzFeK;>g=Irpa3K6i!|1w8k`nW9Z)8 zKYOTWdats1xR|fy$eK;vv%u>7&QrtqvU=v4TgMH?!CGyHQrUufO0VlQw+s&S&h&Ln z)~iiIjMyJS zq^yr`-F~#xVg**u-8g;Xi{nQw?B8>A>z3V9lapOt7OhUktx8WM`nU#!1;yuPGgV4+ zTgQ~Hc@TW^zR_KS6N|&sd;7+Aw{&gl8Qa}Ixwms<_sIM)%ivDruKM;(jUAhnhH<4~ zLZ%xLsCs$w?h<}8o!f-F451Zq6$jr7zK-P>i#!b?qUee{EVZgqK;ZNW%m|I9`UaEY zl8afK+C)N8Y+_!uyrqm)lR;tx1Sa_U$H&A`@c)WdB!n9*YJWg<8KsD&SYq`LOvVGI z@Zeql>b-YXasT}BZ+^Anx4*$!>$+e4+6n`LwHtinQ;ML12;n2_pN7X!(CG>eOHWCI zi+Tx1pbZXBXH}?t0+PUi!I~;s3Lm}GAzZQA6|)BP8N6UF?;aTtLI{l_+c-wpJI8{E z8xlbU#c^r$7MKZQ1LV{q5*hA+nHu91f-10@OolfT98|IWSK2nT51$OciEs)X6@<{l zEIvLQ{4uw*7S3pjMv7t-EQ&p6S ztA(}v3P|6G+gp3jpS^Vd-os~)pF(2|SbYcAR}f!?9t*a8|2MF@Ot@NZ1uQdImauyJ z_Cv6(kgr}if8)%lt0#`4ygI&P+uqsf&4WX|#ul|mmQTthCXxzrO1NyPSX3{qG3t#2 z&6WwBamd&<0Rkk_^}ex%;pzP&n+^?3?Hipt(lxwb=-6cL-`>)@4c>EgrfE&{luS1) ztsmmnbaHAsS>jgYY*7SOOnPNbX)Wr7WJ*;)Y!UViy~C-VAvqqw+0H&he60Zyxq%Tm zPVVukBo9TulT#KYMQ9l4wVU;dGZcj+iY|1_NBcYtX8VBLmZ?j-UVf?zfL0JbLo*;gSX0zrl40tI)Z6{r%GU zFLwZz-}#@{R(}nv53b+%_VVT1pPs*Q_VjXjb#fQjRx{g1hWlGgdYQ5;uQ)A^NC8?& zMTPklTpkRfjoOA@Zk0|^+iqwb9h=>c%Vli#;LNrY<8z0*hIjOi?dcp^=os2%>fNR` zj_J`zX`NLyjRCi!+CGVPfUoS%Ez`tjaU;{pvr9CkRpzvOX-HBjjz?&&cNjDrimhD} z?LATgkrf1IIl3i~sa4!6Ls)cnPClQ**Ybt+Az{SG=qww%0RJF@s;(1$uTbFw>M-|5 zRK%1DiRk+uI-sG1UttOWOE?Tz*RETl4u1Tx9hP1aN=GpB&nb=}IwL7fGm zb-ccHTG=!r)eTl@deP2GrHT`>(Kb}mxCSDvCN`6oNU8FRfympEaITe8>;{*FpqN5$ z?8n8@Xr)T9ykH++!K*JVR}e|1-o6P)DWL)c=D(z-1)Hiq0g!kNK&lD20-Rs~Vzi29 z2%#*Qve^e92l(BGm<8BEqt6=KtoHuPb6Ak}F{4jNrmeK{!k#Q3YGo7X>>dkqgoISO zPY^LRgBcD>j^rXox0u!I{m|7%cgxl}0`CC}-NO&v;3x;zXg8mvjh^tTOAHLliAi9f zZH2fBpdzROt4L|=-IF{+vdcwgL&sJMT?r3y6qUXa)Fo%?n8Nnq{V1}KAT4RBaSQ-0 zP>Ny-1RfKeX9pK5^m4?yQfnDZ-ohWP@JLd*B9humE z$~?HOyt*lyQC(c2QtEolU9-3W8%?89l|`;@Gq;X48v0nQY7R$PC9IQ48xU8~2QbvP zH|aVXYTIh%#zw8B#n3U(J9hT;r!V1a{d{Rp@XgDYuV26n^d%&|e}4V_kFU_Sf~)d> z53c`tTwSiM{xS|g+iDrB4{v_?&6O{J)oZ6uUOjQ_^CJh(?^{Hdb>F6$L6b=@m5Eqv zVtk6bgZoBXHz=rwho!{ClOcUj-`G7mv9NRTEc`m>w;!9BJ%DBiusXfv*!0$8z^$cc zzFO7Btu|_!hS1ciGmSU2&(vX5-8706t6Yj5!#YY?Eww_Q&uJtUE0U$|Udi)W;!q34B#MadklGiM?2vB?>xrHt(8U-lIpdNrpJ%TWr`REC(T<2%E zF~-?5k(@6IkIknPh=Sg&)>=D;f4tVm#wh~j-bSxP951Xb_$1r8L^*rJyZZvPG44JD zZ+{YMtJUj*J^a#-2fyB`nE0VrYWsy*4VYZeQ2*`aJR90tJXYS-#XJaw1A!= zU)f&MFo-@t&(vOB`xIAhqL#@BWEPb!ma5yDTE`Jr@t2*$t3^7;<-(&`NG}$MtF*?( z?l$ufu&R_c%EfxMtVvyCP)h49rXFY~Jih<<*`p_51uScOf^+r9AAb7z^;>9C{o#in z|2|lK^k=Mox*S*03b?Ru_sLz`c2ABCn_JrI>+7p!l+<)bE88_6u5sAl5)+*U;wXzP zYil3hG<7*iA!TNFbm zCt@v*DvpSwl~!n}Mb&IxeM|z?H!vk3xd6pZL<|M0|0~vbZ1jx9)eIpiY&zRwb#$#K z63Y))x_$($cxyi_%?yBx_tXjHa~XWTlw5Erjx zkARH)5>;4Ceo|T)G-09=3Smn7iIpD!34DT);^{~5029C)bAL#A#JYGSfU_EcyWTh5 z*)0iJ1>4HjB@WX!gjOT~?g6CG_+q4~2#l!|p?6pgiY$x(ke%Y*$EDxWyMUf50x9sB zo-f7K59p%&N7l-%=|U?2eHEQ$UZEeYQuatR{kqoKuF<`{69-Ja+gp0J_D=5a9^YHv zI;AyFwDfJ(w2ZJNaD!5$QObiNNTKLD=JQI}N_v?LrD!=@4!%ldg`8b3s}}2;8oJQ4 zYHJxV)OXY=Of3yP7Gr;NV@FTt(4hlIZ{4_k|Lbqzt^D-CBOJH~{`?va0!wif5AUSv z{u`n7Z;Pvszr6kJ7uUY}^y2k1$XAbFK6?1#{@te+wrv|8nC1#DEj>FKTmu?b(Dlt>sG*S#tfK!9IdpUX zA{qh+tw>f8SIfl~6jta4;D^91I<7FJ7Rb9Q#jQ93d51*PQ)?VI_iWdpZPhY{R!raI z{^suarp{T66eYEtETK-UY-RE4GIA?ZNTsw=7_L0G@BSU@7&2%!w+rin>-X$(1CN7## zP*9;(n{ZexDXoCR<*1sB1Ln4IOZ#MlVW6tIiB+kRDqHIt2jrR#vBFf}GB`A|XL|eb z;Y|lRM|K)}=G84@^{88WwhHR{xte}K{YV+~6(#MI3PVz!EHIuKoKO~*!GkY6XoOI{ zg;@+C8-`*^WUXbDTJ!|SdAyYLQj|O{OY&*CBAID}eK4@<>>dMHqUwQ8FR1t^?eRxo z6^I3NaX@y0tpEm94jW3@bu+pES%^F%EF` zOvUPMcw7-iS2*Db^q5p80x95HqZ`q+&b_lxS(-*62S9XP?xv!7h0uyvivIs{i*I>M zfNp?HH;TlS!D*~gbc--#5w?hw-6B<2VR5^e{~P;aGzbe zaqjGm)2F^Te)O}0d(Q6Oero5I#mUia!-HcT?ZVQsD8GOxzaT0pwYhyQ93z!B;%rAZ5;|$)zb7o03(AGm{?&o0GVoRDl?wIf=EIXZ0Iv8 zV+btN{`t(h-igB~uh6qX0Tq(K2#PDl1G-h{N}-jC1Ql3C6h&x7fJOfqQ!V5GfN=p+ zOD$0|`9@$>TGy{=7%HyNCX(2N?Ape5#M13jZEt0DGq1)(=hSA>gsJ56ctTM`JoE>$ z{KG&EN<_nCqZ^#TBmMp3lM-`sb67<*ZYfRR^0wtrNyZ0=`@dYn1^bWjWyNk zk%6&G=b;kt)$QvyAK!ZbtRhqW>DAkxUj6uY#Oj^CoPDi#veT z!*f&nW~OF)yOmrXIWajkDux)J3J36@fH>#|th3q}5}btp%&bgCe0+9hW@%xOkWo_2 zD3Q{Ns({#1mO>zI=o{I#blt4#4{WuJ?C707&@#BIrg>7*I9}B- zR$7C&+EFC#$YSaV`N}ky+CWQ$B+Q`7N_Z_$#4W1OmsB=n<_V$ETFg`y(5q1a1xIB0 z2BlGpB;uM@2yQ@~)x{%jgG0ztwZ6gM%{vi>Tp0APSnK`q8U))wRO>6&VmCGxxhR4s zpbLvb7uO}9ZXchRxOfVhU_~X>VKI4uk+~R2VD-i|fSgH{LEiuaeZLUOI(ulpfHA& zxr9}utVch8ht-oiHXqzHb#T+{&hfDpmAa6W740A7;pn>2!OP7h(A7CGJUBTcy)Zc` zCoC*ABse)Ot&m3J=TSKsFw4kb&>7XD>ZbPYS@?PkPVH*$9Pb+5GCaF?Z1dsXslDA( zd)mhqYc11~h7pl|RHz>XR!d}Em9;~q(r$>_WrF=quLCcO&M{Uu%VQD@-agmXv$Y^plm5;*TBM|#vBy8nlzb2zOFH?8Wv+=tMLWEJO^H$VN$kADDSkqrE8`RX6O`|cO` zhP;Bk%aWGG5+`t3i1o>n?;k%#&uW>zvNXE7bNA_2OLDCDZ!8&JeEI3Q>t`Vwc=*!c zz32DtLMCtsmfuqo`!{dyYcW$&h;FuycCcXa4E1sk5A=&qip!3PBKiBp`}xF%hNQ;E zkW*6fQ&J03Qfb5tdU++rvEw^-pXwjoF0XGlw2w`0IlN`h*`e9}ZNod-#}>40Xa)3% zbORhsFP1N`$u7{3NSmj*nnB3eQknYPQf*#ooj{4TZc{!}i!UoNlP6GgG&DK~^m_>IK?@6GSxB{Sa0mxhf!H-0{Bh$uZj4y5#@pF5 z8TI%o>kwy;M0B6L{8N2{iJsnx(2Gk-Eg@!dAixEAF7MzxSVUn3ERU{clq90Lxw9LEEj)tbWeuGs*5N3|A_6e-oX?o9)u^9Vi7ViOBk0a zNT!IBbHuSEUR)NenJe?z^>wYYd92!`95L)FNX2-lj!3OY&zGUjTB5Af4uW%q4uGb4 z2JNiKRJLDaVPG5`hAf5U+Bjmle`Ibf0TQ(=2(?8g7t>klWMbJ`>i{I`piq*s*&z{- zze`UeLD!CkiJMJjs!Cs8u4I4cfUdGrebi9$Suy5wUh_ZC&l$1HGfe;hr2q4E9TM-x%TS80_vE z5#XEX9lA8T>y)W?UZ(G>HIK=g zhNO){)r~`C(pI{-rBc(QZl6=M&Ty37MU@7ilvb`sQH)XoUlzWpr8Z7!ZIxyq8Jy3I z3J^FkM~F;gWfh2f2DVFUTEe2qp;45mB|XeczmP27P%`$lVa*Yu-Z1w=xVQm`21f!s1IFP$ueY*BO)>WicI4{K0PT*kXxcL z^)6%=D?ycnnkAH133*b_umb;BI);6OJYjl)C?b{NafrFo>Kv0tyjs%V2sUaykZnT+PMr%pe9_z2YNUw(j=;CJw> z!TD=gMQ`dqJU_kD2LMxRiLCVwt5DDW;XlXfT`;b1-oJVE-(mG2uzKOZ?o*4q4)55y zduDdq#8iV^749EmyT;Dl(aX;x(%UWC!zE(rxJJ3VMgp$Z>%E%_W9&UEuusr_=YEX3HMqkp3^Aq6z@8U|BS$WWBA>m=1?t-7b7uD8W7 z*lr$eHxD;8v@2!xReY(gR)6Z)NyJrP^_^1CtAG8&FF*hAS33azAyDzdzXhvHOM=T- z{ruKv$N^4VK7I&dL7yI6gtpawkOL>DCVKj+EBW}c?bq6SIQcl+`r2>sb;b~UBfNm) z{CpC;!Q60-u($IAn=~>qy@XL!CDIDT+De|1BhYm8&+R#UdHdcA15bnY9vMO~O zg08+}20Jf#Y)vj(&DC@%O_Ordgs5S#fU`7VEM)6(1C|L|09qgxWMfjHT&x{dHP1w+ zS4O2*rWMu{a1B`LD&-pnC-#VCrtDnE=CjhWxbSyItqqc)PiU^AXR5VRtd&hDtPSAf zvk|78PT1NbI(cAmkKo{*YVVe6?@qveqJLyjcw%`9S(2P3f}mVf3Wr{4%A#q~^W+qI zZIybEE9=Q;>JTdZql=QsBJ4G|1yMp0N+IQuo?jD|$P9vDS9FnUAZ4|Etc^!{G?5QO z+bEJGo!&s@b>s`X2qldv5bfu+vJ?aK>h?@l9b45SYni5$H%4bkLescprY@CQ4Ja~& zMjA^4(=lmXPfoGaKPoqhP$tn1${NNz!*d;cQ=*9s2cLKdz{jK&J9)!L!+pgXx8Hx_ z{K3ceAf81=WxyWM#v1jn>v}6!ch@in7#6H@T?cB!#xO4!J|e<6hq-&k1_Y;tMUs;V zB{|fpLWZ1Prebq+0%4O#Xi&*pTN(#@J7)%ZH?^4u>r_ojS>0gI@Tp^`?|psm)r%Jx zU@iG6|I44?EA;n>t9S0c!|JtfuU)=<>B5b3CoZ2j^x2Vp!0Mr`b9?7EZ5|$3Vq7y= zfgb)&>zy{*db&CUc)LcyBQ+u@EzmCs3aCC_v4Q?ckrC-2(qr$5oK-?CsDRaD2~%up zAKkI%%>LtFbPsLgh~T57WeT*?y3V$t9cWt>a_Vx*6dXlcjd4VY*{gYqU)z(ME6grZ zYFlRI`Y|x)5m%A9A++Ks43jmD6ToU*7C$LhgyAfXR5vsT=^1AxRNGz00YlUuASw9SJlj#%>Y%)r{LXJD?257{@oFetV(o>Uc= zA%wgMj3m-&YNoi0$~NY)ni#@1QQcVOk{?7nF<%)NSC*J9iOCT7MBzH-k%}}0Y-4n~ z03!^KFq%tHu2TTTF(4-Zt)q$NTSAhEPaV5FAUMx@Y-D{C2*wTbBrc9p)St}BknaP&%u%U}vsUFrE%s~m!z zeB(SrQrFn~JNv{0N0U4P5@43}{>QfOy}#z8kF9-tqXGhBt*xO>?{2+*ad8Q81m$dlkFBjgJjy*hXCq3fIdAH?RL2R!?3& zaTr*=cxdtX&Tad*%x@YP=r9<0jPg*Q5Etu>j_X}LoPq;=5~4ygV!|^+0tx=Ui6KF$ zP#{ky7NOUgl$1-QRumL+%PVV4mf@a(O$@pv za0&Ig_F1)gLZs`fX&x&PH^Y65$#3Z#+Rv4Bh9{LGv>Lm1AZx|=2A~zH`{T3tuogwt zoXgT;K5OjRF*tpsrna9}Rtxu1B)WNJI@pe5-P1qrOAe}DlNn^L%DjGs~x3Pna$&eSn^I%i83LZw>Zbq&5li@JNd@0wDofKiS!9gv~uwF4NVFNPquOL-C*Yd zo4HR`+1fjJy150|*}86Y@o{tYgCZI9IvnhL?d_lg@3MByMmt+S?Dg2dVc8+b$2T!N zA}cN-pOjUOHlw(@S)s7hRJSN=%=L9$tu27)+}QB8@sX|LBb%qjHjfTX@7}TZ&aJOs zK70Ay%U3Y0|KT;#&i^mtIo)XKLjTH(DQi6Q8 zw!t#r(zSz9tW3=o);3Q=ilnl-4Rc1daSFY00u@HF{LErSG2h77^tF%fw+t*Q8^#LR zI<}-8o1R5HGqj!KDAh~4Pej7(;*sHk5=zSKGR|`$vYx61;<=y#k}cVv++xV;o()t!-V_uCupVXYcIfVQ=r^ z?&jm_;=A%=8%H~DI~xy(KY#dv4OS+xK54bq%^J3GE}?$@N#PNs_ykDrv)PpzvDm=l z)X8Nnrsk2ck)2!S4$aN%9~sBW6LcK%n*El#^yL)X64f07uP)$w9PbUr5&0+Ce;pMzC-6U)|zJ6)s}3! zA~vG}3*A+90}A70$Jjwb*LHRD3>DRfc9f$WEUxNEq$=Wbf@8~l!Wa(Tl;9+823;Rdkta}RZtC4yfdRe7QeA7Qk{fF3 znpO2J>iU+knJt@lERIfXmTMYo8(OodB~G5fAu(x*>3IR;j){$qs;qnNeLTY$y{M zYR!{aC1~y4!4@{7K_ssq8lE}Eu4*CXiRAhbMdK(-Y$E216UbbSqO;aK)6|Rk*HK;D zmio3WIn4S>`9OtYs9Z6WUecIEt4(L;~>GC8djVOLtYDU;Jy zUO!V*GsJ7yRArdMG@013)sfzi-CC)afvEW`cdTRZwD2gYVcC+Ft3?%H?Y$fe6y zkDfT)WU@#VwRMfA99mgyGO4(X!{&*KODoFCd1`G#-_Y3HmL1!7E^ghiFtcfXcyzR* zv#X{?UXY(pOe4m{#`}2ryE=J6#M{Zvef=7TH7jjbt+0kh;%|PldgUi}jt;&q&Vja& z33Un#4^JbL%SuZnGFg++I5<4CV`_5m$k2|SuDSm1`GKDK=Ei}>`cAE?Wom58t?OT7 z@9O8bzx?s1Ur=O0k_E_Iwr)X~#ZU11KY~?kUA_GJ8yu{$Ea_WbThe2{jd8%4lUGk3 z`{LM<3kUX{SlGRLW^U{FjI=@otZuY+3-k<+4Np&u$w^D1Wf4m<(@QgmjLeLZyqpSP zH8CkCDk_6WEX<{{skF-IxJ)nKXmSpd%U2f`@fl@eY9XImD9EAl!ehyCX@!Ms1*KS& zQNX8zR>7;2HT3D)rs_?T2Fs?5907$^Jve!=-ZYh2ATHxKiZne%mG!V4k0q677E1-{ zE_KU9`{>yC2_U;L^>P7_h6Ef4hrgKMC(==B%&Z!?S zQw=i|Lq#=%0BxmihFv$#ZpO6Wy}5nI&bE%O?!KXs@!6Kv&hEb9iOEev!xPi9n-3p7aqY&JU)}xY z`i(EYxO(lzyZ>GO{L<0GhbPC!>NIL*X=zGgiZ=xG9Ng_TI9jiBw6=0wyVCZf->v!J z{WU9B*g$}8!v;5~gWB49L3Nox$Y--F7Bwg8a%hqpg2%Uu8Ir=R~?Vz7kaH?N@&@c-Fg zU5=~&9;*;wxpxhtD`0hLJK!Bwk6t)%@Wk#tduBIp8=sMs3j^JPTy5Ne)#%W)q?jDU z)uhfRK6vV`30i_$=LlIZ=3*Zx4f;=`WyOfkwl8{VI zAr=ubOA1QFxy4n986}irF{?^1!BEdKp>7_o(e?_Zmh60SO>N)s^bu-_f{@MQ$t>B$ zvXFS1q^>VD2g#}wDuqIIw`pK!bKg$%vg+Hm7V%Bx^1ia_UXEtGNYqmx?4k-f^0*c< z%b3onk0kPf5=)~na!O*R=BXkGLPCBmv9LZqOO{bwkCR%cCKPFk#O(z_bBVl*Q$NgW z7^&^uX`VdPHhI)Ce%R2r+ca{((7z~cnyNNTR_R8WvQ7c`&!$c7lSgsXt@E|*TMYw? z#^JrSom&-c^NP03qNZtK;}pMPvQ*J8Xqe*b##C)vjDw2`GF1MDN~xc>mk)o;`a7W9@IgzIx@#>Cgkim_bx7USlWsUiW6g! z++93u*V)^yceLB!1kggX+-kMm$`u<{ue7tac6D;{fktR}cuG<-1v(xauBxuCv!!{o zr)%@@z`{`9u8!7Oow`R|W08PlD6H%29>0F|&JS;Xe){iWqOSC1e2^x(l$d-m<0-?nXHR#?LIbMbez@d$8_ zhz(0mh^7FjgoONzGzNuSo}I-+4iF!g9T7nUi3KVs4o?27tu{J12gJr_MaN`BMW^F$ zD7mHmxiquAoZQ6_!+-mM3IOOrqMJu8IAU`T@4Iy=&r#+&CkwAE%TXXo9vp zZYy%j3iX&kH;t5_NZ6KDQkQ^67F1t|oOFPbuBTUZXO|mO3)C5m`U0*ADyB5Pi7v4S zbR*K1DQWYh!ZO=5yg0P|?CAD$Biqgl%%2?IcBW_MNMp~ohVHEmJ=-*`Gk9(t**mf8 z!o;pm+sF5JPahuKd~#sR@wTbGtrL4%$M@;`cGmaoz>%A0a>mSo!W7>dwjvv zyJ>i4@7#_f2ajL8^u_HPUw(7%-jgR_-`~Ig&SUx!ik3Goo<4tg|LKGKkM4bY_txz% zuiw1=B{eSisab^fxz+nv9dJEi)~K35~p~PT8fdG4m_cvTEIy&5O5geDlrSdru!O?F#^_ zxcY%rp!9zOt53hW`}o#Z*bu}f%bm|I-UKu7)X8fnj(>LO@R@zEzudKBVvbYD_IC7k zv+)8}W3Z7If&(Yhf*dkCJBvj~p`jHJ9F&Y1D>!BwH->y;yBA_s)w{ZP~OcjQA_~hOU7HQmzoL zPb_{T1d78G3$thvuBAN?ZM;AJ$_fPFUxBbv%=NY+za6yEQt(nIXu4oJ@u*>>pC92EI>9UosfF}~|0gnGKB5A@6)ZX4TU?AzMhyJcqQ$wQ}a?A&)| zZu_BqhtHop13#kcxY^)<_Wao^nDsn=^ynr09UeXS?(u^kUOf5n)w4IxpS*g!^g}51 zJ-PSb*@Gvqp1geh^yTYkczyBRljjgdd;RRiy91Tf5EbWa>$Gn5`gN-}toU%vCm*d{yUKd~TKf&_mJsXd6%rPi5}QEI zE8vJkhB{5RUOQxNn(4A^wHRkx8pl<#)=HL~RVuDk8y9ySe0U!k7k|!FkpLiZ1yB)S zkrMp1(E7LK0MEX!rhRW;t|x*WR6zo6D)C?zSH8 zw%)*Ms9z$O0O(o8M`aUJi_+8RDM|V9F_eISL~rkC`5OQLd#luAM-n^V;!l$t|h z@)FX^@=N680ukI;q6rK-N1K#g8A)Ie^MwLcyJcusEQyuNR2zD>3pE2QX(!AbDpX6= zO&-t8kakO(=j5h&k$y~JoR%9V_^NKMy05gRmnQC{RkgF0-r32JcHlN=E4mRXv8`Z% z(81iHq4`5|d(UrLJiGJArGsa#?>~Lz$b~NtpTDvD*roYBC#QBE*|P8S*8OJ|j$Yh# z=o*YVrECodm9e-rOHaOTRw@lSW3ytMn|=X3kc&Mcmq-*;|y_o?wMhezi3?>m0! z^BeciUA%GP)MuBke0lTw-5b~L-23{;lZP)}FHx7j|L*aVcjOJY!9M!q>lgp}!|Ol3 z2DRh)kFQ?7efjF;qo*$)K6~@@)!XN9ethx$+vneX|Lo-t&tLuY>if5F@_qi|_4DVi z;Zpq!rs{t_*pkM6^h+cOU*EfPJ97GSX-^JS+ml5 z^-61ddyk-y1W(`SKv3yOOo5=u&@kT9zGI+kcc*!aQ9sVB&@zg|bQ-@fpKWRFz5nf_ zUw-`gUw`=nz==!%SpAoue*sqU@IQ>zJ6|uQ0XJ`9ljZKE&u^W-aPu_MfK#6zId&eY z(c-~fQ(HuFu?1->*jIJCV0$|{X?fbyMq@iM7k_&FV(InOi$4Hw2$&F+diwnJ;}_pQe)+?bS8tzw_x9O$fa^~$UjO{+ z&G*lje5hYNdGhM%6JQm->aSls$BH!6QJ^}7u>1t3KldL#yZ;D?J$Lf-?8J1nP?A9) zdAfRUu(DnKiPg%F*REW#e!~VA51%kEzi4mYxPU+cF^$FNV5fE5sGqK_=~qd+%S+YF zk{VWNH950bz>^)=cjU>#$B3oK0TAJl0|2OhX$bs>aQ)lj>T}pQ!e;Bs+t_6J`qJgw z7e2jt2HIAqFCRUA;oy-odk^oL-cp=Z=w#*MY40285g8Vc6djfk7nv0mnjYwv2r_`D zd!!rOZ~fvyWQ~j@=HxKh6|zD)ub_y-ESK=O3QmQrsGuS_F*`Yll9N+fRKzVR7F5fP z&>0|6m@J-JuI)%lXN1L3@=L4Z(~4;&HAQ90)f)m}{fq!xSf<>7?NKXV>y6Rrd3<_h ztzTrecSIJmsxdjc!p0*uJhfP17=;uG2isdUop5=`NwM;kn z?$EYQtISi?Ewieg1!dPxY3rPRU{Tw%y=&%(abWxSj#JwXUOM*aos$>uocZkT<(rRg z+xNw=+&)z zPj7zv@Y>h+Za;W>>*2G{Zr(lj#jQ&>zx^B+*R6YJKf8M6+ENnRK|LE(NqDVYH?5!}mXa_v+2lr>~zp zMZ|vj=<%}$4Q&iDeX0PDntglbwt8dIwuOS7&#~BSiZLCc>%Q z+bbn5y0C~U=d+uuxUGunF0r76S5eO{S0J^c<(Jp08_%CU_v+bm)c$W?zQX<>BK&gJ z`X2%nKm32N`fr@T|2NO-=^I=wk3eC4^!h#&*zUjl=3Dfvo_~G!>7B10Az`|D?VC$i z{*2Yrr$0Y>^wYzK&L29wuxU#{Ce^{p$<@}|dt*p=P*Ox_a-d(Fk7uNpN0_%qSb%R# zbOeE%S(HyLE2fq6DkLg}zD8D8BdwE)HGGbgOe#o>P0vctr%{;n(~z8$y?!6+e_iaj7w4kXURP9E{#o#qxw80EF;WUiG>$a^2S*f>XmS&iM;1R|JD zMPgNpn}6&I8*leeB1d7VZa}ta=GXP%l*-ytie!B4fWkb}*tbJ%nbme|Y8%;Y8r;z| zuwB=;y?y#{*X*&T!Ck#`$9kp@Y+5`wIJfQglz4MNW^4j|UzrXdCo8-M|qR|)>5Ty6sd+%lFy$-!g2k9L| zQB=fkqDEs&G&U4FAiWR6%rL_gx|;jmKYrh59-SZtV{((V?!B*TopsikGiM%#XFkt9 z`|PvN-l+SLR&NABo`}xTaXQ|eoSL45zBwacOmnALoJqzs6N=;vZEue ze`e5&w>UGvl|2d3N)!&Aff`|}yB<8geC|?BX_b#V1+nKgZ$u_0If<=`GSZrG)7rKb z4t0k5nr?1RvDCtHC!@N0sw>M1z zvqBAaR`8NlcntF36UbkHmdk-A!6eBq?O$%u z`{-l&zkVtwA*rXKW#{c1XJ+ZHtY(;$nxm;>tYu=WV?*(Y%}Xq5@{G>*ODv4et<9=A z9GzRAQ+IS{GqC)w{^;epqnGNBTtqxl!U7GM=d3RwCSUM}+ZY&xBVXOhmC7#v0_&+@|J053ls6}@enWjBjSN^Vw= z*{UwRMN?76NMGB<(=|3MC?`3-Iw`R>C@A0Fo@!(iU}Wg&?HPXQ{58fTdtvq&e`Xf@ zS14eLOrB5-hTYXW%W8|un<{JSN-7#E>T1jDi*ic~a!SgJYicTXA*yFeVpecq zOhi~>Y6=|D<4vF*n7LS6dm5WKn^}9ysac837-+){*dh?8>;dZk{8et1BJ9b~a{|?=5ON+I0L%b?e!>w(s_w`o8tt z?Y0Z;hrVk^ee_bt$t(B2xpe;u;&$8{{P9lj#j6j_U%qqYYRApnkGr~uMuurD2EyP7 z1URPgDn}lP5NZS)K@l+~YLNY_hLN2sYyLDFh8>hu9~6xtuONbr#P8i}(Fa#Igscj2 zUCrtmAi z2rG;X-x(N~=i!xZX%(fX@9ALgTaZ)M(={~B#KMk`d$@>**O2_Lu?kRMmN!`?MeD-! z&!Tmn!Gc^BOin?rlB}}FNLG7cVucPcbnjvRoqN6Qw;x{r;TBQ|T|9mGK(nWdt0vN) zSh)LoMTLhXrX=TN?bw;0SKe5^?`YfCCyso5tnEZwOWWRt=9;qVvVu}X_oy$et}m;q zE3dAvsM}SudvDW0_~$g$x0DoCCnsiwhQxYPLL)*GA|p~99Q|xXXRjsrP++`FjKKexN|NZBd|Ne`Vn3%Ghtg)P|fwdK-q`0BJZtvyGKknMS5AGdF zd6mh9wZ)BX4TsL|Idgce1bhT$Qtcs43MmL z4c&VrWVOA!{bt9tOV=-+ZE32vHZzlxR(7Okg@PO&n-`w0yO$|%05G(tDPc|q>${9<^ny&v+*2R*Y7{E|LD2Xm)p<%(9!;6=*a;6 z$sps_!-2b9qmO!N5Bg{iddBbfPIL`S^^8pS46%mBXU1v#k#Tn4z$EM+-N-l6J3!P42T!83>^{_7-*Tko=($tpFP^^m&5>_f_p~-v zHC2~2R+Q8i=eR^J}GT{v3k;TeTc!0R?CZ}#UAlJX%8z$% z-Rrv5(K$HAgb@gJ&mgUDWNK)f)j!JU$HB6ZsZko6#^6oRxL99ep^42F?EH+5OpXqX zj}MJACZ>cY7vyfh3Iz*l_A;OQ90xRn37uE*Kr;3wU9d5VI#)ID5fPqC!fsa6EUL~|AqZAO^t7Rz%seF{GaYmCTz%Ve;yDw<_7uylf2HOs~(4~sX= zWHTq3Od8hX45*Z#bb-sB<6t&qF2iIrN1R^+fn-@lET|xRL<7)R3pNY}t|E{`!$du+ zt|l7rj*XSqd9D3RtO8N!0KgI}EK;-zCF&e{NUPW1mI&`DK8FkHXk&DoXQD(9S7hw~4rLqbLTxp!K;px#qCcLeBURAqWN^5t zffaNBPuK8>;FQedqP)zC+>ElFc{RoPwFoU66_$h&>>nK;om!k3z!*UNRUKd@t9VB6 zWtKREXeHGEl2uY=C0U&rA7PIUvB2un{)xxEV0Ewq%d3tjH?Kdw`D6FJ_RHta26_jm z$ZP3oTEP|2!znZ|CZ{N;E;G3}EFjU#C4}M{79NxcfYTE5GE#_O$Vt@9_~^8Zq`ZjW zcz>UWsIcV3*zAPZ?68oeAph9N@U+B)0%}ZFXlN>h5@TTCEU#c}XyoSMMO9KZ|I3G4 z*MZfKx8dOMXP?RZ1u<0rx@FzEZMr&E^))SbZa*F#n1C<@fjl->0DBR0T7a!^78}M! z7;v}@mH^IaL=(Ocxmcdu6?`qs4- zbO4A}m|HRXL$VQOTX>#eoyEh=fl~qtM^l#OXXgd{c^t1^T%4aHwiG65jPJhtJ~1If zTh~-tMpac+A8{iM46IF!?Mw}AbTp0hbW9?{skd+3ot|Qoauv6ixWmL*SEOzsR8}-d zJAiOeKnPV7u!=_ptfH)Bl{5vsVinr~!z`q`!j|8YzR?HWLmiI>?%ao5eRSh0$*RAX zpWHSTWm$ck2lR9br-tuHrWVA6Wd?f32KmHAho;9zWhGN{Q{wXwx-%(0H#?&=DLy;M zFDAezIwCX~{$r_0h>28yR9`XCI}+myf&!9!ed0XaBMl8))YYxGNh3awyNMY^>d!(>McAR~GcF)B!{w{eg{l zr}6D0e-o=DsG=nmahG_w2?B6S%p(x0P&dhf_AH+8S)>c#arq$j(ZkNNvKkv37exgP zRb?GReG5BlR|^w+V*^V)ZDTDBy{ycf;@4Ywcrh>S=7` z0!j@HTmh=0qM4k$iH&WLy<^zsEt(Qix?8s51h?u}n^o4WlU}z@Qc6v97DTT{ty(M?qR$dETCajJo8Q!XTd{SNjkz*C=Xac2;_2 zY;=yFPn?%WWKbZ|nHHv}mW2eR;7pc{>hsBG2rmim0{x8}6gP;;e*8aM){9B%Y9lpjP4ClzSz_C65tBH);MlY&-V_Tv z;DkVcp7RE%=y?-V^ng{wr6E1i-%^uf$a*DLe@6S=X?*+0KZjN5005O_6|nN3EiOI7 zkH8a*4UeAw=4^OKqyqev6tzqYto5`_pt5SH>6jQ<)K@q3b@wBjAWR?F{+Q)*U;qTD z5UtONjo9BUSBbz@Q$0hp$NfUN+Sz{xp@Z*sArxCj$Axds`ndYYN~)^L8yRXld)h}N zMHE!#?Q1MOT$s^F4axTNjPr)`vwvzrY+*)PMSN^NSaop@rBJ9*QCX=erO}buULH~I zt`Rsv;N%cuVNO9YGIH0`cU9N0-@YA(D4oHova0PTpDRd6=*dbOeIbUUms>yoL_%__ zVsvD}?VES$v?+KLlUs_j*fC_X;jQsvZUJin;Y5#FUdZ8!nuzN~M)!KXUK3G50uXs{ z2vM-2{xkSodCj*I`0nriVXQ(ef2jkAKqXiOsQj6k=Sxcq0wiSP{`Bm{!tDI{Gv`AC zBa{_1Ww)s)$f{|o>Fenj0oP#v5TtX34gjGFms+@g|Fks!Y#!@14(fk^)lt^q$W+g; zh*g-aI&a>_!HNDykFH<366PPSDzB@dXsWN_7~qzW8CzbN*HT;5nwwG^9h4Q~3lE%} z$dK&t5O}KO#>W3^<>&U{hL# zW`#I)GrSl4IV=i@1r(8P2^;7?*Lb-|%sZIDi5k#~>Yo*W)ss89bee@qwZNYv>jk85 zSUv2QV>JElVed}k+eiMvtiBSbq_Rrr0DL|qByI@Sq^O@^j+S`LR zDru`IY3b`4tE+088JQnHe4NW-lm3BNTmAj{5+v&E%=AC7wi+k$T!7W5!?Z_(qxX7; z?htZy@IIokJsj@r1goKbVQTXFdTKTnhLkX$jP#iDqV!$mIs5X{8WJOmsA2i3ab>9q z<XWTOhHgkI>kHQ-6Pi2)K@{l za;t=av5Bv#dBFOO8WP)#m6dG7H>rR2S1CzxH9alMf}GOct^p2{Jq=K?(>%?B6n%kn zJv@PMcZ0LYAzV9z>X6XQgLL)~))10-epl6`f{uyspYy&+GOii12c;tbE{B^ZKmp)E~+ZF z8`mj(_K}2)q-I!f{12CJ;y4e3M#ns|fCH0koax~FgxiIudwOOG1ySo^(8f0C>otVH zJhqSof|d0OI3XJeKIi!m7ldCB3iyP#8d3O*KNrCQ2E6{ke@VFt#R;}M817(Jg-iA- zI{@Y;ksScD_8g=rC>1@tFCSszj{UUw?5BlgT>XqAYPlA0_ z4WW5eG|i38gZzRopTB@}H}Gr4*#rnxunHpp)PR+<-p`R-}pbHJg>lB>-D&{8<0($|2gnhMtfc~_P)`^oW zT?olO^!VZE(=PhxNPl;4A~juE!ANS0fwHWftyyR=B|SH(uCerJL&@Qt=?%Gw&_(XQ6Ujh@H&*CT{K|Xt zH|mqXevLvX0GQN7H7QtLu`Po9Wn+zttSN+l>-e?)?z?LRyN?i68tN3L_e%GYaHOVSZ$SP-SXnJ^n(ce$9I{LVC z=+VRBCyz#ZyXj*iJ)KWuqtX=Qz^b8=ti7FC7+B3ttZgVcvZvx$RbF#RW_@MuuKJz( zDhqa3vdGs+zpHZB&5tGx0!F;q_t_I+!yOMYO1IN$DZ_$=3Q! z*XsYp8~&Eg-+G-tYW!N)5&h%u*buP_M8WE`kX0Pw6Wv=3z@^APN8X1wDJ6S;@h&Z4 zV`~9Q6c-y_U~+VD;OgZ|Eqiv?RaKrl{muCB5D+CZWBw*qp$V*Hl|MDbrHvA-jtnvf z;4s%e+0`@p7_qG$jdnd5@9&u!8|`}337-?ht|VC94pzg1z0!BYRn-?C-e3E5bLG*7 z;scGv`}b6~HIyBwEk01VV^>1-&aj{?ihGiWOQN@TGQ~R%HUS&kU~@A+Lj#JYx|^bc zqm-n@<}ZylZqnD(_R`X!Y>_aL-fp$=ORWv-Wj25Dm7kZ_-J7>?W685-!sX{H(fXcM z;Sqp$1Qo;nY*w+_LKIf8I>TZTXJ!Tb=_z_|S7*oVTaWMGLu3PDHiU@=A*`{}ItwHD zugg`4R^i&2IL`vPN{H5}Dcgg4MRxhBIxuP9LZ}v9J1QQ+aD$NlWd{{n;rsQ6agJp}E0<**=tX zU*8l@FDj1inwU@w4LtSrytFhuRFs`%x7$i=HItFCHZb&8*L0VXHkXyR-n3cs(@(_} zWEHAPOPMqzrXeOTJnyLSM8B7-r09EhO39IbHmeZ1FP0Wb;Yl(HvkU|*&}Gpl5tjqA zKYD=ZJFEBh4)Q4UN4G483)9ywug)6y)tCC6Kem#mqcdQ_D?W!CFGf@YBy^ zKlx;{v%T~87cP<#6^P;o!aYa*p4ER&R*Bz8z{ie1h(!%(K_+A=a0Q>JQ7`~)5w3Vi z_yeq=uL@l|UOHR>SDX_>Ay}o4^Jt@lw-wS}3t63j8qn2=oEPkgF(z%i{l;xi*TAjf z>ZDvX(+>#nOv_2GuP;5azy9>$-DkmS+pce#s}2{WS0zT~Q^Rs0S0h4lLjtp-qf4Wy z#Q{N??w;}1wxLGGzFOKIs;cmLaFCI<5*Ihp)1z2fhpMSN%E?=NE~faG55?u>v`TlD z4)^s#0RWtsUr10P9Nx3~&&eu~gAd`~Upyy03CX!0HFQ+a3usXQFbYUU!OOR^ihXm! z`$*^<__JswvItG^C&#$3Tn!Ji`iB@j{WJs$=;}la;Tie_i#Bod+D%s{U-8YVQsRaR zGPcG#zF@T=y{WO{_}-dR`y0M)YdYQ5^i50s@uIBSq^N?J(45eKOxOYJZ6oaMv3nKg zj`j2GoG}tp0Pdx`eD$S@#8(Ci(zb?L-u|AcMVWh=s!ldnpKPu< zexUwT>#nbxYmb)YH)W?*$43{12JHy&OLualnwf_h82jrR`5GAe>F86G)ts?_k_4sO zEac>D)HPh4oMLct2dR9-Hpu_=ldT%s=7(BO@Nmptm^uLuEPfprS3xORlej|0q5xpB zkiX!&*T1-!eM{$BS6=HQf7JN3t|R)#-?8y$>#MjvgEj#&fg&Iz;UwiMI)Nw{hEPR6 z20+phwpO7I06|0+LKzU6tw_t&T5@%cIXOEu0lCT=9KzZP`YOGrZ?d|H$Vpk5==o7x6EhNP8>>$4Z#=uJ>S#k*Yjf?fy>-Xx$`0(z-Mu5V zCMmu=IsXWvGEkfVQr;DvSV1j`H%h3JP|*dS2Ex!K!LD8#gI# z+$1k4rJ9nKKQJ&l%YA8{TE*n5muvl$zuNytF}Buq*6RP&FZPZD-hwE3i{7kB`|6uE zEA*paJg$kqj&J^&4!Ncw`V9lMaEd1<`gf^+2dj{)^GrI)D!I0TTt#dvdVe2xVhnN> ztbTvtilwR3=1t05zSL9LZf9;36y&=jFJpIY+0orKC->H!Y_2`tSaGOo=iZV6q@Hie z&1^_Zsfmdx_7BK*bx(G3O>}UHx3-Ul!C%k79~LS#bvIR2XB8DkT|Eyob6;f@3kgYe zneCd6&OXOad<)O>*;lIRDmYiYe8*q*&0)WlrM1TY*8VrY$?xk~i`6#~74`hfu}Zjl z3eU5M^i{CBz#>@XO^iWbogNrw^$jrxhL}Tx*n8zO>FlY=OXn||89P7+kd-o1S8_Eo z4D@nKjEgEQ$l6_3dYE9f?nG_bfwF?##raK;t4QOOlu#ZKQ4oN{lmXcuKABGLDb^0L zM&_Z~`o8K~o~jydY8tL8st%@RKIY~W1$jehX$?(HlcJqf12_wf2s1>wPhkX-*XR28 ztdea1+p{V<&+^*xO33OQgT|*J9{VU~Xp}Pug8+61M!+f#atc|!WMS&GZN6(>a%M+HS2TU(qi_e4H)@hu8Awr<~^zry3q3b2gg5}=~2 zf^*f&-zSvtskP+cS{Gbv{BP}F>-xX7|NjE3gd@!iAzDQ{0&_$P>?wj(SXsx$xWnVT zk#XJ_jYpe+4zPd#OjGo0SFYOIcu0tAs3_R#YEri`DQ?dziJ{kt7YkDZFI!nu# zsjAw@Y}fnza|u^hzl#^I@!%DOFrggIdsg4G3c31>i|Cy{TUn9+nv|=8$qB>?m>s9j z)20@tpu{pzmUtYn`sBgmkU%Qrs*I!w^i>nXKqtFsU$0cKnwC&eTF_iq)>>V%zpA9A zyky_bg67ZlO@1Ex1o?-8rW@#UH_yaxT(m>B5#XRK|wXb dEyH$#xD*I5v9w4eoq4aXu7q<{``?Du{|_6ba#8>Q literal 0 HcmV?d00001 diff --git a/tools/pdpd_poc/framework.proto b/tools/pdpd_poc/framework.proto new file mode 100644 index 00000000000000..84b5502ff7b369 --- /dev/null +++ b/tools/pdpd_poc/framework.proto @@ -0,0 +1,216 @@ +/* Copyright (c) 2016 PaddlePaddle Authors. 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. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. */ + +syntax = "proto2"; +package paddle.framework.proto; + +// Any incompatible changes to ProgramDesc and its dependencies should +// raise the version defined version.h. +// +// Serailization and Deserialization codes should be modified in a way +// that supports old versions following the version and compatibility policy. +message Version { optional int64 version = 1 [ default = 0 ]; } + +enum AttrType { + INT = 0; + FLOAT = 1; + STRING = 2; + INTS = 3; + FLOATS = 4; + STRINGS = 5; + BOOLEAN = 6; + BOOLEANS = 7; + BLOCK = 8; + LONG = 9; + BLOCKS = 10; + LONGS = 11; +} + +// OpDesc describes an instance of a C++ framework::OperatorBase +// derived class type. +message OpDesc { + + message Attr { + required string name = 1; + required AttrType type = 2; + optional int32 i = 3; + optional float f = 4; + optional string s = 5; + repeated int32 ints = 6; + repeated float floats = 7; + repeated string strings = 8; + optional bool b = 10; + repeated bool bools = 11; + optional int32 block_idx = 12; + optional int64 l = 13; + repeated int32 blocks_idx = 14; + repeated int64 longs = 15; + }; + + message Var { + required string parameter = 1; + repeated string arguments = 2; + }; + + required string type = 3; + repeated Var inputs = 1; + repeated Var outputs = 2; + repeated Attr attrs = 4; + optional bool is_target = 5 [ default = false ]; +}; + +// OpProto describes a C++ framework::OperatorBase derived class. +message OpProto { + + // VarProto describes the C++ type framework::Variable. + message Var { + required string name = 1; + required string comment = 2; + + optional bool duplicable = 3 [ default = false ]; + optional bool intermediate = 4 [ default = false ]; + optional bool dispensable = 5 [ default = false ]; + } + + // AttrProto describes the C++ type Attribute. + message Attr { + required string name = 1; + required AttrType type = 2; + required string comment = 3; + // If that attribute is generated, it means the Paddle third + // language binding has responsibility to fill that + // attribute. End-User should not set that attribute. + optional bool generated = 4 [ default = false ]; + } + + required string type = 1; + repeated Var inputs = 2; + repeated Var outputs = 3; + repeated Attr attrs = 4; + required string comment = 5; +} + +message VarType { + enum Type { + // Pod Types + BOOL = 0; + INT16 = 1; + INT32 = 2; + INT64 = 3; + FP16 = 4; + FP32 = 5; + FP64 = 6; + // Tensor is used in C++. + SIZE_T = 19; + UINT8 = 20; + INT8 = 21; + + // Other types that may need additional descriptions + LOD_TENSOR = 7; + SELECTED_ROWS = 8; + FEED_MINIBATCH = 9; + FETCH_LIST = 10; + STEP_SCOPES = 11; + LOD_RANK_TABLE = 12; + LOD_TENSOR_ARRAY = 13; + PLACE_LIST = 14; + READER = 15; + // Any runtime decided variable type is raw + // raw variables should manage their own allocations + // in operators like nccl_op + RAW = 17; + TUPLE = 18; + } + + required Type type = 1; + + message TensorDesc { + // Should only be PODType. Is enforced in C++ + required Type data_type = 1; + repeated int64 dims = 2; // [UNK, 640, 480] is saved as [-1, 640, 480] + } + optional TensorDesc selected_rows = 2; + + message LoDTensorDesc { + required TensorDesc tensor = 1; + optional int32 lod_level = 2 [ default = 0 ]; + } + optional LoDTensorDesc lod_tensor = 3; + + message LoDTensorArrayDesc { + required TensorDesc tensor = 1; + optional int32 lod_level = 2 [ default = 0 ]; + } + optional LoDTensorArrayDesc tensor_array = 4; + + message ReaderDesc { repeated LoDTensorDesc lod_tensor = 1; } + optional ReaderDesc reader = 5; + + message Tuple { repeated Type element_type = 1; } + optional Tuple tuple = 7; +} + +message VarDesc { + required string name = 1; + required VarType type = 2; + optional bool persistable = 3 [ default = false ]; + // True if the variable is an input data and + // have to check the feed data shape and dtype + optional bool need_check_feed = 4 [ default = false ]; +} + +message BlockDesc { + required int32 idx = 1; + required int32 parent_idx = 2; + repeated VarDesc vars = 3; + repeated OpDesc ops = 4; + optional int32 forward_block_idx = 5 [ default = -1 ]; +} + +// CompatibleInfo is used to determine if a feature is compatible and +// provides the information. +message CompatibleInfo { + enum Type { + COMPATIBLE = 0; + DEFINITELY_NOT = 1; + POSSIBLE = 2; + BUG_FIX = 3; + PRECISION_CHANGE = 4; + } + required string version = 1; + required Type type = 2; +} + +// In some cases, Paddle Fluid may perform operator definition iterations, +// and the operator uses OpCompatibleMap for compatibility testing. +message OpCompatibleMap { + message OpCompatiblePair { + required string op_name = 1; + required CompatibleInfo compatible_info = 2; + } + repeated OpCompatiblePair pair = 1; + optional string default_required_version = 2; +} + +// Please refer to +// https://github.com/PaddlePaddle/Paddle/blob/develop/doc/design/program.md +// for more details. +// TODO(panyx0718): A model can have multiple programs. Need a +// way to distinguish them. Maybe ID or name? +message ProgramDesc { + reserved 2; // For backward compatibility. + repeated BlockDesc blocks = 1; + optional Version version = 4; + optional OpCompatibleMap op_compatible_map = 3; +} diff --git a/tools/pdpd_poc/generate_proto.sh b/tools/pdpd_poc/generate_proto.sh new file mode 100644 index 00000000000000..03f40c70db4312 --- /dev/null +++ b/tools/pdpd_poc/generate_proto.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +protoc --python_out=. framework.proto \ No newline at end of file diff --git a/tools/pdpd_poc/pdpd2ir.py b/tools/pdpd_poc/pdpd2ir.py new file mode 100644 index 00000000000000..af8ac96a3066f5 --- /dev/null +++ b/tools/pdpd_poc/pdpd2ir.py @@ -0,0 +1,255 @@ +import numpy as np +import ngraph as ng + +import framework_pb2 + + +def download_pdpd_resnet50(): + import paddlehub as hub + + module = hub.Module(name="resnet_v2_50_imagenet") + return module.directory + + +def make_ng_node(inputs: dict, nodes: dict, op, block): + creators = { + 'conv2d': conv2d_creator, + 'batch_norm': batch_norm_creator, + 'relu': relu_creator, + 'pool2d': pool2d_creator, + 'elementwise_add': elementwise_add_creator, + 'mul': mul_creator, + 'scale': scale_creator + } + assert op.type in creators, 'No creator for {} layer'.format(op.type) + inputs_preproc = {} + for input, input_names in inputs.items(): + inputs_preproc[input] = [nodes[input_name] for input_name in input_names] + return creators[op.type](inputs_preproc, op, block) + + +def get_attr(op, name: str, field: str, default=None, dst_type=None): + attrs = [a for a in op.attrs if a.name == name] + if len(attrs) == 0: + # there is no requested attribute in the protobuf message + return default + elif len(attrs) > 1: + raise Exception( + 'Found multiple entries for attribute name {} when at most one is expected. Protobuf message with ' + 'the issue: {}.', name, op) + else: + res = getattr(attrs[0], field) + if dst_type is not None: + return dst_type(res) + else: + return res + + +def conv2d_creator(inputs: dict, op, block): + assert len(inputs['Input']) == 1 + data = inputs['Input'][0] + assert len(inputs['Filter']) == 1 + filter = inputs['Filter'][0] + assert len(inputs['Bias']) == 0 + assert len(inputs['ResidualData']) == 0 + # TODO: resolve padding according to spec + return ng.convolution(data, + filter, + strides=get_attr(op, 'strides', 'ints'), + pads_begin=get_attr(op, 'paddings', 'ints'), + pads_end=get_attr(op, 'paddings', 'ints'), + dilations=get_attr(op, 'dilations', 'ints')) + + +def batch_norm_creator(inputs: dict, op, block): + assert len(inputs['X']) == 1 + assert len(inputs['Scale']) == 1 + assert len(inputs['Bias']) == 1 + assert len(inputs['Mean']) == 1 + assert len(inputs['Variance']) == 1 + data = inputs['X'][0] + gamma = inputs['Scale'][0] + beta = inputs['Bias'][0] + mean = inputs['Mean'][0] + variance = inputs['Variance'][0] + return ng.batch_norm_inference(data, gamma, beta, mean, variance, epsilon=get_attr(op, 'epsilon', 'f')) + + +def relu_creator(inputs: dict, op, block): + data = inputs['X'][0] + return ng.relu(data) + + +def pool2d_creator(inputs: dict, op, block): + data = inputs['X'][0] + # TODO: resolve padding according to spec + pooling_type = get_attr(op, 'pooling_type', 's') + global_pooling = get_attr(op, 'global_pooling', 'b') + if pooling_type == 'max' and not global_pooling: + return ng.max_pool(data, + strides=get_attr(op, 'strides', 'ints'), + pads_begin=get_attr(op, 'paddings', 'ints'), + pads_end=get_attr(op, 'paddings', 'ints'), + kernel_shape=get_attr(op, 'ksize', 'ints')) + elif pooling_type == 'avg' and global_pooling: + # TODO: resolve axes according to rank + return ng.reduce_mean(data, np.array([2, 3]), keep_dims=True) + else: + raise Exception('Unsupported pooling type') + + +def elementwise_add_creator(inputs: dict, op, block): + x = inputs['X'][0] + y = inputs['Y'][0] + # TODO: resolve broadcast + return ng.add(x, y) + + +def mul_creator(inputs: dict, op, block): + x = inputs['X'][0] + y = inputs['Y'][0] + assert x.output(0).get_partial_shape().rank.is_static + x_rank = x.output(0).get_partial_shape().rank.get_length() + assert y.output(0).get_partial_shape().rank.is_static and y.output(0).get_partial_shape().rank.get_length() == 2 + if x_rank > 2: + shape = ng.shape_of(x) + x_num_col_dims = get_attr(op, 'x_num_col_dims', 'i') + split = ng.variadic_split(shape, + axis=0, + split_lengths=np.array([x_num_col_dims, x_rank - x_num_col_dims])) + first_dim = ng.reduce_prod(split.output(0), reduction_axes=0) + first_dim = ng.reshape(first_dim, np.array([1]), special_zero=False) + second_dim = ng.reduce_prod(split.output(1), reduction_axes=0) + second_dim = ng.reshape(second_dim, np.array([1]), special_zero=False) + out_shape = ng.concat([first_dim, second_dim], axis=0) + x = ng.reshape(x, out_shape, special_zero=False) + return ng.matmul(x, y, transpose_a=False, transpose_b=False) + + +def scale_creator(inputs: dict, op, block): + data = inputs['X'][0] + return ng.multiply(data, np.array(get_attr(op, 'scale', 'f'), dtype=np.float32)) + + +DTYPE_PADDLE_NUMPY_MAP = { + np.float32: framework_pb2.VarType.FP32, + np.float64: framework_pb2.VarType.FP64, + np.int16: framework_pb2.VarType.INT16, + np.int32: framework_pb2.VarType.INT32, + np.int64: framework_pb2.VarType.INT64, + np.bool: framework_pb2.VarType.BOOL, + framework_pb2.VarType.FP32: np.float32, + framework_pb2.VarType.FP64: np.float64, + framework_pb2.VarType.INT16: np.int16, + framework_pb2.VarType.INT32: np.int32, + framework_pb2.VarType.INT64: np.int64, + framework_pb2.VarType.BOOL: np.bool +} + + +def read_tensor(var, model_dir): + assert var.type.type == framework_pb2.VarType.LOD_TENSOR + tensor = var.type.lod_tensor.tensor + with open(model_dir + '/' + var.name, mode='rb') as file: + fileContent = file.read() + assert tensor.data_type == framework_pb2.VarType.FP32 + t_len = np.prod(tensor.dims) * 4 + # TODO: figure out what is written in header of a file + return np.frombuffer(fileContent[len(fileContent) - t_len:], dtype=np.float32).reshape(tensor.dims) + + +def convert_model(model_dir): + fw_model = framework_pb2.ProgramDesc() + + with open(model_dir + '/__model__', 'rb') as f: + fw_model.ParseFromString(f.read()) + + nodes_dict = {} + parameter_nodes = [] + result_nodes = [] + + global_block = fw_model.blocks[0] + for var in global_block.vars: + if var.name.endswith('feed') or var.name.endswith('fetch'): + # feed and fetch is the names of inputs and outputs of the model + continue + if not var.persistable: + continue + tensor = read_tensor(var, model_dir) + nodes_dict[var.name] = ng.constant(tensor, tensor.dtype, var.name) + + for block in fw_model.blocks: + vars_dict = dict(zip([var.name for var in block.vars], + [var.type for var in block.vars])) + for i, op in enumerate(block.ops): + outputs_dict = dict(zip([output.parameter for output in op.outputs], + [output.arguments for output in op.outputs])) + inputs_dict = dict(zip([inp.parameter for inp in op.inputs], + [inp.arguments for inp in op.inputs])) + if op.type == 'feed': + layer_name = outputs_dict['Out'][0] + var = vars_dict[layer_name] + assert var.type == framework_pb2.VarType.LOD_TENSOR + tensor_desc = var.lod_tensor.tensor + param = ng.parameter(tensor_desc.dims, DTYPE_PADDLE_NUMPY_MAP[tensor_desc.data_type], name=layer_name) + nodes_dict[layer_name] = param + parameter_nodes.append(param) + elif op.type == 'fetch': + input_node = inputs_dict['X'][0] + assert input_node in nodes_dict + result_nodes.append(ng.result(nodes_dict[input_node])) + else: + node = make_ng_node(inputs_dict, nodes_dict, op, block) + for outp_var_list in outputs_dict.values(): + assert len(outp_var_list) <= 1 + if len(outp_var_list) == 1: + nodes_dict[outp_var_list[0]] = node + + return ng.Function(result_nodes, parameter_nodes, "PDPD_Resnet50_Function") + + +if __name__ == "__main__": + download_pdpd_resnet50() + + import cv2 + + img = cv2.imread("cat3.bmp") + img = cv2.resize(img, (224, 224)) + img = np.transpose(img, [2, 0, 1]) / 255 + img = np.expand_dims(img, 0) + img_mean = np.array([0.485, 0.456, 0.406]).reshape((3, 1, 1)) + img_std = np.array([0.229, 0.224, 0.225]).reshape((3, 1, 1)) + img -= img_mean + img /= img_std + + model_path = download_pdpd_resnet50() + '/model' + + from paddle import fluid + + exe = fluid.Executor(fluid.CPUPlace()) + exe.run(fluid.default_startup_program()) + [program, feed, fetchs] = fluid.io.load_inference_model(model_path, exe) + + result = exe.run(program, fetch_list=fetchs, + feed={feed[0]: img.astype(np.float32)}, + feed_var_name='@HUB_resnet_v2_50_imagenet@feed', + fetch_var_name='@HUB_resnet_v2_50_imagenet@fetch') + + ng_function = convert_model(model_path) + + ie_network = ng.function_to_cnn(ng_function) + ie_network.reshape({'@HUB_resnet_v2_50_imagenet@image': [1, 3, 224, 224]}) + ie_network.serialize('PDPD_Resnet50_Function.xml', 'PDPD_Resnet50_Function.bin') + + from openvino.inference_engine import IECore + + ie = IECore() + executable_network = ie.load_network(ie_network, 'CPU') + + output = executable_network.infer( + {'@HUB_resnet_v2_50_imagenet@image': img.astype(np.float32)}) + + print(np.abs(result[0] - list(output.values())[0]).max()) + print(np.abs(result[1] - list(output.values())[1]).max()) + + print('') diff --git a/tools/pdpd_poc/pdpd2ir_test.py b/tools/pdpd_poc/pdpd2ir_test.py new file mode 100644 index 00000000000000..ab9ad01ee929ec --- /dev/null +++ b/tools/pdpd_poc/pdpd2ir_test.py @@ -0,0 +1,106 @@ +from unittest import TestCase + +from pdpd2ir import convert_model +import numpy as np +import ngraph as ng + +test_path = '/tmp/pdpd2ir_test/model' + + +class TestConversion(TestCase): + @staticmethod + def infer_ie(func, inp_dict: dict): + from openvino.inference_engine import IECore + + ie = IECore() + ie_network = ng.function_to_cnn(func) + executable_network = ie.load_network(ie_network, 'CPU') + return executable_network.infer(inp_dict) + + @staticmethod + def validate(var: list, inp_dict: dict): + from paddle import fluid + + exe = fluid.Executor(fluid.CPUPlace()) + exe.run(fluid.default_startup_program()) + res_pdpd = exe.run(fluid.default_main_program(), fetch_list=var, feed=inp_dict) + + fluid.io.save_inference_model(test_path, list(inp_dict.keys()), var, exe) + + func = convert_model(test_path) + + res_ie = TestConversion.infer_ie(func, inp_dict) + + return np.all(np.isclose(res_pdpd[0], list(res_ie.values())[0], rtol=1e-4, atol=1e-5)) + + def test_convert_pure_conv_model(self): + from paddle import fluid + + inp_blob = np.random.randn(1, 3, 224, 224).astype(np.float32) + + x = fluid.data(name='x', shape=[1, 3, 224, 224], dtype='float32') + my_conv = fluid.layers.conv2d(input=x, num_filters=64, filter_size=(7, 7), stride=(2, 2), padding=(3, 3), + dilation=(1, 1), groups=1, bias_attr=False) + + result = self.validate([my_conv], {'x': inp_blob}) + + self.assertTrue(result) + + def test_convert_conv_model(self): + from paddle import fluid + + inp_blob = np.random.randn(1, 3, 224, 224).astype(np.float32) + + x = fluid.data(name='x', shape=[1, 3, 224, 224], dtype='float32') + my_conv = fluid.layers.conv2d(input=x, num_filters=64, filter_size=(7, 7), stride=(2, 2), padding=(3, 3), + dilation=(1, 1), groups=1, bias_attr=False) + bn = fluid.layers.batch_norm(my_conv, act='relu', is_test=True) + + result = self.validate([bn], {'x': inp_blob}) + + self.assertTrue(result) + + def test_convert_resnet50(self): + import cv2 + + img = cv2.imread("cat3.bmp") + img = cv2.resize(img, (224, 224)) + img = np.transpose(img, [2, 0, 1]) / 255 + img = np.expand_dims(img, 0) + img_mean = np.array([0.485, 0.456, 0.406]).reshape((3, 1, 1)) + img_std = np.array([0.229, 0.224, 0.225]).reshape((3, 1, 1)) + img -= img_mean + img /= img_std + + import paddlehub as hub + + module = hub.Module(name="resnet_v2_50_imagenet") + + model_path = module.directory + '/model' + + from paddle import fluid + + exe = fluid.Executor(fluid.CPUPlace()) + exe.run(fluid.default_startup_program()) + [program, feed, fetchs] = fluid.io.load_inference_model(model_path, exe) + + result = exe.run(program, fetch_list=fetchs, + feed={feed[0]: img.astype(np.float32)}, + feed_var_name='@HUB_resnet_v2_50_imagenet@feed', + fetch_var_name='@HUB_resnet_v2_50_imagenet@fetch') + + ng_function = convert_model(model_path) + + ie_network = ng.function_to_cnn(ng_function) + ie_network.reshape({'@HUB_resnet_v2_50_imagenet@image': [1, 3, 224, 224]}) + ie_network.serialize('PDPD_Resnet50_Function.xml', 'PDPD_Resnet50_Function.bin') + + from openvino.inference_engine import IECore + + ie = IECore() + executable_network = ie.load_network(ie_network, 'CPU') + + output = executable_network.infer( + {'@HUB_resnet_v2_50_imagenet@image': img.astype(np.float32)}) + + self.assertTrue(np.all(np.isclose(result[0], list(output.values())[0], rtol=1e-4, atol=1e-5))) diff --git a/tools/pdpd_poc/requirements.txt b/tools/pdpd_poc/requirements.txt new file mode 100644 index 00000000000000..229b3c5fe83f00 --- /dev/null +++ b/tools/pdpd_poc/requirements.txt @@ -0,0 +1,4 @@ +numpy +protobuf>=3.6.1 +paddlepaddle==1.8.5 +paddlehub==1.8.3 From 85e2c924e8deaf8eb7c200883251439d16098465 Mon Sep 17 00:00:00 2001 From: "Vafin, Maxim" Date: Tue, 19 Jan 2021 11:46:53 +0300 Subject: [PATCH 014/116] Initial c++ code --- inference-engine/samples/CMakeLists.txt | 65 + .../samples/pdpd_poc/CMakeLists.txt | 12 + .../samples/pdpd_poc/framework.pb.cc | 7018 +++++++++++++++ .../samples/pdpd_poc/framework.pb.h | 7608 +++++++++++++++++ inference-engine/samples/pdpd_poc/main.cpp | 379 + tools/pdpd_poc/framework.proto | 35 +- tools/pdpd_poc/generate_proto.sh | 2 +- tools/pdpd_poc/pdpd2ir.py | 4 +- tools/pdpd_poc/pdpd2ir_test.py | 8 + 9 files changed, 15105 insertions(+), 26 deletions(-) create mode 100644 inference-engine/samples/pdpd_poc/CMakeLists.txt create mode 100644 inference-engine/samples/pdpd_poc/framework.pb.cc create mode 100644 inference-engine/samples/pdpd_poc/framework.pb.h create mode 100644 inference-engine/samples/pdpd_poc/main.cpp diff --git a/inference-engine/samples/CMakeLists.txt b/inference-engine/samples/CMakeLists.txt index 15a795046ec9f6..bc10bfbf46172a 100644 --- a/inference-engine/samples/CMakeLists.txt +++ b/inference-engine/samples/CMakeLists.txt @@ -9,6 +9,71 @@ cmake_policy(SET CMP0025 NEW) project(Samples) +set(HAVE_PROTOBUF FALSE) + +function(get_protobuf_version version include) + file(STRINGS "${include}/google/protobuf/stubs/common.h" ver REGEX "#define GOOGLE_PROTOBUF_VERSION [0-9]+") + string(REGEX MATCHALL "[0-9]+" ver ${ver}) + math(EXPR major "${ver} / 1000000") + math(EXPR minor "${ver} / 1000 % 1000") + math(EXPR patch "${ver} % 1000") + set(${version} "${major}.${minor}.${patch}" PARENT_SCOPE) +endfunction() + +unset(Protobuf_VERSION CACHE) +find_package(Protobuf REQUIRED) + +# Backwards compatibility +# Define camel case versions of input variables +foreach(UPPER + PROTOBUF_FOUND + PROTOBUF_LIBRARY + PROTOBUF_INCLUDE_DIR + PROTOBUF_VERSION + ) + if (DEFINED ${UPPER}) + string(REPLACE "PROTOBUF_" "Protobuf_" Camel ${UPPER}) + if (NOT DEFINED ${Camel}) + set(${Camel} ${${UPPER}}) + endif() + endif() +endforeach() +# end of compatibility block + +add_library(libprotobuf UNKNOWN IMPORTED) +set_target_properties(libprotobuf PROPERTIES + IMPORTED_LOCATION "${Protobuf_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${Protobuf_INCLUDE_DIR}" + INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${Protobuf_INCLUDE_DIR}" +) +get_protobuf_version(Protobuf_VERSION "${Protobuf_INCLUDE_DIR}") +set(Protobuf_LIBRARIES "libprotobuf") +set(HAVE_PROTOBUF TRUE) +INCLUDE_DIRECTORIES(${Protobuf_INCLUDE_DIR}) + +if(HAVE_PROTOBUF AND PROTOBUF_UPDATE_FILES AND NOT COMMAND PROTOBUF_GENERATE_CPP) + message(FATAL_ERROR "Can't configure protobuf dependency (BUILD_PROTOBUF=${BUILD_PROTOBUF} PROTOBUF_UPDATE_FILES=${PROTOBUF_UPDATE_FILES})") +endif() + +if(HAVE_PROTOBUF) + list(APPEND CUSTOM_STATUS protobuf) + if(NOT BUILD_PROTOBUF) + if(TARGET "${Protobuf_LIBRARIES}") + get_target_property(__location "${Protobuf_LIBRARIES}" IMPORTED_LOCATION_RELEASE) + if(NOT __location) + get_target_property(__location "${Protobuf_LIBRARIES}" IMPORTED_LOCATION) + endif() + elseif(Protobuf_LIBRARY) + set(__location "${Protobuf_LIBRARY}") + else() + set(__location "${Protobuf_LIBRARIES}") + endif() + endif() + list(APPEND CUSTOM_STATUS_protobuf " Protobuf:" + BUILD_PROTOBUF THEN "build (${Protobuf_VERSION})" + ELSE "${__location} (${Protobuf_VERSION})") +endif() + if (CMAKE_BUILD_TYPE STREQUAL "") message(STATUS "CMAKE_BUILD_TYPE not defined, 'Release' will be used") set(CMAKE_BUILD_TYPE "Release") diff --git a/inference-engine/samples/pdpd_poc/CMakeLists.txt b/inference-engine/samples/pdpd_poc/CMakeLists.txt new file mode 100644 index 00000000000000..20d03735232889 --- /dev/null +++ b/inference-engine/samples/pdpd_poc/CMakeLists.txt @@ -0,0 +1,12 @@ +# Copyright (C) 2018-2020 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 +# + +file (GLOB SRC ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) +file (GLOB HDR ${CMAKE_CURRENT_SOURCE_DIR}/*.hpp) + +ie_add_sample(NAME pdpd_poc + SOURCES ${SRC} + HEADERS ${HDR} + DEPENDENCIES format_reader ngraph + OPENCV_DEPENDENCIES imgcodecs) diff --git a/inference-engine/samples/pdpd_poc/framework.pb.cc b/inference-engine/samples/pdpd_poc/framework.pb.cc new file mode 100644 index 00000000000000..1c84f3b1a33453 --- /dev/null +++ b/inference-engine/samples/pdpd_poc/framework.pb.cc @@ -0,0 +1,7018 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: framework.proto + +#include "framework.pb.h" + +#include + +#include +#include +#include +#include +#include +#include +#include +// @@protoc_insertion_point(includes) +#include +extern PROTOBUF_INTERNAL_EXPORT_framework_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<2> scc_info_BlockDesc_framework_2eproto; +extern PROTOBUF_INTERNAL_EXPORT_framework_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<2> scc_info_OpDesc_framework_2eproto; +extern PROTOBUF_INTERNAL_EXPORT_framework_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_OpDesc_Attr_framework_2eproto; +extern PROTOBUF_INTERNAL_EXPORT_framework_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_OpDesc_Var_framework_2eproto; +extern PROTOBUF_INTERNAL_EXPORT_framework_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_OpProto_Attr_framework_2eproto; +extern PROTOBUF_INTERNAL_EXPORT_framework_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_OpProto_Var_framework_2eproto; +extern PROTOBUF_INTERNAL_EXPORT_framework_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_OpVersion_framework_2eproto; +extern PROTOBUF_INTERNAL_EXPORT_framework_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_OpVersionMap_framework_2eproto; +extern PROTOBUF_INTERNAL_EXPORT_framework_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_OpVersionMap_OpVersionPair_framework_2eproto; +extern PROTOBUF_INTERNAL_EXPORT_framework_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_VarDesc_framework_2eproto; +extern PROTOBUF_INTERNAL_EXPORT_framework_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<5> scc_info_VarType_framework_2eproto; +extern PROTOBUF_INTERNAL_EXPORT_framework_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_VarType_LoDTensorArrayDesc_framework_2eproto; +extern PROTOBUF_INTERNAL_EXPORT_framework_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_VarType_LoDTensorDesc_framework_2eproto; +extern PROTOBUF_INTERNAL_EXPORT_framework_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_VarType_ReaderDesc_framework_2eproto; +extern PROTOBUF_INTERNAL_EXPORT_framework_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_VarType_TensorDesc_framework_2eproto; +extern PROTOBUF_INTERNAL_EXPORT_framework_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_VarType_Tuple_framework_2eproto; +extern PROTOBUF_INTERNAL_EXPORT_framework_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_Version_framework_2eproto; +namespace paddle { +namespace framework { +namespace proto { +class VersionDefaultTypeInternal { + public: + ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; +} _Version_default_instance_; +class OpDesc_AttrDefaultTypeInternal { + public: + ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; +} _OpDesc_Attr_default_instance_; +class OpDesc_VarDefaultTypeInternal { + public: + ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; +} _OpDesc_Var_default_instance_; +class OpDescDefaultTypeInternal { + public: + ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; +} _OpDesc_default_instance_; +class OpProto_VarDefaultTypeInternal { + public: + ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; +} _OpProto_Var_default_instance_; +class OpProto_AttrDefaultTypeInternal { + public: + ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; +} _OpProto_Attr_default_instance_; +class OpProtoDefaultTypeInternal { + public: + ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; +} _OpProto_default_instance_; +class VarType_TensorDescDefaultTypeInternal { + public: + ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; +} _VarType_TensorDesc_default_instance_; +class VarType_LoDTensorDescDefaultTypeInternal { + public: + ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; +} _VarType_LoDTensorDesc_default_instance_; +class VarType_LoDTensorArrayDescDefaultTypeInternal { + public: + ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; +} _VarType_LoDTensorArrayDesc_default_instance_; +class VarType_ReaderDescDefaultTypeInternal { + public: + ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; +} _VarType_ReaderDesc_default_instance_; +class VarType_TupleDefaultTypeInternal { + public: + ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; +} _VarType_Tuple_default_instance_; +class VarTypeDefaultTypeInternal { + public: + ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; +} _VarType_default_instance_; +class VarDescDefaultTypeInternal { + public: + ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; +} _VarDesc_default_instance_; +class BlockDescDefaultTypeInternal { + public: + ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; +} _BlockDesc_default_instance_; +class OpVersionDefaultTypeInternal { + public: + ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; +} _OpVersion_default_instance_; +class OpVersionMap_OpVersionPairDefaultTypeInternal { + public: + ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; +} _OpVersionMap_OpVersionPair_default_instance_; +class OpVersionMapDefaultTypeInternal { + public: + ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; +} _OpVersionMap_default_instance_; +class ProgramDescDefaultTypeInternal { + public: + ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; +} _ProgramDesc_default_instance_; +} // namespace proto +} // namespace framework +} // namespace paddle +static void InitDefaultsscc_info_BlockDesc_framework_2eproto() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + + { + void* ptr = &::paddle::framework::proto::_BlockDesc_default_instance_; + new (ptr) ::paddle::framework::proto::BlockDesc(); + ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); + } +} + +::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<2> scc_info_BlockDesc_framework_2eproto = + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 2, 0, InitDefaultsscc_info_BlockDesc_framework_2eproto}, { + &scc_info_VarDesc_framework_2eproto.base, + &scc_info_OpDesc_framework_2eproto.base,}}; + +static void InitDefaultsscc_info_OpDesc_framework_2eproto() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + + { + void* ptr = &::paddle::framework::proto::_OpDesc_default_instance_; + new (ptr) ::paddle::framework::proto::OpDesc(); + ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); + } +} + +::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<2> scc_info_OpDesc_framework_2eproto = + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 2, 0, InitDefaultsscc_info_OpDesc_framework_2eproto}, { + &scc_info_OpDesc_Var_framework_2eproto.base, + &scc_info_OpDesc_Attr_framework_2eproto.base,}}; + +static void InitDefaultsscc_info_OpDesc_Attr_framework_2eproto() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + + { + void* ptr = &::paddle::framework::proto::_OpDesc_Attr_default_instance_; + new (ptr) ::paddle::framework::proto::OpDesc_Attr(); + ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); + } +} + +::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_OpDesc_Attr_framework_2eproto = + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, 0, InitDefaultsscc_info_OpDesc_Attr_framework_2eproto}, {}}; + +static void InitDefaultsscc_info_OpDesc_Var_framework_2eproto() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + + { + void* ptr = &::paddle::framework::proto::_OpDesc_Var_default_instance_; + new (ptr) ::paddle::framework::proto::OpDesc_Var(); + ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); + } +} + +::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_OpDesc_Var_framework_2eproto = + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, 0, InitDefaultsscc_info_OpDesc_Var_framework_2eproto}, {}}; + +static void InitDefaultsscc_info_OpProto_framework_2eproto() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + + { + void* ptr = &::paddle::framework::proto::_OpProto_default_instance_; + new (ptr) ::paddle::framework::proto::OpProto(); + ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); + } +} + +::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<2> scc_info_OpProto_framework_2eproto = + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 2, 0, InitDefaultsscc_info_OpProto_framework_2eproto}, { + &scc_info_OpProto_Var_framework_2eproto.base, + &scc_info_OpProto_Attr_framework_2eproto.base,}}; + +static void InitDefaultsscc_info_OpProto_Attr_framework_2eproto() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + + { + void* ptr = &::paddle::framework::proto::_OpProto_Attr_default_instance_; + new (ptr) ::paddle::framework::proto::OpProto_Attr(); + ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); + } +} + +::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_OpProto_Attr_framework_2eproto = + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, 0, InitDefaultsscc_info_OpProto_Attr_framework_2eproto}, {}}; + +static void InitDefaultsscc_info_OpProto_Var_framework_2eproto() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + + { + void* ptr = &::paddle::framework::proto::_OpProto_Var_default_instance_; + new (ptr) ::paddle::framework::proto::OpProto_Var(); + ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); + } +} + +::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_OpProto_Var_framework_2eproto = + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, 0, InitDefaultsscc_info_OpProto_Var_framework_2eproto}, {}}; + +static void InitDefaultsscc_info_OpVersion_framework_2eproto() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + + { + void* ptr = &::paddle::framework::proto::_OpVersion_default_instance_; + new (ptr) ::paddle::framework::proto::OpVersion(); + ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); + } +} + +::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_OpVersion_framework_2eproto = + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, 0, InitDefaultsscc_info_OpVersion_framework_2eproto}, {}}; + +static void InitDefaultsscc_info_OpVersionMap_framework_2eproto() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + + { + void* ptr = &::paddle::framework::proto::_OpVersionMap_default_instance_; + new (ptr) ::paddle::framework::proto::OpVersionMap(); + ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); + } +} + +::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_OpVersionMap_framework_2eproto = + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, 0, InitDefaultsscc_info_OpVersionMap_framework_2eproto}, { + &scc_info_OpVersionMap_OpVersionPair_framework_2eproto.base,}}; + +static void InitDefaultsscc_info_OpVersionMap_OpVersionPair_framework_2eproto() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + + { + void* ptr = &::paddle::framework::proto::_OpVersionMap_OpVersionPair_default_instance_; + new (ptr) ::paddle::framework::proto::OpVersionMap_OpVersionPair(); + ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); + } +} + +::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_OpVersionMap_OpVersionPair_framework_2eproto = + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, 0, InitDefaultsscc_info_OpVersionMap_OpVersionPair_framework_2eproto}, { + &scc_info_OpVersion_framework_2eproto.base,}}; + +static void InitDefaultsscc_info_ProgramDesc_framework_2eproto() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + + { + void* ptr = &::paddle::framework::proto::_ProgramDesc_default_instance_; + new (ptr) ::paddle::framework::proto::ProgramDesc(); + ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); + } +} + +::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<3> scc_info_ProgramDesc_framework_2eproto = + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 3, 0, InitDefaultsscc_info_ProgramDesc_framework_2eproto}, { + &scc_info_BlockDesc_framework_2eproto.base, + &scc_info_Version_framework_2eproto.base, + &scc_info_OpVersionMap_framework_2eproto.base,}}; + +static void InitDefaultsscc_info_VarDesc_framework_2eproto() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + + { + void* ptr = &::paddle::framework::proto::_VarDesc_default_instance_; + new (ptr) ::paddle::framework::proto::VarDesc(); + ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); + } +} + +::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_VarDesc_framework_2eproto = + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, 0, InitDefaultsscc_info_VarDesc_framework_2eproto}, { + &scc_info_VarType_framework_2eproto.base,}}; + +static void InitDefaultsscc_info_VarType_framework_2eproto() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + + { + void* ptr = &::paddle::framework::proto::_VarType_default_instance_; + new (ptr) ::paddle::framework::proto::VarType(); + ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); + } +} + +::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<5> scc_info_VarType_framework_2eproto = + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 5, 0, InitDefaultsscc_info_VarType_framework_2eproto}, { + &scc_info_VarType_TensorDesc_framework_2eproto.base, + &scc_info_VarType_LoDTensorDesc_framework_2eproto.base, + &scc_info_VarType_LoDTensorArrayDesc_framework_2eproto.base, + &scc_info_VarType_ReaderDesc_framework_2eproto.base, + &scc_info_VarType_Tuple_framework_2eproto.base,}}; + +static void InitDefaultsscc_info_VarType_LoDTensorArrayDesc_framework_2eproto() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + + { + void* ptr = &::paddle::framework::proto::_VarType_LoDTensorArrayDesc_default_instance_; + new (ptr) ::paddle::framework::proto::VarType_LoDTensorArrayDesc(); + ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); + } +} + +::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_VarType_LoDTensorArrayDesc_framework_2eproto = + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, 0, InitDefaultsscc_info_VarType_LoDTensorArrayDesc_framework_2eproto}, { + &scc_info_VarType_TensorDesc_framework_2eproto.base,}}; + +static void InitDefaultsscc_info_VarType_LoDTensorDesc_framework_2eproto() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + + { + void* ptr = &::paddle::framework::proto::_VarType_LoDTensorDesc_default_instance_; + new (ptr) ::paddle::framework::proto::VarType_LoDTensorDesc(); + ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); + } +} + +::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_VarType_LoDTensorDesc_framework_2eproto = + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, 0, InitDefaultsscc_info_VarType_LoDTensorDesc_framework_2eproto}, { + &scc_info_VarType_TensorDesc_framework_2eproto.base,}}; + +static void InitDefaultsscc_info_VarType_ReaderDesc_framework_2eproto() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + + { + void* ptr = &::paddle::framework::proto::_VarType_ReaderDesc_default_instance_; + new (ptr) ::paddle::framework::proto::VarType_ReaderDesc(); + ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); + } +} + +::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_VarType_ReaderDesc_framework_2eproto = + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, 0, InitDefaultsscc_info_VarType_ReaderDesc_framework_2eproto}, { + &scc_info_VarType_LoDTensorDesc_framework_2eproto.base,}}; + +static void InitDefaultsscc_info_VarType_TensorDesc_framework_2eproto() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + + { + void* ptr = &::paddle::framework::proto::_VarType_TensorDesc_default_instance_; + new (ptr) ::paddle::framework::proto::VarType_TensorDesc(); + ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); + } +} + +::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_VarType_TensorDesc_framework_2eproto = + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, 0, InitDefaultsscc_info_VarType_TensorDesc_framework_2eproto}, {}}; + +static void InitDefaultsscc_info_VarType_Tuple_framework_2eproto() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + + { + void* ptr = &::paddle::framework::proto::_VarType_Tuple_default_instance_; + new (ptr) ::paddle::framework::proto::VarType_Tuple(); + ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); + } +} + +::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_VarType_Tuple_framework_2eproto = + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, 0, InitDefaultsscc_info_VarType_Tuple_framework_2eproto}, {}}; + +static void InitDefaultsscc_info_Version_framework_2eproto() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + + { + void* ptr = &::paddle::framework::proto::_Version_default_instance_; + new (ptr) ::paddle::framework::proto::Version(); + ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); + } +} + +::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_Version_framework_2eproto = + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, 0, InitDefaultsscc_info_Version_framework_2eproto}, {}}; + +static ::PROTOBUF_NAMESPACE_ID::Metadata file_level_metadata_framework_2eproto[19]; +static const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* file_level_enum_descriptors_framework_2eproto[2]; +static constexpr ::PROTOBUF_NAMESPACE_ID::ServiceDescriptor const** file_level_service_descriptors_framework_2eproto = nullptr; + +const ::PROTOBUF_NAMESPACE_ID::uint32 TableStruct_framework_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::Version, _has_bits_), + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::Version, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::Version, version_), + 0, + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpDesc_Attr, _has_bits_), + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpDesc_Attr, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpDesc_Attr, name_), + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpDesc_Attr, type_), + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpDesc_Attr, i_), + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpDesc_Attr, f_), + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpDesc_Attr, s_), + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpDesc_Attr, ints_), + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpDesc_Attr, floats_), + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpDesc_Attr, strings_), + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpDesc_Attr, b_), + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpDesc_Attr, bools_), + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpDesc_Attr, block_idx_), + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpDesc_Attr, l_), + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpDesc_Attr, blocks_idx_), + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpDesc_Attr, longs_), + 0, + 2, + 3, + 4, + 1, + ~0u, + ~0u, + ~0u, + 5, + ~0u, + 7, + 6, + ~0u, + ~0u, + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpDesc_Var, _has_bits_), + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpDesc_Var, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpDesc_Var, parameter_), + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpDesc_Var, arguments_), + 0, + ~0u, + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpDesc, _has_bits_), + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpDesc, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpDesc, type_), + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpDesc, inputs_), + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpDesc, outputs_), + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpDesc, attrs_), + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpDesc, is_target_), + 0, + ~0u, + ~0u, + ~0u, + 1, + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpProto_Var, _has_bits_), + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpProto_Var, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpProto_Var, name_), + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpProto_Var, comment_), + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpProto_Var, duplicable_), + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpProto_Var, intermediate_), + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpProto_Var, dispensable_), + 0, + 1, + 2, + 3, + 4, + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpProto_Attr, _has_bits_), + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpProto_Attr, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpProto_Attr, name_), + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpProto_Attr, type_), + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpProto_Attr, comment_), + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpProto_Attr, generated_), + 0, + 2, + 1, + 3, + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpProto, _has_bits_), + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpProto, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpProto, type_), + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpProto, inputs_), + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpProto, outputs_), + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpProto, attrs_), + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpProto, comment_), + 0, + ~0u, + ~0u, + ~0u, + 1, + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::VarType_TensorDesc, _has_bits_), + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::VarType_TensorDesc, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::VarType_TensorDesc, data_type_), + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::VarType_TensorDesc, dims_), + 0, + ~0u, + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::VarType_LoDTensorDesc, _has_bits_), + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::VarType_LoDTensorDesc, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::VarType_LoDTensorDesc, tensor_), + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::VarType_LoDTensorDesc, lod_level_), + 0, + 1, + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::VarType_LoDTensorArrayDesc, _has_bits_), + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::VarType_LoDTensorArrayDesc, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::VarType_LoDTensorArrayDesc, tensor_), + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::VarType_LoDTensorArrayDesc, lod_level_), + 0, + 1, + ~0u, // no _has_bits_ + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::VarType_ReaderDesc, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::VarType_ReaderDesc, lod_tensor_), + ~0u, // no _has_bits_ + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::VarType_Tuple, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::VarType_Tuple, element_type_), + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::VarType, _has_bits_), + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::VarType, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::VarType, type_), + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::VarType, selected_rows_), + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::VarType, lod_tensor_), + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::VarType, tensor_array_), + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::VarType, reader_), + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::VarType, tuple_), + 5, + 0, + 1, + 2, + 3, + 4, + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::VarDesc, _has_bits_), + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::VarDesc, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::VarDesc, name_), + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::VarDesc, type_), + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::VarDesc, persistable_), + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::VarDesc, need_check_feed_), + 0, + 1, + 2, + 3, + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::BlockDesc, _has_bits_), + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::BlockDesc, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::BlockDesc, idx_), + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::BlockDesc, parent_idx_), + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::BlockDesc, vars_), + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::BlockDesc, ops_), + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::BlockDesc, forward_block_idx_), + 0, + 1, + ~0u, + ~0u, + 2, + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpVersion, _has_bits_), + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpVersion, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpVersion, version_), + 0, + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpVersionMap_OpVersionPair, _has_bits_), + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpVersionMap_OpVersionPair, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpVersionMap_OpVersionPair, op_name_), + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpVersionMap_OpVersionPair, op_version_), + 0, + 1, + ~0u, // no _has_bits_ + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpVersionMap, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpVersionMap, pair_), + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::ProgramDesc, _has_bits_), + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::ProgramDesc, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::ProgramDesc, blocks_), + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::ProgramDesc, version_), + PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::ProgramDesc, op_version_map_), + ~0u, + 0, + 1, +}; +static const ::PROTOBUF_NAMESPACE_ID::internal::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { + { 0, 6, sizeof(::paddle::framework::proto::Version)}, + { 7, 26, sizeof(::paddle::framework::proto::OpDesc_Attr)}, + { 40, 47, sizeof(::paddle::framework::proto::OpDesc_Var)}, + { 49, 59, sizeof(::paddle::framework::proto::OpDesc)}, + { 64, 74, sizeof(::paddle::framework::proto::OpProto_Var)}, + { 79, 88, sizeof(::paddle::framework::proto::OpProto_Attr)}, + { 92, 102, sizeof(::paddle::framework::proto::OpProto)}, + { 107, 114, sizeof(::paddle::framework::proto::VarType_TensorDesc)}, + { 116, 123, sizeof(::paddle::framework::proto::VarType_LoDTensorDesc)}, + { 125, 132, sizeof(::paddle::framework::proto::VarType_LoDTensorArrayDesc)}, + { 134, -1, sizeof(::paddle::framework::proto::VarType_ReaderDesc)}, + { 140, -1, sizeof(::paddle::framework::proto::VarType_Tuple)}, + { 146, 157, sizeof(::paddle::framework::proto::VarType)}, + { 163, 172, sizeof(::paddle::framework::proto::VarDesc)}, + { 176, 186, sizeof(::paddle::framework::proto::BlockDesc)}, + { 191, 197, sizeof(::paddle::framework::proto::OpVersion)}, + { 198, 205, sizeof(::paddle::framework::proto::OpVersionMap_OpVersionPair)}, + { 207, -1, sizeof(::paddle::framework::proto::OpVersionMap)}, + { 213, 221, sizeof(::paddle::framework::proto::ProgramDesc)}, +}; + +static ::PROTOBUF_NAMESPACE_ID::Message const * const file_default_instances[] = { + reinterpret_cast(&::paddle::framework::proto::_Version_default_instance_), + reinterpret_cast(&::paddle::framework::proto::_OpDesc_Attr_default_instance_), + reinterpret_cast(&::paddle::framework::proto::_OpDesc_Var_default_instance_), + reinterpret_cast(&::paddle::framework::proto::_OpDesc_default_instance_), + reinterpret_cast(&::paddle::framework::proto::_OpProto_Var_default_instance_), + reinterpret_cast(&::paddle::framework::proto::_OpProto_Attr_default_instance_), + reinterpret_cast(&::paddle::framework::proto::_OpProto_default_instance_), + reinterpret_cast(&::paddle::framework::proto::_VarType_TensorDesc_default_instance_), + reinterpret_cast(&::paddle::framework::proto::_VarType_LoDTensorDesc_default_instance_), + reinterpret_cast(&::paddle::framework::proto::_VarType_LoDTensorArrayDesc_default_instance_), + reinterpret_cast(&::paddle::framework::proto::_VarType_ReaderDesc_default_instance_), + reinterpret_cast(&::paddle::framework::proto::_VarType_Tuple_default_instance_), + reinterpret_cast(&::paddle::framework::proto::_VarType_default_instance_), + reinterpret_cast(&::paddle::framework::proto::_VarDesc_default_instance_), + reinterpret_cast(&::paddle::framework::proto::_BlockDesc_default_instance_), + reinterpret_cast(&::paddle::framework::proto::_OpVersion_default_instance_), + reinterpret_cast(&::paddle::framework::proto::_OpVersionMap_OpVersionPair_default_instance_), + reinterpret_cast(&::paddle::framework::proto::_OpVersionMap_default_instance_), + reinterpret_cast(&::paddle::framework::proto::_ProgramDesc_default_instance_), +}; + +const char descriptor_table_protodef_framework_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = + "\n\017framework.proto\022\026paddle.framework.prot" + "o\"\035\n\007Version\022\022\n\007version\030\001 \001(\003:\0010\"\354\003\n\006OpD" + "esc\022\014\n\004type\030\003 \002(\t\0222\n\006inputs\030\001 \003(\0132\".padd" + "le.framework.proto.OpDesc.Var\0223\n\007outputs" + "\030\002 \003(\0132\".paddle.framework.proto.OpDesc.V" + "ar\0222\n\005attrs\030\004 \003(\0132#.paddle.framework.pro" + "to.OpDesc.Attr\022\030\n\tis_target\030\005 \001(\010:\005false" + "\032\357\001\n\004Attr\022\014\n\004name\030\001 \002(\t\022.\n\004type\030\002 \002(\0162 ." + "paddle.framework.proto.AttrType\022\t\n\001i\030\003 \001" + "(\005\022\t\n\001f\030\004 \001(\002\022\t\n\001s\030\005 \001(\t\022\014\n\004ints\030\006 \003(\005\022\016" + "\n\006floats\030\007 \003(\002\022\017\n\007strings\030\010 \003(\t\022\t\n\001b\030\n \001" + "(\010\022\r\n\005bools\030\013 \003(\010\022\021\n\tblock_idx\030\014 \001(\005\022\t\n\001" + "l\030\r \001(\003\022\022\n\nblocks_idx\030\016 \003(\005\022\r\n\005longs\030\017 \003" + "(\003\032+\n\003Var\022\021\n\tparameter\030\001 \002(\t\022\021\n\targument" + "s\030\002 \003(\t\"\263\003\n\007OpProto\022\014\n\004type\030\001 \002(\t\0223\n\006inp" + "uts\030\002 \003(\0132#.paddle.framework.proto.OpPro" + "to.Var\0224\n\007outputs\030\003 \003(\0132#.paddle.framewo" + "rk.proto.OpProto.Var\0223\n\005attrs\030\004 \003(\0132$.pa" + "ddle.framework.proto.OpProto.Attr\022\017\n\007com" + "ment\030\005 \002(\t\032x\n\003Var\022\014\n\004name\030\001 \002(\t\022\017\n\007comme" + "nt\030\002 \002(\t\022\031\n\nduplicable\030\003 \001(\010:\005false\022\033\n\014i" + "ntermediate\030\004 \001(\010:\005false\022\032\n\013dispensable\030" + "\005 \001(\010:\005false\032o\n\004Attr\022\014\n\004name\030\001 \002(\t\022.\n\004ty" + "pe\030\002 \002(\0162 .paddle.framework.proto.AttrTy" + "pe\022\017\n\007comment\030\003 \002(\t\022\030\n\tgenerated\030\004 \001(\010:\005" + "false\"\203\t\n\007VarType\0222\n\004type\030\001 \002(\0162$.paddle" + ".framework.proto.VarType.Type\022A\n\rselecte" + "d_rows\030\002 \001(\0132*.paddle.framework.proto.Va" + "rType.TensorDesc\022A\n\nlod_tensor\030\003 \001(\0132-.p" + "addle.framework.proto.VarType.LoDTensorD" + "esc\022H\n\014tensor_array\030\004 \001(\01322.paddle.frame" + "work.proto.VarType.LoDTensorArrayDesc\022:\n" + "\006reader\030\005 \001(\0132*.paddle.framework.proto.V" + "arType.ReaderDesc\0224\n\005tuple\030\007 \001(\0132%.paddl" + "e.framework.proto.VarType.Tuple\032S\n\nTenso" + "rDesc\0227\n\tdata_type\030\001 \002(\0162$.paddle.framew" + "ork.proto.VarType.Type\022\014\n\004dims\030\002 \003(\003\032a\n\r" + "LoDTensorDesc\022:\n\006tensor\030\001 \002(\0132*.paddle.f" + "ramework.proto.VarType.TensorDesc\022\024\n\tlod" + "_level\030\002 \001(\005:\0010\032f\n\022LoDTensorArrayDesc\022:\n" + "\006tensor\030\001 \002(\0132*.paddle.framework.proto.V" + "arType.TensorDesc\022\024\n\tlod_level\030\002 \001(\005:\0010\032" + "O\n\nReaderDesc\022A\n\nlod_tensor\030\001 \003(\0132-.padd" + "le.framework.proto.VarType.LoDTensorDesc" + "\032C\n\005Tuple\022:\n\014element_type\030\001 \003(\0162$.paddle" + ".framework.proto.VarType.Type\"\313\002\n\004Type\022\010" + "\n\004BOOL\020\000\022\t\n\005INT16\020\001\022\t\n\005INT32\020\002\022\t\n\005INT64\020" + "\003\022\010\n\004FP16\020\004\022\010\n\004FP32\020\005\022\010\n\004FP64\020\006\022\n\n\006SIZE_" + "T\020\023\022\t\n\005UINT8\020\024\022\010\n\004INT8\020\025\022\010\n\004BF16\020\026\022\r\n\tCO" + "MPLEX64\020\027\022\016\n\nCOMPLEX128\020\030\022\016\n\nLOD_TENSOR\020" + "\007\022\021\n\rSELECTED_ROWS\020\010\022\022\n\016FEED_MINIBATCH\020\t" + "\022\016\n\nFETCH_LIST\020\n\022\017\n\013STEP_SCOPES\020\013\022\022\n\016LOD" + "_RANK_TABLE\020\014\022\024\n\020LOD_TENSOR_ARRAY\020\r\022\016\n\nP" + "LACE_LIST\020\016\022\n\n\006READER\020\017\022\007\n\003RAW\020\021\022\t\n\005TUPL" + "E\020\022\"\202\001\n\007VarDesc\022\014\n\004name\030\001 \002(\t\022-\n\004type\030\002 " + "\002(\0132\037.paddle.framework.proto.VarType\022\032\n\013" + "persistable\030\003 \001(\010:\005false\022\036\n\017need_check_f" + "eed\030\004 \001(\010:\005false\"\247\001\n\tBlockDesc\022\013\n\003idx\030\001 " + "\002(\005\022\022\n\nparent_idx\030\002 \002(\005\022-\n\004vars\030\003 \003(\0132\037." + "paddle.framework.proto.VarDesc\022+\n\003ops\030\004 " + "\003(\0132\036.paddle.framework.proto.OpDesc\022\035\n\021f" + "orward_block_idx\030\005 \001(\005:\002-1\"\034\n\tOpVersion\022" + "\017\n\007version\030\001 \002(\005\"\251\001\n\014OpVersionMap\022@\n\004pai" + "r\030\001 \003(\01322.paddle.framework.proto.OpVersi" + "onMap.OpVersionPair\032W\n\rOpVersionPair\022\017\n\007" + "op_name\030\001 \002(\t\0225\n\nop_version\030\002 \002(\0132!.padd" + "le.framework.proto.OpVersion\"\274\001\n\013Program" + "Desc\0221\n\006blocks\030\001 \003(\0132!.paddle.framework." + "proto.BlockDesc\0220\n\007version\030\004 \001(\0132\037.paddl" + "e.framework.proto.Version\022<\n\016op_version_" + "map\030\005 \001(\0132$.paddle.framework.proto.OpVer" + "sionMapJ\004\010\002\020\003J\004\010\003\020\004*\224\001\n\010AttrType\022\007\n\003INT\020" + "\000\022\t\n\005FLOAT\020\001\022\n\n\006STRING\020\002\022\010\n\004INTS\020\003\022\n\n\006FL" + "OATS\020\004\022\013\n\007STRINGS\020\005\022\013\n\007BOOLEAN\020\006\022\014\n\010BOOL" + "EANS\020\007\022\t\n\005BLOCK\020\010\022\010\n\004LONG\020\t\022\n\n\006BLOCKS\020\n\022" + "\t\n\005LONGS\020\013" + ; +static const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable*const descriptor_table_framework_2eproto_deps[1] = { +}; +static ::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase*const descriptor_table_framework_2eproto_sccs[19] = { + &scc_info_BlockDesc_framework_2eproto.base, + &scc_info_OpDesc_framework_2eproto.base, + &scc_info_OpDesc_Attr_framework_2eproto.base, + &scc_info_OpDesc_Var_framework_2eproto.base, + &scc_info_OpProto_framework_2eproto.base, + &scc_info_OpProto_Attr_framework_2eproto.base, + &scc_info_OpProto_Var_framework_2eproto.base, + &scc_info_OpVersion_framework_2eproto.base, + &scc_info_OpVersionMap_framework_2eproto.base, + &scc_info_OpVersionMap_OpVersionPair_framework_2eproto.base, + &scc_info_ProgramDesc_framework_2eproto.base, + &scc_info_VarDesc_framework_2eproto.base, + &scc_info_VarType_framework_2eproto.base, + &scc_info_VarType_LoDTensorArrayDesc_framework_2eproto.base, + &scc_info_VarType_LoDTensorDesc_framework_2eproto.base, + &scc_info_VarType_ReaderDesc_framework_2eproto.base, + &scc_info_VarType_TensorDesc_framework_2eproto.base, + &scc_info_VarType_Tuple_framework_2eproto.base, + &scc_info_Version_framework_2eproto.base, +}; +static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_framework_2eproto_once; +const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_framework_2eproto = { + false, false, descriptor_table_protodef_framework_2eproto, "framework.proto", 3010, + &descriptor_table_framework_2eproto_once, descriptor_table_framework_2eproto_sccs, descriptor_table_framework_2eproto_deps, 19, 0, + schemas, file_default_instances, TableStruct_framework_2eproto::offsets, + file_level_metadata_framework_2eproto, 19, file_level_enum_descriptors_framework_2eproto, file_level_service_descriptors_framework_2eproto, +}; + +// Force running AddDescriptors() at dynamic initialization time. +static bool dynamic_init_dummy_framework_2eproto = (static_cast(::PROTOBUF_NAMESPACE_ID::internal::AddDescriptors(&descriptor_table_framework_2eproto)), true); +namespace paddle { +namespace framework { +namespace proto { +const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* VarType_Type_descriptor() { + ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_framework_2eproto); + return file_level_enum_descriptors_framework_2eproto[0]; +} +bool VarType_Type_IsValid(int value) { + switch (value) { + case 0: + case 1: + case 2: + case 3: + case 4: + case 5: + case 6: + case 7: + case 8: + case 9: + case 10: + case 11: + case 12: + case 13: + case 14: + case 15: + case 17: + case 18: + case 19: + case 20: + case 21: + case 22: + case 23: + case 24: + return true; + default: + return false; + } +} + +#if (__cplusplus < 201703) && (!defined(_MSC_VER) || _MSC_VER >= 1900) +constexpr VarType_Type VarType::BOOL; +constexpr VarType_Type VarType::INT16; +constexpr VarType_Type VarType::INT32; +constexpr VarType_Type VarType::INT64; +constexpr VarType_Type VarType::FP16; +constexpr VarType_Type VarType::FP32; +constexpr VarType_Type VarType::FP64; +constexpr VarType_Type VarType::SIZE_T; +constexpr VarType_Type VarType::UINT8; +constexpr VarType_Type VarType::INT8; +constexpr VarType_Type VarType::BF16; +constexpr VarType_Type VarType::COMPLEX64; +constexpr VarType_Type VarType::COMPLEX128; +constexpr VarType_Type VarType::LOD_TENSOR; +constexpr VarType_Type VarType::SELECTED_ROWS; +constexpr VarType_Type VarType::FEED_MINIBATCH; +constexpr VarType_Type VarType::FETCH_LIST; +constexpr VarType_Type VarType::STEP_SCOPES; +constexpr VarType_Type VarType::LOD_RANK_TABLE; +constexpr VarType_Type VarType::LOD_TENSOR_ARRAY; +constexpr VarType_Type VarType::PLACE_LIST; +constexpr VarType_Type VarType::READER; +constexpr VarType_Type VarType::RAW; +constexpr VarType_Type VarType::TUPLE; +constexpr VarType_Type VarType::Type_MIN; +constexpr VarType_Type VarType::Type_MAX; +constexpr int VarType::Type_ARRAYSIZE; +#endif // (__cplusplus < 201703) && (!defined(_MSC_VER) || _MSC_VER >= 1900) +const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* AttrType_descriptor() { + ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_framework_2eproto); + return file_level_enum_descriptors_framework_2eproto[1]; +} +bool AttrType_IsValid(int value) { + switch (value) { + case 0: + case 1: + case 2: + case 3: + case 4: + case 5: + case 6: + case 7: + case 8: + case 9: + case 10: + case 11: + return true; + default: + return false; + } +} + + +// =================================================================== + +class Version::_Internal { + public: + using HasBits = decltype(std::declval()._has_bits_); + static void set_has_version(HasBits* has_bits) { + (*has_bits)[0] |= 1u; + } +}; + +Version::Version(::PROTOBUF_NAMESPACE_ID::Arena* arena) + : ::PROTOBUF_NAMESPACE_ID::Message(arena) { + SharedCtor(); + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:paddle.framework.proto.Version) +} +Version::Version(const Version& from) + : ::PROTOBUF_NAMESPACE_ID::Message(), + _has_bits_(from._has_bits_) { + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + version_ = from.version_; + // @@protoc_insertion_point(copy_constructor:paddle.framework.proto.Version) +} + +void Version::SharedCtor() { + version_ = PROTOBUF_LONGLONG(0); +} + +Version::~Version() { + // @@protoc_insertion_point(destructor:paddle.framework.proto.Version) + SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +void Version::SharedDtor() { + GOOGLE_DCHECK(GetArena() == nullptr); +} + +void Version::ArenaDtor(void* object) { + Version* _this = reinterpret_cast< Version* >(object); + (void)_this; +} +void Version::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { +} +void Version::SetCachedSize(int size) const { + _cached_size_.Set(size); +} +const Version& Version::default_instance() { + ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_Version_framework_2eproto.base); + return *internal_default_instance(); +} + + +void Version::Clear() { +// @@protoc_insertion_point(message_clear_start:paddle.framework.proto.Version) + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + version_ = PROTOBUF_LONGLONG(0); + _has_bits_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +const char* Version::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure + _Internal::HasBits has_bits{}; + while (!ctx->Done(&ptr)) { + ::PROTOBUF_NAMESPACE_ID::uint32 tag; + ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + CHK_(ptr); + switch (tag >> 3) { + // optional int64 version = 1 [default = 0]; + case 1: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 8)) { + _Internal::set_has_version(&has_bits); + version_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + CHK_(ptr); + } else goto handle_unusual; + continue; + default: { + handle_unusual: + if ((tag & 7) == 4 || tag == 0) { + ctx->SetLastTag(tag); + goto success; + } + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); + CHK_(ptr != nullptr); + continue; + } + } // switch + } // while +success: + _has_bits_.Or(has_bits); + return ptr; +failure: + ptr = nullptr; + goto success; +#undef CHK_ +} + +::PROTOBUF_NAMESPACE_ID::uint8* Version::_InternalSerialize( + ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { + // @@protoc_insertion_point(serialize_to_array_start:paddle.framework.proto.Version) + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + cached_has_bits = _has_bits_[0]; + // optional int64 version = 1 [default = 0]; + if (cached_has_bits & 0x00000001u) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt64ToArray(1, this->_internal_version(), target); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + } + // @@protoc_insertion_point(serialize_to_array_end:paddle.framework.proto.Version) + return target; +} + +size_t Version::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:paddle.framework.proto.Version) + size_t total_size = 0; + + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + // optional int64 version = 1 [default = 0]; + cached_has_bits = _has_bits_[0]; + if (cached_has_bits & 0x00000001u) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int64Size( + this->_internal_version()); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize( + _internal_metadata_, total_size, &_cached_size_); + } + int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size); + SetCachedSize(cached_size); + return total_size; +} + +void Version::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { +// @@protoc_insertion_point(generalized_merge_from_start:paddle.framework.proto.Version) + GOOGLE_DCHECK_NE(&from, this); + const Version* source = + ::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated( + &from); + if (source == nullptr) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:paddle.framework.proto.Version) + ::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this); + } else { + // @@protoc_insertion_point(generalized_merge_from_cast_success:paddle.framework.proto.Version) + MergeFrom(*source); + } +} + +void Version::MergeFrom(const Version& from) { +// @@protoc_insertion_point(class_specific_merge_from_start:paddle.framework.proto.Version) + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + if (from._internal_has_version()) { + _internal_set_version(from._internal_version()); + } +} + +void Version::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:paddle.framework.proto.Version) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +void Version::CopyFrom(const Version& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:paddle.framework.proto.Version) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool Version::IsInitialized() const { + return true; +} + +void Version::InternalSwap(Version* other) { + using std::swap; + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); + swap(_has_bits_[0], other->_has_bits_[0]); + swap(version_, other->version_); +} + +::PROTOBUF_NAMESPACE_ID::Metadata Version::GetMetadata() const { + return GetMetadataStatic(); +} + + +// =================================================================== + +class OpDesc_Attr::_Internal { + public: + using HasBits = decltype(std::declval()._has_bits_); + static void set_has_name(HasBits* has_bits) { + (*has_bits)[0] |= 1u; + } + static void set_has_type(HasBits* has_bits) { + (*has_bits)[0] |= 4u; + } + static void set_has_i(HasBits* has_bits) { + (*has_bits)[0] |= 8u; + } + static void set_has_f(HasBits* has_bits) { + (*has_bits)[0] |= 16u; + } + static void set_has_s(HasBits* has_bits) { + (*has_bits)[0] |= 2u; + } + static void set_has_b(HasBits* has_bits) { + (*has_bits)[0] |= 32u; + } + static void set_has_block_idx(HasBits* has_bits) { + (*has_bits)[0] |= 128u; + } + static void set_has_l(HasBits* has_bits) { + (*has_bits)[0] |= 64u; + } + static bool MissingRequiredFields(const HasBits& has_bits) { + return ((has_bits[0] & 0x00000005) ^ 0x00000005) != 0; + } +}; + +OpDesc_Attr::OpDesc_Attr(::PROTOBUF_NAMESPACE_ID::Arena* arena) + : ::PROTOBUF_NAMESPACE_ID::Message(arena), + ints_(arena), + floats_(arena), + strings_(arena), + bools_(arena), + blocks_idx_(arena), + longs_(arena) { + SharedCtor(); + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:paddle.framework.proto.OpDesc.Attr) +} +OpDesc_Attr::OpDesc_Attr(const OpDesc_Attr& from) + : ::PROTOBUF_NAMESPACE_ID::Message(), + _has_bits_(from._has_bits_), + ints_(from.ints_), + floats_(from.floats_), + strings_(from.strings_), + bools_(from.bools_), + blocks_idx_(from.blocks_idx_), + longs_(from.longs_) { + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + if (from._internal_has_name()) { + name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(), + GetArena()); + } + s_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + if (from._internal_has_s()) { + s_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_s(), + GetArena()); + } + ::memcpy(&type_, &from.type_, + static_cast(reinterpret_cast(&block_idx_) - + reinterpret_cast(&type_)) + sizeof(block_idx_)); + // @@protoc_insertion_point(copy_constructor:paddle.framework.proto.OpDesc.Attr) +} + +void OpDesc_Attr::SharedCtor() { + ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_OpDesc_Attr_framework_2eproto.base); + name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + s_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + ::memset(reinterpret_cast(this) + static_cast( + reinterpret_cast(&type_) - reinterpret_cast(this)), + 0, static_cast(reinterpret_cast(&block_idx_) - + reinterpret_cast(&type_)) + sizeof(block_idx_)); +} + +OpDesc_Attr::~OpDesc_Attr() { + // @@protoc_insertion_point(destructor:paddle.framework.proto.OpDesc.Attr) + SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +void OpDesc_Attr::SharedDtor() { + GOOGLE_DCHECK(GetArena() == nullptr); + name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + s_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); +} + +void OpDesc_Attr::ArenaDtor(void* object) { + OpDesc_Attr* _this = reinterpret_cast< OpDesc_Attr* >(object); + (void)_this; +} +void OpDesc_Attr::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { +} +void OpDesc_Attr::SetCachedSize(int size) const { + _cached_size_.Set(size); +} +const OpDesc_Attr& OpDesc_Attr::default_instance() { + ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_OpDesc_Attr_framework_2eproto.base); + return *internal_default_instance(); +} + + +void OpDesc_Attr::Clear() { +// @@protoc_insertion_point(message_clear_start:paddle.framework.proto.OpDesc.Attr) + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + ints_.Clear(); + floats_.Clear(); + strings_.Clear(); + bools_.Clear(); + blocks_idx_.Clear(); + longs_.Clear(); + cached_has_bits = _has_bits_[0]; + if (cached_has_bits & 0x00000003u) { + if (cached_has_bits & 0x00000001u) { + name_.ClearNonDefaultToEmpty(); + } + if (cached_has_bits & 0x00000002u) { + s_.ClearNonDefaultToEmpty(); + } + } + if (cached_has_bits & 0x000000fcu) { + ::memset(&type_, 0, static_cast( + reinterpret_cast(&block_idx_) - + reinterpret_cast(&type_)) + sizeof(block_idx_)); + } + _has_bits_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +const char* OpDesc_Attr::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure + _Internal::HasBits has_bits{}; + while (!ctx->Done(&ptr)) { + ::PROTOBUF_NAMESPACE_ID::uint32 tag; + ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + CHK_(ptr); + switch (tag >> 3) { + // required string name = 1; + case 1: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) { + auto str = _internal_mutable_name(); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); + #ifndef NDEBUG + ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "paddle.framework.proto.OpDesc.Attr.name"); + #endif // !NDEBUG + CHK_(ptr); + } else goto handle_unusual; + continue; + // required .paddle.framework.proto.AttrType type = 2; + case 2: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 16)) { + ::PROTOBUF_NAMESPACE_ID::uint64 val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + CHK_(ptr); + if (PROTOBUF_PREDICT_TRUE(::paddle::framework::proto::AttrType_IsValid(val))) { + _internal_set_type(static_cast<::paddle::framework::proto::AttrType>(val)); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::WriteVarint(2, val, mutable_unknown_fields()); + } + } else goto handle_unusual; + continue; + // optional int32 i = 3; + case 3: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 24)) { + _Internal::set_has_i(&has_bits); + i_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + CHK_(ptr); + } else goto handle_unusual; + continue; + // optional float f = 4; + case 4: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 37)) { + _Internal::set_has_f(&has_bits); + f_ = ::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad(ptr); + ptr += sizeof(float); + } else goto handle_unusual; + continue; + // optional string s = 5; + case 5: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 42)) { + auto str = _internal_mutable_s(); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); + #ifndef NDEBUG + ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "paddle.framework.proto.OpDesc.Attr.s"); + #endif // !NDEBUG + CHK_(ptr); + } else goto handle_unusual; + continue; + // repeated int32 ints = 6; + case 6: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 48)) { + ptr -= 1; + do { + ptr += 1; + _internal_add_ints(::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr)); + CHK_(ptr); + if (!ctx->DataAvailable(ptr)) break; + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<48>(ptr)); + } else if (static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 50) { + ptr = ::PROTOBUF_NAMESPACE_ID::internal::PackedInt32Parser(_internal_mutable_ints(), ptr, ctx); + CHK_(ptr); + } else goto handle_unusual; + continue; + // repeated float floats = 7; + case 7: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 61)) { + ptr -= 1; + do { + ptr += 1; + _internal_add_floats(::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad(ptr)); + ptr += sizeof(float); + if (!ctx->DataAvailable(ptr)) break; + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<61>(ptr)); + } else if (static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 58) { + ptr = ::PROTOBUF_NAMESPACE_ID::internal::PackedFloatParser(_internal_mutable_floats(), ptr, ctx); + CHK_(ptr); + } else goto handle_unusual; + continue; + // repeated string strings = 8; + case 8: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 66)) { + ptr -= 1; + do { + ptr += 1; + auto str = _internal_add_strings(); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); + #ifndef NDEBUG + ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "paddle.framework.proto.OpDesc.Attr.strings"); + #endif // !NDEBUG + CHK_(ptr); + if (!ctx->DataAvailable(ptr)) break; + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<66>(ptr)); + } else goto handle_unusual; + continue; + // optional bool b = 10; + case 10: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 80)) { + _Internal::set_has_b(&has_bits); + b_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + CHK_(ptr); + } else goto handle_unusual; + continue; + // repeated bool bools = 11; + case 11: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 88)) { + ptr -= 1; + do { + ptr += 1; + _internal_add_bools(::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr)); + CHK_(ptr); + if (!ctx->DataAvailable(ptr)) break; + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<88>(ptr)); + } else if (static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 90) { + ptr = ::PROTOBUF_NAMESPACE_ID::internal::PackedBoolParser(_internal_mutable_bools(), ptr, ctx); + CHK_(ptr); + } else goto handle_unusual; + continue; + // optional int32 block_idx = 12; + case 12: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 96)) { + _Internal::set_has_block_idx(&has_bits); + block_idx_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + CHK_(ptr); + } else goto handle_unusual; + continue; + // optional int64 l = 13; + case 13: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 104)) { + _Internal::set_has_l(&has_bits); + l_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + CHK_(ptr); + } else goto handle_unusual; + continue; + // repeated int32 blocks_idx = 14; + case 14: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 112)) { + ptr -= 1; + do { + ptr += 1; + _internal_add_blocks_idx(::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr)); + CHK_(ptr); + if (!ctx->DataAvailable(ptr)) break; + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<112>(ptr)); + } else if (static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 114) { + ptr = ::PROTOBUF_NAMESPACE_ID::internal::PackedInt32Parser(_internal_mutable_blocks_idx(), ptr, ctx); + CHK_(ptr); + } else goto handle_unusual; + continue; + // repeated int64 longs = 15; + case 15: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 120)) { + ptr -= 1; + do { + ptr += 1; + _internal_add_longs(::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr)); + CHK_(ptr); + if (!ctx->DataAvailable(ptr)) break; + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<120>(ptr)); + } else if (static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 122) { + ptr = ::PROTOBUF_NAMESPACE_ID::internal::PackedInt64Parser(_internal_mutable_longs(), ptr, ctx); + CHK_(ptr); + } else goto handle_unusual; + continue; + default: { + handle_unusual: + if ((tag & 7) == 4 || tag == 0) { + ctx->SetLastTag(tag); + goto success; + } + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); + CHK_(ptr != nullptr); + continue; + } + } // switch + } // while +success: + _has_bits_.Or(has_bits); + return ptr; +failure: + ptr = nullptr; + goto success; +#undef CHK_ +} + +::PROTOBUF_NAMESPACE_ID::uint8* OpDesc_Attr::_InternalSerialize( + ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { + // @@protoc_insertion_point(serialize_to_array_start:paddle.framework.proto.OpDesc.Attr) + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + cached_has_bits = _has_bits_[0]; + // required string name = 1; + if (cached_has_bits & 0x00000001u) { + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( + this->_internal_name().data(), static_cast(this->_internal_name().length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, + "paddle.framework.proto.OpDesc.Attr.name"); + target = stream->WriteStringMaybeAliased( + 1, this->_internal_name(), target); + } + + // required .paddle.framework.proto.AttrType type = 2; + if (cached_has_bits & 0x00000004u) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteEnumToArray( + 2, this->_internal_type(), target); + } + + // optional int32 i = 3; + if (cached_has_bits & 0x00000008u) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(3, this->_internal_i(), target); + } + + // optional float f = 4; + if (cached_has_bits & 0x00000010u) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteFloatToArray(4, this->_internal_f(), target); + } + + // optional string s = 5; + if (cached_has_bits & 0x00000002u) { + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( + this->_internal_s().data(), static_cast(this->_internal_s().length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, + "paddle.framework.proto.OpDesc.Attr.s"); + target = stream->WriteStringMaybeAliased( + 5, this->_internal_s(), target); + } + + // repeated int32 ints = 6; + for (int i = 0, n = this->_internal_ints_size(); i < n; i++) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(6, this->_internal_ints(i), target); + } + + // repeated float floats = 7; + for (int i = 0, n = this->_internal_floats_size(); i < n; i++) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteFloatToArray(7, this->_internal_floats(i), target); + } + + // repeated string strings = 8; + for (int i = 0, n = this->_internal_strings_size(); i < n; i++) { + const auto& s = this->_internal_strings(i); + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( + s.data(), static_cast(s.length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, + "paddle.framework.proto.OpDesc.Attr.strings"); + target = stream->WriteString(8, s, target); + } + + // optional bool b = 10; + if (cached_has_bits & 0x00000020u) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(10, this->_internal_b(), target); + } + + // repeated bool bools = 11; + for (int i = 0, n = this->_internal_bools_size(); i < n; i++) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(11, this->_internal_bools(i), target); + } + + // optional int32 block_idx = 12; + if (cached_has_bits & 0x00000080u) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(12, this->_internal_block_idx(), target); + } + + // optional int64 l = 13; + if (cached_has_bits & 0x00000040u) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt64ToArray(13, this->_internal_l(), target); + } + + // repeated int32 blocks_idx = 14; + for (int i = 0, n = this->_internal_blocks_idx_size(); i < n; i++) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(14, this->_internal_blocks_idx(i), target); + } + + // repeated int64 longs = 15; + for (int i = 0, n = this->_internal_longs_size(); i < n; i++) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt64ToArray(15, this->_internal_longs(i), target); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + } + // @@protoc_insertion_point(serialize_to_array_end:paddle.framework.proto.OpDesc.Attr) + return target; +} + +size_t OpDesc_Attr::RequiredFieldsByteSizeFallback() const { +// @@protoc_insertion_point(required_fields_byte_size_fallback_start:paddle.framework.proto.OpDesc.Attr) + size_t total_size = 0; + + if (_internal_has_name()) { + // required string name = 1; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_name()); + } + + if (_internal_has_type()) { + // required .paddle.framework.proto.AttrType type = 2; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::EnumSize(this->_internal_type()); + } + + return total_size; +} +size_t OpDesc_Attr::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:paddle.framework.proto.OpDesc.Attr) + size_t total_size = 0; + + if (((_has_bits_[0] & 0x00000005) ^ 0x00000005) == 0) { // All required fields are present. + // required string name = 1; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_name()); + + // required .paddle.framework.proto.AttrType type = 2; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::EnumSize(this->_internal_type()); + + } else { + total_size += RequiredFieldsByteSizeFallback(); + } + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + // repeated int32 ints = 6; + { + size_t data_size = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + Int32Size(this->ints_); + total_size += 1 * + ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(this->_internal_ints_size()); + total_size += data_size; + } + + // repeated float floats = 7; + { + unsigned int count = static_cast(this->_internal_floats_size()); + size_t data_size = 4UL * count; + total_size += 1 * + ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(this->_internal_floats_size()); + total_size += data_size; + } + + // repeated string strings = 8; + total_size += 1 * + ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(strings_.size()); + for (int i = 0, n = strings_.size(); i < n; i++) { + total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + strings_.Get(i)); + } + + // repeated bool bools = 11; + { + unsigned int count = static_cast(this->_internal_bools_size()); + size_t data_size = 1UL * count; + total_size += 1 * + ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(this->_internal_bools_size()); + total_size += data_size; + } + + // repeated int32 blocks_idx = 14; + { + size_t data_size = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + Int32Size(this->blocks_idx_); + total_size += 1 * + ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(this->_internal_blocks_idx_size()); + total_size += data_size; + } + + // repeated int64 longs = 15; + { + size_t data_size = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + Int64Size(this->longs_); + total_size += 1 * + ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(this->_internal_longs_size()); + total_size += data_size; + } + + // optional string s = 5; + cached_has_bits = _has_bits_[0]; + if (cached_has_bits & 0x00000002u) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_s()); + } + + if (cached_has_bits & 0x000000f8u) { + // optional int32 i = 3; + if (cached_has_bits & 0x00000008u) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size( + this->_internal_i()); + } + + // optional float f = 4; + if (cached_has_bits & 0x00000010u) { + total_size += 1 + 4; + } + + // optional bool b = 10; + if (cached_has_bits & 0x00000020u) { + total_size += 1 + 1; + } + + // optional int64 l = 13; + if (cached_has_bits & 0x00000040u) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int64Size( + this->_internal_l()); + } + + // optional int32 block_idx = 12; + if (cached_has_bits & 0x00000080u) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size( + this->_internal_block_idx()); + } + + } + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize( + _internal_metadata_, total_size, &_cached_size_); + } + int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size); + SetCachedSize(cached_size); + return total_size; +} + +void OpDesc_Attr::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { +// @@protoc_insertion_point(generalized_merge_from_start:paddle.framework.proto.OpDesc.Attr) + GOOGLE_DCHECK_NE(&from, this); + const OpDesc_Attr* source = + ::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated( + &from); + if (source == nullptr) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:paddle.framework.proto.OpDesc.Attr) + ::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this); + } else { + // @@protoc_insertion_point(generalized_merge_from_cast_success:paddle.framework.proto.OpDesc.Attr) + MergeFrom(*source); + } +} + +void OpDesc_Attr::MergeFrom(const OpDesc_Attr& from) { +// @@protoc_insertion_point(class_specific_merge_from_start:paddle.framework.proto.OpDesc.Attr) + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + ints_.MergeFrom(from.ints_); + floats_.MergeFrom(from.floats_); + strings_.MergeFrom(from.strings_); + bools_.MergeFrom(from.bools_); + blocks_idx_.MergeFrom(from.blocks_idx_); + longs_.MergeFrom(from.longs_); + cached_has_bits = from._has_bits_[0]; + if (cached_has_bits & 0x000000ffu) { + if (cached_has_bits & 0x00000001u) { + _internal_set_name(from._internal_name()); + } + if (cached_has_bits & 0x00000002u) { + _internal_set_s(from._internal_s()); + } + if (cached_has_bits & 0x00000004u) { + type_ = from.type_; + } + if (cached_has_bits & 0x00000008u) { + i_ = from.i_; + } + if (cached_has_bits & 0x00000010u) { + f_ = from.f_; + } + if (cached_has_bits & 0x00000020u) { + b_ = from.b_; + } + if (cached_has_bits & 0x00000040u) { + l_ = from.l_; + } + if (cached_has_bits & 0x00000080u) { + block_idx_ = from.block_idx_; + } + _has_bits_[0] |= cached_has_bits; + } +} + +void OpDesc_Attr::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:paddle.framework.proto.OpDesc.Attr) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +void OpDesc_Attr::CopyFrom(const OpDesc_Attr& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:paddle.framework.proto.OpDesc.Attr) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool OpDesc_Attr::IsInitialized() const { + if (_Internal::MissingRequiredFields(_has_bits_)) return false; + return true; +} + +void OpDesc_Attr::InternalSwap(OpDesc_Attr* other) { + using std::swap; + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); + swap(_has_bits_[0], other->_has_bits_[0]); + ints_.InternalSwap(&other->ints_); + floats_.InternalSwap(&other->floats_); + strings_.InternalSwap(&other->strings_); + bools_.InternalSwap(&other->bools_); + blocks_idx_.InternalSwap(&other->blocks_idx_); + longs_.InternalSwap(&other->longs_); + name_.Swap(&other->name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + s_.Swap(&other->s_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + ::PROTOBUF_NAMESPACE_ID::internal::memswap< + PROTOBUF_FIELD_OFFSET(OpDesc_Attr, block_idx_) + + sizeof(OpDesc_Attr::block_idx_) + - PROTOBUF_FIELD_OFFSET(OpDesc_Attr, type_)>( + reinterpret_cast(&type_), + reinterpret_cast(&other->type_)); +} + +::PROTOBUF_NAMESPACE_ID::Metadata OpDesc_Attr::GetMetadata() const { + return GetMetadataStatic(); +} + + +// =================================================================== + +class OpDesc_Var::_Internal { + public: + using HasBits = decltype(std::declval()._has_bits_); + static void set_has_parameter(HasBits* has_bits) { + (*has_bits)[0] |= 1u; + } + static bool MissingRequiredFields(const HasBits& has_bits) { + return ((has_bits[0] & 0x00000001) ^ 0x00000001) != 0; + } +}; + +OpDesc_Var::OpDesc_Var(::PROTOBUF_NAMESPACE_ID::Arena* arena) + : ::PROTOBUF_NAMESPACE_ID::Message(arena), + arguments_(arena) { + SharedCtor(); + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:paddle.framework.proto.OpDesc.Var) +} +OpDesc_Var::OpDesc_Var(const OpDesc_Var& from) + : ::PROTOBUF_NAMESPACE_ID::Message(), + _has_bits_(from._has_bits_), + arguments_(from.arguments_) { + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + parameter_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + if (from._internal_has_parameter()) { + parameter_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_parameter(), + GetArena()); + } + // @@protoc_insertion_point(copy_constructor:paddle.framework.proto.OpDesc.Var) +} + +void OpDesc_Var::SharedCtor() { + ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_OpDesc_Var_framework_2eproto.base); + parameter_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); +} + +OpDesc_Var::~OpDesc_Var() { + // @@protoc_insertion_point(destructor:paddle.framework.proto.OpDesc.Var) + SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +void OpDesc_Var::SharedDtor() { + GOOGLE_DCHECK(GetArena() == nullptr); + parameter_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); +} + +void OpDesc_Var::ArenaDtor(void* object) { + OpDesc_Var* _this = reinterpret_cast< OpDesc_Var* >(object); + (void)_this; +} +void OpDesc_Var::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { +} +void OpDesc_Var::SetCachedSize(int size) const { + _cached_size_.Set(size); +} +const OpDesc_Var& OpDesc_Var::default_instance() { + ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_OpDesc_Var_framework_2eproto.base); + return *internal_default_instance(); +} + + +void OpDesc_Var::Clear() { +// @@protoc_insertion_point(message_clear_start:paddle.framework.proto.OpDesc.Var) + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + arguments_.Clear(); + cached_has_bits = _has_bits_[0]; + if (cached_has_bits & 0x00000001u) { + parameter_.ClearNonDefaultToEmpty(); + } + _has_bits_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +const char* OpDesc_Var::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure + _Internal::HasBits has_bits{}; + while (!ctx->Done(&ptr)) { + ::PROTOBUF_NAMESPACE_ID::uint32 tag; + ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + CHK_(ptr); + switch (tag >> 3) { + // required string parameter = 1; + case 1: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) { + auto str = _internal_mutable_parameter(); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); + #ifndef NDEBUG + ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "paddle.framework.proto.OpDesc.Var.parameter"); + #endif // !NDEBUG + CHK_(ptr); + } else goto handle_unusual; + continue; + // repeated string arguments = 2; + case 2: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 18)) { + ptr -= 1; + do { + ptr += 1; + auto str = _internal_add_arguments(); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); + #ifndef NDEBUG + ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "paddle.framework.proto.OpDesc.Var.arguments"); + #endif // !NDEBUG + CHK_(ptr); + if (!ctx->DataAvailable(ptr)) break; + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<18>(ptr)); + } else goto handle_unusual; + continue; + default: { + handle_unusual: + if ((tag & 7) == 4 || tag == 0) { + ctx->SetLastTag(tag); + goto success; + } + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); + CHK_(ptr != nullptr); + continue; + } + } // switch + } // while +success: + _has_bits_.Or(has_bits); + return ptr; +failure: + ptr = nullptr; + goto success; +#undef CHK_ +} + +::PROTOBUF_NAMESPACE_ID::uint8* OpDesc_Var::_InternalSerialize( + ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { + // @@protoc_insertion_point(serialize_to_array_start:paddle.framework.proto.OpDesc.Var) + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + cached_has_bits = _has_bits_[0]; + // required string parameter = 1; + if (cached_has_bits & 0x00000001u) { + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( + this->_internal_parameter().data(), static_cast(this->_internal_parameter().length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, + "paddle.framework.proto.OpDesc.Var.parameter"); + target = stream->WriteStringMaybeAliased( + 1, this->_internal_parameter(), target); + } + + // repeated string arguments = 2; + for (int i = 0, n = this->_internal_arguments_size(); i < n; i++) { + const auto& s = this->_internal_arguments(i); + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( + s.data(), static_cast(s.length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, + "paddle.framework.proto.OpDesc.Var.arguments"); + target = stream->WriteString(2, s, target); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + } + // @@protoc_insertion_point(serialize_to_array_end:paddle.framework.proto.OpDesc.Var) + return target; +} + +size_t OpDesc_Var::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:paddle.framework.proto.OpDesc.Var) + size_t total_size = 0; + + // required string parameter = 1; + if (_internal_has_parameter()) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_parameter()); + } + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + // repeated string arguments = 2; + total_size += 1 * + ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(arguments_.size()); + for (int i = 0, n = arguments_.size(); i < n; i++) { + total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + arguments_.Get(i)); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize( + _internal_metadata_, total_size, &_cached_size_); + } + int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size); + SetCachedSize(cached_size); + return total_size; +} + +void OpDesc_Var::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { +// @@protoc_insertion_point(generalized_merge_from_start:paddle.framework.proto.OpDesc.Var) + GOOGLE_DCHECK_NE(&from, this); + const OpDesc_Var* source = + ::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated( + &from); + if (source == nullptr) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:paddle.framework.proto.OpDesc.Var) + ::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this); + } else { + // @@protoc_insertion_point(generalized_merge_from_cast_success:paddle.framework.proto.OpDesc.Var) + MergeFrom(*source); + } +} + +void OpDesc_Var::MergeFrom(const OpDesc_Var& from) { +// @@protoc_insertion_point(class_specific_merge_from_start:paddle.framework.proto.OpDesc.Var) + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + arguments_.MergeFrom(from.arguments_); + if (from._internal_has_parameter()) { + _internal_set_parameter(from._internal_parameter()); + } +} + +void OpDesc_Var::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:paddle.framework.proto.OpDesc.Var) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +void OpDesc_Var::CopyFrom(const OpDesc_Var& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:paddle.framework.proto.OpDesc.Var) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool OpDesc_Var::IsInitialized() const { + if (_Internal::MissingRequiredFields(_has_bits_)) return false; + return true; +} + +void OpDesc_Var::InternalSwap(OpDesc_Var* other) { + using std::swap; + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); + swap(_has_bits_[0], other->_has_bits_[0]); + arguments_.InternalSwap(&other->arguments_); + parameter_.Swap(&other->parameter_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); +} + +::PROTOBUF_NAMESPACE_ID::Metadata OpDesc_Var::GetMetadata() const { + return GetMetadataStatic(); +} + + +// =================================================================== + +class OpDesc::_Internal { + public: + using HasBits = decltype(std::declval()._has_bits_); + static void set_has_type(HasBits* has_bits) { + (*has_bits)[0] |= 1u; + } + static void set_has_is_target(HasBits* has_bits) { + (*has_bits)[0] |= 2u; + } + static bool MissingRequiredFields(const HasBits& has_bits) { + return ((has_bits[0] & 0x00000001) ^ 0x00000001) != 0; + } +}; + +OpDesc::OpDesc(::PROTOBUF_NAMESPACE_ID::Arena* arena) + : ::PROTOBUF_NAMESPACE_ID::Message(arena), + inputs_(arena), + outputs_(arena), + attrs_(arena) { + SharedCtor(); + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:paddle.framework.proto.OpDesc) +} +OpDesc::OpDesc(const OpDesc& from) + : ::PROTOBUF_NAMESPACE_ID::Message(), + _has_bits_(from._has_bits_), + inputs_(from.inputs_), + outputs_(from.outputs_), + attrs_(from.attrs_) { + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + type_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + if (from._internal_has_type()) { + type_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_type(), + GetArena()); + } + is_target_ = from.is_target_; + // @@protoc_insertion_point(copy_constructor:paddle.framework.proto.OpDesc) +} + +void OpDesc::SharedCtor() { + ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_OpDesc_framework_2eproto.base); + type_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + is_target_ = false; +} + +OpDesc::~OpDesc() { + // @@protoc_insertion_point(destructor:paddle.framework.proto.OpDesc) + SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +void OpDesc::SharedDtor() { + GOOGLE_DCHECK(GetArena() == nullptr); + type_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); +} + +void OpDesc::ArenaDtor(void* object) { + OpDesc* _this = reinterpret_cast< OpDesc* >(object); + (void)_this; +} +void OpDesc::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { +} +void OpDesc::SetCachedSize(int size) const { + _cached_size_.Set(size); +} +const OpDesc& OpDesc::default_instance() { + ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_OpDesc_framework_2eproto.base); + return *internal_default_instance(); +} + + +void OpDesc::Clear() { +// @@protoc_insertion_point(message_clear_start:paddle.framework.proto.OpDesc) + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + inputs_.Clear(); + outputs_.Clear(); + attrs_.Clear(); + cached_has_bits = _has_bits_[0]; + if (cached_has_bits & 0x00000001u) { + type_.ClearNonDefaultToEmpty(); + } + is_target_ = false; + _has_bits_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +const char* OpDesc::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure + _Internal::HasBits has_bits{}; + while (!ctx->Done(&ptr)) { + ::PROTOBUF_NAMESPACE_ID::uint32 tag; + ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + CHK_(ptr); + switch (tag >> 3) { + // repeated .paddle.framework.proto.OpDesc.Var inputs = 1; + case 1: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) { + ptr -= 1; + do { + ptr += 1; + ptr = ctx->ParseMessage(_internal_add_inputs(), ptr); + CHK_(ptr); + if (!ctx->DataAvailable(ptr)) break; + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<10>(ptr)); + } else goto handle_unusual; + continue; + // repeated .paddle.framework.proto.OpDesc.Var outputs = 2; + case 2: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 18)) { + ptr -= 1; + do { + ptr += 1; + ptr = ctx->ParseMessage(_internal_add_outputs(), ptr); + CHK_(ptr); + if (!ctx->DataAvailable(ptr)) break; + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<18>(ptr)); + } else goto handle_unusual; + continue; + // required string type = 3; + case 3: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 26)) { + auto str = _internal_mutable_type(); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); + #ifndef NDEBUG + ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "paddle.framework.proto.OpDesc.type"); + #endif // !NDEBUG + CHK_(ptr); + } else goto handle_unusual; + continue; + // repeated .paddle.framework.proto.OpDesc.Attr attrs = 4; + case 4: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 34)) { + ptr -= 1; + do { + ptr += 1; + ptr = ctx->ParseMessage(_internal_add_attrs(), ptr); + CHK_(ptr); + if (!ctx->DataAvailable(ptr)) break; + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<34>(ptr)); + } else goto handle_unusual; + continue; + // optional bool is_target = 5 [default = false]; + case 5: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 40)) { + _Internal::set_has_is_target(&has_bits); + is_target_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + CHK_(ptr); + } else goto handle_unusual; + continue; + default: { + handle_unusual: + if ((tag & 7) == 4 || tag == 0) { + ctx->SetLastTag(tag); + goto success; + } + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); + CHK_(ptr != nullptr); + continue; + } + } // switch + } // while +success: + _has_bits_.Or(has_bits); + return ptr; +failure: + ptr = nullptr; + goto success; +#undef CHK_ +} + +::PROTOBUF_NAMESPACE_ID::uint8* OpDesc::_InternalSerialize( + ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { + // @@protoc_insertion_point(serialize_to_array_start:paddle.framework.proto.OpDesc) + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + // repeated .paddle.framework.proto.OpDesc.Var inputs = 1; + for (unsigned int i = 0, + n = static_cast(this->_internal_inputs_size()); i < n; i++) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage(1, this->_internal_inputs(i), target, stream); + } + + // repeated .paddle.framework.proto.OpDesc.Var outputs = 2; + for (unsigned int i = 0, + n = static_cast(this->_internal_outputs_size()); i < n; i++) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage(2, this->_internal_outputs(i), target, stream); + } + + cached_has_bits = _has_bits_[0]; + // required string type = 3; + if (cached_has_bits & 0x00000001u) { + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( + this->_internal_type().data(), static_cast(this->_internal_type().length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, + "paddle.framework.proto.OpDesc.type"); + target = stream->WriteStringMaybeAliased( + 3, this->_internal_type(), target); + } + + // repeated .paddle.framework.proto.OpDesc.Attr attrs = 4; + for (unsigned int i = 0, + n = static_cast(this->_internal_attrs_size()); i < n; i++) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage(4, this->_internal_attrs(i), target, stream); + } + + // optional bool is_target = 5 [default = false]; + if (cached_has_bits & 0x00000002u) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(5, this->_internal_is_target(), target); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + } + // @@protoc_insertion_point(serialize_to_array_end:paddle.framework.proto.OpDesc) + return target; +} + +size_t OpDesc::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:paddle.framework.proto.OpDesc) + size_t total_size = 0; + + // required string type = 3; + if (_internal_has_type()) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_type()); + } + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + // repeated .paddle.framework.proto.OpDesc.Var inputs = 1; + total_size += 1UL * this->_internal_inputs_size(); + for (const auto& msg : this->inputs_) { + total_size += + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); + } + + // repeated .paddle.framework.proto.OpDesc.Var outputs = 2; + total_size += 1UL * this->_internal_outputs_size(); + for (const auto& msg : this->outputs_) { + total_size += + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); + } + + // repeated .paddle.framework.proto.OpDesc.Attr attrs = 4; + total_size += 1UL * this->_internal_attrs_size(); + for (const auto& msg : this->attrs_) { + total_size += + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); + } + + // optional bool is_target = 5 [default = false]; + cached_has_bits = _has_bits_[0]; + if (cached_has_bits & 0x00000002u) { + total_size += 1 + 1; + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize( + _internal_metadata_, total_size, &_cached_size_); + } + int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size); + SetCachedSize(cached_size); + return total_size; +} + +void OpDesc::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { +// @@protoc_insertion_point(generalized_merge_from_start:paddle.framework.proto.OpDesc) + GOOGLE_DCHECK_NE(&from, this); + const OpDesc* source = + ::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated( + &from); + if (source == nullptr) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:paddle.framework.proto.OpDesc) + ::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this); + } else { + // @@protoc_insertion_point(generalized_merge_from_cast_success:paddle.framework.proto.OpDesc) + MergeFrom(*source); + } +} + +void OpDesc::MergeFrom(const OpDesc& from) { +// @@protoc_insertion_point(class_specific_merge_from_start:paddle.framework.proto.OpDesc) + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + inputs_.MergeFrom(from.inputs_); + outputs_.MergeFrom(from.outputs_); + attrs_.MergeFrom(from.attrs_); + cached_has_bits = from._has_bits_[0]; + if (cached_has_bits & 0x00000003u) { + if (cached_has_bits & 0x00000001u) { + _internal_set_type(from._internal_type()); + } + if (cached_has_bits & 0x00000002u) { + is_target_ = from.is_target_; + } + _has_bits_[0] |= cached_has_bits; + } +} + +void OpDesc::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:paddle.framework.proto.OpDesc) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +void OpDesc::CopyFrom(const OpDesc& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:paddle.framework.proto.OpDesc) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool OpDesc::IsInitialized() const { + if (_Internal::MissingRequiredFields(_has_bits_)) return false; + if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(inputs_)) return false; + if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(outputs_)) return false; + if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(attrs_)) return false; + return true; +} + +void OpDesc::InternalSwap(OpDesc* other) { + using std::swap; + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); + swap(_has_bits_[0], other->_has_bits_[0]); + inputs_.InternalSwap(&other->inputs_); + outputs_.InternalSwap(&other->outputs_); + attrs_.InternalSwap(&other->attrs_); + type_.Swap(&other->type_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + swap(is_target_, other->is_target_); +} + +::PROTOBUF_NAMESPACE_ID::Metadata OpDesc::GetMetadata() const { + return GetMetadataStatic(); +} + + +// =================================================================== + +class OpProto_Var::_Internal { + public: + using HasBits = decltype(std::declval()._has_bits_); + static void set_has_name(HasBits* has_bits) { + (*has_bits)[0] |= 1u; + } + static void set_has_comment(HasBits* has_bits) { + (*has_bits)[0] |= 2u; + } + static void set_has_duplicable(HasBits* has_bits) { + (*has_bits)[0] |= 4u; + } + static void set_has_intermediate(HasBits* has_bits) { + (*has_bits)[0] |= 8u; + } + static void set_has_dispensable(HasBits* has_bits) { + (*has_bits)[0] |= 16u; + } + static bool MissingRequiredFields(const HasBits& has_bits) { + return ((has_bits[0] & 0x00000003) ^ 0x00000003) != 0; + } +}; + +OpProto_Var::OpProto_Var(::PROTOBUF_NAMESPACE_ID::Arena* arena) + : ::PROTOBUF_NAMESPACE_ID::Message(arena) { + SharedCtor(); + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:paddle.framework.proto.OpProto.Var) +} +OpProto_Var::OpProto_Var(const OpProto_Var& from) + : ::PROTOBUF_NAMESPACE_ID::Message(), + _has_bits_(from._has_bits_) { + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + if (from._internal_has_name()) { + name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(), + GetArena()); + } + comment_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + if (from._internal_has_comment()) { + comment_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_comment(), + GetArena()); + } + ::memcpy(&duplicable_, &from.duplicable_, + static_cast(reinterpret_cast(&dispensable_) - + reinterpret_cast(&duplicable_)) + sizeof(dispensable_)); + // @@protoc_insertion_point(copy_constructor:paddle.framework.proto.OpProto.Var) +} + +void OpProto_Var::SharedCtor() { + ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_OpProto_Var_framework_2eproto.base); + name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + comment_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + ::memset(reinterpret_cast(this) + static_cast( + reinterpret_cast(&duplicable_) - reinterpret_cast(this)), + 0, static_cast(reinterpret_cast(&dispensable_) - + reinterpret_cast(&duplicable_)) + sizeof(dispensable_)); +} + +OpProto_Var::~OpProto_Var() { + // @@protoc_insertion_point(destructor:paddle.framework.proto.OpProto.Var) + SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +void OpProto_Var::SharedDtor() { + GOOGLE_DCHECK(GetArena() == nullptr); + name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + comment_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); +} + +void OpProto_Var::ArenaDtor(void* object) { + OpProto_Var* _this = reinterpret_cast< OpProto_Var* >(object); + (void)_this; +} +void OpProto_Var::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { +} +void OpProto_Var::SetCachedSize(int size) const { + _cached_size_.Set(size); +} +const OpProto_Var& OpProto_Var::default_instance() { + ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_OpProto_Var_framework_2eproto.base); + return *internal_default_instance(); +} + + +void OpProto_Var::Clear() { +// @@protoc_insertion_point(message_clear_start:paddle.framework.proto.OpProto.Var) + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + cached_has_bits = _has_bits_[0]; + if (cached_has_bits & 0x00000003u) { + if (cached_has_bits & 0x00000001u) { + name_.ClearNonDefaultToEmpty(); + } + if (cached_has_bits & 0x00000002u) { + comment_.ClearNonDefaultToEmpty(); + } + } + ::memset(&duplicable_, 0, static_cast( + reinterpret_cast(&dispensable_) - + reinterpret_cast(&duplicable_)) + sizeof(dispensable_)); + _has_bits_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +const char* OpProto_Var::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure + _Internal::HasBits has_bits{}; + while (!ctx->Done(&ptr)) { + ::PROTOBUF_NAMESPACE_ID::uint32 tag; + ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + CHK_(ptr); + switch (tag >> 3) { + // required string name = 1; + case 1: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) { + auto str = _internal_mutable_name(); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); + #ifndef NDEBUG + ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "paddle.framework.proto.OpProto.Var.name"); + #endif // !NDEBUG + CHK_(ptr); + } else goto handle_unusual; + continue; + // required string comment = 2; + case 2: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 18)) { + auto str = _internal_mutable_comment(); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); + #ifndef NDEBUG + ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "paddle.framework.proto.OpProto.Var.comment"); + #endif // !NDEBUG + CHK_(ptr); + } else goto handle_unusual; + continue; + // optional bool duplicable = 3 [default = false]; + case 3: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 24)) { + _Internal::set_has_duplicable(&has_bits); + duplicable_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + CHK_(ptr); + } else goto handle_unusual; + continue; + // optional bool intermediate = 4 [default = false]; + case 4: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 32)) { + _Internal::set_has_intermediate(&has_bits); + intermediate_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + CHK_(ptr); + } else goto handle_unusual; + continue; + // optional bool dispensable = 5 [default = false]; + case 5: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 40)) { + _Internal::set_has_dispensable(&has_bits); + dispensable_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + CHK_(ptr); + } else goto handle_unusual; + continue; + default: { + handle_unusual: + if ((tag & 7) == 4 || tag == 0) { + ctx->SetLastTag(tag); + goto success; + } + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); + CHK_(ptr != nullptr); + continue; + } + } // switch + } // while +success: + _has_bits_.Or(has_bits); + return ptr; +failure: + ptr = nullptr; + goto success; +#undef CHK_ +} + +::PROTOBUF_NAMESPACE_ID::uint8* OpProto_Var::_InternalSerialize( + ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { + // @@protoc_insertion_point(serialize_to_array_start:paddle.framework.proto.OpProto.Var) + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + cached_has_bits = _has_bits_[0]; + // required string name = 1; + if (cached_has_bits & 0x00000001u) { + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( + this->_internal_name().data(), static_cast(this->_internal_name().length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, + "paddle.framework.proto.OpProto.Var.name"); + target = stream->WriteStringMaybeAliased( + 1, this->_internal_name(), target); + } + + // required string comment = 2; + if (cached_has_bits & 0x00000002u) { + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( + this->_internal_comment().data(), static_cast(this->_internal_comment().length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, + "paddle.framework.proto.OpProto.Var.comment"); + target = stream->WriteStringMaybeAliased( + 2, this->_internal_comment(), target); + } + + // optional bool duplicable = 3 [default = false]; + if (cached_has_bits & 0x00000004u) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(3, this->_internal_duplicable(), target); + } + + // optional bool intermediate = 4 [default = false]; + if (cached_has_bits & 0x00000008u) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(4, this->_internal_intermediate(), target); + } + + // optional bool dispensable = 5 [default = false]; + if (cached_has_bits & 0x00000010u) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(5, this->_internal_dispensable(), target); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + } + // @@protoc_insertion_point(serialize_to_array_end:paddle.framework.proto.OpProto.Var) + return target; +} + +size_t OpProto_Var::RequiredFieldsByteSizeFallback() const { +// @@protoc_insertion_point(required_fields_byte_size_fallback_start:paddle.framework.proto.OpProto.Var) + size_t total_size = 0; + + if (_internal_has_name()) { + // required string name = 1; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_name()); + } + + if (_internal_has_comment()) { + // required string comment = 2; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_comment()); + } + + return total_size; +} +size_t OpProto_Var::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:paddle.framework.proto.OpProto.Var) + size_t total_size = 0; + + if (((_has_bits_[0] & 0x00000003) ^ 0x00000003) == 0) { // All required fields are present. + // required string name = 1; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_name()); + + // required string comment = 2; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_comment()); + + } else { + total_size += RequiredFieldsByteSizeFallback(); + } + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + cached_has_bits = _has_bits_[0]; + if (cached_has_bits & 0x0000001cu) { + // optional bool duplicable = 3 [default = false]; + if (cached_has_bits & 0x00000004u) { + total_size += 1 + 1; + } + + // optional bool intermediate = 4 [default = false]; + if (cached_has_bits & 0x00000008u) { + total_size += 1 + 1; + } + + // optional bool dispensable = 5 [default = false]; + if (cached_has_bits & 0x00000010u) { + total_size += 1 + 1; + } + + } + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize( + _internal_metadata_, total_size, &_cached_size_); + } + int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size); + SetCachedSize(cached_size); + return total_size; +} + +void OpProto_Var::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { +// @@protoc_insertion_point(generalized_merge_from_start:paddle.framework.proto.OpProto.Var) + GOOGLE_DCHECK_NE(&from, this); + const OpProto_Var* source = + ::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated( + &from); + if (source == nullptr) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:paddle.framework.proto.OpProto.Var) + ::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this); + } else { + // @@protoc_insertion_point(generalized_merge_from_cast_success:paddle.framework.proto.OpProto.Var) + MergeFrom(*source); + } +} + +void OpProto_Var::MergeFrom(const OpProto_Var& from) { +// @@protoc_insertion_point(class_specific_merge_from_start:paddle.framework.proto.OpProto.Var) + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + cached_has_bits = from._has_bits_[0]; + if (cached_has_bits & 0x0000001fu) { + if (cached_has_bits & 0x00000001u) { + _internal_set_name(from._internal_name()); + } + if (cached_has_bits & 0x00000002u) { + _internal_set_comment(from._internal_comment()); + } + if (cached_has_bits & 0x00000004u) { + duplicable_ = from.duplicable_; + } + if (cached_has_bits & 0x00000008u) { + intermediate_ = from.intermediate_; + } + if (cached_has_bits & 0x00000010u) { + dispensable_ = from.dispensable_; + } + _has_bits_[0] |= cached_has_bits; + } +} + +void OpProto_Var::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:paddle.framework.proto.OpProto.Var) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +void OpProto_Var::CopyFrom(const OpProto_Var& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:paddle.framework.proto.OpProto.Var) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool OpProto_Var::IsInitialized() const { + if (_Internal::MissingRequiredFields(_has_bits_)) return false; + return true; +} + +void OpProto_Var::InternalSwap(OpProto_Var* other) { + using std::swap; + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); + swap(_has_bits_[0], other->_has_bits_[0]); + name_.Swap(&other->name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + comment_.Swap(&other->comment_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + ::PROTOBUF_NAMESPACE_ID::internal::memswap< + PROTOBUF_FIELD_OFFSET(OpProto_Var, dispensable_) + + sizeof(OpProto_Var::dispensable_) + - PROTOBUF_FIELD_OFFSET(OpProto_Var, duplicable_)>( + reinterpret_cast(&duplicable_), + reinterpret_cast(&other->duplicable_)); +} + +::PROTOBUF_NAMESPACE_ID::Metadata OpProto_Var::GetMetadata() const { + return GetMetadataStatic(); +} + + +// =================================================================== + +class OpProto_Attr::_Internal { + public: + using HasBits = decltype(std::declval()._has_bits_); + static void set_has_name(HasBits* has_bits) { + (*has_bits)[0] |= 1u; + } + static void set_has_type(HasBits* has_bits) { + (*has_bits)[0] |= 4u; + } + static void set_has_comment(HasBits* has_bits) { + (*has_bits)[0] |= 2u; + } + static void set_has_generated(HasBits* has_bits) { + (*has_bits)[0] |= 8u; + } + static bool MissingRequiredFields(const HasBits& has_bits) { + return ((has_bits[0] & 0x00000007) ^ 0x00000007) != 0; + } +}; + +OpProto_Attr::OpProto_Attr(::PROTOBUF_NAMESPACE_ID::Arena* arena) + : ::PROTOBUF_NAMESPACE_ID::Message(arena) { + SharedCtor(); + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:paddle.framework.proto.OpProto.Attr) +} +OpProto_Attr::OpProto_Attr(const OpProto_Attr& from) + : ::PROTOBUF_NAMESPACE_ID::Message(), + _has_bits_(from._has_bits_) { + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + if (from._internal_has_name()) { + name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(), + GetArena()); + } + comment_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + if (from._internal_has_comment()) { + comment_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_comment(), + GetArena()); + } + ::memcpy(&type_, &from.type_, + static_cast(reinterpret_cast(&generated_) - + reinterpret_cast(&type_)) + sizeof(generated_)); + // @@protoc_insertion_point(copy_constructor:paddle.framework.proto.OpProto.Attr) +} + +void OpProto_Attr::SharedCtor() { + ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_OpProto_Attr_framework_2eproto.base); + name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + comment_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + ::memset(reinterpret_cast(this) + static_cast( + reinterpret_cast(&type_) - reinterpret_cast(this)), + 0, static_cast(reinterpret_cast(&generated_) - + reinterpret_cast(&type_)) + sizeof(generated_)); +} + +OpProto_Attr::~OpProto_Attr() { + // @@protoc_insertion_point(destructor:paddle.framework.proto.OpProto.Attr) + SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +void OpProto_Attr::SharedDtor() { + GOOGLE_DCHECK(GetArena() == nullptr); + name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + comment_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); +} + +void OpProto_Attr::ArenaDtor(void* object) { + OpProto_Attr* _this = reinterpret_cast< OpProto_Attr* >(object); + (void)_this; +} +void OpProto_Attr::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { +} +void OpProto_Attr::SetCachedSize(int size) const { + _cached_size_.Set(size); +} +const OpProto_Attr& OpProto_Attr::default_instance() { + ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_OpProto_Attr_framework_2eproto.base); + return *internal_default_instance(); +} + + +void OpProto_Attr::Clear() { +// @@protoc_insertion_point(message_clear_start:paddle.framework.proto.OpProto.Attr) + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + cached_has_bits = _has_bits_[0]; + if (cached_has_bits & 0x00000003u) { + if (cached_has_bits & 0x00000001u) { + name_.ClearNonDefaultToEmpty(); + } + if (cached_has_bits & 0x00000002u) { + comment_.ClearNonDefaultToEmpty(); + } + } + if (cached_has_bits & 0x0000000cu) { + ::memset(&type_, 0, static_cast( + reinterpret_cast(&generated_) - + reinterpret_cast(&type_)) + sizeof(generated_)); + } + _has_bits_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +const char* OpProto_Attr::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure + _Internal::HasBits has_bits{}; + while (!ctx->Done(&ptr)) { + ::PROTOBUF_NAMESPACE_ID::uint32 tag; + ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + CHK_(ptr); + switch (tag >> 3) { + // required string name = 1; + case 1: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) { + auto str = _internal_mutable_name(); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); + #ifndef NDEBUG + ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "paddle.framework.proto.OpProto.Attr.name"); + #endif // !NDEBUG + CHK_(ptr); + } else goto handle_unusual; + continue; + // required .paddle.framework.proto.AttrType type = 2; + case 2: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 16)) { + ::PROTOBUF_NAMESPACE_ID::uint64 val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + CHK_(ptr); + if (PROTOBUF_PREDICT_TRUE(::paddle::framework::proto::AttrType_IsValid(val))) { + _internal_set_type(static_cast<::paddle::framework::proto::AttrType>(val)); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::WriteVarint(2, val, mutable_unknown_fields()); + } + } else goto handle_unusual; + continue; + // required string comment = 3; + case 3: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 26)) { + auto str = _internal_mutable_comment(); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); + #ifndef NDEBUG + ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "paddle.framework.proto.OpProto.Attr.comment"); + #endif // !NDEBUG + CHK_(ptr); + } else goto handle_unusual; + continue; + // optional bool generated = 4 [default = false]; + case 4: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 32)) { + _Internal::set_has_generated(&has_bits); + generated_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + CHK_(ptr); + } else goto handle_unusual; + continue; + default: { + handle_unusual: + if ((tag & 7) == 4 || tag == 0) { + ctx->SetLastTag(tag); + goto success; + } + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); + CHK_(ptr != nullptr); + continue; + } + } // switch + } // while +success: + _has_bits_.Or(has_bits); + return ptr; +failure: + ptr = nullptr; + goto success; +#undef CHK_ +} + +::PROTOBUF_NAMESPACE_ID::uint8* OpProto_Attr::_InternalSerialize( + ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { + // @@protoc_insertion_point(serialize_to_array_start:paddle.framework.proto.OpProto.Attr) + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + cached_has_bits = _has_bits_[0]; + // required string name = 1; + if (cached_has_bits & 0x00000001u) { + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( + this->_internal_name().data(), static_cast(this->_internal_name().length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, + "paddle.framework.proto.OpProto.Attr.name"); + target = stream->WriteStringMaybeAliased( + 1, this->_internal_name(), target); + } + + // required .paddle.framework.proto.AttrType type = 2; + if (cached_has_bits & 0x00000004u) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteEnumToArray( + 2, this->_internal_type(), target); + } + + // required string comment = 3; + if (cached_has_bits & 0x00000002u) { + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( + this->_internal_comment().data(), static_cast(this->_internal_comment().length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, + "paddle.framework.proto.OpProto.Attr.comment"); + target = stream->WriteStringMaybeAliased( + 3, this->_internal_comment(), target); + } + + // optional bool generated = 4 [default = false]; + if (cached_has_bits & 0x00000008u) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(4, this->_internal_generated(), target); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + } + // @@protoc_insertion_point(serialize_to_array_end:paddle.framework.proto.OpProto.Attr) + return target; +} + +size_t OpProto_Attr::RequiredFieldsByteSizeFallback() const { +// @@protoc_insertion_point(required_fields_byte_size_fallback_start:paddle.framework.proto.OpProto.Attr) + size_t total_size = 0; + + if (_internal_has_name()) { + // required string name = 1; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_name()); + } + + if (_internal_has_comment()) { + // required string comment = 3; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_comment()); + } + + if (_internal_has_type()) { + // required .paddle.framework.proto.AttrType type = 2; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::EnumSize(this->_internal_type()); + } + + return total_size; +} +size_t OpProto_Attr::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:paddle.framework.proto.OpProto.Attr) + size_t total_size = 0; + + if (((_has_bits_[0] & 0x00000007) ^ 0x00000007) == 0) { // All required fields are present. + // required string name = 1; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_name()); + + // required string comment = 3; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_comment()); + + // required .paddle.framework.proto.AttrType type = 2; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::EnumSize(this->_internal_type()); + + } else { + total_size += RequiredFieldsByteSizeFallback(); + } + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + // optional bool generated = 4 [default = false]; + cached_has_bits = _has_bits_[0]; + if (cached_has_bits & 0x00000008u) { + total_size += 1 + 1; + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize( + _internal_metadata_, total_size, &_cached_size_); + } + int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size); + SetCachedSize(cached_size); + return total_size; +} + +void OpProto_Attr::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { +// @@protoc_insertion_point(generalized_merge_from_start:paddle.framework.proto.OpProto.Attr) + GOOGLE_DCHECK_NE(&from, this); + const OpProto_Attr* source = + ::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated( + &from); + if (source == nullptr) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:paddle.framework.proto.OpProto.Attr) + ::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this); + } else { + // @@protoc_insertion_point(generalized_merge_from_cast_success:paddle.framework.proto.OpProto.Attr) + MergeFrom(*source); + } +} + +void OpProto_Attr::MergeFrom(const OpProto_Attr& from) { +// @@protoc_insertion_point(class_specific_merge_from_start:paddle.framework.proto.OpProto.Attr) + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + cached_has_bits = from._has_bits_[0]; + if (cached_has_bits & 0x0000000fu) { + if (cached_has_bits & 0x00000001u) { + _internal_set_name(from._internal_name()); + } + if (cached_has_bits & 0x00000002u) { + _internal_set_comment(from._internal_comment()); + } + if (cached_has_bits & 0x00000004u) { + type_ = from.type_; + } + if (cached_has_bits & 0x00000008u) { + generated_ = from.generated_; + } + _has_bits_[0] |= cached_has_bits; + } +} + +void OpProto_Attr::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:paddle.framework.proto.OpProto.Attr) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +void OpProto_Attr::CopyFrom(const OpProto_Attr& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:paddle.framework.proto.OpProto.Attr) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool OpProto_Attr::IsInitialized() const { + if (_Internal::MissingRequiredFields(_has_bits_)) return false; + return true; +} + +void OpProto_Attr::InternalSwap(OpProto_Attr* other) { + using std::swap; + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); + swap(_has_bits_[0], other->_has_bits_[0]); + name_.Swap(&other->name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + comment_.Swap(&other->comment_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + ::PROTOBUF_NAMESPACE_ID::internal::memswap< + PROTOBUF_FIELD_OFFSET(OpProto_Attr, generated_) + + sizeof(OpProto_Attr::generated_) + - PROTOBUF_FIELD_OFFSET(OpProto_Attr, type_)>( + reinterpret_cast(&type_), + reinterpret_cast(&other->type_)); +} + +::PROTOBUF_NAMESPACE_ID::Metadata OpProto_Attr::GetMetadata() const { + return GetMetadataStatic(); +} + + +// =================================================================== + +class OpProto::_Internal { + public: + using HasBits = decltype(std::declval()._has_bits_); + static void set_has_type(HasBits* has_bits) { + (*has_bits)[0] |= 1u; + } + static void set_has_comment(HasBits* has_bits) { + (*has_bits)[0] |= 2u; + } + static bool MissingRequiredFields(const HasBits& has_bits) { + return ((has_bits[0] & 0x00000003) ^ 0x00000003) != 0; + } +}; + +OpProto::OpProto(::PROTOBUF_NAMESPACE_ID::Arena* arena) + : ::PROTOBUF_NAMESPACE_ID::Message(arena), + inputs_(arena), + outputs_(arena), + attrs_(arena) { + SharedCtor(); + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:paddle.framework.proto.OpProto) +} +OpProto::OpProto(const OpProto& from) + : ::PROTOBUF_NAMESPACE_ID::Message(), + _has_bits_(from._has_bits_), + inputs_(from.inputs_), + outputs_(from.outputs_), + attrs_(from.attrs_) { + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + type_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + if (from._internal_has_type()) { + type_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_type(), + GetArena()); + } + comment_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + if (from._internal_has_comment()) { + comment_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_comment(), + GetArena()); + } + // @@protoc_insertion_point(copy_constructor:paddle.framework.proto.OpProto) +} + +void OpProto::SharedCtor() { + ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_OpProto_framework_2eproto.base); + type_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + comment_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); +} + +OpProto::~OpProto() { + // @@protoc_insertion_point(destructor:paddle.framework.proto.OpProto) + SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +void OpProto::SharedDtor() { + GOOGLE_DCHECK(GetArena() == nullptr); + type_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + comment_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); +} + +void OpProto::ArenaDtor(void* object) { + OpProto* _this = reinterpret_cast< OpProto* >(object); + (void)_this; +} +void OpProto::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { +} +void OpProto::SetCachedSize(int size) const { + _cached_size_.Set(size); +} +const OpProto& OpProto::default_instance() { + ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_OpProto_framework_2eproto.base); + return *internal_default_instance(); +} + + +void OpProto::Clear() { +// @@protoc_insertion_point(message_clear_start:paddle.framework.proto.OpProto) + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + inputs_.Clear(); + outputs_.Clear(); + attrs_.Clear(); + cached_has_bits = _has_bits_[0]; + if (cached_has_bits & 0x00000003u) { + if (cached_has_bits & 0x00000001u) { + type_.ClearNonDefaultToEmpty(); + } + if (cached_has_bits & 0x00000002u) { + comment_.ClearNonDefaultToEmpty(); + } + } + _has_bits_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +const char* OpProto::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure + _Internal::HasBits has_bits{}; + while (!ctx->Done(&ptr)) { + ::PROTOBUF_NAMESPACE_ID::uint32 tag; + ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + CHK_(ptr); + switch (tag >> 3) { + // required string type = 1; + case 1: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) { + auto str = _internal_mutable_type(); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); + #ifndef NDEBUG + ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "paddle.framework.proto.OpProto.type"); + #endif // !NDEBUG + CHK_(ptr); + } else goto handle_unusual; + continue; + // repeated .paddle.framework.proto.OpProto.Var inputs = 2; + case 2: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 18)) { + ptr -= 1; + do { + ptr += 1; + ptr = ctx->ParseMessage(_internal_add_inputs(), ptr); + CHK_(ptr); + if (!ctx->DataAvailable(ptr)) break; + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<18>(ptr)); + } else goto handle_unusual; + continue; + // repeated .paddle.framework.proto.OpProto.Var outputs = 3; + case 3: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 26)) { + ptr -= 1; + do { + ptr += 1; + ptr = ctx->ParseMessage(_internal_add_outputs(), ptr); + CHK_(ptr); + if (!ctx->DataAvailable(ptr)) break; + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<26>(ptr)); + } else goto handle_unusual; + continue; + // repeated .paddle.framework.proto.OpProto.Attr attrs = 4; + case 4: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 34)) { + ptr -= 1; + do { + ptr += 1; + ptr = ctx->ParseMessage(_internal_add_attrs(), ptr); + CHK_(ptr); + if (!ctx->DataAvailable(ptr)) break; + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<34>(ptr)); + } else goto handle_unusual; + continue; + // required string comment = 5; + case 5: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 42)) { + auto str = _internal_mutable_comment(); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); + #ifndef NDEBUG + ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "paddle.framework.proto.OpProto.comment"); + #endif // !NDEBUG + CHK_(ptr); + } else goto handle_unusual; + continue; + default: { + handle_unusual: + if ((tag & 7) == 4 || tag == 0) { + ctx->SetLastTag(tag); + goto success; + } + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); + CHK_(ptr != nullptr); + continue; + } + } // switch + } // while +success: + _has_bits_.Or(has_bits); + return ptr; +failure: + ptr = nullptr; + goto success; +#undef CHK_ +} + +::PROTOBUF_NAMESPACE_ID::uint8* OpProto::_InternalSerialize( + ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { + // @@protoc_insertion_point(serialize_to_array_start:paddle.framework.proto.OpProto) + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + cached_has_bits = _has_bits_[0]; + // required string type = 1; + if (cached_has_bits & 0x00000001u) { + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( + this->_internal_type().data(), static_cast(this->_internal_type().length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, + "paddle.framework.proto.OpProto.type"); + target = stream->WriteStringMaybeAliased( + 1, this->_internal_type(), target); + } + + // repeated .paddle.framework.proto.OpProto.Var inputs = 2; + for (unsigned int i = 0, + n = static_cast(this->_internal_inputs_size()); i < n; i++) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage(2, this->_internal_inputs(i), target, stream); + } + + // repeated .paddle.framework.proto.OpProto.Var outputs = 3; + for (unsigned int i = 0, + n = static_cast(this->_internal_outputs_size()); i < n; i++) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage(3, this->_internal_outputs(i), target, stream); + } + + // repeated .paddle.framework.proto.OpProto.Attr attrs = 4; + for (unsigned int i = 0, + n = static_cast(this->_internal_attrs_size()); i < n; i++) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage(4, this->_internal_attrs(i), target, stream); + } + + // required string comment = 5; + if (cached_has_bits & 0x00000002u) { + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( + this->_internal_comment().data(), static_cast(this->_internal_comment().length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, + "paddle.framework.proto.OpProto.comment"); + target = stream->WriteStringMaybeAliased( + 5, this->_internal_comment(), target); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + } + // @@protoc_insertion_point(serialize_to_array_end:paddle.framework.proto.OpProto) + return target; +} + +size_t OpProto::RequiredFieldsByteSizeFallback() const { +// @@protoc_insertion_point(required_fields_byte_size_fallback_start:paddle.framework.proto.OpProto) + size_t total_size = 0; + + if (_internal_has_type()) { + // required string type = 1; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_type()); + } + + if (_internal_has_comment()) { + // required string comment = 5; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_comment()); + } + + return total_size; +} +size_t OpProto::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:paddle.framework.proto.OpProto) + size_t total_size = 0; + + if (((_has_bits_[0] & 0x00000003) ^ 0x00000003) == 0) { // All required fields are present. + // required string type = 1; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_type()); + + // required string comment = 5; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_comment()); + + } else { + total_size += RequiredFieldsByteSizeFallback(); + } + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + // repeated .paddle.framework.proto.OpProto.Var inputs = 2; + total_size += 1UL * this->_internal_inputs_size(); + for (const auto& msg : this->inputs_) { + total_size += + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); + } + + // repeated .paddle.framework.proto.OpProto.Var outputs = 3; + total_size += 1UL * this->_internal_outputs_size(); + for (const auto& msg : this->outputs_) { + total_size += + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); + } + + // repeated .paddle.framework.proto.OpProto.Attr attrs = 4; + total_size += 1UL * this->_internal_attrs_size(); + for (const auto& msg : this->attrs_) { + total_size += + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize( + _internal_metadata_, total_size, &_cached_size_); + } + int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size); + SetCachedSize(cached_size); + return total_size; +} + +void OpProto::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { +// @@protoc_insertion_point(generalized_merge_from_start:paddle.framework.proto.OpProto) + GOOGLE_DCHECK_NE(&from, this); + const OpProto* source = + ::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated( + &from); + if (source == nullptr) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:paddle.framework.proto.OpProto) + ::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this); + } else { + // @@protoc_insertion_point(generalized_merge_from_cast_success:paddle.framework.proto.OpProto) + MergeFrom(*source); + } +} + +void OpProto::MergeFrom(const OpProto& from) { +// @@protoc_insertion_point(class_specific_merge_from_start:paddle.framework.proto.OpProto) + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + inputs_.MergeFrom(from.inputs_); + outputs_.MergeFrom(from.outputs_); + attrs_.MergeFrom(from.attrs_); + cached_has_bits = from._has_bits_[0]; + if (cached_has_bits & 0x00000003u) { + if (cached_has_bits & 0x00000001u) { + _internal_set_type(from._internal_type()); + } + if (cached_has_bits & 0x00000002u) { + _internal_set_comment(from._internal_comment()); + } + } +} + +void OpProto::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:paddle.framework.proto.OpProto) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +void OpProto::CopyFrom(const OpProto& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:paddle.framework.proto.OpProto) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool OpProto::IsInitialized() const { + if (_Internal::MissingRequiredFields(_has_bits_)) return false; + if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(inputs_)) return false; + if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(outputs_)) return false; + if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(attrs_)) return false; + return true; +} + +void OpProto::InternalSwap(OpProto* other) { + using std::swap; + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); + swap(_has_bits_[0], other->_has_bits_[0]); + inputs_.InternalSwap(&other->inputs_); + outputs_.InternalSwap(&other->outputs_); + attrs_.InternalSwap(&other->attrs_); + type_.Swap(&other->type_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + comment_.Swap(&other->comment_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); +} + +::PROTOBUF_NAMESPACE_ID::Metadata OpProto::GetMetadata() const { + return GetMetadataStatic(); +} + + +// =================================================================== + +class VarType_TensorDesc::_Internal { + public: + using HasBits = decltype(std::declval()._has_bits_); + static void set_has_data_type(HasBits* has_bits) { + (*has_bits)[0] |= 1u; + } + static bool MissingRequiredFields(const HasBits& has_bits) { + return ((has_bits[0] & 0x00000001) ^ 0x00000001) != 0; + } +}; + +VarType_TensorDesc::VarType_TensorDesc(::PROTOBUF_NAMESPACE_ID::Arena* arena) + : ::PROTOBUF_NAMESPACE_ID::Message(arena), + dims_(arena) { + SharedCtor(); + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:paddle.framework.proto.VarType.TensorDesc) +} +VarType_TensorDesc::VarType_TensorDesc(const VarType_TensorDesc& from) + : ::PROTOBUF_NAMESPACE_ID::Message(), + _has_bits_(from._has_bits_), + dims_(from.dims_) { + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + data_type_ = from.data_type_; + // @@protoc_insertion_point(copy_constructor:paddle.framework.proto.VarType.TensorDesc) +} + +void VarType_TensorDesc::SharedCtor() { + data_type_ = 0; +} + +VarType_TensorDesc::~VarType_TensorDesc() { + // @@protoc_insertion_point(destructor:paddle.framework.proto.VarType.TensorDesc) + SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +void VarType_TensorDesc::SharedDtor() { + GOOGLE_DCHECK(GetArena() == nullptr); +} + +void VarType_TensorDesc::ArenaDtor(void* object) { + VarType_TensorDesc* _this = reinterpret_cast< VarType_TensorDesc* >(object); + (void)_this; +} +void VarType_TensorDesc::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { +} +void VarType_TensorDesc::SetCachedSize(int size) const { + _cached_size_.Set(size); +} +const VarType_TensorDesc& VarType_TensorDesc::default_instance() { + ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_VarType_TensorDesc_framework_2eproto.base); + return *internal_default_instance(); +} + + +void VarType_TensorDesc::Clear() { +// @@protoc_insertion_point(message_clear_start:paddle.framework.proto.VarType.TensorDesc) + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + dims_.Clear(); + data_type_ = 0; + _has_bits_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +const char* VarType_TensorDesc::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure + _Internal::HasBits has_bits{}; + while (!ctx->Done(&ptr)) { + ::PROTOBUF_NAMESPACE_ID::uint32 tag; + ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + CHK_(ptr); + switch (tag >> 3) { + // required .paddle.framework.proto.VarType.Type data_type = 1; + case 1: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 8)) { + ::PROTOBUF_NAMESPACE_ID::uint64 val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + CHK_(ptr); + if (PROTOBUF_PREDICT_TRUE(::paddle::framework::proto::VarType_Type_IsValid(val))) { + _internal_set_data_type(static_cast<::paddle::framework::proto::VarType_Type>(val)); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::WriteVarint(1, val, mutable_unknown_fields()); + } + } else goto handle_unusual; + continue; + // repeated int64 dims = 2; + case 2: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 16)) { + ptr -= 1; + do { + ptr += 1; + _internal_add_dims(::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr)); + CHK_(ptr); + if (!ctx->DataAvailable(ptr)) break; + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<16>(ptr)); + } else if (static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 18) { + ptr = ::PROTOBUF_NAMESPACE_ID::internal::PackedInt64Parser(_internal_mutable_dims(), ptr, ctx); + CHK_(ptr); + } else goto handle_unusual; + continue; + default: { + handle_unusual: + if ((tag & 7) == 4 || tag == 0) { + ctx->SetLastTag(tag); + goto success; + } + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); + CHK_(ptr != nullptr); + continue; + } + } // switch + } // while +success: + _has_bits_.Or(has_bits); + return ptr; +failure: + ptr = nullptr; + goto success; +#undef CHK_ +} + +::PROTOBUF_NAMESPACE_ID::uint8* VarType_TensorDesc::_InternalSerialize( + ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { + // @@protoc_insertion_point(serialize_to_array_start:paddle.framework.proto.VarType.TensorDesc) + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + cached_has_bits = _has_bits_[0]; + // required .paddle.framework.proto.VarType.Type data_type = 1; + if (cached_has_bits & 0x00000001u) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteEnumToArray( + 1, this->_internal_data_type(), target); + } + + // repeated int64 dims = 2; + for (int i = 0, n = this->_internal_dims_size(); i < n; i++) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt64ToArray(2, this->_internal_dims(i), target); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + } + // @@protoc_insertion_point(serialize_to_array_end:paddle.framework.proto.VarType.TensorDesc) + return target; +} + +size_t VarType_TensorDesc::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:paddle.framework.proto.VarType.TensorDesc) + size_t total_size = 0; + + // required .paddle.framework.proto.VarType.Type data_type = 1; + if (_internal_has_data_type()) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::EnumSize(this->_internal_data_type()); + } + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + // repeated int64 dims = 2; + { + size_t data_size = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + Int64Size(this->dims_); + total_size += 1 * + ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(this->_internal_dims_size()); + total_size += data_size; + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize( + _internal_metadata_, total_size, &_cached_size_); + } + int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size); + SetCachedSize(cached_size); + return total_size; +} + +void VarType_TensorDesc::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { +// @@protoc_insertion_point(generalized_merge_from_start:paddle.framework.proto.VarType.TensorDesc) + GOOGLE_DCHECK_NE(&from, this); + const VarType_TensorDesc* source = + ::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated( + &from); + if (source == nullptr) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:paddle.framework.proto.VarType.TensorDesc) + ::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this); + } else { + // @@protoc_insertion_point(generalized_merge_from_cast_success:paddle.framework.proto.VarType.TensorDesc) + MergeFrom(*source); + } +} + +void VarType_TensorDesc::MergeFrom(const VarType_TensorDesc& from) { +// @@protoc_insertion_point(class_specific_merge_from_start:paddle.framework.proto.VarType.TensorDesc) + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + dims_.MergeFrom(from.dims_); + if (from._internal_has_data_type()) { + _internal_set_data_type(from._internal_data_type()); + } +} + +void VarType_TensorDesc::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:paddle.framework.proto.VarType.TensorDesc) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +void VarType_TensorDesc::CopyFrom(const VarType_TensorDesc& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:paddle.framework.proto.VarType.TensorDesc) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool VarType_TensorDesc::IsInitialized() const { + if (_Internal::MissingRequiredFields(_has_bits_)) return false; + return true; +} + +void VarType_TensorDesc::InternalSwap(VarType_TensorDesc* other) { + using std::swap; + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); + swap(_has_bits_[0], other->_has_bits_[0]); + dims_.InternalSwap(&other->dims_); + swap(data_type_, other->data_type_); +} + +::PROTOBUF_NAMESPACE_ID::Metadata VarType_TensorDesc::GetMetadata() const { + return GetMetadataStatic(); +} + + +// =================================================================== + +class VarType_LoDTensorDesc::_Internal { + public: + using HasBits = decltype(std::declval()._has_bits_); + static const ::paddle::framework::proto::VarType_TensorDesc& tensor(const VarType_LoDTensorDesc* msg); + static void set_has_tensor(HasBits* has_bits) { + (*has_bits)[0] |= 1u; + } + static void set_has_lod_level(HasBits* has_bits) { + (*has_bits)[0] |= 2u; + } + static bool MissingRequiredFields(const HasBits& has_bits) { + return ((has_bits[0] & 0x00000001) ^ 0x00000001) != 0; + } +}; + +const ::paddle::framework::proto::VarType_TensorDesc& +VarType_LoDTensorDesc::_Internal::tensor(const VarType_LoDTensorDesc* msg) { + return *msg->tensor_; +} +VarType_LoDTensorDesc::VarType_LoDTensorDesc(::PROTOBUF_NAMESPACE_ID::Arena* arena) + : ::PROTOBUF_NAMESPACE_ID::Message(arena) { + SharedCtor(); + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:paddle.framework.proto.VarType.LoDTensorDesc) +} +VarType_LoDTensorDesc::VarType_LoDTensorDesc(const VarType_LoDTensorDesc& from) + : ::PROTOBUF_NAMESPACE_ID::Message(), + _has_bits_(from._has_bits_) { + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + if (from._internal_has_tensor()) { + tensor_ = new ::paddle::framework::proto::VarType_TensorDesc(*from.tensor_); + } else { + tensor_ = nullptr; + } + lod_level_ = from.lod_level_; + // @@protoc_insertion_point(copy_constructor:paddle.framework.proto.VarType.LoDTensorDesc) +} + +void VarType_LoDTensorDesc::SharedCtor() { + ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_VarType_LoDTensorDesc_framework_2eproto.base); + ::memset(reinterpret_cast(this) + static_cast( + reinterpret_cast(&tensor_) - reinterpret_cast(this)), + 0, static_cast(reinterpret_cast(&lod_level_) - + reinterpret_cast(&tensor_)) + sizeof(lod_level_)); +} + +VarType_LoDTensorDesc::~VarType_LoDTensorDesc() { + // @@protoc_insertion_point(destructor:paddle.framework.proto.VarType.LoDTensorDesc) + SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +void VarType_LoDTensorDesc::SharedDtor() { + GOOGLE_DCHECK(GetArena() == nullptr); + if (this != internal_default_instance()) delete tensor_; +} + +void VarType_LoDTensorDesc::ArenaDtor(void* object) { + VarType_LoDTensorDesc* _this = reinterpret_cast< VarType_LoDTensorDesc* >(object); + (void)_this; +} +void VarType_LoDTensorDesc::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { +} +void VarType_LoDTensorDesc::SetCachedSize(int size) const { + _cached_size_.Set(size); +} +const VarType_LoDTensorDesc& VarType_LoDTensorDesc::default_instance() { + ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_VarType_LoDTensorDesc_framework_2eproto.base); + return *internal_default_instance(); +} + + +void VarType_LoDTensorDesc::Clear() { +// @@protoc_insertion_point(message_clear_start:paddle.framework.proto.VarType.LoDTensorDesc) + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + cached_has_bits = _has_bits_[0]; + if (cached_has_bits & 0x00000001u) { + GOOGLE_DCHECK(tensor_ != nullptr); + tensor_->Clear(); + } + lod_level_ = 0; + _has_bits_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +const char* VarType_LoDTensorDesc::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure + _Internal::HasBits has_bits{}; + while (!ctx->Done(&ptr)) { + ::PROTOBUF_NAMESPACE_ID::uint32 tag; + ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + CHK_(ptr); + switch (tag >> 3) { + // required .paddle.framework.proto.VarType.TensorDesc tensor = 1; + case 1: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) { + ptr = ctx->ParseMessage(_internal_mutable_tensor(), ptr); + CHK_(ptr); + } else goto handle_unusual; + continue; + // optional int32 lod_level = 2 [default = 0]; + case 2: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 16)) { + _Internal::set_has_lod_level(&has_bits); + lod_level_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + CHK_(ptr); + } else goto handle_unusual; + continue; + default: { + handle_unusual: + if ((tag & 7) == 4 || tag == 0) { + ctx->SetLastTag(tag); + goto success; + } + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); + CHK_(ptr != nullptr); + continue; + } + } // switch + } // while +success: + _has_bits_.Or(has_bits); + return ptr; +failure: + ptr = nullptr; + goto success; +#undef CHK_ +} + +::PROTOBUF_NAMESPACE_ID::uint8* VarType_LoDTensorDesc::_InternalSerialize( + ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { + // @@protoc_insertion_point(serialize_to_array_start:paddle.framework.proto.VarType.LoDTensorDesc) + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + cached_has_bits = _has_bits_[0]; + // required .paddle.framework.proto.VarType.TensorDesc tensor = 1; + if (cached_has_bits & 0x00000001u) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage( + 1, _Internal::tensor(this), target, stream); + } + + // optional int32 lod_level = 2 [default = 0]; + if (cached_has_bits & 0x00000002u) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(2, this->_internal_lod_level(), target); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + } + // @@protoc_insertion_point(serialize_to_array_end:paddle.framework.proto.VarType.LoDTensorDesc) + return target; +} + +size_t VarType_LoDTensorDesc::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:paddle.framework.proto.VarType.LoDTensorDesc) + size_t total_size = 0; + + // required .paddle.framework.proto.VarType.TensorDesc tensor = 1; + if (_internal_has_tensor()) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *tensor_); + } + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + // optional int32 lod_level = 2 [default = 0]; + cached_has_bits = _has_bits_[0]; + if (cached_has_bits & 0x00000002u) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size( + this->_internal_lod_level()); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize( + _internal_metadata_, total_size, &_cached_size_); + } + int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size); + SetCachedSize(cached_size); + return total_size; +} + +void VarType_LoDTensorDesc::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { +// @@protoc_insertion_point(generalized_merge_from_start:paddle.framework.proto.VarType.LoDTensorDesc) + GOOGLE_DCHECK_NE(&from, this); + const VarType_LoDTensorDesc* source = + ::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated( + &from); + if (source == nullptr) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:paddle.framework.proto.VarType.LoDTensorDesc) + ::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this); + } else { + // @@protoc_insertion_point(generalized_merge_from_cast_success:paddle.framework.proto.VarType.LoDTensorDesc) + MergeFrom(*source); + } +} + +void VarType_LoDTensorDesc::MergeFrom(const VarType_LoDTensorDesc& from) { +// @@protoc_insertion_point(class_specific_merge_from_start:paddle.framework.proto.VarType.LoDTensorDesc) + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + cached_has_bits = from._has_bits_[0]; + if (cached_has_bits & 0x00000003u) { + if (cached_has_bits & 0x00000001u) { + _internal_mutable_tensor()->::paddle::framework::proto::VarType_TensorDesc::MergeFrom(from._internal_tensor()); + } + if (cached_has_bits & 0x00000002u) { + lod_level_ = from.lod_level_; + } + _has_bits_[0] |= cached_has_bits; + } +} + +void VarType_LoDTensorDesc::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:paddle.framework.proto.VarType.LoDTensorDesc) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +void VarType_LoDTensorDesc::CopyFrom(const VarType_LoDTensorDesc& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:paddle.framework.proto.VarType.LoDTensorDesc) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool VarType_LoDTensorDesc::IsInitialized() const { + if (_Internal::MissingRequiredFields(_has_bits_)) return false; + if (_internal_has_tensor()) { + if (!tensor_->IsInitialized()) return false; + } + return true; +} + +void VarType_LoDTensorDesc::InternalSwap(VarType_LoDTensorDesc* other) { + using std::swap; + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); + swap(_has_bits_[0], other->_has_bits_[0]); + ::PROTOBUF_NAMESPACE_ID::internal::memswap< + PROTOBUF_FIELD_OFFSET(VarType_LoDTensorDesc, lod_level_) + + sizeof(VarType_LoDTensorDesc::lod_level_) + - PROTOBUF_FIELD_OFFSET(VarType_LoDTensorDesc, tensor_)>( + reinterpret_cast(&tensor_), + reinterpret_cast(&other->tensor_)); +} + +::PROTOBUF_NAMESPACE_ID::Metadata VarType_LoDTensorDesc::GetMetadata() const { + return GetMetadataStatic(); +} + + +// =================================================================== + +class VarType_LoDTensorArrayDesc::_Internal { + public: + using HasBits = decltype(std::declval()._has_bits_); + static const ::paddle::framework::proto::VarType_TensorDesc& tensor(const VarType_LoDTensorArrayDesc* msg); + static void set_has_tensor(HasBits* has_bits) { + (*has_bits)[0] |= 1u; + } + static void set_has_lod_level(HasBits* has_bits) { + (*has_bits)[0] |= 2u; + } + static bool MissingRequiredFields(const HasBits& has_bits) { + return ((has_bits[0] & 0x00000001) ^ 0x00000001) != 0; + } +}; + +const ::paddle::framework::proto::VarType_TensorDesc& +VarType_LoDTensorArrayDesc::_Internal::tensor(const VarType_LoDTensorArrayDesc* msg) { + return *msg->tensor_; +} +VarType_LoDTensorArrayDesc::VarType_LoDTensorArrayDesc(::PROTOBUF_NAMESPACE_ID::Arena* arena) + : ::PROTOBUF_NAMESPACE_ID::Message(arena) { + SharedCtor(); + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:paddle.framework.proto.VarType.LoDTensorArrayDesc) +} +VarType_LoDTensorArrayDesc::VarType_LoDTensorArrayDesc(const VarType_LoDTensorArrayDesc& from) + : ::PROTOBUF_NAMESPACE_ID::Message(), + _has_bits_(from._has_bits_) { + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + if (from._internal_has_tensor()) { + tensor_ = new ::paddle::framework::proto::VarType_TensorDesc(*from.tensor_); + } else { + tensor_ = nullptr; + } + lod_level_ = from.lod_level_; + // @@protoc_insertion_point(copy_constructor:paddle.framework.proto.VarType.LoDTensorArrayDesc) +} + +void VarType_LoDTensorArrayDesc::SharedCtor() { + ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_VarType_LoDTensorArrayDesc_framework_2eproto.base); + ::memset(reinterpret_cast(this) + static_cast( + reinterpret_cast(&tensor_) - reinterpret_cast(this)), + 0, static_cast(reinterpret_cast(&lod_level_) - + reinterpret_cast(&tensor_)) + sizeof(lod_level_)); +} + +VarType_LoDTensorArrayDesc::~VarType_LoDTensorArrayDesc() { + // @@protoc_insertion_point(destructor:paddle.framework.proto.VarType.LoDTensorArrayDesc) + SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +void VarType_LoDTensorArrayDesc::SharedDtor() { + GOOGLE_DCHECK(GetArena() == nullptr); + if (this != internal_default_instance()) delete tensor_; +} + +void VarType_LoDTensorArrayDesc::ArenaDtor(void* object) { + VarType_LoDTensorArrayDesc* _this = reinterpret_cast< VarType_LoDTensorArrayDesc* >(object); + (void)_this; +} +void VarType_LoDTensorArrayDesc::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { +} +void VarType_LoDTensorArrayDesc::SetCachedSize(int size) const { + _cached_size_.Set(size); +} +const VarType_LoDTensorArrayDesc& VarType_LoDTensorArrayDesc::default_instance() { + ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_VarType_LoDTensorArrayDesc_framework_2eproto.base); + return *internal_default_instance(); +} + + +void VarType_LoDTensorArrayDesc::Clear() { +// @@protoc_insertion_point(message_clear_start:paddle.framework.proto.VarType.LoDTensorArrayDesc) + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + cached_has_bits = _has_bits_[0]; + if (cached_has_bits & 0x00000001u) { + GOOGLE_DCHECK(tensor_ != nullptr); + tensor_->Clear(); + } + lod_level_ = 0; + _has_bits_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +const char* VarType_LoDTensorArrayDesc::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure + _Internal::HasBits has_bits{}; + while (!ctx->Done(&ptr)) { + ::PROTOBUF_NAMESPACE_ID::uint32 tag; + ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + CHK_(ptr); + switch (tag >> 3) { + // required .paddle.framework.proto.VarType.TensorDesc tensor = 1; + case 1: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) { + ptr = ctx->ParseMessage(_internal_mutable_tensor(), ptr); + CHK_(ptr); + } else goto handle_unusual; + continue; + // optional int32 lod_level = 2 [default = 0]; + case 2: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 16)) { + _Internal::set_has_lod_level(&has_bits); + lod_level_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + CHK_(ptr); + } else goto handle_unusual; + continue; + default: { + handle_unusual: + if ((tag & 7) == 4 || tag == 0) { + ctx->SetLastTag(tag); + goto success; + } + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); + CHK_(ptr != nullptr); + continue; + } + } // switch + } // while +success: + _has_bits_.Or(has_bits); + return ptr; +failure: + ptr = nullptr; + goto success; +#undef CHK_ +} + +::PROTOBUF_NAMESPACE_ID::uint8* VarType_LoDTensorArrayDesc::_InternalSerialize( + ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { + // @@protoc_insertion_point(serialize_to_array_start:paddle.framework.proto.VarType.LoDTensorArrayDesc) + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + cached_has_bits = _has_bits_[0]; + // required .paddle.framework.proto.VarType.TensorDesc tensor = 1; + if (cached_has_bits & 0x00000001u) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage( + 1, _Internal::tensor(this), target, stream); + } + + // optional int32 lod_level = 2 [default = 0]; + if (cached_has_bits & 0x00000002u) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(2, this->_internal_lod_level(), target); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + } + // @@protoc_insertion_point(serialize_to_array_end:paddle.framework.proto.VarType.LoDTensorArrayDesc) + return target; +} + +size_t VarType_LoDTensorArrayDesc::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:paddle.framework.proto.VarType.LoDTensorArrayDesc) + size_t total_size = 0; + + // required .paddle.framework.proto.VarType.TensorDesc tensor = 1; + if (_internal_has_tensor()) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *tensor_); + } + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + // optional int32 lod_level = 2 [default = 0]; + cached_has_bits = _has_bits_[0]; + if (cached_has_bits & 0x00000002u) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size( + this->_internal_lod_level()); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize( + _internal_metadata_, total_size, &_cached_size_); + } + int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size); + SetCachedSize(cached_size); + return total_size; +} + +void VarType_LoDTensorArrayDesc::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { +// @@protoc_insertion_point(generalized_merge_from_start:paddle.framework.proto.VarType.LoDTensorArrayDesc) + GOOGLE_DCHECK_NE(&from, this); + const VarType_LoDTensorArrayDesc* source = + ::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated( + &from); + if (source == nullptr) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:paddle.framework.proto.VarType.LoDTensorArrayDesc) + ::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this); + } else { + // @@protoc_insertion_point(generalized_merge_from_cast_success:paddle.framework.proto.VarType.LoDTensorArrayDesc) + MergeFrom(*source); + } +} + +void VarType_LoDTensorArrayDesc::MergeFrom(const VarType_LoDTensorArrayDesc& from) { +// @@protoc_insertion_point(class_specific_merge_from_start:paddle.framework.proto.VarType.LoDTensorArrayDesc) + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + cached_has_bits = from._has_bits_[0]; + if (cached_has_bits & 0x00000003u) { + if (cached_has_bits & 0x00000001u) { + _internal_mutable_tensor()->::paddle::framework::proto::VarType_TensorDesc::MergeFrom(from._internal_tensor()); + } + if (cached_has_bits & 0x00000002u) { + lod_level_ = from.lod_level_; + } + _has_bits_[0] |= cached_has_bits; + } +} + +void VarType_LoDTensorArrayDesc::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:paddle.framework.proto.VarType.LoDTensorArrayDesc) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +void VarType_LoDTensorArrayDesc::CopyFrom(const VarType_LoDTensorArrayDesc& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:paddle.framework.proto.VarType.LoDTensorArrayDesc) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool VarType_LoDTensorArrayDesc::IsInitialized() const { + if (_Internal::MissingRequiredFields(_has_bits_)) return false; + if (_internal_has_tensor()) { + if (!tensor_->IsInitialized()) return false; + } + return true; +} + +void VarType_LoDTensorArrayDesc::InternalSwap(VarType_LoDTensorArrayDesc* other) { + using std::swap; + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); + swap(_has_bits_[0], other->_has_bits_[0]); + ::PROTOBUF_NAMESPACE_ID::internal::memswap< + PROTOBUF_FIELD_OFFSET(VarType_LoDTensorArrayDesc, lod_level_) + + sizeof(VarType_LoDTensorArrayDesc::lod_level_) + - PROTOBUF_FIELD_OFFSET(VarType_LoDTensorArrayDesc, tensor_)>( + reinterpret_cast(&tensor_), + reinterpret_cast(&other->tensor_)); +} + +::PROTOBUF_NAMESPACE_ID::Metadata VarType_LoDTensorArrayDesc::GetMetadata() const { + return GetMetadataStatic(); +} + + +// =================================================================== + +class VarType_ReaderDesc::_Internal { + public: +}; + +VarType_ReaderDesc::VarType_ReaderDesc(::PROTOBUF_NAMESPACE_ID::Arena* arena) + : ::PROTOBUF_NAMESPACE_ID::Message(arena), + lod_tensor_(arena) { + SharedCtor(); + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:paddle.framework.proto.VarType.ReaderDesc) +} +VarType_ReaderDesc::VarType_ReaderDesc(const VarType_ReaderDesc& from) + : ::PROTOBUF_NAMESPACE_ID::Message(), + lod_tensor_(from.lod_tensor_) { + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + // @@protoc_insertion_point(copy_constructor:paddle.framework.proto.VarType.ReaderDesc) +} + +void VarType_ReaderDesc::SharedCtor() { + ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_VarType_ReaderDesc_framework_2eproto.base); +} + +VarType_ReaderDesc::~VarType_ReaderDesc() { + // @@protoc_insertion_point(destructor:paddle.framework.proto.VarType.ReaderDesc) + SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +void VarType_ReaderDesc::SharedDtor() { + GOOGLE_DCHECK(GetArena() == nullptr); +} + +void VarType_ReaderDesc::ArenaDtor(void* object) { + VarType_ReaderDesc* _this = reinterpret_cast< VarType_ReaderDesc* >(object); + (void)_this; +} +void VarType_ReaderDesc::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { +} +void VarType_ReaderDesc::SetCachedSize(int size) const { + _cached_size_.Set(size); +} +const VarType_ReaderDesc& VarType_ReaderDesc::default_instance() { + ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_VarType_ReaderDesc_framework_2eproto.base); + return *internal_default_instance(); +} + + +void VarType_ReaderDesc::Clear() { +// @@protoc_insertion_point(message_clear_start:paddle.framework.proto.VarType.ReaderDesc) + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + lod_tensor_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +const char* VarType_ReaderDesc::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure + while (!ctx->Done(&ptr)) { + ::PROTOBUF_NAMESPACE_ID::uint32 tag; + ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + CHK_(ptr); + switch (tag >> 3) { + // repeated .paddle.framework.proto.VarType.LoDTensorDesc lod_tensor = 1; + case 1: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) { + ptr -= 1; + do { + ptr += 1; + ptr = ctx->ParseMessage(_internal_add_lod_tensor(), ptr); + CHK_(ptr); + if (!ctx->DataAvailable(ptr)) break; + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<10>(ptr)); + } else goto handle_unusual; + continue; + default: { + handle_unusual: + if ((tag & 7) == 4 || tag == 0) { + ctx->SetLastTag(tag); + goto success; + } + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); + CHK_(ptr != nullptr); + continue; + } + } // switch + } // while +success: + return ptr; +failure: + ptr = nullptr; + goto success; +#undef CHK_ +} + +::PROTOBUF_NAMESPACE_ID::uint8* VarType_ReaderDesc::_InternalSerialize( + ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { + // @@protoc_insertion_point(serialize_to_array_start:paddle.framework.proto.VarType.ReaderDesc) + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + // repeated .paddle.framework.proto.VarType.LoDTensorDesc lod_tensor = 1; + for (unsigned int i = 0, + n = static_cast(this->_internal_lod_tensor_size()); i < n; i++) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage(1, this->_internal_lod_tensor(i), target, stream); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + } + // @@protoc_insertion_point(serialize_to_array_end:paddle.framework.proto.VarType.ReaderDesc) + return target; +} + +size_t VarType_ReaderDesc::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:paddle.framework.proto.VarType.ReaderDesc) + size_t total_size = 0; + + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + // repeated .paddle.framework.proto.VarType.LoDTensorDesc lod_tensor = 1; + total_size += 1UL * this->_internal_lod_tensor_size(); + for (const auto& msg : this->lod_tensor_) { + total_size += + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize( + _internal_metadata_, total_size, &_cached_size_); + } + int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size); + SetCachedSize(cached_size); + return total_size; +} + +void VarType_ReaderDesc::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { +// @@protoc_insertion_point(generalized_merge_from_start:paddle.framework.proto.VarType.ReaderDesc) + GOOGLE_DCHECK_NE(&from, this); + const VarType_ReaderDesc* source = + ::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated( + &from); + if (source == nullptr) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:paddle.framework.proto.VarType.ReaderDesc) + ::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this); + } else { + // @@protoc_insertion_point(generalized_merge_from_cast_success:paddle.framework.proto.VarType.ReaderDesc) + MergeFrom(*source); + } +} + +void VarType_ReaderDesc::MergeFrom(const VarType_ReaderDesc& from) { +// @@protoc_insertion_point(class_specific_merge_from_start:paddle.framework.proto.VarType.ReaderDesc) + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + lod_tensor_.MergeFrom(from.lod_tensor_); +} + +void VarType_ReaderDesc::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:paddle.framework.proto.VarType.ReaderDesc) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +void VarType_ReaderDesc::CopyFrom(const VarType_ReaderDesc& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:paddle.framework.proto.VarType.ReaderDesc) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool VarType_ReaderDesc::IsInitialized() const { + if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(lod_tensor_)) return false; + return true; +} + +void VarType_ReaderDesc::InternalSwap(VarType_ReaderDesc* other) { + using std::swap; + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); + lod_tensor_.InternalSwap(&other->lod_tensor_); +} + +::PROTOBUF_NAMESPACE_ID::Metadata VarType_ReaderDesc::GetMetadata() const { + return GetMetadataStatic(); +} + + +// =================================================================== + +class VarType_Tuple::_Internal { + public: +}; + +VarType_Tuple::VarType_Tuple(::PROTOBUF_NAMESPACE_ID::Arena* arena) + : ::PROTOBUF_NAMESPACE_ID::Message(arena), + element_type_(arena) { + SharedCtor(); + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:paddle.framework.proto.VarType.Tuple) +} +VarType_Tuple::VarType_Tuple(const VarType_Tuple& from) + : ::PROTOBUF_NAMESPACE_ID::Message(), + element_type_(from.element_type_) { + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + // @@protoc_insertion_point(copy_constructor:paddle.framework.proto.VarType.Tuple) +} + +void VarType_Tuple::SharedCtor() { +} + +VarType_Tuple::~VarType_Tuple() { + // @@protoc_insertion_point(destructor:paddle.framework.proto.VarType.Tuple) + SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +void VarType_Tuple::SharedDtor() { + GOOGLE_DCHECK(GetArena() == nullptr); +} + +void VarType_Tuple::ArenaDtor(void* object) { + VarType_Tuple* _this = reinterpret_cast< VarType_Tuple* >(object); + (void)_this; +} +void VarType_Tuple::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { +} +void VarType_Tuple::SetCachedSize(int size) const { + _cached_size_.Set(size); +} +const VarType_Tuple& VarType_Tuple::default_instance() { + ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_VarType_Tuple_framework_2eproto.base); + return *internal_default_instance(); +} + + +void VarType_Tuple::Clear() { +// @@protoc_insertion_point(message_clear_start:paddle.framework.proto.VarType.Tuple) + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + element_type_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +const char* VarType_Tuple::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure + while (!ctx->Done(&ptr)) { + ::PROTOBUF_NAMESPACE_ID::uint32 tag; + ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + CHK_(ptr); + switch (tag >> 3) { + // repeated .paddle.framework.proto.VarType.Type element_type = 1; + case 1: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 8)) { + ptr -= 1; + do { + ptr += 1; + ::PROTOBUF_NAMESPACE_ID::uint64 val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + CHK_(ptr); + if (PROTOBUF_PREDICT_TRUE(::paddle::framework::proto::VarType_Type_IsValid(val))) { + _internal_add_element_type(static_cast<::paddle::framework::proto::VarType_Type>(val)); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::WriteVarint(1, val, mutable_unknown_fields()); + } + if (!ctx->DataAvailable(ptr)) break; + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<8>(ptr)); + } else if (static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10) { + ptr = ::PROTOBUF_NAMESPACE_ID::internal::PackedEnumParser<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(_internal_mutable_element_type(), ptr, ctx, ::paddle::framework::proto::VarType_Type_IsValid, &_internal_metadata_, 1); + CHK_(ptr); + } else goto handle_unusual; + continue; + default: { + handle_unusual: + if ((tag & 7) == 4 || tag == 0) { + ctx->SetLastTag(tag); + goto success; + } + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); + CHK_(ptr != nullptr); + continue; + } + } // switch + } // while +success: + return ptr; +failure: + ptr = nullptr; + goto success; +#undef CHK_ +} + +::PROTOBUF_NAMESPACE_ID::uint8* VarType_Tuple::_InternalSerialize( + ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { + // @@protoc_insertion_point(serialize_to_array_start:paddle.framework.proto.VarType.Tuple) + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + // repeated .paddle.framework.proto.VarType.Type element_type = 1; + for (int i = 0, n = this->_internal_element_type_size(); i < n; i++) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteEnumToArray( + 1, this->_internal_element_type(i), target); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + } + // @@protoc_insertion_point(serialize_to_array_end:paddle.framework.proto.VarType.Tuple) + return target; +} + +size_t VarType_Tuple::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:paddle.framework.proto.VarType.Tuple) + size_t total_size = 0; + + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + // repeated .paddle.framework.proto.VarType.Type element_type = 1; + { + size_t data_size = 0; + unsigned int count = static_cast(this->_internal_element_type_size());for (unsigned int i = 0; i < count; i++) { + data_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::EnumSize( + this->_internal_element_type(static_cast(i))); + } + total_size += (1UL * count) + data_size; + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize( + _internal_metadata_, total_size, &_cached_size_); + } + int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size); + SetCachedSize(cached_size); + return total_size; +} + +void VarType_Tuple::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { +// @@protoc_insertion_point(generalized_merge_from_start:paddle.framework.proto.VarType.Tuple) + GOOGLE_DCHECK_NE(&from, this); + const VarType_Tuple* source = + ::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated( + &from); + if (source == nullptr) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:paddle.framework.proto.VarType.Tuple) + ::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this); + } else { + // @@protoc_insertion_point(generalized_merge_from_cast_success:paddle.framework.proto.VarType.Tuple) + MergeFrom(*source); + } +} + +void VarType_Tuple::MergeFrom(const VarType_Tuple& from) { +// @@protoc_insertion_point(class_specific_merge_from_start:paddle.framework.proto.VarType.Tuple) + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + element_type_.MergeFrom(from.element_type_); +} + +void VarType_Tuple::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:paddle.framework.proto.VarType.Tuple) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +void VarType_Tuple::CopyFrom(const VarType_Tuple& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:paddle.framework.proto.VarType.Tuple) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool VarType_Tuple::IsInitialized() const { + return true; +} + +void VarType_Tuple::InternalSwap(VarType_Tuple* other) { + using std::swap; + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); + element_type_.InternalSwap(&other->element_type_); +} + +::PROTOBUF_NAMESPACE_ID::Metadata VarType_Tuple::GetMetadata() const { + return GetMetadataStatic(); +} + + +// =================================================================== + +class VarType::_Internal { + public: + using HasBits = decltype(std::declval()._has_bits_); + static void set_has_type(HasBits* has_bits) { + (*has_bits)[0] |= 32u; + } + static const ::paddle::framework::proto::VarType_TensorDesc& selected_rows(const VarType* msg); + static void set_has_selected_rows(HasBits* has_bits) { + (*has_bits)[0] |= 1u; + } + static const ::paddle::framework::proto::VarType_LoDTensorDesc& lod_tensor(const VarType* msg); + static void set_has_lod_tensor(HasBits* has_bits) { + (*has_bits)[0] |= 2u; + } + static const ::paddle::framework::proto::VarType_LoDTensorArrayDesc& tensor_array(const VarType* msg); + static void set_has_tensor_array(HasBits* has_bits) { + (*has_bits)[0] |= 4u; + } + static const ::paddle::framework::proto::VarType_ReaderDesc& reader(const VarType* msg); + static void set_has_reader(HasBits* has_bits) { + (*has_bits)[0] |= 8u; + } + static const ::paddle::framework::proto::VarType_Tuple& tuple(const VarType* msg); + static void set_has_tuple(HasBits* has_bits) { + (*has_bits)[0] |= 16u; + } + static bool MissingRequiredFields(const HasBits& has_bits) { + return ((has_bits[0] & 0x00000020) ^ 0x00000020) != 0; + } +}; + +const ::paddle::framework::proto::VarType_TensorDesc& +VarType::_Internal::selected_rows(const VarType* msg) { + return *msg->selected_rows_; +} +const ::paddle::framework::proto::VarType_LoDTensorDesc& +VarType::_Internal::lod_tensor(const VarType* msg) { + return *msg->lod_tensor_; +} +const ::paddle::framework::proto::VarType_LoDTensorArrayDesc& +VarType::_Internal::tensor_array(const VarType* msg) { + return *msg->tensor_array_; +} +const ::paddle::framework::proto::VarType_ReaderDesc& +VarType::_Internal::reader(const VarType* msg) { + return *msg->reader_; +} +const ::paddle::framework::proto::VarType_Tuple& +VarType::_Internal::tuple(const VarType* msg) { + return *msg->tuple_; +} +VarType::VarType(::PROTOBUF_NAMESPACE_ID::Arena* arena) + : ::PROTOBUF_NAMESPACE_ID::Message(arena) { + SharedCtor(); + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:paddle.framework.proto.VarType) +} +VarType::VarType(const VarType& from) + : ::PROTOBUF_NAMESPACE_ID::Message(), + _has_bits_(from._has_bits_) { + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + if (from._internal_has_selected_rows()) { + selected_rows_ = new ::paddle::framework::proto::VarType_TensorDesc(*from.selected_rows_); + } else { + selected_rows_ = nullptr; + } + if (from._internal_has_lod_tensor()) { + lod_tensor_ = new ::paddle::framework::proto::VarType_LoDTensorDesc(*from.lod_tensor_); + } else { + lod_tensor_ = nullptr; + } + if (from._internal_has_tensor_array()) { + tensor_array_ = new ::paddle::framework::proto::VarType_LoDTensorArrayDesc(*from.tensor_array_); + } else { + tensor_array_ = nullptr; + } + if (from._internal_has_reader()) { + reader_ = new ::paddle::framework::proto::VarType_ReaderDesc(*from.reader_); + } else { + reader_ = nullptr; + } + if (from._internal_has_tuple()) { + tuple_ = new ::paddle::framework::proto::VarType_Tuple(*from.tuple_); + } else { + tuple_ = nullptr; + } + type_ = from.type_; + // @@protoc_insertion_point(copy_constructor:paddle.framework.proto.VarType) +} + +void VarType::SharedCtor() { + ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_VarType_framework_2eproto.base); + ::memset(reinterpret_cast(this) + static_cast( + reinterpret_cast(&selected_rows_) - reinterpret_cast(this)), + 0, static_cast(reinterpret_cast(&type_) - + reinterpret_cast(&selected_rows_)) + sizeof(type_)); +} + +VarType::~VarType() { + // @@protoc_insertion_point(destructor:paddle.framework.proto.VarType) + SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +void VarType::SharedDtor() { + GOOGLE_DCHECK(GetArena() == nullptr); + if (this != internal_default_instance()) delete selected_rows_; + if (this != internal_default_instance()) delete lod_tensor_; + if (this != internal_default_instance()) delete tensor_array_; + if (this != internal_default_instance()) delete reader_; + if (this != internal_default_instance()) delete tuple_; +} + +void VarType::ArenaDtor(void* object) { + VarType* _this = reinterpret_cast< VarType* >(object); + (void)_this; +} +void VarType::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { +} +void VarType::SetCachedSize(int size) const { + _cached_size_.Set(size); +} +const VarType& VarType::default_instance() { + ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_VarType_framework_2eproto.base); + return *internal_default_instance(); +} + + +void VarType::Clear() { +// @@protoc_insertion_point(message_clear_start:paddle.framework.proto.VarType) + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + cached_has_bits = _has_bits_[0]; + if (cached_has_bits & 0x0000001fu) { + if (cached_has_bits & 0x00000001u) { + GOOGLE_DCHECK(selected_rows_ != nullptr); + selected_rows_->Clear(); + } + if (cached_has_bits & 0x00000002u) { + GOOGLE_DCHECK(lod_tensor_ != nullptr); + lod_tensor_->Clear(); + } + if (cached_has_bits & 0x00000004u) { + GOOGLE_DCHECK(tensor_array_ != nullptr); + tensor_array_->Clear(); + } + if (cached_has_bits & 0x00000008u) { + GOOGLE_DCHECK(reader_ != nullptr); + reader_->Clear(); + } + if (cached_has_bits & 0x00000010u) { + GOOGLE_DCHECK(tuple_ != nullptr); + tuple_->Clear(); + } + } + type_ = 0; + _has_bits_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +const char* VarType::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure + _Internal::HasBits has_bits{}; + while (!ctx->Done(&ptr)) { + ::PROTOBUF_NAMESPACE_ID::uint32 tag; + ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + CHK_(ptr); + switch (tag >> 3) { + // required .paddle.framework.proto.VarType.Type type = 1; + case 1: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 8)) { + ::PROTOBUF_NAMESPACE_ID::uint64 val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + CHK_(ptr); + if (PROTOBUF_PREDICT_TRUE(::paddle::framework::proto::VarType_Type_IsValid(val))) { + _internal_set_type(static_cast<::paddle::framework::proto::VarType_Type>(val)); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::WriteVarint(1, val, mutable_unknown_fields()); + } + } else goto handle_unusual; + continue; + // optional .paddle.framework.proto.VarType.TensorDesc selected_rows = 2; + case 2: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 18)) { + ptr = ctx->ParseMessage(_internal_mutable_selected_rows(), ptr); + CHK_(ptr); + } else goto handle_unusual; + continue; + // optional .paddle.framework.proto.VarType.LoDTensorDesc lod_tensor = 3; + case 3: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 26)) { + ptr = ctx->ParseMessage(_internal_mutable_lod_tensor(), ptr); + CHK_(ptr); + } else goto handle_unusual; + continue; + // optional .paddle.framework.proto.VarType.LoDTensorArrayDesc tensor_array = 4; + case 4: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 34)) { + ptr = ctx->ParseMessage(_internal_mutable_tensor_array(), ptr); + CHK_(ptr); + } else goto handle_unusual; + continue; + // optional .paddle.framework.proto.VarType.ReaderDesc reader = 5; + case 5: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 42)) { + ptr = ctx->ParseMessage(_internal_mutable_reader(), ptr); + CHK_(ptr); + } else goto handle_unusual; + continue; + // optional .paddle.framework.proto.VarType.Tuple tuple = 7; + case 7: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 58)) { + ptr = ctx->ParseMessage(_internal_mutable_tuple(), ptr); + CHK_(ptr); + } else goto handle_unusual; + continue; + default: { + handle_unusual: + if ((tag & 7) == 4 || tag == 0) { + ctx->SetLastTag(tag); + goto success; + } + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); + CHK_(ptr != nullptr); + continue; + } + } // switch + } // while +success: + _has_bits_.Or(has_bits); + return ptr; +failure: + ptr = nullptr; + goto success; +#undef CHK_ +} + +::PROTOBUF_NAMESPACE_ID::uint8* VarType::_InternalSerialize( + ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { + // @@protoc_insertion_point(serialize_to_array_start:paddle.framework.proto.VarType) + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + cached_has_bits = _has_bits_[0]; + // required .paddle.framework.proto.VarType.Type type = 1; + if (cached_has_bits & 0x00000020u) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteEnumToArray( + 1, this->_internal_type(), target); + } + + // optional .paddle.framework.proto.VarType.TensorDesc selected_rows = 2; + if (cached_has_bits & 0x00000001u) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage( + 2, _Internal::selected_rows(this), target, stream); + } + + // optional .paddle.framework.proto.VarType.LoDTensorDesc lod_tensor = 3; + if (cached_has_bits & 0x00000002u) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage( + 3, _Internal::lod_tensor(this), target, stream); + } + + // optional .paddle.framework.proto.VarType.LoDTensorArrayDesc tensor_array = 4; + if (cached_has_bits & 0x00000004u) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage( + 4, _Internal::tensor_array(this), target, stream); + } + + // optional .paddle.framework.proto.VarType.ReaderDesc reader = 5; + if (cached_has_bits & 0x00000008u) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage( + 5, _Internal::reader(this), target, stream); + } + + // optional .paddle.framework.proto.VarType.Tuple tuple = 7; + if (cached_has_bits & 0x00000010u) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage( + 7, _Internal::tuple(this), target, stream); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + } + // @@protoc_insertion_point(serialize_to_array_end:paddle.framework.proto.VarType) + return target; +} + +size_t VarType::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:paddle.framework.proto.VarType) + size_t total_size = 0; + + // required .paddle.framework.proto.VarType.Type type = 1; + if (_internal_has_type()) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::EnumSize(this->_internal_type()); + } + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + cached_has_bits = _has_bits_[0]; + if (cached_has_bits & 0x0000001fu) { + // optional .paddle.framework.proto.VarType.TensorDesc selected_rows = 2; + if (cached_has_bits & 0x00000001u) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *selected_rows_); + } + + // optional .paddle.framework.proto.VarType.LoDTensorDesc lod_tensor = 3; + if (cached_has_bits & 0x00000002u) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *lod_tensor_); + } + + // optional .paddle.framework.proto.VarType.LoDTensorArrayDesc tensor_array = 4; + if (cached_has_bits & 0x00000004u) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *tensor_array_); + } + + // optional .paddle.framework.proto.VarType.ReaderDesc reader = 5; + if (cached_has_bits & 0x00000008u) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *reader_); + } + + // optional .paddle.framework.proto.VarType.Tuple tuple = 7; + if (cached_has_bits & 0x00000010u) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *tuple_); + } + + } + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize( + _internal_metadata_, total_size, &_cached_size_); + } + int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size); + SetCachedSize(cached_size); + return total_size; +} + +void VarType::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { +// @@protoc_insertion_point(generalized_merge_from_start:paddle.framework.proto.VarType) + GOOGLE_DCHECK_NE(&from, this); + const VarType* source = + ::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated( + &from); + if (source == nullptr) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:paddle.framework.proto.VarType) + ::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this); + } else { + // @@protoc_insertion_point(generalized_merge_from_cast_success:paddle.framework.proto.VarType) + MergeFrom(*source); + } +} + +void VarType::MergeFrom(const VarType& from) { +// @@protoc_insertion_point(class_specific_merge_from_start:paddle.framework.proto.VarType) + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + cached_has_bits = from._has_bits_[0]; + if (cached_has_bits & 0x0000003fu) { + if (cached_has_bits & 0x00000001u) { + _internal_mutable_selected_rows()->::paddle::framework::proto::VarType_TensorDesc::MergeFrom(from._internal_selected_rows()); + } + if (cached_has_bits & 0x00000002u) { + _internal_mutable_lod_tensor()->::paddle::framework::proto::VarType_LoDTensorDesc::MergeFrom(from._internal_lod_tensor()); + } + if (cached_has_bits & 0x00000004u) { + _internal_mutable_tensor_array()->::paddle::framework::proto::VarType_LoDTensorArrayDesc::MergeFrom(from._internal_tensor_array()); + } + if (cached_has_bits & 0x00000008u) { + _internal_mutable_reader()->::paddle::framework::proto::VarType_ReaderDesc::MergeFrom(from._internal_reader()); + } + if (cached_has_bits & 0x00000010u) { + _internal_mutable_tuple()->::paddle::framework::proto::VarType_Tuple::MergeFrom(from._internal_tuple()); + } + if (cached_has_bits & 0x00000020u) { + type_ = from.type_; + } + _has_bits_[0] |= cached_has_bits; + } +} + +void VarType::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:paddle.framework.proto.VarType) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +void VarType::CopyFrom(const VarType& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:paddle.framework.proto.VarType) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool VarType::IsInitialized() const { + if (_Internal::MissingRequiredFields(_has_bits_)) return false; + if (_internal_has_selected_rows()) { + if (!selected_rows_->IsInitialized()) return false; + } + if (_internal_has_lod_tensor()) { + if (!lod_tensor_->IsInitialized()) return false; + } + if (_internal_has_tensor_array()) { + if (!tensor_array_->IsInitialized()) return false; + } + if (_internal_has_reader()) { + if (!reader_->IsInitialized()) return false; + } + return true; +} + +void VarType::InternalSwap(VarType* other) { + using std::swap; + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); + swap(_has_bits_[0], other->_has_bits_[0]); + ::PROTOBUF_NAMESPACE_ID::internal::memswap< + PROTOBUF_FIELD_OFFSET(VarType, type_) + + sizeof(VarType::type_) + - PROTOBUF_FIELD_OFFSET(VarType, selected_rows_)>( + reinterpret_cast(&selected_rows_), + reinterpret_cast(&other->selected_rows_)); +} + +::PROTOBUF_NAMESPACE_ID::Metadata VarType::GetMetadata() const { + return GetMetadataStatic(); +} + + +// =================================================================== + +class VarDesc::_Internal { + public: + using HasBits = decltype(std::declval()._has_bits_); + static void set_has_name(HasBits* has_bits) { + (*has_bits)[0] |= 1u; + } + static const ::paddle::framework::proto::VarType& type(const VarDesc* msg); + static void set_has_type(HasBits* has_bits) { + (*has_bits)[0] |= 2u; + } + static void set_has_persistable(HasBits* has_bits) { + (*has_bits)[0] |= 4u; + } + static void set_has_need_check_feed(HasBits* has_bits) { + (*has_bits)[0] |= 8u; + } + static bool MissingRequiredFields(const HasBits& has_bits) { + return ((has_bits[0] & 0x00000003) ^ 0x00000003) != 0; + } +}; + +const ::paddle::framework::proto::VarType& +VarDesc::_Internal::type(const VarDesc* msg) { + return *msg->type_; +} +VarDesc::VarDesc(::PROTOBUF_NAMESPACE_ID::Arena* arena) + : ::PROTOBUF_NAMESPACE_ID::Message(arena) { + SharedCtor(); + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:paddle.framework.proto.VarDesc) +} +VarDesc::VarDesc(const VarDesc& from) + : ::PROTOBUF_NAMESPACE_ID::Message(), + _has_bits_(from._has_bits_) { + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + if (from._internal_has_name()) { + name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(), + GetArena()); + } + if (from._internal_has_type()) { + type_ = new ::paddle::framework::proto::VarType(*from.type_); + } else { + type_ = nullptr; + } + ::memcpy(&persistable_, &from.persistable_, + static_cast(reinterpret_cast(&need_check_feed_) - + reinterpret_cast(&persistable_)) + sizeof(need_check_feed_)); + // @@protoc_insertion_point(copy_constructor:paddle.framework.proto.VarDesc) +} + +void VarDesc::SharedCtor() { + ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_VarDesc_framework_2eproto.base); + name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + ::memset(reinterpret_cast(this) + static_cast( + reinterpret_cast(&type_) - reinterpret_cast(this)), + 0, static_cast(reinterpret_cast(&need_check_feed_) - + reinterpret_cast(&type_)) + sizeof(need_check_feed_)); +} + +VarDesc::~VarDesc() { + // @@protoc_insertion_point(destructor:paddle.framework.proto.VarDesc) + SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +void VarDesc::SharedDtor() { + GOOGLE_DCHECK(GetArena() == nullptr); + name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + if (this != internal_default_instance()) delete type_; +} + +void VarDesc::ArenaDtor(void* object) { + VarDesc* _this = reinterpret_cast< VarDesc* >(object); + (void)_this; +} +void VarDesc::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { +} +void VarDesc::SetCachedSize(int size) const { + _cached_size_.Set(size); +} +const VarDesc& VarDesc::default_instance() { + ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_VarDesc_framework_2eproto.base); + return *internal_default_instance(); +} + + +void VarDesc::Clear() { +// @@protoc_insertion_point(message_clear_start:paddle.framework.proto.VarDesc) + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + cached_has_bits = _has_bits_[0]; + if (cached_has_bits & 0x00000003u) { + if (cached_has_bits & 0x00000001u) { + name_.ClearNonDefaultToEmpty(); + } + if (cached_has_bits & 0x00000002u) { + GOOGLE_DCHECK(type_ != nullptr); + type_->Clear(); + } + } + ::memset(&persistable_, 0, static_cast( + reinterpret_cast(&need_check_feed_) - + reinterpret_cast(&persistable_)) + sizeof(need_check_feed_)); + _has_bits_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +const char* VarDesc::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure + _Internal::HasBits has_bits{}; + while (!ctx->Done(&ptr)) { + ::PROTOBUF_NAMESPACE_ID::uint32 tag; + ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + CHK_(ptr); + switch (tag >> 3) { + // required string name = 1; + case 1: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) { + auto str = _internal_mutable_name(); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); + #ifndef NDEBUG + ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "paddle.framework.proto.VarDesc.name"); + #endif // !NDEBUG + CHK_(ptr); + } else goto handle_unusual; + continue; + // required .paddle.framework.proto.VarType type = 2; + case 2: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 18)) { + ptr = ctx->ParseMessage(_internal_mutable_type(), ptr); + CHK_(ptr); + } else goto handle_unusual; + continue; + // optional bool persistable = 3 [default = false]; + case 3: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 24)) { + _Internal::set_has_persistable(&has_bits); + persistable_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + CHK_(ptr); + } else goto handle_unusual; + continue; + // optional bool need_check_feed = 4 [default = false]; + case 4: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 32)) { + _Internal::set_has_need_check_feed(&has_bits); + need_check_feed_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + CHK_(ptr); + } else goto handle_unusual; + continue; + default: { + handle_unusual: + if ((tag & 7) == 4 || tag == 0) { + ctx->SetLastTag(tag); + goto success; + } + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); + CHK_(ptr != nullptr); + continue; + } + } // switch + } // while +success: + _has_bits_.Or(has_bits); + return ptr; +failure: + ptr = nullptr; + goto success; +#undef CHK_ +} + +::PROTOBUF_NAMESPACE_ID::uint8* VarDesc::_InternalSerialize( + ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { + // @@protoc_insertion_point(serialize_to_array_start:paddle.framework.proto.VarDesc) + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + cached_has_bits = _has_bits_[0]; + // required string name = 1; + if (cached_has_bits & 0x00000001u) { + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( + this->_internal_name().data(), static_cast(this->_internal_name().length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, + "paddle.framework.proto.VarDesc.name"); + target = stream->WriteStringMaybeAliased( + 1, this->_internal_name(), target); + } + + // required .paddle.framework.proto.VarType type = 2; + if (cached_has_bits & 0x00000002u) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage( + 2, _Internal::type(this), target, stream); + } + + // optional bool persistable = 3 [default = false]; + if (cached_has_bits & 0x00000004u) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(3, this->_internal_persistable(), target); + } + + // optional bool need_check_feed = 4 [default = false]; + if (cached_has_bits & 0x00000008u) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(4, this->_internal_need_check_feed(), target); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + } + // @@protoc_insertion_point(serialize_to_array_end:paddle.framework.proto.VarDesc) + return target; +} + +size_t VarDesc::RequiredFieldsByteSizeFallback() const { +// @@protoc_insertion_point(required_fields_byte_size_fallback_start:paddle.framework.proto.VarDesc) + size_t total_size = 0; + + if (_internal_has_name()) { + // required string name = 1; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_name()); + } + + if (_internal_has_type()) { + // required .paddle.framework.proto.VarType type = 2; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *type_); + } + + return total_size; +} +size_t VarDesc::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:paddle.framework.proto.VarDesc) + size_t total_size = 0; + + if (((_has_bits_[0] & 0x00000003) ^ 0x00000003) == 0) { // All required fields are present. + // required string name = 1; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_name()); + + // required .paddle.framework.proto.VarType type = 2; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *type_); + + } else { + total_size += RequiredFieldsByteSizeFallback(); + } + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + cached_has_bits = _has_bits_[0]; + if (cached_has_bits & 0x0000000cu) { + // optional bool persistable = 3 [default = false]; + if (cached_has_bits & 0x00000004u) { + total_size += 1 + 1; + } + + // optional bool need_check_feed = 4 [default = false]; + if (cached_has_bits & 0x00000008u) { + total_size += 1 + 1; + } + + } + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize( + _internal_metadata_, total_size, &_cached_size_); + } + int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size); + SetCachedSize(cached_size); + return total_size; +} + +void VarDesc::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { +// @@protoc_insertion_point(generalized_merge_from_start:paddle.framework.proto.VarDesc) + GOOGLE_DCHECK_NE(&from, this); + const VarDesc* source = + ::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated( + &from); + if (source == nullptr) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:paddle.framework.proto.VarDesc) + ::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this); + } else { + // @@protoc_insertion_point(generalized_merge_from_cast_success:paddle.framework.proto.VarDesc) + MergeFrom(*source); + } +} + +void VarDesc::MergeFrom(const VarDesc& from) { +// @@protoc_insertion_point(class_specific_merge_from_start:paddle.framework.proto.VarDesc) + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + cached_has_bits = from._has_bits_[0]; + if (cached_has_bits & 0x0000000fu) { + if (cached_has_bits & 0x00000001u) { + _internal_set_name(from._internal_name()); + } + if (cached_has_bits & 0x00000002u) { + _internal_mutable_type()->::paddle::framework::proto::VarType::MergeFrom(from._internal_type()); + } + if (cached_has_bits & 0x00000004u) { + persistable_ = from.persistable_; + } + if (cached_has_bits & 0x00000008u) { + need_check_feed_ = from.need_check_feed_; + } + _has_bits_[0] |= cached_has_bits; + } +} + +void VarDesc::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:paddle.framework.proto.VarDesc) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +void VarDesc::CopyFrom(const VarDesc& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:paddle.framework.proto.VarDesc) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool VarDesc::IsInitialized() const { + if (_Internal::MissingRequiredFields(_has_bits_)) return false; + if (_internal_has_type()) { + if (!type_->IsInitialized()) return false; + } + return true; +} + +void VarDesc::InternalSwap(VarDesc* other) { + using std::swap; + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); + swap(_has_bits_[0], other->_has_bits_[0]); + name_.Swap(&other->name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + ::PROTOBUF_NAMESPACE_ID::internal::memswap< + PROTOBUF_FIELD_OFFSET(VarDesc, need_check_feed_) + + sizeof(VarDesc::need_check_feed_) + - PROTOBUF_FIELD_OFFSET(VarDesc, type_)>( + reinterpret_cast(&type_), + reinterpret_cast(&other->type_)); +} + +::PROTOBUF_NAMESPACE_ID::Metadata VarDesc::GetMetadata() const { + return GetMetadataStatic(); +} + + +// =================================================================== + +class BlockDesc::_Internal { + public: + using HasBits = decltype(std::declval()._has_bits_); + static void set_has_idx(HasBits* has_bits) { + (*has_bits)[0] |= 1u; + } + static void set_has_parent_idx(HasBits* has_bits) { + (*has_bits)[0] |= 2u; + } + static void set_has_forward_block_idx(HasBits* has_bits) { + (*has_bits)[0] |= 4u; + } + static bool MissingRequiredFields(const HasBits& has_bits) { + return ((has_bits[0] & 0x00000003) ^ 0x00000003) != 0; + } +}; + +BlockDesc::BlockDesc(::PROTOBUF_NAMESPACE_ID::Arena* arena) + : ::PROTOBUF_NAMESPACE_ID::Message(arena), + vars_(arena), + ops_(arena) { + SharedCtor(); + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:paddle.framework.proto.BlockDesc) +} +BlockDesc::BlockDesc(const BlockDesc& from) + : ::PROTOBUF_NAMESPACE_ID::Message(), + _has_bits_(from._has_bits_), + vars_(from.vars_), + ops_(from.ops_) { + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + ::memcpy(&idx_, &from.idx_, + static_cast(reinterpret_cast(&forward_block_idx_) - + reinterpret_cast(&idx_)) + sizeof(forward_block_idx_)); + // @@protoc_insertion_point(copy_constructor:paddle.framework.proto.BlockDesc) +} + +void BlockDesc::SharedCtor() { + ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_BlockDesc_framework_2eproto.base); + ::memset(reinterpret_cast(this) + static_cast( + reinterpret_cast(&idx_) - reinterpret_cast(this)), + 0, static_cast(reinterpret_cast(&parent_idx_) - + reinterpret_cast(&idx_)) + sizeof(parent_idx_)); + forward_block_idx_ = -1; +} + +BlockDesc::~BlockDesc() { + // @@protoc_insertion_point(destructor:paddle.framework.proto.BlockDesc) + SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +void BlockDesc::SharedDtor() { + GOOGLE_DCHECK(GetArena() == nullptr); +} + +void BlockDesc::ArenaDtor(void* object) { + BlockDesc* _this = reinterpret_cast< BlockDesc* >(object); + (void)_this; +} +void BlockDesc::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { +} +void BlockDesc::SetCachedSize(int size) const { + _cached_size_.Set(size); +} +const BlockDesc& BlockDesc::default_instance() { + ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_BlockDesc_framework_2eproto.base); + return *internal_default_instance(); +} + + +void BlockDesc::Clear() { +// @@protoc_insertion_point(message_clear_start:paddle.framework.proto.BlockDesc) + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + vars_.Clear(); + ops_.Clear(); + cached_has_bits = _has_bits_[0]; + if (cached_has_bits & 0x00000007u) { + ::memset(&idx_, 0, static_cast( + reinterpret_cast(&parent_idx_) - + reinterpret_cast(&idx_)) + sizeof(parent_idx_)); + forward_block_idx_ = -1; + } + _has_bits_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +const char* BlockDesc::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure + _Internal::HasBits has_bits{}; + while (!ctx->Done(&ptr)) { + ::PROTOBUF_NAMESPACE_ID::uint32 tag; + ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + CHK_(ptr); + switch (tag >> 3) { + // required int32 idx = 1; + case 1: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 8)) { + _Internal::set_has_idx(&has_bits); + idx_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + CHK_(ptr); + } else goto handle_unusual; + continue; + // required int32 parent_idx = 2; + case 2: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 16)) { + _Internal::set_has_parent_idx(&has_bits); + parent_idx_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + CHK_(ptr); + } else goto handle_unusual; + continue; + // repeated .paddle.framework.proto.VarDesc vars = 3; + case 3: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 26)) { + ptr -= 1; + do { + ptr += 1; + ptr = ctx->ParseMessage(_internal_add_vars(), ptr); + CHK_(ptr); + if (!ctx->DataAvailable(ptr)) break; + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<26>(ptr)); + } else goto handle_unusual; + continue; + // repeated .paddle.framework.proto.OpDesc ops = 4; + case 4: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 34)) { + ptr -= 1; + do { + ptr += 1; + ptr = ctx->ParseMessage(_internal_add_ops(), ptr); + CHK_(ptr); + if (!ctx->DataAvailable(ptr)) break; + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<34>(ptr)); + } else goto handle_unusual; + continue; + // optional int32 forward_block_idx = 5 [default = -1]; + case 5: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 40)) { + _Internal::set_has_forward_block_idx(&has_bits); + forward_block_idx_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + CHK_(ptr); + } else goto handle_unusual; + continue; + default: { + handle_unusual: + if ((tag & 7) == 4 || tag == 0) { + ctx->SetLastTag(tag); + goto success; + } + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); + CHK_(ptr != nullptr); + continue; + } + } // switch + } // while +success: + _has_bits_.Or(has_bits); + return ptr; +failure: + ptr = nullptr; + goto success; +#undef CHK_ +} + +::PROTOBUF_NAMESPACE_ID::uint8* BlockDesc::_InternalSerialize( + ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { + // @@protoc_insertion_point(serialize_to_array_start:paddle.framework.proto.BlockDesc) + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + cached_has_bits = _has_bits_[0]; + // required int32 idx = 1; + if (cached_has_bits & 0x00000001u) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(1, this->_internal_idx(), target); + } + + // required int32 parent_idx = 2; + if (cached_has_bits & 0x00000002u) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(2, this->_internal_parent_idx(), target); + } + + // repeated .paddle.framework.proto.VarDesc vars = 3; + for (unsigned int i = 0, + n = static_cast(this->_internal_vars_size()); i < n; i++) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage(3, this->_internal_vars(i), target, stream); + } + + // repeated .paddle.framework.proto.OpDesc ops = 4; + for (unsigned int i = 0, + n = static_cast(this->_internal_ops_size()); i < n; i++) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage(4, this->_internal_ops(i), target, stream); + } + + // optional int32 forward_block_idx = 5 [default = -1]; + if (cached_has_bits & 0x00000004u) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(5, this->_internal_forward_block_idx(), target); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + } + // @@protoc_insertion_point(serialize_to_array_end:paddle.framework.proto.BlockDesc) + return target; +} + +size_t BlockDesc::RequiredFieldsByteSizeFallback() const { +// @@protoc_insertion_point(required_fields_byte_size_fallback_start:paddle.framework.proto.BlockDesc) + size_t total_size = 0; + + if (_internal_has_idx()) { + // required int32 idx = 1; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size( + this->_internal_idx()); + } + + if (_internal_has_parent_idx()) { + // required int32 parent_idx = 2; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size( + this->_internal_parent_idx()); + } + + return total_size; +} +size_t BlockDesc::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:paddle.framework.proto.BlockDesc) + size_t total_size = 0; + + if (((_has_bits_[0] & 0x00000003) ^ 0x00000003) == 0) { // All required fields are present. + // required int32 idx = 1; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size( + this->_internal_idx()); + + // required int32 parent_idx = 2; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size( + this->_internal_parent_idx()); + + } else { + total_size += RequiredFieldsByteSizeFallback(); + } + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + // repeated .paddle.framework.proto.VarDesc vars = 3; + total_size += 1UL * this->_internal_vars_size(); + for (const auto& msg : this->vars_) { + total_size += + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); + } + + // repeated .paddle.framework.proto.OpDesc ops = 4; + total_size += 1UL * this->_internal_ops_size(); + for (const auto& msg : this->ops_) { + total_size += + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); + } + + // optional int32 forward_block_idx = 5 [default = -1]; + cached_has_bits = _has_bits_[0]; + if (cached_has_bits & 0x00000004u) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size( + this->_internal_forward_block_idx()); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize( + _internal_metadata_, total_size, &_cached_size_); + } + int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size); + SetCachedSize(cached_size); + return total_size; +} + +void BlockDesc::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { +// @@protoc_insertion_point(generalized_merge_from_start:paddle.framework.proto.BlockDesc) + GOOGLE_DCHECK_NE(&from, this); + const BlockDesc* source = + ::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated( + &from); + if (source == nullptr) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:paddle.framework.proto.BlockDesc) + ::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this); + } else { + // @@protoc_insertion_point(generalized_merge_from_cast_success:paddle.framework.proto.BlockDesc) + MergeFrom(*source); + } +} + +void BlockDesc::MergeFrom(const BlockDesc& from) { +// @@protoc_insertion_point(class_specific_merge_from_start:paddle.framework.proto.BlockDesc) + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + vars_.MergeFrom(from.vars_); + ops_.MergeFrom(from.ops_); + cached_has_bits = from._has_bits_[0]; + if (cached_has_bits & 0x00000007u) { + if (cached_has_bits & 0x00000001u) { + idx_ = from.idx_; + } + if (cached_has_bits & 0x00000002u) { + parent_idx_ = from.parent_idx_; + } + if (cached_has_bits & 0x00000004u) { + forward_block_idx_ = from.forward_block_idx_; + } + _has_bits_[0] |= cached_has_bits; + } +} + +void BlockDesc::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:paddle.framework.proto.BlockDesc) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +void BlockDesc::CopyFrom(const BlockDesc& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:paddle.framework.proto.BlockDesc) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool BlockDesc::IsInitialized() const { + if (_Internal::MissingRequiredFields(_has_bits_)) return false; + if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(vars_)) return false; + if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(ops_)) return false; + return true; +} + +void BlockDesc::InternalSwap(BlockDesc* other) { + using std::swap; + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); + swap(_has_bits_[0], other->_has_bits_[0]); + vars_.InternalSwap(&other->vars_); + ops_.InternalSwap(&other->ops_); + ::PROTOBUF_NAMESPACE_ID::internal::memswap< + PROTOBUF_FIELD_OFFSET(BlockDesc, parent_idx_) + + sizeof(BlockDesc::parent_idx_) + - PROTOBUF_FIELD_OFFSET(BlockDesc, idx_)>( + reinterpret_cast(&idx_), + reinterpret_cast(&other->idx_)); + swap(forward_block_idx_, other->forward_block_idx_); +} + +::PROTOBUF_NAMESPACE_ID::Metadata BlockDesc::GetMetadata() const { + return GetMetadataStatic(); +} + + +// =================================================================== + +class OpVersion::_Internal { + public: + using HasBits = decltype(std::declval()._has_bits_); + static void set_has_version(HasBits* has_bits) { + (*has_bits)[0] |= 1u; + } + static bool MissingRequiredFields(const HasBits& has_bits) { + return ((has_bits[0] & 0x00000001) ^ 0x00000001) != 0; + } +}; + +OpVersion::OpVersion(::PROTOBUF_NAMESPACE_ID::Arena* arena) + : ::PROTOBUF_NAMESPACE_ID::Message(arena) { + SharedCtor(); + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:paddle.framework.proto.OpVersion) +} +OpVersion::OpVersion(const OpVersion& from) + : ::PROTOBUF_NAMESPACE_ID::Message(), + _has_bits_(from._has_bits_) { + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + version_ = from.version_; + // @@protoc_insertion_point(copy_constructor:paddle.framework.proto.OpVersion) +} + +void OpVersion::SharedCtor() { + version_ = 0; +} + +OpVersion::~OpVersion() { + // @@protoc_insertion_point(destructor:paddle.framework.proto.OpVersion) + SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +void OpVersion::SharedDtor() { + GOOGLE_DCHECK(GetArena() == nullptr); +} + +void OpVersion::ArenaDtor(void* object) { + OpVersion* _this = reinterpret_cast< OpVersion* >(object); + (void)_this; +} +void OpVersion::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { +} +void OpVersion::SetCachedSize(int size) const { + _cached_size_.Set(size); +} +const OpVersion& OpVersion::default_instance() { + ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_OpVersion_framework_2eproto.base); + return *internal_default_instance(); +} + + +void OpVersion::Clear() { +// @@protoc_insertion_point(message_clear_start:paddle.framework.proto.OpVersion) + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + version_ = 0; + _has_bits_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +const char* OpVersion::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure + _Internal::HasBits has_bits{}; + while (!ctx->Done(&ptr)) { + ::PROTOBUF_NAMESPACE_ID::uint32 tag; + ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + CHK_(ptr); + switch (tag >> 3) { + // required int32 version = 1; + case 1: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 8)) { + _Internal::set_has_version(&has_bits); + version_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + CHK_(ptr); + } else goto handle_unusual; + continue; + default: { + handle_unusual: + if ((tag & 7) == 4 || tag == 0) { + ctx->SetLastTag(tag); + goto success; + } + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); + CHK_(ptr != nullptr); + continue; + } + } // switch + } // while +success: + _has_bits_.Or(has_bits); + return ptr; +failure: + ptr = nullptr; + goto success; +#undef CHK_ +} + +::PROTOBUF_NAMESPACE_ID::uint8* OpVersion::_InternalSerialize( + ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { + // @@protoc_insertion_point(serialize_to_array_start:paddle.framework.proto.OpVersion) + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + cached_has_bits = _has_bits_[0]; + // required int32 version = 1; + if (cached_has_bits & 0x00000001u) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(1, this->_internal_version(), target); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + } + // @@protoc_insertion_point(serialize_to_array_end:paddle.framework.proto.OpVersion) + return target; +} + +size_t OpVersion::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:paddle.framework.proto.OpVersion) + size_t total_size = 0; + + // required int32 version = 1; + if (_internal_has_version()) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size( + this->_internal_version()); + } + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize( + _internal_metadata_, total_size, &_cached_size_); + } + int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size); + SetCachedSize(cached_size); + return total_size; +} + +void OpVersion::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { +// @@protoc_insertion_point(generalized_merge_from_start:paddle.framework.proto.OpVersion) + GOOGLE_DCHECK_NE(&from, this); + const OpVersion* source = + ::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated( + &from); + if (source == nullptr) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:paddle.framework.proto.OpVersion) + ::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this); + } else { + // @@protoc_insertion_point(generalized_merge_from_cast_success:paddle.framework.proto.OpVersion) + MergeFrom(*source); + } +} + +void OpVersion::MergeFrom(const OpVersion& from) { +// @@protoc_insertion_point(class_specific_merge_from_start:paddle.framework.proto.OpVersion) + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + if (from._internal_has_version()) { + _internal_set_version(from._internal_version()); + } +} + +void OpVersion::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:paddle.framework.proto.OpVersion) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +void OpVersion::CopyFrom(const OpVersion& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:paddle.framework.proto.OpVersion) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool OpVersion::IsInitialized() const { + if (_Internal::MissingRequiredFields(_has_bits_)) return false; + return true; +} + +void OpVersion::InternalSwap(OpVersion* other) { + using std::swap; + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); + swap(_has_bits_[0], other->_has_bits_[0]); + swap(version_, other->version_); +} + +::PROTOBUF_NAMESPACE_ID::Metadata OpVersion::GetMetadata() const { + return GetMetadataStatic(); +} + + +// =================================================================== + +class OpVersionMap_OpVersionPair::_Internal { + public: + using HasBits = decltype(std::declval()._has_bits_); + static void set_has_op_name(HasBits* has_bits) { + (*has_bits)[0] |= 1u; + } + static const ::paddle::framework::proto::OpVersion& op_version(const OpVersionMap_OpVersionPair* msg); + static void set_has_op_version(HasBits* has_bits) { + (*has_bits)[0] |= 2u; + } + static bool MissingRequiredFields(const HasBits& has_bits) { + return ((has_bits[0] & 0x00000003) ^ 0x00000003) != 0; + } +}; + +const ::paddle::framework::proto::OpVersion& +OpVersionMap_OpVersionPair::_Internal::op_version(const OpVersionMap_OpVersionPair* msg) { + return *msg->op_version_; +} +OpVersionMap_OpVersionPair::OpVersionMap_OpVersionPair(::PROTOBUF_NAMESPACE_ID::Arena* arena) + : ::PROTOBUF_NAMESPACE_ID::Message(arena) { + SharedCtor(); + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:paddle.framework.proto.OpVersionMap.OpVersionPair) +} +OpVersionMap_OpVersionPair::OpVersionMap_OpVersionPair(const OpVersionMap_OpVersionPair& from) + : ::PROTOBUF_NAMESPACE_ID::Message(), + _has_bits_(from._has_bits_) { + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + op_name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + if (from._internal_has_op_name()) { + op_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_op_name(), + GetArena()); + } + if (from._internal_has_op_version()) { + op_version_ = new ::paddle::framework::proto::OpVersion(*from.op_version_); + } else { + op_version_ = nullptr; + } + // @@protoc_insertion_point(copy_constructor:paddle.framework.proto.OpVersionMap.OpVersionPair) +} + +void OpVersionMap_OpVersionPair::SharedCtor() { + ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_OpVersionMap_OpVersionPair_framework_2eproto.base); + op_name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + op_version_ = nullptr; +} + +OpVersionMap_OpVersionPair::~OpVersionMap_OpVersionPair() { + // @@protoc_insertion_point(destructor:paddle.framework.proto.OpVersionMap.OpVersionPair) + SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +void OpVersionMap_OpVersionPair::SharedDtor() { + GOOGLE_DCHECK(GetArena() == nullptr); + op_name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + if (this != internal_default_instance()) delete op_version_; +} + +void OpVersionMap_OpVersionPair::ArenaDtor(void* object) { + OpVersionMap_OpVersionPair* _this = reinterpret_cast< OpVersionMap_OpVersionPair* >(object); + (void)_this; +} +void OpVersionMap_OpVersionPair::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { +} +void OpVersionMap_OpVersionPair::SetCachedSize(int size) const { + _cached_size_.Set(size); +} +const OpVersionMap_OpVersionPair& OpVersionMap_OpVersionPair::default_instance() { + ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_OpVersionMap_OpVersionPair_framework_2eproto.base); + return *internal_default_instance(); +} + + +void OpVersionMap_OpVersionPair::Clear() { +// @@protoc_insertion_point(message_clear_start:paddle.framework.proto.OpVersionMap.OpVersionPair) + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + cached_has_bits = _has_bits_[0]; + if (cached_has_bits & 0x00000003u) { + if (cached_has_bits & 0x00000001u) { + op_name_.ClearNonDefaultToEmpty(); + } + if (cached_has_bits & 0x00000002u) { + GOOGLE_DCHECK(op_version_ != nullptr); + op_version_->Clear(); + } + } + _has_bits_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +const char* OpVersionMap_OpVersionPair::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure + _Internal::HasBits has_bits{}; + while (!ctx->Done(&ptr)) { + ::PROTOBUF_NAMESPACE_ID::uint32 tag; + ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + CHK_(ptr); + switch (tag >> 3) { + // required string op_name = 1; + case 1: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) { + auto str = _internal_mutable_op_name(); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); + #ifndef NDEBUG + ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "paddle.framework.proto.OpVersionMap.OpVersionPair.op_name"); + #endif // !NDEBUG + CHK_(ptr); + } else goto handle_unusual; + continue; + // required .paddle.framework.proto.OpVersion op_version = 2; + case 2: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 18)) { + ptr = ctx->ParseMessage(_internal_mutable_op_version(), ptr); + CHK_(ptr); + } else goto handle_unusual; + continue; + default: { + handle_unusual: + if ((tag & 7) == 4 || tag == 0) { + ctx->SetLastTag(tag); + goto success; + } + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); + CHK_(ptr != nullptr); + continue; + } + } // switch + } // while +success: + _has_bits_.Or(has_bits); + return ptr; +failure: + ptr = nullptr; + goto success; +#undef CHK_ +} + +::PROTOBUF_NAMESPACE_ID::uint8* OpVersionMap_OpVersionPair::_InternalSerialize( + ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { + // @@protoc_insertion_point(serialize_to_array_start:paddle.framework.proto.OpVersionMap.OpVersionPair) + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + cached_has_bits = _has_bits_[0]; + // required string op_name = 1; + if (cached_has_bits & 0x00000001u) { + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( + this->_internal_op_name().data(), static_cast(this->_internal_op_name().length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, + "paddle.framework.proto.OpVersionMap.OpVersionPair.op_name"); + target = stream->WriteStringMaybeAliased( + 1, this->_internal_op_name(), target); + } + + // required .paddle.framework.proto.OpVersion op_version = 2; + if (cached_has_bits & 0x00000002u) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage( + 2, _Internal::op_version(this), target, stream); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + } + // @@protoc_insertion_point(serialize_to_array_end:paddle.framework.proto.OpVersionMap.OpVersionPair) + return target; +} + +size_t OpVersionMap_OpVersionPair::RequiredFieldsByteSizeFallback() const { +// @@protoc_insertion_point(required_fields_byte_size_fallback_start:paddle.framework.proto.OpVersionMap.OpVersionPair) + size_t total_size = 0; + + if (_internal_has_op_name()) { + // required string op_name = 1; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_op_name()); + } + + if (_internal_has_op_version()) { + // required .paddle.framework.proto.OpVersion op_version = 2; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *op_version_); + } + + return total_size; +} +size_t OpVersionMap_OpVersionPair::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:paddle.framework.proto.OpVersionMap.OpVersionPair) + size_t total_size = 0; + + if (((_has_bits_[0] & 0x00000003) ^ 0x00000003) == 0) { // All required fields are present. + // required string op_name = 1; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_op_name()); + + // required .paddle.framework.proto.OpVersion op_version = 2; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *op_version_); + + } else { + total_size += RequiredFieldsByteSizeFallback(); + } + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize( + _internal_metadata_, total_size, &_cached_size_); + } + int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size); + SetCachedSize(cached_size); + return total_size; +} + +void OpVersionMap_OpVersionPair::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { +// @@protoc_insertion_point(generalized_merge_from_start:paddle.framework.proto.OpVersionMap.OpVersionPair) + GOOGLE_DCHECK_NE(&from, this); + const OpVersionMap_OpVersionPair* source = + ::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated( + &from); + if (source == nullptr) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:paddle.framework.proto.OpVersionMap.OpVersionPair) + ::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this); + } else { + // @@protoc_insertion_point(generalized_merge_from_cast_success:paddle.framework.proto.OpVersionMap.OpVersionPair) + MergeFrom(*source); + } +} + +void OpVersionMap_OpVersionPair::MergeFrom(const OpVersionMap_OpVersionPair& from) { +// @@protoc_insertion_point(class_specific_merge_from_start:paddle.framework.proto.OpVersionMap.OpVersionPair) + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + cached_has_bits = from._has_bits_[0]; + if (cached_has_bits & 0x00000003u) { + if (cached_has_bits & 0x00000001u) { + _internal_set_op_name(from._internal_op_name()); + } + if (cached_has_bits & 0x00000002u) { + _internal_mutable_op_version()->::paddle::framework::proto::OpVersion::MergeFrom(from._internal_op_version()); + } + } +} + +void OpVersionMap_OpVersionPair::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:paddle.framework.proto.OpVersionMap.OpVersionPair) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +void OpVersionMap_OpVersionPair::CopyFrom(const OpVersionMap_OpVersionPair& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:paddle.framework.proto.OpVersionMap.OpVersionPair) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool OpVersionMap_OpVersionPair::IsInitialized() const { + if (_Internal::MissingRequiredFields(_has_bits_)) return false; + if (_internal_has_op_version()) { + if (!op_version_->IsInitialized()) return false; + } + return true; +} + +void OpVersionMap_OpVersionPair::InternalSwap(OpVersionMap_OpVersionPair* other) { + using std::swap; + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); + swap(_has_bits_[0], other->_has_bits_[0]); + op_name_.Swap(&other->op_name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + swap(op_version_, other->op_version_); +} + +::PROTOBUF_NAMESPACE_ID::Metadata OpVersionMap_OpVersionPair::GetMetadata() const { + return GetMetadataStatic(); +} + + +// =================================================================== + +class OpVersionMap::_Internal { + public: +}; + +OpVersionMap::OpVersionMap(::PROTOBUF_NAMESPACE_ID::Arena* arena) + : ::PROTOBUF_NAMESPACE_ID::Message(arena), + pair_(arena) { + SharedCtor(); + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:paddle.framework.proto.OpVersionMap) +} +OpVersionMap::OpVersionMap(const OpVersionMap& from) + : ::PROTOBUF_NAMESPACE_ID::Message(), + pair_(from.pair_) { + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + // @@protoc_insertion_point(copy_constructor:paddle.framework.proto.OpVersionMap) +} + +void OpVersionMap::SharedCtor() { + ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_OpVersionMap_framework_2eproto.base); +} + +OpVersionMap::~OpVersionMap() { + // @@protoc_insertion_point(destructor:paddle.framework.proto.OpVersionMap) + SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +void OpVersionMap::SharedDtor() { + GOOGLE_DCHECK(GetArena() == nullptr); +} + +void OpVersionMap::ArenaDtor(void* object) { + OpVersionMap* _this = reinterpret_cast< OpVersionMap* >(object); + (void)_this; +} +void OpVersionMap::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { +} +void OpVersionMap::SetCachedSize(int size) const { + _cached_size_.Set(size); +} +const OpVersionMap& OpVersionMap::default_instance() { + ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_OpVersionMap_framework_2eproto.base); + return *internal_default_instance(); +} + + +void OpVersionMap::Clear() { +// @@protoc_insertion_point(message_clear_start:paddle.framework.proto.OpVersionMap) + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + pair_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +const char* OpVersionMap::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure + while (!ctx->Done(&ptr)) { + ::PROTOBUF_NAMESPACE_ID::uint32 tag; + ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + CHK_(ptr); + switch (tag >> 3) { + // repeated .paddle.framework.proto.OpVersionMap.OpVersionPair pair = 1; + case 1: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) { + ptr -= 1; + do { + ptr += 1; + ptr = ctx->ParseMessage(_internal_add_pair(), ptr); + CHK_(ptr); + if (!ctx->DataAvailable(ptr)) break; + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<10>(ptr)); + } else goto handle_unusual; + continue; + default: { + handle_unusual: + if ((tag & 7) == 4 || tag == 0) { + ctx->SetLastTag(tag); + goto success; + } + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); + CHK_(ptr != nullptr); + continue; + } + } // switch + } // while +success: + return ptr; +failure: + ptr = nullptr; + goto success; +#undef CHK_ +} + +::PROTOBUF_NAMESPACE_ID::uint8* OpVersionMap::_InternalSerialize( + ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { + // @@protoc_insertion_point(serialize_to_array_start:paddle.framework.proto.OpVersionMap) + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + // repeated .paddle.framework.proto.OpVersionMap.OpVersionPair pair = 1; + for (unsigned int i = 0, + n = static_cast(this->_internal_pair_size()); i < n; i++) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage(1, this->_internal_pair(i), target, stream); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + } + // @@protoc_insertion_point(serialize_to_array_end:paddle.framework.proto.OpVersionMap) + return target; +} + +size_t OpVersionMap::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:paddle.framework.proto.OpVersionMap) + size_t total_size = 0; + + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + // repeated .paddle.framework.proto.OpVersionMap.OpVersionPair pair = 1; + total_size += 1UL * this->_internal_pair_size(); + for (const auto& msg : this->pair_) { + total_size += + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize( + _internal_metadata_, total_size, &_cached_size_); + } + int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size); + SetCachedSize(cached_size); + return total_size; +} + +void OpVersionMap::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { +// @@protoc_insertion_point(generalized_merge_from_start:paddle.framework.proto.OpVersionMap) + GOOGLE_DCHECK_NE(&from, this); + const OpVersionMap* source = + ::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated( + &from); + if (source == nullptr) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:paddle.framework.proto.OpVersionMap) + ::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this); + } else { + // @@protoc_insertion_point(generalized_merge_from_cast_success:paddle.framework.proto.OpVersionMap) + MergeFrom(*source); + } +} + +void OpVersionMap::MergeFrom(const OpVersionMap& from) { +// @@protoc_insertion_point(class_specific_merge_from_start:paddle.framework.proto.OpVersionMap) + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + pair_.MergeFrom(from.pair_); +} + +void OpVersionMap::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:paddle.framework.proto.OpVersionMap) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +void OpVersionMap::CopyFrom(const OpVersionMap& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:paddle.framework.proto.OpVersionMap) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool OpVersionMap::IsInitialized() const { + if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(pair_)) return false; + return true; +} + +void OpVersionMap::InternalSwap(OpVersionMap* other) { + using std::swap; + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); + pair_.InternalSwap(&other->pair_); +} + +::PROTOBUF_NAMESPACE_ID::Metadata OpVersionMap::GetMetadata() const { + return GetMetadataStatic(); +} + + +// =================================================================== + +class ProgramDesc::_Internal { + public: + using HasBits = decltype(std::declval()._has_bits_); + static const ::paddle::framework::proto::Version& version(const ProgramDesc* msg); + static void set_has_version(HasBits* has_bits) { + (*has_bits)[0] |= 1u; + } + static const ::paddle::framework::proto::OpVersionMap& op_version_map(const ProgramDesc* msg); + static void set_has_op_version_map(HasBits* has_bits) { + (*has_bits)[0] |= 2u; + } +}; + +const ::paddle::framework::proto::Version& +ProgramDesc::_Internal::version(const ProgramDesc* msg) { + return *msg->version_; +} +const ::paddle::framework::proto::OpVersionMap& +ProgramDesc::_Internal::op_version_map(const ProgramDesc* msg) { + return *msg->op_version_map_; +} +ProgramDesc::ProgramDesc(::PROTOBUF_NAMESPACE_ID::Arena* arena) + : ::PROTOBUF_NAMESPACE_ID::Message(arena), + blocks_(arena) { + SharedCtor(); + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:paddle.framework.proto.ProgramDesc) +} +ProgramDesc::ProgramDesc(const ProgramDesc& from) + : ::PROTOBUF_NAMESPACE_ID::Message(), + _has_bits_(from._has_bits_), + blocks_(from.blocks_) { + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + if (from._internal_has_version()) { + version_ = new ::paddle::framework::proto::Version(*from.version_); + } else { + version_ = nullptr; + } + if (from._internal_has_op_version_map()) { + op_version_map_ = new ::paddle::framework::proto::OpVersionMap(*from.op_version_map_); + } else { + op_version_map_ = nullptr; + } + // @@protoc_insertion_point(copy_constructor:paddle.framework.proto.ProgramDesc) +} + +void ProgramDesc::SharedCtor() { + ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_ProgramDesc_framework_2eproto.base); + ::memset(reinterpret_cast(this) + static_cast( + reinterpret_cast(&version_) - reinterpret_cast(this)), + 0, static_cast(reinterpret_cast(&op_version_map_) - + reinterpret_cast(&version_)) + sizeof(op_version_map_)); +} + +ProgramDesc::~ProgramDesc() { + // @@protoc_insertion_point(destructor:paddle.framework.proto.ProgramDesc) + SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +void ProgramDesc::SharedDtor() { + GOOGLE_DCHECK(GetArena() == nullptr); + if (this != internal_default_instance()) delete version_; + if (this != internal_default_instance()) delete op_version_map_; +} + +void ProgramDesc::ArenaDtor(void* object) { + ProgramDesc* _this = reinterpret_cast< ProgramDesc* >(object); + (void)_this; +} +void ProgramDesc::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { +} +void ProgramDesc::SetCachedSize(int size) const { + _cached_size_.Set(size); +} +const ProgramDesc& ProgramDesc::default_instance() { + ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_ProgramDesc_framework_2eproto.base); + return *internal_default_instance(); +} + + +void ProgramDesc::Clear() { +// @@protoc_insertion_point(message_clear_start:paddle.framework.proto.ProgramDesc) + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + blocks_.Clear(); + cached_has_bits = _has_bits_[0]; + if (cached_has_bits & 0x00000003u) { + if (cached_has_bits & 0x00000001u) { + GOOGLE_DCHECK(version_ != nullptr); + version_->Clear(); + } + if (cached_has_bits & 0x00000002u) { + GOOGLE_DCHECK(op_version_map_ != nullptr); + op_version_map_->Clear(); + } + } + _has_bits_.Clear(); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +const char* ProgramDesc::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure + _Internal::HasBits has_bits{}; + while (!ctx->Done(&ptr)) { + ::PROTOBUF_NAMESPACE_ID::uint32 tag; + ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + CHK_(ptr); + switch (tag >> 3) { + // repeated .paddle.framework.proto.BlockDesc blocks = 1; + case 1: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) { + ptr -= 1; + do { + ptr += 1; + ptr = ctx->ParseMessage(_internal_add_blocks(), ptr); + CHK_(ptr); + if (!ctx->DataAvailable(ptr)) break; + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<10>(ptr)); + } else goto handle_unusual; + continue; + // optional .paddle.framework.proto.Version version = 4; + case 4: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 34)) { + ptr = ctx->ParseMessage(_internal_mutable_version(), ptr); + CHK_(ptr); + } else goto handle_unusual; + continue; + // optional .paddle.framework.proto.OpVersionMap op_version_map = 5; + case 5: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 42)) { + ptr = ctx->ParseMessage(_internal_mutable_op_version_map(), ptr); + CHK_(ptr); + } else goto handle_unusual; + continue; + default: { + handle_unusual: + if ((tag & 7) == 4 || tag == 0) { + ctx->SetLastTag(tag); + goto success; + } + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); + CHK_(ptr != nullptr); + continue; + } + } // switch + } // while +success: + _has_bits_.Or(has_bits); + return ptr; +failure: + ptr = nullptr; + goto success; +#undef CHK_ +} + +::PROTOBUF_NAMESPACE_ID::uint8* ProgramDesc::_InternalSerialize( + ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { + // @@protoc_insertion_point(serialize_to_array_start:paddle.framework.proto.ProgramDesc) + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + // repeated .paddle.framework.proto.BlockDesc blocks = 1; + for (unsigned int i = 0, + n = static_cast(this->_internal_blocks_size()); i < n; i++) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage(1, this->_internal_blocks(i), target, stream); + } + + cached_has_bits = _has_bits_[0]; + // optional .paddle.framework.proto.Version version = 4; + if (cached_has_bits & 0x00000001u) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage( + 4, _Internal::version(this), target, stream); + } + + // optional .paddle.framework.proto.OpVersionMap op_version_map = 5; + if (cached_has_bits & 0x00000002u) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage( + 5, _Internal::op_version_map(this), target, stream); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + } + // @@protoc_insertion_point(serialize_to_array_end:paddle.framework.proto.ProgramDesc) + return target; +} + +size_t ProgramDesc::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:paddle.framework.proto.ProgramDesc) + size_t total_size = 0; + + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + // repeated .paddle.framework.proto.BlockDesc blocks = 1; + total_size += 1UL * this->_internal_blocks_size(); + for (const auto& msg : this->blocks_) { + total_size += + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); + } + + cached_has_bits = _has_bits_[0]; + if (cached_has_bits & 0x00000003u) { + // optional .paddle.framework.proto.Version version = 4; + if (cached_has_bits & 0x00000001u) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *version_); + } + + // optional .paddle.framework.proto.OpVersionMap op_version_map = 5; + if (cached_has_bits & 0x00000002u) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *op_version_map_); + } + + } + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize( + _internal_metadata_, total_size, &_cached_size_); + } + int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size); + SetCachedSize(cached_size); + return total_size; +} + +void ProgramDesc::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { +// @@protoc_insertion_point(generalized_merge_from_start:paddle.framework.proto.ProgramDesc) + GOOGLE_DCHECK_NE(&from, this); + const ProgramDesc* source = + ::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated( + &from); + if (source == nullptr) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:paddle.framework.proto.ProgramDesc) + ::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this); + } else { + // @@protoc_insertion_point(generalized_merge_from_cast_success:paddle.framework.proto.ProgramDesc) + MergeFrom(*source); + } +} + +void ProgramDesc::MergeFrom(const ProgramDesc& from) { +// @@protoc_insertion_point(class_specific_merge_from_start:paddle.framework.proto.ProgramDesc) + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + blocks_.MergeFrom(from.blocks_); + cached_has_bits = from._has_bits_[0]; + if (cached_has_bits & 0x00000003u) { + if (cached_has_bits & 0x00000001u) { + _internal_mutable_version()->::paddle::framework::proto::Version::MergeFrom(from._internal_version()); + } + if (cached_has_bits & 0x00000002u) { + _internal_mutable_op_version_map()->::paddle::framework::proto::OpVersionMap::MergeFrom(from._internal_op_version_map()); + } + } +} + +void ProgramDesc::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:paddle.framework.proto.ProgramDesc) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +void ProgramDesc::CopyFrom(const ProgramDesc& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:paddle.framework.proto.ProgramDesc) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool ProgramDesc::IsInitialized() const { + if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(blocks_)) return false; + if (_internal_has_op_version_map()) { + if (!op_version_map_->IsInitialized()) return false; + } + return true; +} + +void ProgramDesc::InternalSwap(ProgramDesc* other) { + using std::swap; + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); + swap(_has_bits_[0], other->_has_bits_[0]); + blocks_.InternalSwap(&other->blocks_); + ::PROTOBUF_NAMESPACE_ID::internal::memswap< + PROTOBUF_FIELD_OFFSET(ProgramDesc, op_version_map_) + + sizeof(ProgramDesc::op_version_map_) + - PROTOBUF_FIELD_OFFSET(ProgramDesc, version_)>( + reinterpret_cast(&version_), + reinterpret_cast(&other->version_)); +} + +::PROTOBUF_NAMESPACE_ID::Metadata ProgramDesc::GetMetadata() const { + return GetMetadataStatic(); +} + + +// @@protoc_insertion_point(namespace_scope) +} // namespace proto +} // namespace framework +} // namespace paddle +PROTOBUF_NAMESPACE_OPEN +template<> PROTOBUF_NOINLINE ::paddle::framework::proto::Version* Arena::CreateMaybeMessage< ::paddle::framework::proto::Version >(Arena* arena) { + return Arena::CreateMessageInternal< ::paddle::framework::proto::Version >(arena); +} +template<> PROTOBUF_NOINLINE ::paddle::framework::proto::OpDesc_Attr* Arena::CreateMaybeMessage< ::paddle::framework::proto::OpDesc_Attr >(Arena* arena) { + return Arena::CreateMessageInternal< ::paddle::framework::proto::OpDesc_Attr >(arena); +} +template<> PROTOBUF_NOINLINE ::paddle::framework::proto::OpDesc_Var* Arena::CreateMaybeMessage< ::paddle::framework::proto::OpDesc_Var >(Arena* arena) { + return Arena::CreateMessageInternal< ::paddle::framework::proto::OpDesc_Var >(arena); +} +template<> PROTOBUF_NOINLINE ::paddle::framework::proto::OpDesc* Arena::CreateMaybeMessage< ::paddle::framework::proto::OpDesc >(Arena* arena) { + return Arena::CreateMessageInternal< ::paddle::framework::proto::OpDesc >(arena); +} +template<> PROTOBUF_NOINLINE ::paddle::framework::proto::OpProto_Var* Arena::CreateMaybeMessage< ::paddle::framework::proto::OpProto_Var >(Arena* arena) { + return Arena::CreateMessageInternal< ::paddle::framework::proto::OpProto_Var >(arena); +} +template<> PROTOBUF_NOINLINE ::paddle::framework::proto::OpProto_Attr* Arena::CreateMaybeMessage< ::paddle::framework::proto::OpProto_Attr >(Arena* arena) { + return Arena::CreateMessageInternal< ::paddle::framework::proto::OpProto_Attr >(arena); +} +template<> PROTOBUF_NOINLINE ::paddle::framework::proto::OpProto* Arena::CreateMaybeMessage< ::paddle::framework::proto::OpProto >(Arena* arena) { + return Arena::CreateMessageInternal< ::paddle::framework::proto::OpProto >(arena); +} +template<> PROTOBUF_NOINLINE ::paddle::framework::proto::VarType_TensorDesc* Arena::CreateMaybeMessage< ::paddle::framework::proto::VarType_TensorDesc >(Arena* arena) { + return Arena::CreateMessageInternal< ::paddle::framework::proto::VarType_TensorDesc >(arena); +} +template<> PROTOBUF_NOINLINE ::paddle::framework::proto::VarType_LoDTensorDesc* Arena::CreateMaybeMessage< ::paddle::framework::proto::VarType_LoDTensorDesc >(Arena* arena) { + return Arena::CreateMessageInternal< ::paddle::framework::proto::VarType_LoDTensorDesc >(arena); +} +template<> PROTOBUF_NOINLINE ::paddle::framework::proto::VarType_LoDTensorArrayDesc* Arena::CreateMaybeMessage< ::paddle::framework::proto::VarType_LoDTensorArrayDesc >(Arena* arena) { + return Arena::CreateMessageInternal< ::paddle::framework::proto::VarType_LoDTensorArrayDesc >(arena); +} +template<> PROTOBUF_NOINLINE ::paddle::framework::proto::VarType_ReaderDesc* Arena::CreateMaybeMessage< ::paddle::framework::proto::VarType_ReaderDesc >(Arena* arena) { + return Arena::CreateMessageInternal< ::paddle::framework::proto::VarType_ReaderDesc >(arena); +} +template<> PROTOBUF_NOINLINE ::paddle::framework::proto::VarType_Tuple* Arena::CreateMaybeMessage< ::paddle::framework::proto::VarType_Tuple >(Arena* arena) { + return Arena::CreateMessageInternal< ::paddle::framework::proto::VarType_Tuple >(arena); +} +template<> PROTOBUF_NOINLINE ::paddle::framework::proto::VarType* Arena::CreateMaybeMessage< ::paddle::framework::proto::VarType >(Arena* arena) { + return Arena::CreateMessageInternal< ::paddle::framework::proto::VarType >(arena); +} +template<> PROTOBUF_NOINLINE ::paddle::framework::proto::VarDesc* Arena::CreateMaybeMessage< ::paddle::framework::proto::VarDesc >(Arena* arena) { + return Arena::CreateMessageInternal< ::paddle::framework::proto::VarDesc >(arena); +} +template<> PROTOBUF_NOINLINE ::paddle::framework::proto::BlockDesc* Arena::CreateMaybeMessage< ::paddle::framework::proto::BlockDesc >(Arena* arena) { + return Arena::CreateMessageInternal< ::paddle::framework::proto::BlockDesc >(arena); +} +template<> PROTOBUF_NOINLINE ::paddle::framework::proto::OpVersion* Arena::CreateMaybeMessage< ::paddle::framework::proto::OpVersion >(Arena* arena) { + return Arena::CreateMessageInternal< ::paddle::framework::proto::OpVersion >(arena); +} +template<> PROTOBUF_NOINLINE ::paddle::framework::proto::OpVersionMap_OpVersionPair* Arena::CreateMaybeMessage< ::paddle::framework::proto::OpVersionMap_OpVersionPair >(Arena* arena) { + return Arena::CreateMessageInternal< ::paddle::framework::proto::OpVersionMap_OpVersionPair >(arena); +} +template<> PROTOBUF_NOINLINE ::paddle::framework::proto::OpVersionMap* Arena::CreateMaybeMessage< ::paddle::framework::proto::OpVersionMap >(Arena* arena) { + return Arena::CreateMessageInternal< ::paddle::framework::proto::OpVersionMap >(arena); +} +template<> PROTOBUF_NOINLINE ::paddle::framework::proto::ProgramDesc* Arena::CreateMaybeMessage< ::paddle::framework::proto::ProgramDesc >(Arena* arena) { + return Arena::CreateMessageInternal< ::paddle::framework::proto::ProgramDesc >(arena); +} +PROTOBUF_NAMESPACE_CLOSE + +// @@protoc_insertion_point(global_scope) +#include diff --git a/inference-engine/samples/pdpd_poc/framework.pb.h b/inference-engine/samples/pdpd_poc/framework.pb.h new file mode 100644 index 00000000000000..ed6855ea28330c --- /dev/null +++ b/inference-engine/samples/pdpd_poc/framework.pb.h @@ -0,0 +1,7608 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: framework.proto + +#ifndef GOOGLE_PROTOBUF_INCLUDED_framework_2eproto +#define GOOGLE_PROTOBUF_INCLUDED_framework_2eproto + +#include +#include + +#include +#if PROTOBUF_VERSION < 3014000 +#error This file was generated by a newer version of protoc which is +#error incompatible with your Protocol Buffer headers. Please update +#error your headers. +#endif +#if 3014000 < PROTOBUF_MIN_PROTOC_VERSION +#error This file was generated by an older version of protoc which is +#error incompatible with your Protocol Buffer headers. Please +#error regenerate this file with a newer version of protoc. +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include // IWYU pragma: export +#include // IWYU pragma: export +#include +#include +// @@protoc_insertion_point(includes) +#include +#define PROTOBUF_INTERNAL_EXPORT_framework_2eproto +PROTOBUF_NAMESPACE_OPEN +namespace internal { +class AnyMetadata; +} // namespace internal +PROTOBUF_NAMESPACE_CLOSE + +// Internal implementation detail -- do not use these members. +struct TableStruct_framework_2eproto { + static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTableField entries[] + PROTOBUF_SECTION_VARIABLE(protodesc_cold); + static const ::PROTOBUF_NAMESPACE_ID::internal::AuxiliaryParseTableField aux[] + PROTOBUF_SECTION_VARIABLE(protodesc_cold); + static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTable schema[19] + PROTOBUF_SECTION_VARIABLE(protodesc_cold); + static const ::PROTOBUF_NAMESPACE_ID::internal::FieldMetadata field_metadata[]; + static const ::PROTOBUF_NAMESPACE_ID::internal::SerializationTable serialization_table[]; + static const ::PROTOBUF_NAMESPACE_ID::uint32 offsets[]; +}; +extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_framework_2eproto; +namespace paddle { +namespace framework { +namespace proto { +class BlockDesc; +class BlockDescDefaultTypeInternal; +extern BlockDescDefaultTypeInternal _BlockDesc_default_instance_; +class OpDesc; +class OpDescDefaultTypeInternal; +extern OpDescDefaultTypeInternal _OpDesc_default_instance_; +class OpDesc_Attr; +class OpDesc_AttrDefaultTypeInternal; +extern OpDesc_AttrDefaultTypeInternal _OpDesc_Attr_default_instance_; +class OpDesc_Var; +class OpDesc_VarDefaultTypeInternal; +extern OpDesc_VarDefaultTypeInternal _OpDesc_Var_default_instance_; +class OpProto; +class OpProtoDefaultTypeInternal; +extern OpProtoDefaultTypeInternal _OpProto_default_instance_; +class OpProto_Attr; +class OpProto_AttrDefaultTypeInternal; +extern OpProto_AttrDefaultTypeInternal _OpProto_Attr_default_instance_; +class OpProto_Var; +class OpProto_VarDefaultTypeInternal; +extern OpProto_VarDefaultTypeInternal _OpProto_Var_default_instance_; +class OpVersion; +class OpVersionDefaultTypeInternal; +extern OpVersionDefaultTypeInternal _OpVersion_default_instance_; +class OpVersionMap; +class OpVersionMapDefaultTypeInternal; +extern OpVersionMapDefaultTypeInternal _OpVersionMap_default_instance_; +class OpVersionMap_OpVersionPair; +class OpVersionMap_OpVersionPairDefaultTypeInternal; +extern OpVersionMap_OpVersionPairDefaultTypeInternal _OpVersionMap_OpVersionPair_default_instance_; +class ProgramDesc; +class ProgramDescDefaultTypeInternal; +extern ProgramDescDefaultTypeInternal _ProgramDesc_default_instance_; +class VarDesc; +class VarDescDefaultTypeInternal; +extern VarDescDefaultTypeInternal _VarDesc_default_instance_; +class VarType; +class VarTypeDefaultTypeInternal; +extern VarTypeDefaultTypeInternal _VarType_default_instance_; +class VarType_LoDTensorArrayDesc; +class VarType_LoDTensorArrayDescDefaultTypeInternal; +extern VarType_LoDTensorArrayDescDefaultTypeInternal _VarType_LoDTensorArrayDesc_default_instance_; +class VarType_LoDTensorDesc; +class VarType_LoDTensorDescDefaultTypeInternal; +extern VarType_LoDTensorDescDefaultTypeInternal _VarType_LoDTensorDesc_default_instance_; +class VarType_ReaderDesc; +class VarType_ReaderDescDefaultTypeInternal; +extern VarType_ReaderDescDefaultTypeInternal _VarType_ReaderDesc_default_instance_; +class VarType_TensorDesc; +class VarType_TensorDescDefaultTypeInternal; +extern VarType_TensorDescDefaultTypeInternal _VarType_TensorDesc_default_instance_; +class VarType_Tuple; +class VarType_TupleDefaultTypeInternal; +extern VarType_TupleDefaultTypeInternal _VarType_Tuple_default_instance_; +class Version; +class VersionDefaultTypeInternal; +extern VersionDefaultTypeInternal _Version_default_instance_; +} // namespace proto +} // namespace framework +} // namespace paddle +PROTOBUF_NAMESPACE_OPEN +template<> ::paddle::framework::proto::BlockDesc* Arena::CreateMaybeMessage<::paddle::framework::proto::BlockDesc>(Arena*); +template<> ::paddle::framework::proto::OpDesc* Arena::CreateMaybeMessage<::paddle::framework::proto::OpDesc>(Arena*); +template<> ::paddle::framework::proto::OpDesc_Attr* Arena::CreateMaybeMessage<::paddle::framework::proto::OpDesc_Attr>(Arena*); +template<> ::paddle::framework::proto::OpDesc_Var* Arena::CreateMaybeMessage<::paddle::framework::proto::OpDesc_Var>(Arena*); +template<> ::paddle::framework::proto::OpProto* Arena::CreateMaybeMessage<::paddle::framework::proto::OpProto>(Arena*); +template<> ::paddle::framework::proto::OpProto_Attr* Arena::CreateMaybeMessage<::paddle::framework::proto::OpProto_Attr>(Arena*); +template<> ::paddle::framework::proto::OpProto_Var* Arena::CreateMaybeMessage<::paddle::framework::proto::OpProto_Var>(Arena*); +template<> ::paddle::framework::proto::OpVersion* Arena::CreateMaybeMessage<::paddle::framework::proto::OpVersion>(Arena*); +template<> ::paddle::framework::proto::OpVersionMap* Arena::CreateMaybeMessage<::paddle::framework::proto::OpVersionMap>(Arena*); +template<> ::paddle::framework::proto::OpVersionMap_OpVersionPair* Arena::CreateMaybeMessage<::paddle::framework::proto::OpVersionMap_OpVersionPair>(Arena*); +template<> ::paddle::framework::proto::ProgramDesc* Arena::CreateMaybeMessage<::paddle::framework::proto::ProgramDesc>(Arena*); +template<> ::paddle::framework::proto::VarDesc* Arena::CreateMaybeMessage<::paddle::framework::proto::VarDesc>(Arena*); +template<> ::paddle::framework::proto::VarType* Arena::CreateMaybeMessage<::paddle::framework::proto::VarType>(Arena*); +template<> ::paddle::framework::proto::VarType_LoDTensorArrayDesc* Arena::CreateMaybeMessage<::paddle::framework::proto::VarType_LoDTensorArrayDesc>(Arena*); +template<> ::paddle::framework::proto::VarType_LoDTensorDesc* Arena::CreateMaybeMessage<::paddle::framework::proto::VarType_LoDTensorDesc>(Arena*); +template<> ::paddle::framework::proto::VarType_ReaderDesc* Arena::CreateMaybeMessage<::paddle::framework::proto::VarType_ReaderDesc>(Arena*); +template<> ::paddle::framework::proto::VarType_TensorDesc* Arena::CreateMaybeMessage<::paddle::framework::proto::VarType_TensorDesc>(Arena*); +template<> ::paddle::framework::proto::VarType_Tuple* Arena::CreateMaybeMessage<::paddle::framework::proto::VarType_Tuple>(Arena*); +template<> ::paddle::framework::proto::Version* Arena::CreateMaybeMessage<::paddle::framework::proto::Version>(Arena*); +PROTOBUF_NAMESPACE_CLOSE +namespace paddle { +namespace framework { +namespace proto { + +enum VarType_Type : int { + VarType_Type_BOOL = 0, + VarType_Type_INT16 = 1, + VarType_Type_INT32 = 2, + VarType_Type_INT64 = 3, + VarType_Type_FP16 = 4, + VarType_Type_FP32 = 5, + VarType_Type_FP64 = 6, + VarType_Type_SIZE_T = 19, + VarType_Type_UINT8 = 20, + VarType_Type_INT8 = 21, + VarType_Type_BF16 = 22, + VarType_Type_COMPLEX64 = 23, + VarType_Type_COMPLEX128 = 24, + VarType_Type_LOD_TENSOR = 7, + VarType_Type_SELECTED_ROWS = 8, + VarType_Type_FEED_MINIBATCH = 9, + VarType_Type_FETCH_LIST = 10, + VarType_Type_STEP_SCOPES = 11, + VarType_Type_LOD_RANK_TABLE = 12, + VarType_Type_LOD_TENSOR_ARRAY = 13, + VarType_Type_PLACE_LIST = 14, + VarType_Type_READER = 15, + VarType_Type_RAW = 17, + VarType_Type_TUPLE = 18 +}; +bool VarType_Type_IsValid(int value); +constexpr VarType_Type VarType_Type_Type_MIN = VarType_Type_BOOL; +constexpr VarType_Type VarType_Type_Type_MAX = VarType_Type_COMPLEX128; +constexpr int VarType_Type_Type_ARRAYSIZE = VarType_Type_Type_MAX + 1; + +const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* VarType_Type_descriptor(); +template +inline const std::string& VarType_Type_Name(T enum_t_value) { + static_assert(::std::is_same::value || + ::std::is_integral::value, + "Incorrect type passed to function VarType_Type_Name."); + return ::PROTOBUF_NAMESPACE_ID::internal::NameOfEnum( + VarType_Type_descriptor(), enum_t_value); +} +inline bool VarType_Type_Parse( + ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, VarType_Type* value) { + return ::PROTOBUF_NAMESPACE_ID::internal::ParseNamedEnum( + VarType_Type_descriptor(), name, value); +} +enum AttrType : int { + INT = 0, + FLOAT = 1, + STRING = 2, + INTS = 3, + FLOATS = 4, + STRINGS = 5, + BOOLEAN = 6, + BOOLEANS = 7, + BLOCK = 8, + LONG = 9, + BLOCKS = 10, + LONGS = 11 +}; +bool AttrType_IsValid(int value); +constexpr AttrType AttrType_MIN = INT; +constexpr AttrType AttrType_MAX = LONGS; +constexpr int AttrType_ARRAYSIZE = AttrType_MAX + 1; + +const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* AttrType_descriptor(); +template +inline const std::string& AttrType_Name(T enum_t_value) { + static_assert(::std::is_same::value || + ::std::is_integral::value, + "Incorrect type passed to function AttrType_Name."); + return ::PROTOBUF_NAMESPACE_ID::internal::NameOfEnum( + AttrType_descriptor(), enum_t_value); +} +inline bool AttrType_Parse( + ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, AttrType* value) { + return ::PROTOBUF_NAMESPACE_ID::internal::ParseNamedEnum( + AttrType_descriptor(), name, value); +} +// =================================================================== + +class Version PROTOBUF_FINAL : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:paddle.framework.proto.Version) */ { + public: + inline Version() : Version(nullptr) {} + virtual ~Version(); + + Version(const Version& from); + Version(Version&& from) noexcept + : Version() { + *this = ::std::move(from); + } + + inline Version& operator=(const Version& from) { + CopyFrom(from); + return *this; + } + inline Version& operator=(Version&& from) noexcept { + if (GetArena() == from.GetArena()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); + } + inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + } + + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return GetMetadataStatic().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return GetMetadataStatic().reflection; + } + static const Version& default_instance(); + + static inline const Version* internal_default_instance() { + return reinterpret_cast( + &_Version_default_instance_); + } + static constexpr int kIndexInFileMessages = + 0; + + friend void swap(Version& a, Version& b) { + a.Swap(&b); + } + inline void Swap(Version* other) { + if (other == this) return; + if (GetArena() == other->GetArena()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(Version* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArena() == other->GetArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + inline Version* New() const final { + return CreateMaybeMessage(nullptr); + } + + Version* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { + return CreateMaybeMessage(arena); + } + void CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; + void MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; + void CopyFrom(const Version& from); + void MergeFrom(const Version& from); + PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; + bool IsInitialized() const final; + + size_t ByteSizeLong() const final; + const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; + ::PROTOBUF_NAMESPACE_ID::uint8* _InternalSerialize( + ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; + int GetCachedSize() const final { return _cached_size_.Get(); } + + private: + inline void SharedCtor(); + inline void SharedDtor(); + void SetCachedSize(int size) const final; + void InternalSwap(Version* other); + friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; + static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { + return "paddle.framework.proto.Version"; + } + protected: + explicit Version(::PROTOBUF_NAMESPACE_ID::Arena* arena); + private: + static void ArenaDtor(void* object); + inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); + public: + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + private: + static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { + ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_framework_2eproto); + return ::descriptor_table_framework_2eproto.file_level_metadata[kIndexInFileMessages]; + } + + public: + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kVersionFieldNumber = 1, + }; + // optional int64 version = 1 [default = 0]; + bool has_version() const; + private: + bool _internal_has_version() const; + public: + void clear_version(); + ::PROTOBUF_NAMESPACE_ID::int64 version() const; + void set_version(::PROTOBUF_NAMESPACE_ID::int64 value); + private: + ::PROTOBUF_NAMESPACE_ID::int64 _internal_version() const; + void _internal_set_version(::PROTOBUF_NAMESPACE_ID::int64 value); + public: + + // @@protoc_insertion_point(class_scope:paddle.framework.proto.Version) + private: + class _Internal; + + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + ::PROTOBUF_NAMESPACE_ID::int64 version_; + friend struct ::TableStruct_framework_2eproto; +}; +// ------------------------------------------------------------------- + +class OpDesc_Attr PROTOBUF_FINAL : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:paddle.framework.proto.OpDesc.Attr) */ { + public: + inline OpDesc_Attr() : OpDesc_Attr(nullptr) {} + virtual ~OpDesc_Attr(); + + OpDesc_Attr(const OpDesc_Attr& from); + OpDesc_Attr(OpDesc_Attr&& from) noexcept + : OpDesc_Attr() { + *this = ::std::move(from); + } + + inline OpDesc_Attr& operator=(const OpDesc_Attr& from) { + CopyFrom(from); + return *this; + } + inline OpDesc_Attr& operator=(OpDesc_Attr&& from) noexcept { + if (GetArena() == from.GetArena()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); + } + inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + } + + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return GetMetadataStatic().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return GetMetadataStatic().reflection; + } + static const OpDesc_Attr& default_instance(); + + static inline const OpDesc_Attr* internal_default_instance() { + return reinterpret_cast( + &_OpDesc_Attr_default_instance_); + } + static constexpr int kIndexInFileMessages = + 1; + + friend void swap(OpDesc_Attr& a, OpDesc_Attr& b) { + a.Swap(&b); + } + inline void Swap(OpDesc_Attr* other) { + if (other == this) return; + if (GetArena() == other->GetArena()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(OpDesc_Attr* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArena() == other->GetArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + inline OpDesc_Attr* New() const final { + return CreateMaybeMessage(nullptr); + } + + OpDesc_Attr* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { + return CreateMaybeMessage(arena); + } + void CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; + void MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; + void CopyFrom(const OpDesc_Attr& from); + void MergeFrom(const OpDesc_Attr& from); + PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; + bool IsInitialized() const final; + + size_t ByteSizeLong() const final; + const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; + ::PROTOBUF_NAMESPACE_ID::uint8* _InternalSerialize( + ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; + int GetCachedSize() const final { return _cached_size_.Get(); } + + private: + inline void SharedCtor(); + inline void SharedDtor(); + void SetCachedSize(int size) const final; + void InternalSwap(OpDesc_Attr* other); + friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; + static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { + return "paddle.framework.proto.OpDesc.Attr"; + } + protected: + explicit OpDesc_Attr(::PROTOBUF_NAMESPACE_ID::Arena* arena); + private: + static void ArenaDtor(void* object); + inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); + public: + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + private: + static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { + ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_framework_2eproto); + return ::descriptor_table_framework_2eproto.file_level_metadata[kIndexInFileMessages]; + } + + public: + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kIntsFieldNumber = 6, + kFloatsFieldNumber = 7, + kStringsFieldNumber = 8, + kBoolsFieldNumber = 11, + kBlocksIdxFieldNumber = 14, + kLongsFieldNumber = 15, + kNameFieldNumber = 1, + kSFieldNumber = 5, + kTypeFieldNumber = 2, + kIFieldNumber = 3, + kFFieldNumber = 4, + kBFieldNumber = 10, + kLFieldNumber = 13, + kBlockIdxFieldNumber = 12, + }; + // repeated int32 ints = 6; + int ints_size() const; + private: + int _internal_ints_size() const; + public: + void clear_ints(); + private: + ::PROTOBUF_NAMESPACE_ID::int32 _internal_ints(int index) const; + const ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int32 >& + _internal_ints() const; + void _internal_add_ints(::PROTOBUF_NAMESPACE_ID::int32 value); + ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int32 >* + _internal_mutable_ints(); + public: + ::PROTOBUF_NAMESPACE_ID::int32 ints(int index) const; + void set_ints(int index, ::PROTOBUF_NAMESPACE_ID::int32 value); + void add_ints(::PROTOBUF_NAMESPACE_ID::int32 value); + const ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int32 >& + ints() const; + ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int32 >* + mutable_ints(); + + // repeated float floats = 7; + int floats_size() const; + private: + int _internal_floats_size() const; + public: + void clear_floats(); + private: + float _internal_floats(int index) const; + const ::PROTOBUF_NAMESPACE_ID::RepeatedField< float >& + _internal_floats() const; + void _internal_add_floats(float value); + ::PROTOBUF_NAMESPACE_ID::RepeatedField< float >* + _internal_mutable_floats(); + public: + float floats(int index) const; + void set_floats(int index, float value); + void add_floats(float value); + const ::PROTOBUF_NAMESPACE_ID::RepeatedField< float >& + floats() const; + ::PROTOBUF_NAMESPACE_ID::RepeatedField< float >* + mutable_floats(); + + // repeated string strings = 8; + int strings_size() const; + private: + int _internal_strings_size() const; + public: + void clear_strings(); + const std::string& strings(int index) const; + std::string* mutable_strings(int index); + void set_strings(int index, const std::string& value); + void set_strings(int index, std::string&& value); + void set_strings(int index, const char* value); + void set_strings(int index, const char* value, size_t size); + std::string* add_strings(); + void add_strings(const std::string& value); + void add_strings(std::string&& value); + void add_strings(const char* value); + void add_strings(const char* value, size_t size); + const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField& strings() const; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField* mutable_strings(); + private: + const std::string& _internal_strings(int index) const; + std::string* _internal_add_strings(); + public: + + // repeated bool bools = 11; + int bools_size() const; + private: + int _internal_bools_size() const; + public: + void clear_bools(); + private: + bool _internal_bools(int index) const; + const ::PROTOBUF_NAMESPACE_ID::RepeatedField< bool >& + _internal_bools() const; + void _internal_add_bools(bool value); + ::PROTOBUF_NAMESPACE_ID::RepeatedField< bool >* + _internal_mutable_bools(); + public: + bool bools(int index) const; + void set_bools(int index, bool value); + void add_bools(bool value); + const ::PROTOBUF_NAMESPACE_ID::RepeatedField< bool >& + bools() const; + ::PROTOBUF_NAMESPACE_ID::RepeatedField< bool >* + mutable_bools(); + + // repeated int32 blocks_idx = 14; + int blocks_idx_size() const; + private: + int _internal_blocks_idx_size() const; + public: + void clear_blocks_idx(); + private: + ::PROTOBUF_NAMESPACE_ID::int32 _internal_blocks_idx(int index) const; + const ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int32 >& + _internal_blocks_idx() const; + void _internal_add_blocks_idx(::PROTOBUF_NAMESPACE_ID::int32 value); + ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int32 >* + _internal_mutable_blocks_idx(); + public: + ::PROTOBUF_NAMESPACE_ID::int32 blocks_idx(int index) const; + void set_blocks_idx(int index, ::PROTOBUF_NAMESPACE_ID::int32 value); + void add_blocks_idx(::PROTOBUF_NAMESPACE_ID::int32 value); + const ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int32 >& + blocks_idx() const; + ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int32 >* + mutable_blocks_idx(); + + // repeated int64 longs = 15; + int longs_size() const; + private: + int _internal_longs_size() const; + public: + void clear_longs(); + private: + ::PROTOBUF_NAMESPACE_ID::int64 _internal_longs(int index) const; + const ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int64 >& + _internal_longs() const; + void _internal_add_longs(::PROTOBUF_NAMESPACE_ID::int64 value); + ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int64 >* + _internal_mutable_longs(); + public: + ::PROTOBUF_NAMESPACE_ID::int64 longs(int index) const; + void set_longs(int index, ::PROTOBUF_NAMESPACE_ID::int64 value); + void add_longs(::PROTOBUF_NAMESPACE_ID::int64 value); + const ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int64 >& + longs() const; + ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int64 >* + mutable_longs(); + + // required string name = 1; + bool has_name() const; + private: + bool _internal_has_name() const; + public: + void clear_name(); + const std::string& name() const; + void set_name(const std::string& value); + void set_name(std::string&& value); + void set_name(const char* value); + void set_name(const char* value, size_t size); + std::string* mutable_name(); + std::string* release_name(); + void set_allocated_name(std::string* name); + private: + const std::string& _internal_name() const; + void _internal_set_name(const std::string& value); + std::string* _internal_mutable_name(); + public: + + // optional string s = 5; + bool has_s() const; + private: + bool _internal_has_s() const; + public: + void clear_s(); + const std::string& s() const; + void set_s(const std::string& value); + void set_s(std::string&& value); + void set_s(const char* value); + void set_s(const char* value, size_t size); + std::string* mutable_s(); + std::string* release_s(); + void set_allocated_s(std::string* s); + private: + const std::string& _internal_s() const; + void _internal_set_s(const std::string& value); + std::string* _internal_mutable_s(); + public: + + // required .paddle.framework.proto.AttrType type = 2; + bool has_type() const; + private: + bool _internal_has_type() const; + public: + void clear_type(); + ::paddle::framework::proto::AttrType type() const; + void set_type(::paddle::framework::proto::AttrType value); + private: + ::paddle::framework::proto::AttrType _internal_type() const; + void _internal_set_type(::paddle::framework::proto::AttrType value); + public: + + // optional int32 i = 3; + bool has_i() const; + private: + bool _internal_has_i() const; + public: + void clear_i(); + ::PROTOBUF_NAMESPACE_ID::int32 i() const; + void set_i(::PROTOBUF_NAMESPACE_ID::int32 value); + private: + ::PROTOBUF_NAMESPACE_ID::int32 _internal_i() const; + void _internal_set_i(::PROTOBUF_NAMESPACE_ID::int32 value); + public: + + // optional float f = 4; + bool has_f() const; + private: + bool _internal_has_f() const; + public: + void clear_f(); + float f() const; + void set_f(float value); + private: + float _internal_f() const; + void _internal_set_f(float value); + public: + + // optional bool b = 10; + bool has_b() const; + private: + bool _internal_has_b() const; + public: + void clear_b(); + bool b() const; + void set_b(bool value); + private: + bool _internal_b() const; + void _internal_set_b(bool value); + public: + + // optional int64 l = 13; + bool has_l() const; + private: + bool _internal_has_l() const; + public: + void clear_l(); + ::PROTOBUF_NAMESPACE_ID::int64 l() const; + void set_l(::PROTOBUF_NAMESPACE_ID::int64 value); + private: + ::PROTOBUF_NAMESPACE_ID::int64 _internal_l() const; + void _internal_set_l(::PROTOBUF_NAMESPACE_ID::int64 value); + public: + + // optional int32 block_idx = 12; + bool has_block_idx() const; + private: + bool _internal_has_block_idx() const; + public: + void clear_block_idx(); + ::PROTOBUF_NAMESPACE_ID::int32 block_idx() const; + void set_block_idx(::PROTOBUF_NAMESPACE_ID::int32 value); + private: + ::PROTOBUF_NAMESPACE_ID::int32 _internal_block_idx() const; + void _internal_set_block_idx(::PROTOBUF_NAMESPACE_ID::int32 value); + public: + + // @@protoc_insertion_point(class_scope:paddle.framework.proto.OpDesc.Attr) + private: + class _Internal; + + // helper for ByteSizeLong() + size_t RequiredFieldsByteSizeFallback() const; + + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int32 > ints_; + ::PROTOBUF_NAMESPACE_ID::RepeatedField< float > floats_; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField strings_; + ::PROTOBUF_NAMESPACE_ID::RepeatedField< bool > bools_; + ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int32 > blocks_idx_; + ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int64 > longs_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr name_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr s_; + int type_; + ::PROTOBUF_NAMESPACE_ID::int32 i_; + float f_; + bool b_; + ::PROTOBUF_NAMESPACE_ID::int64 l_; + ::PROTOBUF_NAMESPACE_ID::int32 block_idx_; + friend struct ::TableStruct_framework_2eproto; +}; +// ------------------------------------------------------------------- + +class OpDesc_Var PROTOBUF_FINAL : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:paddle.framework.proto.OpDesc.Var) */ { + public: + inline OpDesc_Var() : OpDesc_Var(nullptr) {} + virtual ~OpDesc_Var(); + + OpDesc_Var(const OpDesc_Var& from); + OpDesc_Var(OpDesc_Var&& from) noexcept + : OpDesc_Var() { + *this = ::std::move(from); + } + + inline OpDesc_Var& operator=(const OpDesc_Var& from) { + CopyFrom(from); + return *this; + } + inline OpDesc_Var& operator=(OpDesc_Var&& from) noexcept { + if (GetArena() == from.GetArena()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); + } + inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + } + + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return GetMetadataStatic().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return GetMetadataStatic().reflection; + } + static const OpDesc_Var& default_instance(); + + static inline const OpDesc_Var* internal_default_instance() { + return reinterpret_cast( + &_OpDesc_Var_default_instance_); + } + static constexpr int kIndexInFileMessages = + 2; + + friend void swap(OpDesc_Var& a, OpDesc_Var& b) { + a.Swap(&b); + } + inline void Swap(OpDesc_Var* other) { + if (other == this) return; + if (GetArena() == other->GetArena()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(OpDesc_Var* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArena() == other->GetArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + inline OpDesc_Var* New() const final { + return CreateMaybeMessage(nullptr); + } + + OpDesc_Var* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { + return CreateMaybeMessage(arena); + } + void CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; + void MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; + void CopyFrom(const OpDesc_Var& from); + void MergeFrom(const OpDesc_Var& from); + PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; + bool IsInitialized() const final; + + size_t ByteSizeLong() const final; + const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; + ::PROTOBUF_NAMESPACE_ID::uint8* _InternalSerialize( + ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; + int GetCachedSize() const final { return _cached_size_.Get(); } + + private: + inline void SharedCtor(); + inline void SharedDtor(); + void SetCachedSize(int size) const final; + void InternalSwap(OpDesc_Var* other); + friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; + static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { + return "paddle.framework.proto.OpDesc.Var"; + } + protected: + explicit OpDesc_Var(::PROTOBUF_NAMESPACE_ID::Arena* arena); + private: + static void ArenaDtor(void* object); + inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); + public: + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + private: + static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { + ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_framework_2eproto); + return ::descriptor_table_framework_2eproto.file_level_metadata[kIndexInFileMessages]; + } + + public: + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kArgumentsFieldNumber = 2, + kParameterFieldNumber = 1, + }; + // repeated string arguments = 2; + int arguments_size() const; + private: + int _internal_arguments_size() const; + public: + void clear_arguments(); + const std::string& arguments(int index) const; + std::string* mutable_arguments(int index); + void set_arguments(int index, const std::string& value); + void set_arguments(int index, std::string&& value); + void set_arguments(int index, const char* value); + void set_arguments(int index, const char* value, size_t size); + std::string* add_arguments(); + void add_arguments(const std::string& value); + void add_arguments(std::string&& value); + void add_arguments(const char* value); + void add_arguments(const char* value, size_t size); + const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField& arguments() const; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField* mutable_arguments(); + private: + const std::string& _internal_arguments(int index) const; + std::string* _internal_add_arguments(); + public: + + // required string parameter = 1; + bool has_parameter() const; + private: + bool _internal_has_parameter() const; + public: + void clear_parameter(); + const std::string& parameter() const; + void set_parameter(const std::string& value); + void set_parameter(std::string&& value); + void set_parameter(const char* value); + void set_parameter(const char* value, size_t size); + std::string* mutable_parameter(); + std::string* release_parameter(); + void set_allocated_parameter(std::string* parameter); + private: + const std::string& _internal_parameter() const; + void _internal_set_parameter(const std::string& value); + std::string* _internal_mutable_parameter(); + public: + + // @@protoc_insertion_point(class_scope:paddle.framework.proto.OpDesc.Var) + private: + class _Internal; + + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField arguments_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr parameter_; + friend struct ::TableStruct_framework_2eproto; +}; +// ------------------------------------------------------------------- + +class OpDesc PROTOBUF_FINAL : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:paddle.framework.proto.OpDesc) */ { + public: + inline OpDesc() : OpDesc(nullptr) {} + virtual ~OpDesc(); + + OpDesc(const OpDesc& from); + OpDesc(OpDesc&& from) noexcept + : OpDesc() { + *this = ::std::move(from); + } + + inline OpDesc& operator=(const OpDesc& from) { + CopyFrom(from); + return *this; + } + inline OpDesc& operator=(OpDesc&& from) noexcept { + if (GetArena() == from.GetArena()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); + } + inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + } + + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return GetMetadataStatic().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return GetMetadataStatic().reflection; + } + static const OpDesc& default_instance(); + + static inline const OpDesc* internal_default_instance() { + return reinterpret_cast( + &_OpDesc_default_instance_); + } + static constexpr int kIndexInFileMessages = + 3; + + friend void swap(OpDesc& a, OpDesc& b) { + a.Swap(&b); + } + inline void Swap(OpDesc* other) { + if (other == this) return; + if (GetArena() == other->GetArena()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(OpDesc* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArena() == other->GetArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + inline OpDesc* New() const final { + return CreateMaybeMessage(nullptr); + } + + OpDesc* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { + return CreateMaybeMessage(arena); + } + void CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; + void MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; + void CopyFrom(const OpDesc& from); + void MergeFrom(const OpDesc& from); + PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; + bool IsInitialized() const final; + + size_t ByteSizeLong() const final; + const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; + ::PROTOBUF_NAMESPACE_ID::uint8* _InternalSerialize( + ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; + int GetCachedSize() const final { return _cached_size_.Get(); } + + private: + inline void SharedCtor(); + inline void SharedDtor(); + void SetCachedSize(int size) const final; + void InternalSwap(OpDesc* other); + friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; + static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { + return "paddle.framework.proto.OpDesc"; + } + protected: + explicit OpDesc(::PROTOBUF_NAMESPACE_ID::Arena* arena); + private: + static void ArenaDtor(void* object); + inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); + public: + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + private: + static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { + ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_framework_2eproto); + return ::descriptor_table_framework_2eproto.file_level_metadata[kIndexInFileMessages]; + } + + public: + + // nested types ---------------------------------------------------- + + typedef OpDesc_Attr Attr; + typedef OpDesc_Var Var; + + // accessors ------------------------------------------------------- + + enum : int { + kInputsFieldNumber = 1, + kOutputsFieldNumber = 2, + kAttrsFieldNumber = 4, + kTypeFieldNumber = 3, + kIsTargetFieldNumber = 5, + }; + // repeated .paddle.framework.proto.OpDesc.Var inputs = 1; + int inputs_size() const; + private: + int _internal_inputs_size() const; + public: + void clear_inputs(); + ::paddle::framework::proto::OpDesc_Var* mutable_inputs(int index); + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::OpDesc_Var >* + mutable_inputs(); + private: + const ::paddle::framework::proto::OpDesc_Var& _internal_inputs(int index) const; + ::paddle::framework::proto::OpDesc_Var* _internal_add_inputs(); + public: + const ::paddle::framework::proto::OpDesc_Var& inputs(int index) const; + ::paddle::framework::proto::OpDesc_Var* add_inputs(); + const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::OpDesc_Var >& + inputs() const; + + // repeated .paddle.framework.proto.OpDesc.Var outputs = 2; + int outputs_size() const; + private: + int _internal_outputs_size() const; + public: + void clear_outputs(); + ::paddle::framework::proto::OpDesc_Var* mutable_outputs(int index); + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::OpDesc_Var >* + mutable_outputs(); + private: + const ::paddle::framework::proto::OpDesc_Var& _internal_outputs(int index) const; + ::paddle::framework::proto::OpDesc_Var* _internal_add_outputs(); + public: + const ::paddle::framework::proto::OpDesc_Var& outputs(int index) const; + ::paddle::framework::proto::OpDesc_Var* add_outputs(); + const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::OpDesc_Var >& + outputs() const; + + // repeated .paddle.framework.proto.OpDesc.Attr attrs = 4; + int attrs_size() const; + private: + int _internal_attrs_size() const; + public: + void clear_attrs(); + ::paddle::framework::proto::OpDesc_Attr* mutable_attrs(int index); + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::OpDesc_Attr >* + mutable_attrs(); + private: + const ::paddle::framework::proto::OpDesc_Attr& _internal_attrs(int index) const; + ::paddle::framework::proto::OpDesc_Attr* _internal_add_attrs(); + public: + const ::paddle::framework::proto::OpDesc_Attr& attrs(int index) const; + ::paddle::framework::proto::OpDesc_Attr* add_attrs(); + const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::OpDesc_Attr >& + attrs() const; + + // required string type = 3; + bool has_type() const; + private: + bool _internal_has_type() const; + public: + void clear_type(); + const std::string& type() const; + void set_type(const std::string& value); + void set_type(std::string&& value); + void set_type(const char* value); + void set_type(const char* value, size_t size); + std::string* mutable_type(); + std::string* release_type(); + void set_allocated_type(std::string* type); + private: + const std::string& _internal_type() const; + void _internal_set_type(const std::string& value); + std::string* _internal_mutable_type(); + public: + + // optional bool is_target = 5 [default = false]; + bool has_is_target() const; + private: + bool _internal_has_is_target() const; + public: + void clear_is_target(); + bool is_target() const; + void set_is_target(bool value); + private: + bool _internal_is_target() const; + void _internal_set_is_target(bool value); + public: + + // @@protoc_insertion_point(class_scope:paddle.framework.proto.OpDesc) + private: + class _Internal; + + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::OpDesc_Var > inputs_; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::OpDesc_Var > outputs_; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::OpDesc_Attr > attrs_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr type_; + bool is_target_; + friend struct ::TableStruct_framework_2eproto; +}; +// ------------------------------------------------------------------- + +class OpProto_Var PROTOBUF_FINAL : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:paddle.framework.proto.OpProto.Var) */ { + public: + inline OpProto_Var() : OpProto_Var(nullptr) {} + virtual ~OpProto_Var(); + + OpProto_Var(const OpProto_Var& from); + OpProto_Var(OpProto_Var&& from) noexcept + : OpProto_Var() { + *this = ::std::move(from); + } + + inline OpProto_Var& operator=(const OpProto_Var& from) { + CopyFrom(from); + return *this; + } + inline OpProto_Var& operator=(OpProto_Var&& from) noexcept { + if (GetArena() == from.GetArena()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); + } + inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + } + + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return GetMetadataStatic().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return GetMetadataStatic().reflection; + } + static const OpProto_Var& default_instance(); + + static inline const OpProto_Var* internal_default_instance() { + return reinterpret_cast( + &_OpProto_Var_default_instance_); + } + static constexpr int kIndexInFileMessages = + 4; + + friend void swap(OpProto_Var& a, OpProto_Var& b) { + a.Swap(&b); + } + inline void Swap(OpProto_Var* other) { + if (other == this) return; + if (GetArena() == other->GetArena()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(OpProto_Var* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArena() == other->GetArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + inline OpProto_Var* New() const final { + return CreateMaybeMessage(nullptr); + } + + OpProto_Var* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { + return CreateMaybeMessage(arena); + } + void CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; + void MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; + void CopyFrom(const OpProto_Var& from); + void MergeFrom(const OpProto_Var& from); + PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; + bool IsInitialized() const final; + + size_t ByteSizeLong() const final; + const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; + ::PROTOBUF_NAMESPACE_ID::uint8* _InternalSerialize( + ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; + int GetCachedSize() const final { return _cached_size_.Get(); } + + private: + inline void SharedCtor(); + inline void SharedDtor(); + void SetCachedSize(int size) const final; + void InternalSwap(OpProto_Var* other); + friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; + static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { + return "paddle.framework.proto.OpProto.Var"; + } + protected: + explicit OpProto_Var(::PROTOBUF_NAMESPACE_ID::Arena* arena); + private: + static void ArenaDtor(void* object); + inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); + public: + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + private: + static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { + ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_framework_2eproto); + return ::descriptor_table_framework_2eproto.file_level_metadata[kIndexInFileMessages]; + } + + public: + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kNameFieldNumber = 1, + kCommentFieldNumber = 2, + kDuplicableFieldNumber = 3, + kIntermediateFieldNumber = 4, + kDispensableFieldNumber = 5, + }; + // required string name = 1; + bool has_name() const; + private: + bool _internal_has_name() const; + public: + void clear_name(); + const std::string& name() const; + void set_name(const std::string& value); + void set_name(std::string&& value); + void set_name(const char* value); + void set_name(const char* value, size_t size); + std::string* mutable_name(); + std::string* release_name(); + void set_allocated_name(std::string* name); + private: + const std::string& _internal_name() const; + void _internal_set_name(const std::string& value); + std::string* _internal_mutable_name(); + public: + + // required string comment = 2; + bool has_comment() const; + private: + bool _internal_has_comment() const; + public: + void clear_comment(); + const std::string& comment() const; + void set_comment(const std::string& value); + void set_comment(std::string&& value); + void set_comment(const char* value); + void set_comment(const char* value, size_t size); + std::string* mutable_comment(); + std::string* release_comment(); + void set_allocated_comment(std::string* comment); + private: + const std::string& _internal_comment() const; + void _internal_set_comment(const std::string& value); + std::string* _internal_mutable_comment(); + public: + + // optional bool duplicable = 3 [default = false]; + bool has_duplicable() const; + private: + bool _internal_has_duplicable() const; + public: + void clear_duplicable(); + bool duplicable() const; + void set_duplicable(bool value); + private: + bool _internal_duplicable() const; + void _internal_set_duplicable(bool value); + public: + + // optional bool intermediate = 4 [default = false]; + bool has_intermediate() const; + private: + bool _internal_has_intermediate() const; + public: + void clear_intermediate(); + bool intermediate() const; + void set_intermediate(bool value); + private: + bool _internal_intermediate() const; + void _internal_set_intermediate(bool value); + public: + + // optional bool dispensable = 5 [default = false]; + bool has_dispensable() const; + private: + bool _internal_has_dispensable() const; + public: + void clear_dispensable(); + bool dispensable() const; + void set_dispensable(bool value); + private: + bool _internal_dispensable() const; + void _internal_set_dispensable(bool value); + public: + + // @@protoc_insertion_point(class_scope:paddle.framework.proto.OpProto.Var) + private: + class _Internal; + + // helper for ByteSizeLong() + size_t RequiredFieldsByteSizeFallback() const; + + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr name_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr comment_; + bool duplicable_; + bool intermediate_; + bool dispensable_; + friend struct ::TableStruct_framework_2eproto; +}; +// ------------------------------------------------------------------- + +class OpProto_Attr PROTOBUF_FINAL : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:paddle.framework.proto.OpProto.Attr) */ { + public: + inline OpProto_Attr() : OpProto_Attr(nullptr) {} + virtual ~OpProto_Attr(); + + OpProto_Attr(const OpProto_Attr& from); + OpProto_Attr(OpProto_Attr&& from) noexcept + : OpProto_Attr() { + *this = ::std::move(from); + } + + inline OpProto_Attr& operator=(const OpProto_Attr& from) { + CopyFrom(from); + return *this; + } + inline OpProto_Attr& operator=(OpProto_Attr&& from) noexcept { + if (GetArena() == from.GetArena()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); + } + inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + } + + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return GetMetadataStatic().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return GetMetadataStatic().reflection; + } + static const OpProto_Attr& default_instance(); + + static inline const OpProto_Attr* internal_default_instance() { + return reinterpret_cast( + &_OpProto_Attr_default_instance_); + } + static constexpr int kIndexInFileMessages = + 5; + + friend void swap(OpProto_Attr& a, OpProto_Attr& b) { + a.Swap(&b); + } + inline void Swap(OpProto_Attr* other) { + if (other == this) return; + if (GetArena() == other->GetArena()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(OpProto_Attr* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArena() == other->GetArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + inline OpProto_Attr* New() const final { + return CreateMaybeMessage(nullptr); + } + + OpProto_Attr* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { + return CreateMaybeMessage(arena); + } + void CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; + void MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; + void CopyFrom(const OpProto_Attr& from); + void MergeFrom(const OpProto_Attr& from); + PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; + bool IsInitialized() const final; + + size_t ByteSizeLong() const final; + const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; + ::PROTOBUF_NAMESPACE_ID::uint8* _InternalSerialize( + ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; + int GetCachedSize() const final { return _cached_size_.Get(); } + + private: + inline void SharedCtor(); + inline void SharedDtor(); + void SetCachedSize(int size) const final; + void InternalSwap(OpProto_Attr* other); + friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; + static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { + return "paddle.framework.proto.OpProto.Attr"; + } + protected: + explicit OpProto_Attr(::PROTOBUF_NAMESPACE_ID::Arena* arena); + private: + static void ArenaDtor(void* object); + inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); + public: + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + private: + static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { + ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_framework_2eproto); + return ::descriptor_table_framework_2eproto.file_level_metadata[kIndexInFileMessages]; + } + + public: + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kNameFieldNumber = 1, + kCommentFieldNumber = 3, + kTypeFieldNumber = 2, + kGeneratedFieldNumber = 4, + }; + // required string name = 1; + bool has_name() const; + private: + bool _internal_has_name() const; + public: + void clear_name(); + const std::string& name() const; + void set_name(const std::string& value); + void set_name(std::string&& value); + void set_name(const char* value); + void set_name(const char* value, size_t size); + std::string* mutable_name(); + std::string* release_name(); + void set_allocated_name(std::string* name); + private: + const std::string& _internal_name() const; + void _internal_set_name(const std::string& value); + std::string* _internal_mutable_name(); + public: + + // required string comment = 3; + bool has_comment() const; + private: + bool _internal_has_comment() const; + public: + void clear_comment(); + const std::string& comment() const; + void set_comment(const std::string& value); + void set_comment(std::string&& value); + void set_comment(const char* value); + void set_comment(const char* value, size_t size); + std::string* mutable_comment(); + std::string* release_comment(); + void set_allocated_comment(std::string* comment); + private: + const std::string& _internal_comment() const; + void _internal_set_comment(const std::string& value); + std::string* _internal_mutable_comment(); + public: + + // required .paddle.framework.proto.AttrType type = 2; + bool has_type() const; + private: + bool _internal_has_type() const; + public: + void clear_type(); + ::paddle::framework::proto::AttrType type() const; + void set_type(::paddle::framework::proto::AttrType value); + private: + ::paddle::framework::proto::AttrType _internal_type() const; + void _internal_set_type(::paddle::framework::proto::AttrType value); + public: + + // optional bool generated = 4 [default = false]; + bool has_generated() const; + private: + bool _internal_has_generated() const; + public: + void clear_generated(); + bool generated() const; + void set_generated(bool value); + private: + bool _internal_generated() const; + void _internal_set_generated(bool value); + public: + + // @@protoc_insertion_point(class_scope:paddle.framework.proto.OpProto.Attr) + private: + class _Internal; + + // helper for ByteSizeLong() + size_t RequiredFieldsByteSizeFallback() const; + + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr name_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr comment_; + int type_; + bool generated_; + friend struct ::TableStruct_framework_2eproto; +}; +// ------------------------------------------------------------------- + +class OpProto PROTOBUF_FINAL : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:paddle.framework.proto.OpProto) */ { + public: + inline OpProto() : OpProto(nullptr) {} + virtual ~OpProto(); + + OpProto(const OpProto& from); + OpProto(OpProto&& from) noexcept + : OpProto() { + *this = ::std::move(from); + } + + inline OpProto& operator=(const OpProto& from) { + CopyFrom(from); + return *this; + } + inline OpProto& operator=(OpProto&& from) noexcept { + if (GetArena() == from.GetArena()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); + } + inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + } + + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return GetMetadataStatic().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return GetMetadataStatic().reflection; + } + static const OpProto& default_instance(); + + static inline const OpProto* internal_default_instance() { + return reinterpret_cast( + &_OpProto_default_instance_); + } + static constexpr int kIndexInFileMessages = + 6; + + friend void swap(OpProto& a, OpProto& b) { + a.Swap(&b); + } + inline void Swap(OpProto* other) { + if (other == this) return; + if (GetArena() == other->GetArena()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(OpProto* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArena() == other->GetArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + inline OpProto* New() const final { + return CreateMaybeMessage(nullptr); + } + + OpProto* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { + return CreateMaybeMessage(arena); + } + void CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; + void MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; + void CopyFrom(const OpProto& from); + void MergeFrom(const OpProto& from); + PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; + bool IsInitialized() const final; + + size_t ByteSizeLong() const final; + const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; + ::PROTOBUF_NAMESPACE_ID::uint8* _InternalSerialize( + ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; + int GetCachedSize() const final { return _cached_size_.Get(); } + + private: + inline void SharedCtor(); + inline void SharedDtor(); + void SetCachedSize(int size) const final; + void InternalSwap(OpProto* other); + friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; + static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { + return "paddle.framework.proto.OpProto"; + } + protected: + explicit OpProto(::PROTOBUF_NAMESPACE_ID::Arena* arena); + private: + static void ArenaDtor(void* object); + inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); + public: + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + private: + static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { + ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_framework_2eproto); + return ::descriptor_table_framework_2eproto.file_level_metadata[kIndexInFileMessages]; + } + + public: + + // nested types ---------------------------------------------------- + + typedef OpProto_Var Var; + typedef OpProto_Attr Attr; + + // accessors ------------------------------------------------------- + + enum : int { + kInputsFieldNumber = 2, + kOutputsFieldNumber = 3, + kAttrsFieldNumber = 4, + kTypeFieldNumber = 1, + kCommentFieldNumber = 5, + }; + // repeated .paddle.framework.proto.OpProto.Var inputs = 2; + int inputs_size() const; + private: + int _internal_inputs_size() const; + public: + void clear_inputs(); + ::paddle::framework::proto::OpProto_Var* mutable_inputs(int index); + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::OpProto_Var >* + mutable_inputs(); + private: + const ::paddle::framework::proto::OpProto_Var& _internal_inputs(int index) const; + ::paddle::framework::proto::OpProto_Var* _internal_add_inputs(); + public: + const ::paddle::framework::proto::OpProto_Var& inputs(int index) const; + ::paddle::framework::proto::OpProto_Var* add_inputs(); + const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::OpProto_Var >& + inputs() const; + + // repeated .paddle.framework.proto.OpProto.Var outputs = 3; + int outputs_size() const; + private: + int _internal_outputs_size() const; + public: + void clear_outputs(); + ::paddle::framework::proto::OpProto_Var* mutable_outputs(int index); + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::OpProto_Var >* + mutable_outputs(); + private: + const ::paddle::framework::proto::OpProto_Var& _internal_outputs(int index) const; + ::paddle::framework::proto::OpProto_Var* _internal_add_outputs(); + public: + const ::paddle::framework::proto::OpProto_Var& outputs(int index) const; + ::paddle::framework::proto::OpProto_Var* add_outputs(); + const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::OpProto_Var >& + outputs() const; + + // repeated .paddle.framework.proto.OpProto.Attr attrs = 4; + int attrs_size() const; + private: + int _internal_attrs_size() const; + public: + void clear_attrs(); + ::paddle::framework::proto::OpProto_Attr* mutable_attrs(int index); + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::OpProto_Attr >* + mutable_attrs(); + private: + const ::paddle::framework::proto::OpProto_Attr& _internal_attrs(int index) const; + ::paddle::framework::proto::OpProto_Attr* _internal_add_attrs(); + public: + const ::paddle::framework::proto::OpProto_Attr& attrs(int index) const; + ::paddle::framework::proto::OpProto_Attr* add_attrs(); + const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::OpProto_Attr >& + attrs() const; + + // required string type = 1; + bool has_type() const; + private: + bool _internal_has_type() const; + public: + void clear_type(); + const std::string& type() const; + void set_type(const std::string& value); + void set_type(std::string&& value); + void set_type(const char* value); + void set_type(const char* value, size_t size); + std::string* mutable_type(); + std::string* release_type(); + void set_allocated_type(std::string* type); + private: + const std::string& _internal_type() const; + void _internal_set_type(const std::string& value); + std::string* _internal_mutable_type(); + public: + + // required string comment = 5; + bool has_comment() const; + private: + bool _internal_has_comment() const; + public: + void clear_comment(); + const std::string& comment() const; + void set_comment(const std::string& value); + void set_comment(std::string&& value); + void set_comment(const char* value); + void set_comment(const char* value, size_t size); + std::string* mutable_comment(); + std::string* release_comment(); + void set_allocated_comment(std::string* comment); + private: + const std::string& _internal_comment() const; + void _internal_set_comment(const std::string& value); + std::string* _internal_mutable_comment(); + public: + + // @@protoc_insertion_point(class_scope:paddle.framework.proto.OpProto) + private: + class _Internal; + + // helper for ByteSizeLong() + size_t RequiredFieldsByteSizeFallback() const; + + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::OpProto_Var > inputs_; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::OpProto_Var > outputs_; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::OpProto_Attr > attrs_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr type_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr comment_; + friend struct ::TableStruct_framework_2eproto; +}; +// ------------------------------------------------------------------- + +class VarType_TensorDesc PROTOBUF_FINAL : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:paddle.framework.proto.VarType.TensorDesc) */ { + public: + inline VarType_TensorDesc() : VarType_TensorDesc(nullptr) {} + virtual ~VarType_TensorDesc(); + + VarType_TensorDesc(const VarType_TensorDesc& from); + VarType_TensorDesc(VarType_TensorDesc&& from) noexcept + : VarType_TensorDesc() { + *this = ::std::move(from); + } + + inline VarType_TensorDesc& operator=(const VarType_TensorDesc& from) { + CopyFrom(from); + return *this; + } + inline VarType_TensorDesc& operator=(VarType_TensorDesc&& from) noexcept { + if (GetArena() == from.GetArena()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); + } + inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + } + + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return GetMetadataStatic().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return GetMetadataStatic().reflection; + } + static const VarType_TensorDesc& default_instance(); + + static inline const VarType_TensorDesc* internal_default_instance() { + return reinterpret_cast( + &_VarType_TensorDesc_default_instance_); + } + static constexpr int kIndexInFileMessages = + 7; + + friend void swap(VarType_TensorDesc& a, VarType_TensorDesc& b) { + a.Swap(&b); + } + inline void Swap(VarType_TensorDesc* other) { + if (other == this) return; + if (GetArena() == other->GetArena()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(VarType_TensorDesc* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArena() == other->GetArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + inline VarType_TensorDesc* New() const final { + return CreateMaybeMessage(nullptr); + } + + VarType_TensorDesc* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { + return CreateMaybeMessage(arena); + } + void CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; + void MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; + void CopyFrom(const VarType_TensorDesc& from); + void MergeFrom(const VarType_TensorDesc& from); + PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; + bool IsInitialized() const final; + + size_t ByteSizeLong() const final; + const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; + ::PROTOBUF_NAMESPACE_ID::uint8* _InternalSerialize( + ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; + int GetCachedSize() const final { return _cached_size_.Get(); } + + private: + inline void SharedCtor(); + inline void SharedDtor(); + void SetCachedSize(int size) const final; + void InternalSwap(VarType_TensorDesc* other); + friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; + static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { + return "paddle.framework.proto.VarType.TensorDesc"; + } + protected: + explicit VarType_TensorDesc(::PROTOBUF_NAMESPACE_ID::Arena* arena); + private: + static void ArenaDtor(void* object); + inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); + public: + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + private: + static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { + ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_framework_2eproto); + return ::descriptor_table_framework_2eproto.file_level_metadata[kIndexInFileMessages]; + } + + public: + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kDimsFieldNumber = 2, + kDataTypeFieldNumber = 1, + }; + // repeated int64 dims = 2; + int dims_size() const; + private: + int _internal_dims_size() const; + public: + void clear_dims(); + private: + ::PROTOBUF_NAMESPACE_ID::int64 _internal_dims(int index) const; + const ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int64 >& + _internal_dims() const; + void _internal_add_dims(::PROTOBUF_NAMESPACE_ID::int64 value); + ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int64 >* + _internal_mutable_dims(); + public: + ::PROTOBUF_NAMESPACE_ID::int64 dims(int index) const; + void set_dims(int index, ::PROTOBUF_NAMESPACE_ID::int64 value); + void add_dims(::PROTOBUF_NAMESPACE_ID::int64 value); + const ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int64 >& + dims() const; + ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int64 >* + mutable_dims(); + + // required .paddle.framework.proto.VarType.Type data_type = 1; + bool has_data_type() const; + private: + bool _internal_has_data_type() const; + public: + void clear_data_type(); + ::paddle::framework::proto::VarType_Type data_type() const; + void set_data_type(::paddle::framework::proto::VarType_Type value); + private: + ::paddle::framework::proto::VarType_Type _internal_data_type() const; + void _internal_set_data_type(::paddle::framework::proto::VarType_Type value); + public: + + // @@protoc_insertion_point(class_scope:paddle.framework.proto.VarType.TensorDesc) + private: + class _Internal; + + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int64 > dims_; + int data_type_; + friend struct ::TableStruct_framework_2eproto; +}; +// ------------------------------------------------------------------- + +class VarType_LoDTensorDesc PROTOBUF_FINAL : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:paddle.framework.proto.VarType.LoDTensorDesc) */ { + public: + inline VarType_LoDTensorDesc() : VarType_LoDTensorDesc(nullptr) {} + virtual ~VarType_LoDTensorDesc(); + + VarType_LoDTensorDesc(const VarType_LoDTensorDesc& from); + VarType_LoDTensorDesc(VarType_LoDTensorDesc&& from) noexcept + : VarType_LoDTensorDesc() { + *this = ::std::move(from); + } + + inline VarType_LoDTensorDesc& operator=(const VarType_LoDTensorDesc& from) { + CopyFrom(from); + return *this; + } + inline VarType_LoDTensorDesc& operator=(VarType_LoDTensorDesc&& from) noexcept { + if (GetArena() == from.GetArena()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); + } + inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + } + + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return GetMetadataStatic().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return GetMetadataStatic().reflection; + } + static const VarType_LoDTensorDesc& default_instance(); + + static inline const VarType_LoDTensorDesc* internal_default_instance() { + return reinterpret_cast( + &_VarType_LoDTensorDesc_default_instance_); + } + static constexpr int kIndexInFileMessages = + 8; + + friend void swap(VarType_LoDTensorDesc& a, VarType_LoDTensorDesc& b) { + a.Swap(&b); + } + inline void Swap(VarType_LoDTensorDesc* other) { + if (other == this) return; + if (GetArena() == other->GetArena()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(VarType_LoDTensorDesc* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArena() == other->GetArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + inline VarType_LoDTensorDesc* New() const final { + return CreateMaybeMessage(nullptr); + } + + VarType_LoDTensorDesc* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { + return CreateMaybeMessage(arena); + } + void CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; + void MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; + void CopyFrom(const VarType_LoDTensorDesc& from); + void MergeFrom(const VarType_LoDTensorDesc& from); + PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; + bool IsInitialized() const final; + + size_t ByteSizeLong() const final; + const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; + ::PROTOBUF_NAMESPACE_ID::uint8* _InternalSerialize( + ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; + int GetCachedSize() const final { return _cached_size_.Get(); } + + private: + inline void SharedCtor(); + inline void SharedDtor(); + void SetCachedSize(int size) const final; + void InternalSwap(VarType_LoDTensorDesc* other); + friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; + static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { + return "paddle.framework.proto.VarType.LoDTensorDesc"; + } + protected: + explicit VarType_LoDTensorDesc(::PROTOBUF_NAMESPACE_ID::Arena* arena); + private: + static void ArenaDtor(void* object); + inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); + public: + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + private: + static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { + ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_framework_2eproto); + return ::descriptor_table_framework_2eproto.file_level_metadata[kIndexInFileMessages]; + } + + public: + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kTensorFieldNumber = 1, + kLodLevelFieldNumber = 2, + }; + // required .paddle.framework.proto.VarType.TensorDesc tensor = 1; + bool has_tensor() const; + private: + bool _internal_has_tensor() const; + public: + void clear_tensor(); + const ::paddle::framework::proto::VarType_TensorDesc& tensor() const; + ::paddle::framework::proto::VarType_TensorDesc* release_tensor(); + ::paddle::framework::proto::VarType_TensorDesc* mutable_tensor(); + void set_allocated_tensor(::paddle::framework::proto::VarType_TensorDesc* tensor); + private: + const ::paddle::framework::proto::VarType_TensorDesc& _internal_tensor() const; + ::paddle::framework::proto::VarType_TensorDesc* _internal_mutable_tensor(); + public: + void unsafe_arena_set_allocated_tensor( + ::paddle::framework::proto::VarType_TensorDesc* tensor); + ::paddle::framework::proto::VarType_TensorDesc* unsafe_arena_release_tensor(); + + // optional int32 lod_level = 2 [default = 0]; + bool has_lod_level() const; + private: + bool _internal_has_lod_level() const; + public: + void clear_lod_level(); + ::PROTOBUF_NAMESPACE_ID::int32 lod_level() const; + void set_lod_level(::PROTOBUF_NAMESPACE_ID::int32 value); + private: + ::PROTOBUF_NAMESPACE_ID::int32 _internal_lod_level() const; + void _internal_set_lod_level(::PROTOBUF_NAMESPACE_ID::int32 value); + public: + + // @@protoc_insertion_point(class_scope:paddle.framework.proto.VarType.LoDTensorDesc) + private: + class _Internal; + + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + ::paddle::framework::proto::VarType_TensorDesc* tensor_; + ::PROTOBUF_NAMESPACE_ID::int32 lod_level_; + friend struct ::TableStruct_framework_2eproto; +}; +// ------------------------------------------------------------------- + +class VarType_LoDTensorArrayDesc PROTOBUF_FINAL : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:paddle.framework.proto.VarType.LoDTensorArrayDesc) */ { + public: + inline VarType_LoDTensorArrayDesc() : VarType_LoDTensorArrayDesc(nullptr) {} + virtual ~VarType_LoDTensorArrayDesc(); + + VarType_LoDTensorArrayDesc(const VarType_LoDTensorArrayDesc& from); + VarType_LoDTensorArrayDesc(VarType_LoDTensorArrayDesc&& from) noexcept + : VarType_LoDTensorArrayDesc() { + *this = ::std::move(from); + } + + inline VarType_LoDTensorArrayDesc& operator=(const VarType_LoDTensorArrayDesc& from) { + CopyFrom(from); + return *this; + } + inline VarType_LoDTensorArrayDesc& operator=(VarType_LoDTensorArrayDesc&& from) noexcept { + if (GetArena() == from.GetArena()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); + } + inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + } + + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return GetMetadataStatic().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return GetMetadataStatic().reflection; + } + static const VarType_LoDTensorArrayDesc& default_instance(); + + static inline const VarType_LoDTensorArrayDesc* internal_default_instance() { + return reinterpret_cast( + &_VarType_LoDTensorArrayDesc_default_instance_); + } + static constexpr int kIndexInFileMessages = + 9; + + friend void swap(VarType_LoDTensorArrayDesc& a, VarType_LoDTensorArrayDesc& b) { + a.Swap(&b); + } + inline void Swap(VarType_LoDTensorArrayDesc* other) { + if (other == this) return; + if (GetArena() == other->GetArena()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(VarType_LoDTensorArrayDesc* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArena() == other->GetArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + inline VarType_LoDTensorArrayDesc* New() const final { + return CreateMaybeMessage(nullptr); + } + + VarType_LoDTensorArrayDesc* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { + return CreateMaybeMessage(arena); + } + void CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; + void MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; + void CopyFrom(const VarType_LoDTensorArrayDesc& from); + void MergeFrom(const VarType_LoDTensorArrayDesc& from); + PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; + bool IsInitialized() const final; + + size_t ByteSizeLong() const final; + const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; + ::PROTOBUF_NAMESPACE_ID::uint8* _InternalSerialize( + ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; + int GetCachedSize() const final { return _cached_size_.Get(); } + + private: + inline void SharedCtor(); + inline void SharedDtor(); + void SetCachedSize(int size) const final; + void InternalSwap(VarType_LoDTensorArrayDesc* other); + friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; + static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { + return "paddle.framework.proto.VarType.LoDTensorArrayDesc"; + } + protected: + explicit VarType_LoDTensorArrayDesc(::PROTOBUF_NAMESPACE_ID::Arena* arena); + private: + static void ArenaDtor(void* object); + inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); + public: + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + private: + static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { + ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_framework_2eproto); + return ::descriptor_table_framework_2eproto.file_level_metadata[kIndexInFileMessages]; + } + + public: + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kTensorFieldNumber = 1, + kLodLevelFieldNumber = 2, + }; + // required .paddle.framework.proto.VarType.TensorDesc tensor = 1; + bool has_tensor() const; + private: + bool _internal_has_tensor() const; + public: + void clear_tensor(); + const ::paddle::framework::proto::VarType_TensorDesc& tensor() const; + ::paddle::framework::proto::VarType_TensorDesc* release_tensor(); + ::paddle::framework::proto::VarType_TensorDesc* mutable_tensor(); + void set_allocated_tensor(::paddle::framework::proto::VarType_TensorDesc* tensor); + private: + const ::paddle::framework::proto::VarType_TensorDesc& _internal_tensor() const; + ::paddle::framework::proto::VarType_TensorDesc* _internal_mutable_tensor(); + public: + void unsafe_arena_set_allocated_tensor( + ::paddle::framework::proto::VarType_TensorDesc* tensor); + ::paddle::framework::proto::VarType_TensorDesc* unsafe_arena_release_tensor(); + + // optional int32 lod_level = 2 [default = 0]; + bool has_lod_level() const; + private: + bool _internal_has_lod_level() const; + public: + void clear_lod_level(); + ::PROTOBUF_NAMESPACE_ID::int32 lod_level() const; + void set_lod_level(::PROTOBUF_NAMESPACE_ID::int32 value); + private: + ::PROTOBUF_NAMESPACE_ID::int32 _internal_lod_level() const; + void _internal_set_lod_level(::PROTOBUF_NAMESPACE_ID::int32 value); + public: + + // @@protoc_insertion_point(class_scope:paddle.framework.proto.VarType.LoDTensorArrayDesc) + private: + class _Internal; + + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + ::paddle::framework::proto::VarType_TensorDesc* tensor_; + ::PROTOBUF_NAMESPACE_ID::int32 lod_level_; + friend struct ::TableStruct_framework_2eproto; +}; +// ------------------------------------------------------------------- + +class VarType_ReaderDesc PROTOBUF_FINAL : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:paddle.framework.proto.VarType.ReaderDesc) */ { + public: + inline VarType_ReaderDesc() : VarType_ReaderDesc(nullptr) {} + virtual ~VarType_ReaderDesc(); + + VarType_ReaderDesc(const VarType_ReaderDesc& from); + VarType_ReaderDesc(VarType_ReaderDesc&& from) noexcept + : VarType_ReaderDesc() { + *this = ::std::move(from); + } + + inline VarType_ReaderDesc& operator=(const VarType_ReaderDesc& from) { + CopyFrom(from); + return *this; + } + inline VarType_ReaderDesc& operator=(VarType_ReaderDesc&& from) noexcept { + if (GetArena() == from.GetArena()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); + } + inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + } + + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return GetMetadataStatic().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return GetMetadataStatic().reflection; + } + static const VarType_ReaderDesc& default_instance(); + + static inline const VarType_ReaderDesc* internal_default_instance() { + return reinterpret_cast( + &_VarType_ReaderDesc_default_instance_); + } + static constexpr int kIndexInFileMessages = + 10; + + friend void swap(VarType_ReaderDesc& a, VarType_ReaderDesc& b) { + a.Swap(&b); + } + inline void Swap(VarType_ReaderDesc* other) { + if (other == this) return; + if (GetArena() == other->GetArena()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(VarType_ReaderDesc* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArena() == other->GetArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + inline VarType_ReaderDesc* New() const final { + return CreateMaybeMessage(nullptr); + } + + VarType_ReaderDesc* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { + return CreateMaybeMessage(arena); + } + void CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; + void MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; + void CopyFrom(const VarType_ReaderDesc& from); + void MergeFrom(const VarType_ReaderDesc& from); + PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; + bool IsInitialized() const final; + + size_t ByteSizeLong() const final; + const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; + ::PROTOBUF_NAMESPACE_ID::uint8* _InternalSerialize( + ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; + int GetCachedSize() const final { return _cached_size_.Get(); } + + private: + inline void SharedCtor(); + inline void SharedDtor(); + void SetCachedSize(int size) const final; + void InternalSwap(VarType_ReaderDesc* other); + friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; + static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { + return "paddle.framework.proto.VarType.ReaderDesc"; + } + protected: + explicit VarType_ReaderDesc(::PROTOBUF_NAMESPACE_ID::Arena* arena); + private: + static void ArenaDtor(void* object); + inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); + public: + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + private: + static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { + ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_framework_2eproto); + return ::descriptor_table_framework_2eproto.file_level_metadata[kIndexInFileMessages]; + } + + public: + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kLodTensorFieldNumber = 1, + }; + // repeated .paddle.framework.proto.VarType.LoDTensorDesc lod_tensor = 1; + int lod_tensor_size() const; + private: + int _internal_lod_tensor_size() const; + public: + void clear_lod_tensor(); + ::paddle::framework::proto::VarType_LoDTensorDesc* mutable_lod_tensor(int index); + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::VarType_LoDTensorDesc >* + mutable_lod_tensor(); + private: + const ::paddle::framework::proto::VarType_LoDTensorDesc& _internal_lod_tensor(int index) const; + ::paddle::framework::proto::VarType_LoDTensorDesc* _internal_add_lod_tensor(); + public: + const ::paddle::framework::proto::VarType_LoDTensorDesc& lod_tensor(int index) const; + ::paddle::framework::proto::VarType_LoDTensorDesc* add_lod_tensor(); + const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::VarType_LoDTensorDesc >& + lod_tensor() const; + + // @@protoc_insertion_point(class_scope:paddle.framework.proto.VarType.ReaderDesc) + private: + class _Internal; + + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::VarType_LoDTensorDesc > lod_tensor_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + friend struct ::TableStruct_framework_2eproto; +}; +// ------------------------------------------------------------------- + +class VarType_Tuple PROTOBUF_FINAL : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:paddle.framework.proto.VarType.Tuple) */ { + public: + inline VarType_Tuple() : VarType_Tuple(nullptr) {} + virtual ~VarType_Tuple(); + + VarType_Tuple(const VarType_Tuple& from); + VarType_Tuple(VarType_Tuple&& from) noexcept + : VarType_Tuple() { + *this = ::std::move(from); + } + + inline VarType_Tuple& operator=(const VarType_Tuple& from) { + CopyFrom(from); + return *this; + } + inline VarType_Tuple& operator=(VarType_Tuple&& from) noexcept { + if (GetArena() == from.GetArena()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); + } + inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + } + + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return GetMetadataStatic().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return GetMetadataStatic().reflection; + } + static const VarType_Tuple& default_instance(); + + static inline const VarType_Tuple* internal_default_instance() { + return reinterpret_cast( + &_VarType_Tuple_default_instance_); + } + static constexpr int kIndexInFileMessages = + 11; + + friend void swap(VarType_Tuple& a, VarType_Tuple& b) { + a.Swap(&b); + } + inline void Swap(VarType_Tuple* other) { + if (other == this) return; + if (GetArena() == other->GetArena()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(VarType_Tuple* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArena() == other->GetArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + inline VarType_Tuple* New() const final { + return CreateMaybeMessage(nullptr); + } + + VarType_Tuple* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { + return CreateMaybeMessage(arena); + } + void CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; + void MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; + void CopyFrom(const VarType_Tuple& from); + void MergeFrom(const VarType_Tuple& from); + PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; + bool IsInitialized() const final; + + size_t ByteSizeLong() const final; + const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; + ::PROTOBUF_NAMESPACE_ID::uint8* _InternalSerialize( + ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; + int GetCachedSize() const final { return _cached_size_.Get(); } + + private: + inline void SharedCtor(); + inline void SharedDtor(); + void SetCachedSize(int size) const final; + void InternalSwap(VarType_Tuple* other); + friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; + static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { + return "paddle.framework.proto.VarType.Tuple"; + } + protected: + explicit VarType_Tuple(::PROTOBUF_NAMESPACE_ID::Arena* arena); + private: + static void ArenaDtor(void* object); + inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); + public: + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + private: + static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { + ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_framework_2eproto); + return ::descriptor_table_framework_2eproto.file_level_metadata[kIndexInFileMessages]; + } + + public: + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kElementTypeFieldNumber = 1, + }; + // repeated .paddle.framework.proto.VarType.Type element_type = 1; + int element_type_size() const; + private: + int _internal_element_type_size() const; + public: + void clear_element_type(); + private: + ::paddle::framework::proto::VarType_Type _internal_element_type(int index) const; + void _internal_add_element_type(::paddle::framework::proto::VarType_Type value); + ::PROTOBUF_NAMESPACE_ID::RepeatedField* _internal_mutable_element_type(); + public: + ::paddle::framework::proto::VarType_Type element_type(int index) const; + void set_element_type(int index, ::paddle::framework::proto::VarType_Type value); + void add_element_type(::paddle::framework::proto::VarType_Type value); + const ::PROTOBUF_NAMESPACE_ID::RepeatedField& element_type() const; + ::PROTOBUF_NAMESPACE_ID::RepeatedField* mutable_element_type(); + + // @@protoc_insertion_point(class_scope:paddle.framework.proto.VarType.Tuple) + private: + class _Internal; + + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + ::PROTOBUF_NAMESPACE_ID::RepeatedField element_type_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + friend struct ::TableStruct_framework_2eproto; +}; +// ------------------------------------------------------------------- + +class VarType PROTOBUF_FINAL : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:paddle.framework.proto.VarType) */ { + public: + inline VarType() : VarType(nullptr) {} + virtual ~VarType(); + + VarType(const VarType& from); + VarType(VarType&& from) noexcept + : VarType() { + *this = ::std::move(from); + } + + inline VarType& operator=(const VarType& from) { + CopyFrom(from); + return *this; + } + inline VarType& operator=(VarType&& from) noexcept { + if (GetArena() == from.GetArena()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); + } + inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + } + + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return GetMetadataStatic().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return GetMetadataStatic().reflection; + } + static const VarType& default_instance(); + + static inline const VarType* internal_default_instance() { + return reinterpret_cast( + &_VarType_default_instance_); + } + static constexpr int kIndexInFileMessages = + 12; + + friend void swap(VarType& a, VarType& b) { + a.Swap(&b); + } + inline void Swap(VarType* other) { + if (other == this) return; + if (GetArena() == other->GetArena()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(VarType* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArena() == other->GetArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + inline VarType* New() const final { + return CreateMaybeMessage(nullptr); + } + + VarType* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { + return CreateMaybeMessage(arena); + } + void CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; + void MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; + void CopyFrom(const VarType& from); + void MergeFrom(const VarType& from); + PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; + bool IsInitialized() const final; + + size_t ByteSizeLong() const final; + const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; + ::PROTOBUF_NAMESPACE_ID::uint8* _InternalSerialize( + ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; + int GetCachedSize() const final { return _cached_size_.Get(); } + + private: + inline void SharedCtor(); + inline void SharedDtor(); + void SetCachedSize(int size) const final; + void InternalSwap(VarType* other); + friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; + static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { + return "paddle.framework.proto.VarType"; + } + protected: + explicit VarType(::PROTOBUF_NAMESPACE_ID::Arena* arena); + private: + static void ArenaDtor(void* object); + inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); + public: + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + private: + static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { + ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_framework_2eproto); + return ::descriptor_table_framework_2eproto.file_level_metadata[kIndexInFileMessages]; + } + + public: + + // nested types ---------------------------------------------------- + + typedef VarType_TensorDesc TensorDesc; + typedef VarType_LoDTensorDesc LoDTensorDesc; + typedef VarType_LoDTensorArrayDesc LoDTensorArrayDesc; + typedef VarType_ReaderDesc ReaderDesc; + typedef VarType_Tuple Tuple; + + typedef VarType_Type Type; + static constexpr Type BOOL = + VarType_Type_BOOL; + static constexpr Type INT16 = + VarType_Type_INT16; + static constexpr Type INT32 = + VarType_Type_INT32; + static constexpr Type INT64 = + VarType_Type_INT64; + static constexpr Type FP16 = + VarType_Type_FP16; + static constexpr Type FP32 = + VarType_Type_FP32; + static constexpr Type FP64 = + VarType_Type_FP64; + static constexpr Type SIZE_T = + VarType_Type_SIZE_T; + static constexpr Type UINT8 = + VarType_Type_UINT8; + static constexpr Type INT8 = + VarType_Type_INT8; + static constexpr Type BF16 = + VarType_Type_BF16; + static constexpr Type COMPLEX64 = + VarType_Type_COMPLEX64; + static constexpr Type COMPLEX128 = + VarType_Type_COMPLEX128; + static constexpr Type LOD_TENSOR = + VarType_Type_LOD_TENSOR; + static constexpr Type SELECTED_ROWS = + VarType_Type_SELECTED_ROWS; + static constexpr Type FEED_MINIBATCH = + VarType_Type_FEED_MINIBATCH; + static constexpr Type FETCH_LIST = + VarType_Type_FETCH_LIST; + static constexpr Type STEP_SCOPES = + VarType_Type_STEP_SCOPES; + static constexpr Type LOD_RANK_TABLE = + VarType_Type_LOD_RANK_TABLE; + static constexpr Type LOD_TENSOR_ARRAY = + VarType_Type_LOD_TENSOR_ARRAY; + static constexpr Type PLACE_LIST = + VarType_Type_PLACE_LIST; + static constexpr Type READER = + VarType_Type_READER; + static constexpr Type RAW = + VarType_Type_RAW; + static constexpr Type TUPLE = + VarType_Type_TUPLE; + static inline bool Type_IsValid(int value) { + return VarType_Type_IsValid(value); + } + static constexpr Type Type_MIN = + VarType_Type_Type_MIN; + static constexpr Type Type_MAX = + VarType_Type_Type_MAX; + static constexpr int Type_ARRAYSIZE = + VarType_Type_Type_ARRAYSIZE; + static inline const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* + Type_descriptor() { + return VarType_Type_descriptor(); + } + template + static inline const std::string& Type_Name(T enum_t_value) { + static_assert(::std::is_same::value || + ::std::is_integral::value, + "Incorrect type passed to function Type_Name."); + return VarType_Type_Name(enum_t_value); + } + static inline bool Type_Parse(::PROTOBUF_NAMESPACE_ID::ConstStringParam name, + Type* value) { + return VarType_Type_Parse(name, value); + } + + // accessors ------------------------------------------------------- + + enum : int { + kSelectedRowsFieldNumber = 2, + kLodTensorFieldNumber = 3, + kTensorArrayFieldNumber = 4, + kReaderFieldNumber = 5, + kTupleFieldNumber = 7, + kTypeFieldNumber = 1, + }; + // optional .paddle.framework.proto.VarType.TensorDesc selected_rows = 2; + bool has_selected_rows() const; + private: + bool _internal_has_selected_rows() const; + public: + void clear_selected_rows(); + const ::paddle::framework::proto::VarType_TensorDesc& selected_rows() const; + ::paddle::framework::proto::VarType_TensorDesc* release_selected_rows(); + ::paddle::framework::proto::VarType_TensorDesc* mutable_selected_rows(); + void set_allocated_selected_rows(::paddle::framework::proto::VarType_TensorDesc* selected_rows); + private: + const ::paddle::framework::proto::VarType_TensorDesc& _internal_selected_rows() const; + ::paddle::framework::proto::VarType_TensorDesc* _internal_mutable_selected_rows(); + public: + void unsafe_arena_set_allocated_selected_rows( + ::paddle::framework::proto::VarType_TensorDesc* selected_rows); + ::paddle::framework::proto::VarType_TensorDesc* unsafe_arena_release_selected_rows(); + + // optional .paddle.framework.proto.VarType.LoDTensorDesc lod_tensor = 3; + bool has_lod_tensor() const; + private: + bool _internal_has_lod_tensor() const; + public: + void clear_lod_tensor(); + const ::paddle::framework::proto::VarType_LoDTensorDesc& lod_tensor() const; + ::paddle::framework::proto::VarType_LoDTensorDesc* release_lod_tensor(); + ::paddle::framework::proto::VarType_LoDTensorDesc* mutable_lod_tensor(); + void set_allocated_lod_tensor(::paddle::framework::proto::VarType_LoDTensorDesc* lod_tensor); + private: + const ::paddle::framework::proto::VarType_LoDTensorDesc& _internal_lod_tensor() const; + ::paddle::framework::proto::VarType_LoDTensorDesc* _internal_mutable_lod_tensor(); + public: + void unsafe_arena_set_allocated_lod_tensor( + ::paddle::framework::proto::VarType_LoDTensorDesc* lod_tensor); + ::paddle::framework::proto::VarType_LoDTensorDesc* unsafe_arena_release_lod_tensor(); + + // optional .paddle.framework.proto.VarType.LoDTensorArrayDesc tensor_array = 4; + bool has_tensor_array() const; + private: + bool _internal_has_tensor_array() const; + public: + void clear_tensor_array(); + const ::paddle::framework::proto::VarType_LoDTensorArrayDesc& tensor_array() const; + ::paddle::framework::proto::VarType_LoDTensorArrayDesc* release_tensor_array(); + ::paddle::framework::proto::VarType_LoDTensorArrayDesc* mutable_tensor_array(); + void set_allocated_tensor_array(::paddle::framework::proto::VarType_LoDTensorArrayDesc* tensor_array); + private: + const ::paddle::framework::proto::VarType_LoDTensorArrayDesc& _internal_tensor_array() const; + ::paddle::framework::proto::VarType_LoDTensorArrayDesc* _internal_mutable_tensor_array(); + public: + void unsafe_arena_set_allocated_tensor_array( + ::paddle::framework::proto::VarType_LoDTensorArrayDesc* tensor_array); + ::paddle::framework::proto::VarType_LoDTensorArrayDesc* unsafe_arena_release_tensor_array(); + + // optional .paddle.framework.proto.VarType.ReaderDesc reader = 5; + bool has_reader() const; + private: + bool _internal_has_reader() const; + public: + void clear_reader(); + const ::paddle::framework::proto::VarType_ReaderDesc& reader() const; + ::paddle::framework::proto::VarType_ReaderDesc* release_reader(); + ::paddle::framework::proto::VarType_ReaderDesc* mutable_reader(); + void set_allocated_reader(::paddle::framework::proto::VarType_ReaderDesc* reader); + private: + const ::paddle::framework::proto::VarType_ReaderDesc& _internal_reader() const; + ::paddle::framework::proto::VarType_ReaderDesc* _internal_mutable_reader(); + public: + void unsafe_arena_set_allocated_reader( + ::paddle::framework::proto::VarType_ReaderDesc* reader); + ::paddle::framework::proto::VarType_ReaderDesc* unsafe_arena_release_reader(); + + // optional .paddle.framework.proto.VarType.Tuple tuple = 7; + bool has_tuple() const; + private: + bool _internal_has_tuple() const; + public: + void clear_tuple(); + const ::paddle::framework::proto::VarType_Tuple& tuple() const; + ::paddle::framework::proto::VarType_Tuple* release_tuple(); + ::paddle::framework::proto::VarType_Tuple* mutable_tuple(); + void set_allocated_tuple(::paddle::framework::proto::VarType_Tuple* tuple); + private: + const ::paddle::framework::proto::VarType_Tuple& _internal_tuple() const; + ::paddle::framework::proto::VarType_Tuple* _internal_mutable_tuple(); + public: + void unsafe_arena_set_allocated_tuple( + ::paddle::framework::proto::VarType_Tuple* tuple); + ::paddle::framework::proto::VarType_Tuple* unsafe_arena_release_tuple(); + + // required .paddle.framework.proto.VarType.Type type = 1; + bool has_type() const; + private: + bool _internal_has_type() const; + public: + void clear_type(); + ::paddle::framework::proto::VarType_Type type() const; + void set_type(::paddle::framework::proto::VarType_Type value); + private: + ::paddle::framework::proto::VarType_Type _internal_type() const; + void _internal_set_type(::paddle::framework::proto::VarType_Type value); + public: + + // @@protoc_insertion_point(class_scope:paddle.framework.proto.VarType) + private: + class _Internal; + + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + ::paddle::framework::proto::VarType_TensorDesc* selected_rows_; + ::paddle::framework::proto::VarType_LoDTensorDesc* lod_tensor_; + ::paddle::framework::proto::VarType_LoDTensorArrayDesc* tensor_array_; + ::paddle::framework::proto::VarType_ReaderDesc* reader_; + ::paddle::framework::proto::VarType_Tuple* tuple_; + int type_; + friend struct ::TableStruct_framework_2eproto; +}; +// ------------------------------------------------------------------- + +class VarDesc PROTOBUF_FINAL : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:paddle.framework.proto.VarDesc) */ { + public: + inline VarDesc() : VarDesc(nullptr) {} + virtual ~VarDesc(); + + VarDesc(const VarDesc& from); + VarDesc(VarDesc&& from) noexcept + : VarDesc() { + *this = ::std::move(from); + } + + inline VarDesc& operator=(const VarDesc& from) { + CopyFrom(from); + return *this; + } + inline VarDesc& operator=(VarDesc&& from) noexcept { + if (GetArena() == from.GetArena()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); + } + inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + } + + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return GetMetadataStatic().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return GetMetadataStatic().reflection; + } + static const VarDesc& default_instance(); + + static inline const VarDesc* internal_default_instance() { + return reinterpret_cast( + &_VarDesc_default_instance_); + } + static constexpr int kIndexInFileMessages = + 13; + + friend void swap(VarDesc& a, VarDesc& b) { + a.Swap(&b); + } + inline void Swap(VarDesc* other) { + if (other == this) return; + if (GetArena() == other->GetArena()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(VarDesc* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArena() == other->GetArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + inline VarDesc* New() const final { + return CreateMaybeMessage(nullptr); + } + + VarDesc* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { + return CreateMaybeMessage(arena); + } + void CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; + void MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; + void CopyFrom(const VarDesc& from); + void MergeFrom(const VarDesc& from); + PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; + bool IsInitialized() const final; + + size_t ByteSizeLong() const final; + const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; + ::PROTOBUF_NAMESPACE_ID::uint8* _InternalSerialize( + ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; + int GetCachedSize() const final { return _cached_size_.Get(); } + + private: + inline void SharedCtor(); + inline void SharedDtor(); + void SetCachedSize(int size) const final; + void InternalSwap(VarDesc* other); + friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; + static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { + return "paddle.framework.proto.VarDesc"; + } + protected: + explicit VarDesc(::PROTOBUF_NAMESPACE_ID::Arena* arena); + private: + static void ArenaDtor(void* object); + inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); + public: + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + private: + static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { + ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_framework_2eproto); + return ::descriptor_table_framework_2eproto.file_level_metadata[kIndexInFileMessages]; + } + + public: + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kNameFieldNumber = 1, + kTypeFieldNumber = 2, + kPersistableFieldNumber = 3, + kNeedCheckFeedFieldNumber = 4, + }; + // required string name = 1; + bool has_name() const; + private: + bool _internal_has_name() const; + public: + void clear_name(); + const std::string& name() const; + void set_name(const std::string& value); + void set_name(std::string&& value); + void set_name(const char* value); + void set_name(const char* value, size_t size); + std::string* mutable_name(); + std::string* release_name(); + void set_allocated_name(std::string* name); + private: + const std::string& _internal_name() const; + void _internal_set_name(const std::string& value); + std::string* _internal_mutable_name(); + public: + + // required .paddle.framework.proto.VarType type = 2; + bool has_type() const; + private: + bool _internal_has_type() const; + public: + void clear_type(); + const ::paddle::framework::proto::VarType& type() const; + ::paddle::framework::proto::VarType* release_type(); + ::paddle::framework::proto::VarType* mutable_type(); + void set_allocated_type(::paddle::framework::proto::VarType* type); + private: + const ::paddle::framework::proto::VarType& _internal_type() const; + ::paddle::framework::proto::VarType* _internal_mutable_type(); + public: + void unsafe_arena_set_allocated_type( + ::paddle::framework::proto::VarType* type); + ::paddle::framework::proto::VarType* unsafe_arena_release_type(); + + // optional bool persistable = 3 [default = false]; + bool has_persistable() const; + private: + bool _internal_has_persistable() const; + public: + void clear_persistable(); + bool persistable() const; + void set_persistable(bool value); + private: + bool _internal_persistable() const; + void _internal_set_persistable(bool value); + public: + + // optional bool need_check_feed = 4 [default = false]; + bool has_need_check_feed() const; + private: + bool _internal_has_need_check_feed() const; + public: + void clear_need_check_feed(); + bool need_check_feed() const; + void set_need_check_feed(bool value); + private: + bool _internal_need_check_feed() const; + void _internal_set_need_check_feed(bool value); + public: + + // @@protoc_insertion_point(class_scope:paddle.framework.proto.VarDesc) + private: + class _Internal; + + // helper for ByteSizeLong() + size_t RequiredFieldsByteSizeFallback() const; + + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr name_; + ::paddle::framework::proto::VarType* type_; + bool persistable_; + bool need_check_feed_; + friend struct ::TableStruct_framework_2eproto; +}; +// ------------------------------------------------------------------- + +class BlockDesc PROTOBUF_FINAL : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:paddle.framework.proto.BlockDesc) */ { + public: + inline BlockDesc() : BlockDesc(nullptr) {} + virtual ~BlockDesc(); + + BlockDesc(const BlockDesc& from); + BlockDesc(BlockDesc&& from) noexcept + : BlockDesc() { + *this = ::std::move(from); + } + + inline BlockDesc& operator=(const BlockDesc& from) { + CopyFrom(from); + return *this; + } + inline BlockDesc& operator=(BlockDesc&& from) noexcept { + if (GetArena() == from.GetArena()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); + } + inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + } + + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return GetMetadataStatic().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return GetMetadataStatic().reflection; + } + static const BlockDesc& default_instance(); + + static inline const BlockDesc* internal_default_instance() { + return reinterpret_cast( + &_BlockDesc_default_instance_); + } + static constexpr int kIndexInFileMessages = + 14; + + friend void swap(BlockDesc& a, BlockDesc& b) { + a.Swap(&b); + } + inline void Swap(BlockDesc* other) { + if (other == this) return; + if (GetArena() == other->GetArena()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(BlockDesc* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArena() == other->GetArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + inline BlockDesc* New() const final { + return CreateMaybeMessage(nullptr); + } + + BlockDesc* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { + return CreateMaybeMessage(arena); + } + void CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; + void MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; + void CopyFrom(const BlockDesc& from); + void MergeFrom(const BlockDesc& from); + PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; + bool IsInitialized() const final; + + size_t ByteSizeLong() const final; + const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; + ::PROTOBUF_NAMESPACE_ID::uint8* _InternalSerialize( + ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; + int GetCachedSize() const final { return _cached_size_.Get(); } + + private: + inline void SharedCtor(); + inline void SharedDtor(); + void SetCachedSize(int size) const final; + void InternalSwap(BlockDesc* other); + friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; + static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { + return "paddle.framework.proto.BlockDesc"; + } + protected: + explicit BlockDesc(::PROTOBUF_NAMESPACE_ID::Arena* arena); + private: + static void ArenaDtor(void* object); + inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); + public: + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + private: + static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { + ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_framework_2eproto); + return ::descriptor_table_framework_2eproto.file_level_metadata[kIndexInFileMessages]; + } + + public: + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kVarsFieldNumber = 3, + kOpsFieldNumber = 4, + kIdxFieldNumber = 1, + kParentIdxFieldNumber = 2, + kForwardBlockIdxFieldNumber = 5, + }; + // repeated .paddle.framework.proto.VarDesc vars = 3; + int vars_size() const; + private: + int _internal_vars_size() const; + public: + void clear_vars(); + ::paddle::framework::proto::VarDesc* mutable_vars(int index); + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::VarDesc >* + mutable_vars(); + private: + const ::paddle::framework::proto::VarDesc& _internal_vars(int index) const; + ::paddle::framework::proto::VarDesc* _internal_add_vars(); + public: + const ::paddle::framework::proto::VarDesc& vars(int index) const; + ::paddle::framework::proto::VarDesc* add_vars(); + const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::VarDesc >& + vars() const; + + // repeated .paddle.framework.proto.OpDesc ops = 4; + int ops_size() const; + private: + int _internal_ops_size() const; + public: + void clear_ops(); + ::paddle::framework::proto::OpDesc* mutable_ops(int index); + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::OpDesc >* + mutable_ops(); + private: + const ::paddle::framework::proto::OpDesc& _internal_ops(int index) const; + ::paddle::framework::proto::OpDesc* _internal_add_ops(); + public: + const ::paddle::framework::proto::OpDesc& ops(int index) const; + ::paddle::framework::proto::OpDesc* add_ops(); + const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::OpDesc >& + ops() const; + + // required int32 idx = 1; + bool has_idx() const; + private: + bool _internal_has_idx() const; + public: + void clear_idx(); + ::PROTOBUF_NAMESPACE_ID::int32 idx() const; + void set_idx(::PROTOBUF_NAMESPACE_ID::int32 value); + private: + ::PROTOBUF_NAMESPACE_ID::int32 _internal_idx() const; + void _internal_set_idx(::PROTOBUF_NAMESPACE_ID::int32 value); + public: + + // required int32 parent_idx = 2; + bool has_parent_idx() const; + private: + bool _internal_has_parent_idx() const; + public: + void clear_parent_idx(); + ::PROTOBUF_NAMESPACE_ID::int32 parent_idx() const; + void set_parent_idx(::PROTOBUF_NAMESPACE_ID::int32 value); + private: + ::PROTOBUF_NAMESPACE_ID::int32 _internal_parent_idx() const; + void _internal_set_parent_idx(::PROTOBUF_NAMESPACE_ID::int32 value); + public: + + // optional int32 forward_block_idx = 5 [default = -1]; + bool has_forward_block_idx() const; + private: + bool _internal_has_forward_block_idx() const; + public: + void clear_forward_block_idx(); + ::PROTOBUF_NAMESPACE_ID::int32 forward_block_idx() const; + void set_forward_block_idx(::PROTOBUF_NAMESPACE_ID::int32 value); + private: + ::PROTOBUF_NAMESPACE_ID::int32 _internal_forward_block_idx() const; + void _internal_set_forward_block_idx(::PROTOBUF_NAMESPACE_ID::int32 value); + public: + + // @@protoc_insertion_point(class_scope:paddle.framework.proto.BlockDesc) + private: + class _Internal; + + // helper for ByteSizeLong() + size_t RequiredFieldsByteSizeFallback() const; + + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::VarDesc > vars_; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::OpDesc > ops_; + ::PROTOBUF_NAMESPACE_ID::int32 idx_; + ::PROTOBUF_NAMESPACE_ID::int32 parent_idx_; + ::PROTOBUF_NAMESPACE_ID::int32 forward_block_idx_; + friend struct ::TableStruct_framework_2eproto; +}; +// ------------------------------------------------------------------- + +class OpVersion PROTOBUF_FINAL : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:paddle.framework.proto.OpVersion) */ { + public: + inline OpVersion() : OpVersion(nullptr) {} + virtual ~OpVersion(); + + OpVersion(const OpVersion& from); + OpVersion(OpVersion&& from) noexcept + : OpVersion() { + *this = ::std::move(from); + } + + inline OpVersion& operator=(const OpVersion& from) { + CopyFrom(from); + return *this; + } + inline OpVersion& operator=(OpVersion&& from) noexcept { + if (GetArena() == from.GetArena()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); + } + inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + } + + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return GetMetadataStatic().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return GetMetadataStatic().reflection; + } + static const OpVersion& default_instance(); + + static inline const OpVersion* internal_default_instance() { + return reinterpret_cast( + &_OpVersion_default_instance_); + } + static constexpr int kIndexInFileMessages = + 15; + + friend void swap(OpVersion& a, OpVersion& b) { + a.Swap(&b); + } + inline void Swap(OpVersion* other) { + if (other == this) return; + if (GetArena() == other->GetArena()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(OpVersion* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArena() == other->GetArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + inline OpVersion* New() const final { + return CreateMaybeMessage(nullptr); + } + + OpVersion* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { + return CreateMaybeMessage(arena); + } + void CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; + void MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; + void CopyFrom(const OpVersion& from); + void MergeFrom(const OpVersion& from); + PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; + bool IsInitialized() const final; + + size_t ByteSizeLong() const final; + const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; + ::PROTOBUF_NAMESPACE_ID::uint8* _InternalSerialize( + ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; + int GetCachedSize() const final { return _cached_size_.Get(); } + + private: + inline void SharedCtor(); + inline void SharedDtor(); + void SetCachedSize(int size) const final; + void InternalSwap(OpVersion* other); + friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; + static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { + return "paddle.framework.proto.OpVersion"; + } + protected: + explicit OpVersion(::PROTOBUF_NAMESPACE_ID::Arena* arena); + private: + static void ArenaDtor(void* object); + inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); + public: + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + private: + static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { + ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_framework_2eproto); + return ::descriptor_table_framework_2eproto.file_level_metadata[kIndexInFileMessages]; + } + + public: + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kVersionFieldNumber = 1, + }; + // required int32 version = 1; + bool has_version() const; + private: + bool _internal_has_version() const; + public: + void clear_version(); + ::PROTOBUF_NAMESPACE_ID::int32 version() const; + void set_version(::PROTOBUF_NAMESPACE_ID::int32 value); + private: + ::PROTOBUF_NAMESPACE_ID::int32 _internal_version() const; + void _internal_set_version(::PROTOBUF_NAMESPACE_ID::int32 value); + public: + + // @@protoc_insertion_point(class_scope:paddle.framework.proto.OpVersion) + private: + class _Internal; + + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + ::PROTOBUF_NAMESPACE_ID::int32 version_; + friend struct ::TableStruct_framework_2eproto; +}; +// ------------------------------------------------------------------- + +class OpVersionMap_OpVersionPair PROTOBUF_FINAL : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:paddle.framework.proto.OpVersionMap.OpVersionPair) */ { + public: + inline OpVersionMap_OpVersionPair() : OpVersionMap_OpVersionPair(nullptr) {} + virtual ~OpVersionMap_OpVersionPair(); + + OpVersionMap_OpVersionPair(const OpVersionMap_OpVersionPair& from); + OpVersionMap_OpVersionPair(OpVersionMap_OpVersionPair&& from) noexcept + : OpVersionMap_OpVersionPair() { + *this = ::std::move(from); + } + + inline OpVersionMap_OpVersionPair& operator=(const OpVersionMap_OpVersionPair& from) { + CopyFrom(from); + return *this; + } + inline OpVersionMap_OpVersionPair& operator=(OpVersionMap_OpVersionPair&& from) noexcept { + if (GetArena() == from.GetArena()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); + } + inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + } + + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return GetMetadataStatic().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return GetMetadataStatic().reflection; + } + static const OpVersionMap_OpVersionPair& default_instance(); + + static inline const OpVersionMap_OpVersionPair* internal_default_instance() { + return reinterpret_cast( + &_OpVersionMap_OpVersionPair_default_instance_); + } + static constexpr int kIndexInFileMessages = + 16; + + friend void swap(OpVersionMap_OpVersionPair& a, OpVersionMap_OpVersionPair& b) { + a.Swap(&b); + } + inline void Swap(OpVersionMap_OpVersionPair* other) { + if (other == this) return; + if (GetArena() == other->GetArena()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(OpVersionMap_OpVersionPair* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArena() == other->GetArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + inline OpVersionMap_OpVersionPair* New() const final { + return CreateMaybeMessage(nullptr); + } + + OpVersionMap_OpVersionPair* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { + return CreateMaybeMessage(arena); + } + void CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; + void MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; + void CopyFrom(const OpVersionMap_OpVersionPair& from); + void MergeFrom(const OpVersionMap_OpVersionPair& from); + PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; + bool IsInitialized() const final; + + size_t ByteSizeLong() const final; + const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; + ::PROTOBUF_NAMESPACE_ID::uint8* _InternalSerialize( + ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; + int GetCachedSize() const final { return _cached_size_.Get(); } + + private: + inline void SharedCtor(); + inline void SharedDtor(); + void SetCachedSize(int size) const final; + void InternalSwap(OpVersionMap_OpVersionPair* other); + friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; + static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { + return "paddle.framework.proto.OpVersionMap.OpVersionPair"; + } + protected: + explicit OpVersionMap_OpVersionPair(::PROTOBUF_NAMESPACE_ID::Arena* arena); + private: + static void ArenaDtor(void* object); + inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); + public: + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + private: + static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { + ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_framework_2eproto); + return ::descriptor_table_framework_2eproto.file_level_metadata[kIndexInFileMessages]; + } + + public: + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kOpNameFieldNumber = 1, + kOpVersionFieldNumber = 2, + }; + // required string op_name = 1; + bool has_op_name() const; + private: + bool _internal_has_op_name() const; + public: + void clear_op_name(); + const std::string& op_name() const; + void set_op_name(const std::string& value); + void set_op_name(std::string&& value); + void set_op_name(const char* value); + void set_op_name(const char* value, size_t size); + std::string* mutable_op_name(); + std::string* release_op_name(); + void set_allocated_op_name(std::string* op_name); + private: + const std::string& _internal_op_name() const; + void _internal_set_op_name(const std::string& value); + std::string* _internal_mutable_op_name(); + public: + + // required .paddle.framework.proto.OpVersion op_version = 2; + bool has_op_version() const; + private: + bool _internal_has_op_version() const; + public: + void clear_op_version(); + const ::paddle::framework::proto::OpVersion& op_version() const; + ::paddle::framework::proto::OpVersion* release_op_version(); + ::paddle::framework::proto::OpVersion* mutable_op_version(); + void set_allocated_op_version(::paddle::framework::proto::OpVersion* op_version); + private: + const ::paddle::framework::proto::OpVersion& _internal_op_version() const; + ::paddle::framework::proto::OpVersion* _internal_mutable_op_version(); + public: + void unsafe_arena_set_allocated_op_version( + ::paddle::framework::proto::OpVersion* op_version); + ::paddle::framework::proto::OpVersion* unsafe_arena_release_op_version(); + + // @@protoc_insertion_point(class_scope:paddle.framework.proto.OpVersionMap.OpVersionPair) + private: + class _Internal; + + // helper for ByteSizeLong() + size_t RequiredFieldsByteSizeFallback() const; + + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr op_name_; + ::paddle::framework::proto::OpVersion* op_version_; + friend struct ::TableStruct_framework_2eproto; +}; +// ------------------------------------------------------------------- + +class OpVersionMap PROTOBUF_FINAL : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:paddle.framework.proto.OpVersionMap) */ { + public: + inline OpVersionMap() : OpVersionMap(nullptr) {} + virtual ~OpVersionMap(); + + OpVersionMap(const OpVersionMap& from); + OpVersionMap(OpVersionMap&& from) noexcept + : OpVersionMap() { + *this = ::std::move(from); + } + + inline OpVersionMap& operator=(const OpVersionMap& from) { + CopyFrom(from); + return *this; + } + inline OpVersionMap& operator=(OpVersionMap&& from) noexcept { + if (GetArena() == from.GetArena()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); + } + inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + } + + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return GetMetadataStatic().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return GetMetadataStatic().reflection; + } + static const OpVersionMap& default_instance(); + + static inline const OpVersionMap* internal_default_instance() { + return reinterpret_cast( + &_OpVersionMap_default_instance_); + } + static constexpr int kIndexInFileMessages = + 17; + + friend void swap(OpVersionMap& a, OpVersionMap& b) { + a.Swap(&b); + } + inline void Swap(OpVersionMap* other) { + if (other == this) return; + if (GetArena() == other->GetArena()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(OpVersionMap* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArena() == other->GetArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + inline OpVersionMap* New() const final { + return CreateMaybeMessage(nullptr); + } + + OpVersionMap* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { + return CreateMaybeMessage(arena); + } + void CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; + void MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; + void CopyFrom(const OpVersionMap& from); + void MergeFrom(const OpVersionMap& from); + PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; + bool IsInitialized() const final; + + size_t ByteSizeLong() const final; + const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; + ::PROTOBUF_NAMESPACE_ID::uint8* _InternalSerialize( + ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; + int GetCachedSize() const final { return _cached_size_.Get(); } + + private: + inline void SharedCtor(); + inline void SharedDtor(); + void SetCachedSize(int size) const final; + void InternalSwap(OpVersionMap* other); + friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; + static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { + return "paddle.framework.proto.OpVersionMap"; + } + protected: + explicit OpVersionMap(::PROTOBUF_NAMESPACE_ID::Arena* arena); + private: + static void ArenaDtor(void* object); + inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); + public: + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + private: + static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { + ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_framework_2eproto); + return ::descriptor_table_framework_2eproto.file_level_metadata[kIndexInFileMessages]; + } + + public: + + // nested types ---------------------------------------------------- + + typedef OpVersionMap_OpVersionPair OpVersionPair; + + // accessors ------------------------------------------------------- + + enum : int { + kPairFieldNumber = 1, + }; + // repeated .paddle.framework.proto.OpVersionMap.OpVersionPair pair = 1; + int pair_size() const; + private: + int _internal_pair_size() const; + public: + void clear_pair(); + ::paddle::framework::proto::OpVersionMap_OpVersionPair* mutable_pair(int index); + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::OpVersionMap_OpVersionPair >* + mutable_pair(); + private: + const ::paddle::framework::proto::OpVersionMap_OpVersionPair& _internal_pair(int index) const; + ::paddle::framework::proto::OpVersionMap_OpVersionPair* _internal_add_pair(); + public: + const ::paddle::framework::proto::OpVersionMap_OpVersionPair& pair(int index) const; + ::paddle::framework::proto::OpVersionMap_OpVersionPair* add_pair(); + const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::OpVersionMap_OpVersionPair >& + pair() const; + + // @@protoc_insertion_point(class_scope:paddle.framework.proto.OpVersionMap) + private: + class _Internal; + + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::OpVersionMap_OpVersionPair > pair_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + friend struct ::TableStruct_framework_2eproto; +}; +// ------------------------------------------------------------------- + +class ProgramDesc PROTOBUF_FINAL : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:paddle.framework.proto.ProgramDesc) */ { + public: + inline ProgramDesc() : ProgramDesc(nullptr) {} + virtual ~ProgramDesc(); + + ProgramDesc(const ProgramDesc& from); + ProgramDesc(ProgramDesc&& from) noexcept + : ProgramDesc() { + *this = ::std::move(from); + } + + inline ProgramDesc& operator=(const ProgramDesc& from) { + CopyFrom(from); + return *this; + } + inline ProgramDesc& operator=(ProgramDesc&& from) noexcept { + if (GetArena() == from.GetArena()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { + return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); + } + inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); + } + + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return GetMetadataStatic().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return GetMetadataStatic().reflection; + } + static const ProgramDesc& default_instance(); + + static inline const ProgramDesc* internal_default_instance() { + return reinterpret_cast( + &_ProgramDesc_default_instance_); + } + static constexpr int kIndexInFileMessages = + 18; + + friend void swap(ProgramDesc& a, ProgramDesc& b) { + a.Swap(&b); + } + inline void Swap(ProgramDesc* other) { + if (other == this) return; + if (GetArena() == other->GetArena()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(ProgramDesc* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArena() == other->GetArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + inline ProgramDesc* New() const final { + return CreateMaybeMessage(nullptr); + } + + ProgramDesc* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { + return CreateMaybeMessage(arena); + } + void CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; + void MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; + void CopyFrom(const ProgramDesc& from); + void MergeFrom(const ProgramDesc& from); + PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; + bool IsInitialized() const final; + + size_t ByteSizeLong() const final; + const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; + ::PROTOBUF_NAMESPACE_ID::uint8* _InternalSerialize( + ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; + int GetCachedSize() const final { return _cached_size_.Get(); } + + private: + inline void SharedCtor(); + inline void SharedDtor(); + void SetCachedSize(int size) const final; + void InternalSwap(ProgramDesc* other); + friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; + static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { + return "paddle.framework.proto.ProgramDesc"; + } + protected: + explicit ProgramDesc(::PROTOBUF_NAMESPACE_ID::Arena* arena); + private: + static void ArenaDtor(void* object); + inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); + public: + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + private: + static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { + ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_framework_2eproto); + return ::descriptor_table_framework_2eproto.file_level_metadata[kIndexInFileMessages]; + } + + public: + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kBlocksFieldNumber = 1, + kVersionFieldNumber = 4, + kOpVersionMapFieldNumber = 5, + }; + // repeated .paddle.framework.proto.BlockDesc blocks = 1; + int blocks_size() const; + private: + int _internal_blocks_size() const; + public: + void clear_blocks(); + ::paddle::framework::proto::BlockDesc* mutable_blocks(int index); + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::BlockDesc >* + mutable_blocks(); + private: + const ::paddle::framework::proto::BlockDesc& _internal_blocks(int index) const; + ::paddle::framework::proto::BlockDesc* _internal_add_blocks(); + public: + const ::paddle::framework::proto::BlockDesc& blocks(int index) const; + ::paddle::framework::proto::BlockDesc* add_blocks(); + const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::BlockDesc >& + blocks() const; + + // optional .paddle.framework.proto.Version version = 4; + bool has_version() const; + private: + bool _internal_has_version() const; + public: + void clear_version(); + const ::paddle::framework::proto::Version& version() const; + ::paddle::framework::proto::Version* release_version(); + ::paddle::framework::proto::Version* mutable_version(); + void set_allocated_version(::paddle::framework::proto::Version* version); + private: + const ::paddle::framework::proto::Version& _internal_version() const; + ::paddle::framework::proto::Version* _internal_mutable_version(); + public: + void unsafe_arena_set_allocated_version( + ::paddle::framework::proto::Version* version); + ::paddle::framework::proto::Version* unsafe_arena_release_version(); + + // optional .paddle.framework.proto.OpVersionMap op_version_map = 5; + bool has_op_version_map() const; + private: + bool _internal_has_op_version_map() const; + public: + void clear_op_version_map(); + const ::paddle::framework::proto::OpVersionMap& op_version_map() const; + ::paddle::framework::proto::OpVersionMap* release_op_version_map(); + ::paddle::framework::proto::OpVersionMap* mutable_op_version_map(); + void set_allocated_op_version_map(::paddle::framework::proto::OpVersionMap* op_version_map); + private: + const ::paddle::framework::proto::OpVersionMap& _internal_op_version_map() const; + ::paddle::framework::proto::OpVersionMap* _internal_mutable_op_version_map(); + public: + void unsafe_arena_set_allocated_op_version_map( + ::paddle::framework::proto::OpVersionMap* op_version_map); + ::paddle::framework::proto::OpVersionMap* unsafe_arena_release_op_version_map(); + + // @@protoc_insertion_point(class_scope:paddle.framework.proto.ProgramDesc) + private: + class _Internal; + + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::BlockDesc > blocks_; + ::paddle::framework::proto::Version* version_; + ::paddle::framework::proto::OpVersionMap* op_version_map_; + friend struct ::TableStruct_framework_2eproto; +}; +// =================================================================== + + +// =================================================================== + +#ifdef __GNUC__ + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wstrict-aliasing" +#endif // __GNUC__ +// Version + +// optional int64 version = 1 [default = 0]; +inline bool Version::_internal_has_version() const { + bool value = (_has_bits_[0] & 0x00000001u) != 0; + return value; +} +inline bool Version::has_version() const { + return _internal_has_version(); +} +inline void Version::clear_version() { + version_ = PROTOBUF_LONGLONG(0); + _has_bits_[0] &= ~0x00000001u; +} +inline ::PROTOBUF_NAMESPACE_ID::int64 Version::_internal_version() const { + return version_; +} +inline ::PROTOBUF_NAMESPACE_ID::int64 Version::version() const { + // @@protoc_insertion_point(field_get:paddle.framework.proto.Version.version) + return _internal_version(); +} +inline void Version::_internal_set_version(::PROTOBUF_NAMESPACE_ID::int64 value) { + _has_bits_[0] |= 0x00000001u; + version_ = value; +} +inline void Version::set_version(::PROTOBUF_NAMESPACE_ID::int64 value) { + _internal_set_version(value); + // @@protoc_insertion_point(field_set:paddle.framework.proto.Version.version) +} + +// ------------------------------------------------------------------- + +// OpDesc_Attr + +// required string name = 1; +inline bool OpDesc_Attr::_internal_has_name() const { + bool value = (_has_bits_[0] & 0x00000001u) != 0; + return value; +} +inline bool OpDesc_Attr::has_name() const { + return _internal_has_name(); +} +inline void OpDesc_Attr::clear_name() { + name_.ClearToEmpty(); + _has_bits_[0] &= ~0x00000001u; +} +inline const std::string& OpDesc_Attr::name() const { + // @@protoc_insertion_point(field_get:paddle.framework.proto.OpDesc.Attr.name) + return _internal_name(); +} +inline void OpDesc_Attr::set_name(const std::string& value) { + _internal_set_name(value); + // @@protoc_insertion_point(field_set:paddle.framework.proto.OpDesc.Attr.name) +} +inline std::string* OpDesc_Attr::mutable_name() { + // @@protoc_insertion_point(field_mutable:paddle.framework.proto.OpDesc.Attr.name) + return _internal_mutable_name(); +} +inline const std::string& OpDesc_Attr::_internal_name() const { + return name_.Get(); +} +inline void OpDesc_Attr::_internal_set_name(const std::string& value) { + _has_bits_[0] |= 0x00000001u; + name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); +} +inline void OpDesc_Attr::set_name(std::string&& value) { + _has_bits_[0] |= 0x00000001u; + name_.Set( + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena()); + // @@protoc_insertion_point(field_set_rvalue:paddle.framework.proto.OpDesc.Attr.name) +} +inline void OpDesc_Attr::set_name(const char* value) { + GOOGLE_DCHECK(value != nullptr); + _has_bits_[0] |= 0x00000001u; + name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena()); + // @@protoc_insertion_point(field_set_char:paddle.framework.proto.OpDesc.Attr.name) +} +inline void OpDesc_Attr::set_name(const char* value, + size_t size) { + _has_bits_[0] |= 0x00000001u; + name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string( + reinterpret_cast(value), size), GetArena()); + // @@protoc_insertion_point(field_set_pointer:paddle.framework.proto.OpDesc.Attr.name) +} +inline std::string* OpDesc_Attr::_internal_mutable_name() { + _has_bits_[0] |= 0x00000001u; + return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); +} +inline std::string* OpDesc_Attr::release_name() { + // @@protoc_insertion_point(field_release:paddle.framework.proto.OpDesc.Attr.name) + if (!_internal_has_name()) { + return nullptr; + } + _has_bits_[0] &= ~0x00000001u; + return name_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); +} +inline void OpDesc_Attr::set_allocated_name(std::string* name) { + if (name != nullptr) { + _has_bits_[0] |= 0x00000001u; + } else { + _has_bits_[0] &= ~0x00000001u; + } + name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name, + GetArena()); + // @@protoc_insertion_point(field_set_allocated:paddle.framework.proto.OpDesc.Attr.name) +} + +// required .paddle.framework.proto.AttrType type = 2; +inline bool OpDesc_Attr::_internal_has_type() const { + bool value = (_has_bits_[0] & 0x00000004u) != 0; + return value; +} +inline bool OpDesc_Attr::has_type() const { + return _internal_has_type(); +} +inline void OpDesc_Attr::clear_type() { + type_ = 0; + _has_bits_[0] &= ~0x00000004u; +} +inline ::paddle::framework::proto::AttrType OpDesc_Attr::_internal_type() const { + return static_cast< ::paddle::framework::proto::AttrType >(type_); +} +inline ::paddle::framework::proto::AttrType OpDesc_Attr::type() const { + // @@protoc_insertion_point(field_get:paddle.framework.proto.OpDesc.Attr.type) + return _internal_type(); +} +inline void OpDesc_Attr::_internal_set_type(::paddle::framework::proto::AttrType value) { + assert(::paddle::framework::proto::AttrType_IsValid(value)); + _has_bits_[0] |= 0x00000004u; + type_ = value; +} +inline void OpDesc_Attr::set_type(::paddle::framework::proto::AttrType value) { + _internal_set_type(value); + // @@protoc_insertion_point(field_set:paddle.framework.proto.OpDesc.Attr.type) +} + +// optional int32 i = 3; +inline bool OpDesc_Attr::_internal_has_i() const { + bool value = (_has_bits_[0] & 0x00000008u) != 0; + return value; +} +inline bool OpDesc_Attr::has_i() const { + return _internal_has_i(); +} +inline void OpDesc_Attr::clear_i() { + i_ = 0; + _has_bits_[0] &= ~0x00000008u; +} +inline ::PROTOBUF_NAMESPACE_ID::int32 OpDesc_Attr::_internal_i() const { + return i_; +} +inline ::PROTOBUF_NAMESPACE_ID::int32 OpDesc_Attr::i() const { + // @@protoc_insertion_point(field_get:paddle.framework.proto.OpDesc.Attr.i) + return _internal_i(); +} +inline void OpDesc_Attr::_internal_set_i(::PROTOBUF_NAMESPACE_ID::int32 value) { + _has_bits_[0] |= 0x00000008u; + i_ = value; +} +inline void OpDesc_Attr::set_i(::PROTOBUF_NAMESPACE_ID::int32 value) { + _internal_set_i(value); + // @@protoc_insertion_point(field_set:paddle.framework.proto.OpDesc.Attr.i) +} + +// optional float f = 4; +inline bool OpDesc_Attr::_internal_has_f() const { + bool value = (_has_bits_[0] & 0x00000010u) != 0; + return value; +} +inline bool OpDesc_Attr::has_f() const { + return _internal_has_f(); +} +inline void OpDesc_Attr::clear_f() { + f_ = 0; + _has_bits_[0] &= ~0x00000010u; +} +inline float OpDesc_Attr::_internal_f() const { + return f_; +} +inline float OpDesc_Attr::f() const { + // @@protoc_insertion_point(field_get:paddle.framework.proto.OpDesc.Attr.f) + return _internal_f(); +} +inline void OpDesc_Attr::_internal_set_f(float value) { + _has_bits_[0] |= 0x00000010u; + f_ = value; +} +inline void OpDesc_Attr::set_f(float value) { + _internal_set_f(value); + // @@protoc_insertion_point(field_set:paddle.framework.proto.OpDesc.Attr.f) +} + +// optional string s = 5; +inline bool OpDesc_Attr::_internal_has_s() const { + bool value = (_has_bits_[0] & 0x00000002u) != 0; + return value; +} +inline bool OpDesc_Attr::has_s() const { + return _internal_has_s(); +} +inline void OpDesc_Attr::clear_s() { + s_.ClearToEmpty(); + _has_bits_[0] &= ~0x00000002u; +} +inline const std::string& OpDesc_Attr::s() const { + // @@protoc_insertion_point(field_get:paddle.framework.proto.OpDesc.Attr.s) + return _internal_s(); +} +inline void OpDesc_Attr::set_s(const std::string& value) { + _internal_set_s(value); + // @@protoc_insertion_point(field_set:paddle.framework.proto.OpDesc.Attr.s) +} +inline std::string* OpDesc_Attr::mutable_s() { + // @@protoc_insertion_point(field_mutable:paddle.framework.proto.OpDesc.Attr.s) + return _internal_mutable_s(); +} +inline const std::string& OpDesc_Attr::_internal_s() const { + return s_.Get(); +} +inline void OpDesc_Attr::_internal_set_s(const std::string& value) { + _has_bits_[0] |= 0x00000002u; + s_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); +} +inline void OpDesc_Attr::set_s(std::string&& value) { + _has_bits_[0] |= 0x00000002u; + s_.Set( + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena()); + // @@protoc_insertion_point(field_set_rvalue:paddle.framework.proto.OpDesc.Attr.s) +} +inline void OpDesc_Attr::set_s(const char* value) { + GOOGLE_DCHECK(value != nullptr); + _has_bits_[0] |= 0x00000002u; + s_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena()); + // @@protoc_insertion_point(field_set_char:paddle.framework.proto.OpDesc.Attr.s) +} +inline void OpDesc_Attr::set_s(const char* value, + size_t size) { + _has_bits_[0] |= 0x00000002u; + s_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string( + reinterpret_cast(value), size), GetArena()); + // @@protoc_insertion_point(field_set_pointer:paddle.framework.proto.OpDesc.Attr.s) +} +inline std::string* OpDesc_Attr::_internal_mutable_s() { + _has_bits_[0] |= 0x00000002u; + return s_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); +} +inline std::string* OpDesc_Attr::release_s() { + // @@protoc_insertion_point(field_release:paddle.framework.proto.OpDesc.Attr.s) + if (!_internal_has_s()) { + return nullptr; + } + _has_bits_[0] &= ~0x00000002u; + return s_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); +} +inline void OpDesc_Attr::set_allocated_s(std::string* s) { + if (s != nullptr) { + _has_bits_[0] |= 0x00000002u; + } else { + _has_bits_[0] &= ~0x00000002u; + } + s_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), s, + GetArena()); + // @@protoc_insertion_point(field_set_allocated:paddle.framework.proto.OpDesc.Attr.s) +} + +// repeated int32 ints = 6; +inline int OpDesc_Attr::_internal_ints_size() const { + return ints_.size(); +} +inline int OpDesc_Attr::ints_size() const { + return _internal_ints_size(); +} +inline void OpDesc_Attr::clear_ints() { + ints_.Clear(); +} +inline ::PROTOBUF_NAMESPACE_ID::int32 OpDesc_Attr::_internal_ints(int index) const { + return ints_.Get(index); +} +inline ::PROTOBUF_NAMESPACE_ID::int32 OpDesc_Attr::ints(int index) const { + // @@protoc_insertion_point(field_get:paddle.framework.proto.OpDesc.Attr.ints) + return _internal_ints(index); +} +inline void OpDesc_Attr::set_ints(int index, ::PROTOBUF_NAMESPACE_ID::int32 value) { + ints_.Set(index, value); + // @@protoc_insertion_point(field_set:paddle.framework.proto.OpDesc.Attr.ints) +} +inline void OpDesc_Attr::_internal_add_ints(::PROTOBUF_NAMESPACE_ID::int32 value) { + ints_.Add(value); +} +inline void OpDesc_Attr::add_ints(::PROTOBUF_NAMESPACE_ID::int32 value) { + _internal_add_ints(value); + // @@protoc_insertion_point(field_add:paddle.framework.proto.OpDesc.Attr.ints) +} +inline const ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int32 >& +OpDesc_Attr::_internal_ints() const { + return ints_; +} +inline const ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int32 >& +OpDesc_Attr::ints() const { + // @@protoc_insertion_point(field_list:paddle.framework.proto.OpDesc.Attr.ints) + return _internal_ints(); +} +inline ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int32 >* +OpDesc_Attr::_internal_mutable_ints() { + return &ints_; +} +inline ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int32 >* +OpDesc_Attr::mutable_ints() { + // @@protoc_insertion_point(field_mutable_list:paddle.framework.proto.OpDesc.Attr.ints) + return _internal_mutable_ints(); +} + +// repeated float floats = 7; +inline int OpDesc_Attr::_internal_floats_size() const { + return floats_.size(); +} +inline int OpDesc_Attr::floats_size() const { + return _internal_floats_size(); +} +inline void OpDesc_Attr::clear_floats() { + floats_.Clear(); +} +inline float OpDesc_Attr::_internal_floats(int index) const { + return floats_.Get(index); +} +inline float OpDesc_Attr::floats(int index) const { + // @@protoc_insertion_point(field_get:paddle.framework.proto.OpDesc.Attr.floats) + return _internal_floats(index); +} +inline void OpDesc_Attr::set_floats(int index, float value) { + floats_.Set(index, value); + // @@protoc_insertion_point(field_set:paddle.framework.proto.OpDesc.Attr.floats) +} +inline void OpDesc_Attr::_internal_add_floats(float value) { + floats_.Add(value); +} +inline void OpDesc_Attr::add_floats(float value) { + _internal_add_floats(value); + // @@protoc_insertion_point(field_add:paddle.framework.proto.OpDesc.Attr.floats) +} +inline const ::PROTOBUF_NAMESPACE_ID::RepeatedField< float >& +OpDesc_Attr::_internal_floats() const { + return floats_; +} +inline const ::PROTOBUF_NAMESPACE_ID::RepeatedField< float >& +OpDesc_Attr::floats() const { + // @@protoc_insertion_point(field_list:paddle.framework.proto.OpDesc.Attr.floats) + return _internal_floats(); +} +inline ::PROTOBUF_NAMESPACE_ID::RepeatedField< float >* +OpDesc_Attr::_internal_mutable_floats() { + return &floats_; +} +inline ::PROTOBUF_NAMESPACE_ID::RepeatedField< float >* +OpDesc_Attr::mutable_floats() { + // @@protoc_insertion_point(field_mutable_list:paddle.framework.proto.OpDesc.Attr.floats) + return _internal_mutable_floats(); +} + +// repeated string strings = 8; +inline int OpDesc_Attr::_internal_strings_size() const { + return strings_.size(); +} +inline int OpDesc_Attr::strings_size() const { + return _internal_strings_size(); +} +inline void OpDesc_Attr::clear_strings() { + strings_.Clear(); +} +inline std::string* OpDesc_Attr::add_strings() { + // @@protoc_insertion_point(field_add_mutable:paddle.framework.proto.OpDesc.Attr.strings) + return _internal_add_strings(); +} +inline const std::string& OpDesc_Attr::_internal_strings(int index) const { + return strings_.Get(index); +} +inline const std::string& OpDesc_Attr::strings(int index) const { + // @@protoc_insertion_point(field_get:paddle.framework.proto.OpDesc.Attr.strings) + return _internal_strings(index); +} +inline std::string* OpDesc_Attr::mutable_strings(int index) { + // @@protoc_insertion_point(field_mutable:paddle.framework.proto.OpDesc.Attr.strings) + return strings_.Mutable(index); +} +inline void OpDesc_Attr::set_strings(int index, const std::string& value) { + // @@protoc_insertion_point(field_set:paddle.framework.proto.OpDesc.Attr.strings) + strings_.Mutable(index)->assign(value); +} +inline void OpDesc_Attr::set_strings(int index, std::string&& value) { + // @@protoc_insertion_point(field_set:paddle.framework.proto.OpDesc.Attr.strings) + strings_.Mutable(index)->assign(std::move(value)); +} +inline void OpDesc_Attr::set_strings(int index, const char* value) { + GOOGLE_DCHECK(value != nullptr); + strings_.Mutable(index)->assign(value); + // @@protoc_insertion_point(field_set_char:paddle.framework.proto.OpDesc.Attr.strings) +} +inline void OpDesc_Attr::set_strings(int index, const char* value, size_t size) { + strings_.Mutable(index)->assign( + reinterpret_cast(value), size); + // @@protoc_insertion_point(field_set_pointer:paddle.framework.proto.OpDesc.Attr.strings) +} +inline std::string* OpDesc_Attr::_internal_add_strings() { + return strings_.Add(); +} +inline void OpDesc_Attr::add_strings(const std::string& value) { + strings_.Add()->assign(value); + // @@protoc_insertion_point(field_add:paddle.framework.proto.OpDesc.Attr.strings) +} +inline void OpDesc_Attr::add_strings(std::string&& value) { + strings_.Add(std::move(value)); + // @@protoc_insertion_point(field_add:paddle.framework.proto.OpDesc.Attr.strings) +} +inline void OpDesc_Attr::add_strings(const char* value) { + GOOGLE_DCHECK(value != nullptr); + strings_.Add()->assign(value); + // @@protoc_insertion_point(field_add_char:paddle.framework.proto.OpDesc.Attr.strings) +} +inline void OpDesc_Attr::add_strings(const char* value, size_t size) { + strings_.Add()->assign(reinterpret_cast(value), size); + // @@protoc_insertion_point(field_add_pointer:paddle.framework.proto.OpDesc.Attr.strings) +} +inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField& +OpDesc_Attr::strings() const { + // @@protoc_insertion_point(field_list:paddle.framework.proto.OpDesc.Attr.strings) + return strings_; +} +inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField* +OpDesc_Attr::mutable_strings() { + // @@protoc_insertion_point(field_mutable_list:paddle.framework.proto.OpDesc.Attr.strings) + return &strings_; +} + +// optional bool b = 10; +inline bool OpDesc_Attr::_internal_has_b() const { + bool value = (_has_bits_[0] & 0x00000020u) != 0; + return value; +} +inline bool OpDesc_Attr::has_b() const { + return _internal_has_b(); +} +inline void OpDesc_Attr::clear_b() { + b_ = false; + _has_bits_[0] &= ~0x00000020u; +} +inline bool OpDesc_Attr::_internal_b() const { + return b_; +} +inline bool OpDesc_Attr::b() const { + // @@protoc_insertion_point(field_get:paddle.framework.proto.OpDesc.Attr.b) + return _internal_b(); +} +inline void OpDesc_Attr::_internal_set_b(bool value) { + _has_bits_[0] |= 0x00000020u; + b_ = value; +} +inline void OpDesc_Attr::set_b(bool value) { + _internal_set_b(value); + // @@protoc_insertion_point(field_set:paddle.framework.proto.OpDesc.Attr.b) +} + +// repeated bool bools = 11; +inline int OpDesc_Attr::_internal_bools_size() const { + return bools_.size(); +} +inline int OpDesc_Attr::bools_size() const { + return _internal_bools_size(); +} +inline void OpDesc_Attr::clear_bools() { + bools_.Clear(); +} +inline bool OpDesc_Attr::_internal_bools(int index) const { + return bools_.Get(index); +} +inline bool OpDesc_Attr::bools(int index) const { + // @@protoc_insertion_point(field_get:paddle.framework.proto.OpDesc.Attr.bools) + return _internal_bools(index); +} +inline void OpDesc_Attr::set_bools(int index, bool value) { + bools_.Set(index, value); + // @@protoc_insertion_point(field_set:paddle.framework.proto.OpDesc.Attr.bools) +} +inline void OpDesc_Attr::_internal_add_bools(bool value) { + bools_.Add(value); +} +inline void OpDesc_Attr::add_bools(bool value) { + _internal_add_bools(value); + // @@protoc_insertion_point(field_add:paddle.framework.proto.OpDesc.Attr.bools) +} +inline const ::PROTOBUF_NAMESPACE_ID::RepeatedField< bool >& +OpDesc_Attr::_internal_bools() const { + return bools_; +} +inline const ::PROTOBUF_NAMESPACE_ID::RepeatedField< bool >& +OpDesc_Attr::bools() const { + // @@protoc_insertion_point(field_list:paddle.framework.proto.OpDesc.Attr.bools) + return _internal_bools(); +} +inline ::PROTOBUF_NAMESPACE_ID::RepeatedField< bool >* +OpDesc_Attr::_internal_mutable_bools() { + return &bools_; +} +inline ::PROTOBUF_NAMESPACE_ID::RepeatedField< bool >* +OpDesc_Attr::mutable_bools() { + // @@protoc_insertion_point(field_mutable_list:paddle.framework.proto.OpDesc.Attr.bools) + return _internal_mutable_bools(); +} + +// optional int32 block_idx = 12; +inline bool OpDesc_Attr::_internal_has_block_idx() const { + bool value = (_has_bits_[0] & 0x00000080u) != 0; + return value; +} +inline bool OpDesc_Attr::has_block_idx() const { + return _internal_has_block_idx(); +} +inline void OpDesc_Attr::clear_block_idx() { + block_idx_ = 0; + _has_bits_[0] &= ~0x00000080u; +} +inline ::PROTOBUF_NAMESPACE_ID::int32 OpDesc_Attr::_internal_block_idx() const { + return block_idx_; +} +inline ::PROTOBUF_NAMESPACE_ID::int32 OpDesc_Attr::block_idx() const { + // @@protoc_insertion_point(field_get:paddle.framework.proto.OpDesc.Attr.block_idx) + return _internal_block_idx(); +} +inline void OpDesc_Attr::_internal_set_block_idx(::PROTOBUF_NAMESPACE_ID::int32 value) { + _has_bits_[0] |= 0x00000080u; + block_idx_ = value; +} +inline void OpDesc_Attr::set_block_idx(::PROTOBUF_NAMESPACE_ID::int32 value) { + _internal_set_block_idx(value); + // @@protoc_insertion_point(field_set:paddle.framework.proto.OpDesc.Attr.block_idx) +} + +// optional int64 l = 13; +inline bool OpDesc_Attr::_internal_has_l() const { + bool value = (_has_bits_[0] & 0x00000040u) != 0; + return value; +} +inline bool OpDesc_Attr::has_l() const { + return _internal_has_l(); +} +inline void OpDesc_Attr::clear_l() { + l_ = PROTOBUF_LONGLONG(0); + _has_bits_[0] &= ~0x00000040u; +} +inline ::PROTOBUF_NAMESPACE_ID::int64 OpDesc_Attr::_internal_l() const { + return l_; +} +inline ::PROTOBUF_NAMESPACE_ID::int64 OpDesc_Attr::l() const { + // @@protoc_insertion_point(field_get:paddle.framework.proto.OpDesc.Attr.l) + return _internal_l(); +} +inline void OpDesc_Attr::_internal_set_l(::PROTOBUF_NAMESPACE_ID::int64 value) { + _has_bits_[0] |= 0x00000040u; + l_ = value; +} +inline void OpDesc_Attr::set_l(::PROTOBUF_NAMESPACE_ID::int64 value) { + _internal_set_l(value); + // @@protoc_insertion_point(field_set:paddle.framework.proto.OpDesc.Attr.l) +} + +// repeated int32 blocks_idx = 14; +inline int OpDesc_Attr::_internal_blocks_idx_size() const { + return blocks_idx_.size(); +} +inline int OpDesc_Attr::blocks_idx_size() const { + return _internal_blocks_idx_size(); +} +inline void OpDesc_Attr::clear_blocks_idx() { + blocks_idx_.Clear(); +} +inline ::PROTOBUF_NAMESPACE_ID::int32 OpDesc_Attr::_internal_blocks_idx(int index) const { + return blocks_idx_.Get(index); +} +inline ::PROTOBUF_NAMESPACE_ID::int32 OpDesc_Attr::blocks_idx(int index) const { + // @@protoc_insertion_point(field_get:paddle.framework.proto.OpDesc.Attr.blocks_idx) + return _internal_blocks_idx(index); +} +inline void OpDesc_Attr::set_blocks_idx(int index, ::PROTOBUF_NAMESPACE_ID::int32 value) { + blocks_idx_.Set(index, value); + // @@protoc_insertion_point(field_set:paddle.framework.proto.OpDesc.Attr.blocks_idx) +} +inline void OpDesc_Attr::_internal_add_blocks_idx(::PROTOBUF_NAMESPACE_ID::int32 value) { + blocks_idx_.Add(value); +} +inline void OpDesc_Attr::add_blocks_idx(::PROTOBUF_NAMESPACE_ID::int32 value) { + _internal_add_blocks_idx(value); + // @@protoc_insertion_point(field_add:paddle.framework.proto.OpDesc.Attr.blocks_idx) +} +inline const ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int32 >& +OpDesc_Attr::_internal_blocks_idx() const { + return blocks_idx_; +} +inline const ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int32 >& +OpDesc_Attr::blocks_idx() const { + // @@protoc_insertion_point(field_list:paddle.framework.proto.OpDesc.Attr.blocks_idx) + return _internal_blocks_idx(); +} +inline ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int32 >* +OpDesc_Attr::_internal_mutable_blocks_idx() { + return &blocks_idx_; +} +inline ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int32 >* +OpDesc_Attr::mutable_blocks_idx() { + // @@protoc_insertion_point(field_mutable_list:paddle.framework.proto.OpDesc.Attr.blocks_idx) + return _internal_mutable_blocks_idx(); +} + +// repeated int64 longs = 15; +inline int OpDesc_Attr::_internal_longs_size() const { + return longs_.size(); +} +inline int OpDesc_Attr::longs_size() const { + return _internal_longs_size(); +} +inline void OpDesc_Attr::clear_longs() { + longs_.Clear(); +} +inline ::PROTOBUF_NAMESPACE_ID::int64 OpDesc_Attr::_internal_longs(int index) const { + return longs_.Get(index); +} +inline ::PROTOBUF_NAMESPACE_ID::int64 OpDesc_Attr::longs(int index) const { + // @@protoc_insertion_point(field_get:paddle.framework.proto.OpDesc.Attr.longs) + return _internal_longs(index); +} +inline void OpDesc_Attr::set_longs(int index, ::PROTOBUF_NAMESPACE_ID::int64 value) { + longs_.Set(index, value); + // @@protoc_insertion_point(field_set:paddle.framework.proto.OpDesc.Attr.longs) +} +inline void OpDesc_Attr::_internal_add_longs(::PROTOBUF_NAMESPACE_ID::int64 value) { + longs_.Add(value); +} +inline void OpDesc_Attr::add_longs(::PROTOBUF_NAMESPACE_ID::int64 value) { + _internal_add_longs(value); + // @@protoc_insertion_point(field_add:paddle.framework.proto.OpDesc.Attr.longs) +} +inline const ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int64 >& +OpDesc_Attr::_internal_longs() const { + return longs_; +} +inline const ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int64 >& +OpDesc_Attr::longs() const { + // @@protoc_insertion_point(field_list:paddle.framework.proto.OpDesc.Attr.longs) + return _internal_longs(); +} +inline ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int64 >* +OpDesc_Attr::_internal_mutable_longs() { + return &longs_; +} +inline ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int64 >* +OpDesc_Attr::mutable_longs() { + // @@protoc_insertion_point(field_mutable_list:paddle.framework.proto.OpDesc.Attr.longs) + return _internal_mutable_longs(); +} + +// ------------------------------------------------------------------- + +// OpDesc_Var + +// required string parameter = 1; +inline bool OpDesc_Var::_internal_has_parameter() const { + bool value = (_has_bits_[0] & 0x00000001u) != 0; + return value; +} +inline bool OpDesc_Var::has_parameter() const { + return _internal_has_parameter(); +} +inline void OpDesc_Var::clear_parameter() { + parameter_.ClearToEmpty(); + _has_bits_[0] &= ~0x00000001u; +} +inline const std::string& OpDesc_Var::parameter() const { + // @@protoc_insertion_point(field_get:paddle.framework.proto.OpDesc.Var.parameter) + return _internal_parameter(); +} +inline void OpDesc_Var::set_parameter(const std::string& value) { + _internal_set_parameter(value); + // @@protoc_insertion_point(field_set:paddle.framework.proto.OpDesc.Var.parameter) +} +inline std::string* OpDesc_Var::mutable_parameter() { + // @@protoc_insertion_point(field_mutable:paddle.framework.proto.OpDesc.Var.parameter) + return _internal_mutable_parameter(); +} +inline const std::string& OpDesc_Var::_internal_parameter() const { + return parameter_.Get(); +} +inline void OpDesc_Var::_internal_set_parameter(const std::string& value) { + _has_bits_[0] |= 0x00000001u; + parameter_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); +} +inline void OpDesc_Var::set_parameter(std::string&& value) { + _has_bits_[0] |= 0x00000001u; + parameter_.Set( + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena()); + // @@protoc_insertion_point(field_set_rvalue:paddle.framework.proto.OpDesc.Var.parameter) +} +inline void OpDesc_Var::set_parameter(const char* value) { + GOOGLE_DCHECK(value != nullptr); + _has_bits_[0] |= 0x00000001u; + parameter_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena()); + // @@protoc_insertion_point(field_set_char:paddle.framework.proto.OpDesc.Var.parameter) +} +inline void OpDesc_Var::set_parameter(const char* value, + size_t size) { + _has_bits_[0] |= 0x00000001u; + parameter_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string( + reinterpret_cast(value), size), GetArena()); + // @@protoc_insertion_point(field_set_pointer:paddle.framework.proto.OpDesc.Var.parameter) +} +inline std::string* OpDesc_Var::_internal_mutable_parameter() { + _has_bits_[0] |= 0x00000001u; + return parameter_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); +} +inline std::string* OpDesc_Var::release_parameter() { + // @@protoc_insertion_point(field_release:paddle.framework.proto.OpDesc.Var.parameter) + if (!_internal_has_parameter()) { + return nullptr; + } + _has_bits_[0] &= ~0x00000001u; + return parameter_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); +} +inline void OpDesc_Var::set_allocated_parameter(std::string* parameter) { + if (parameter != nullptr) { + _has_bits_[0] |= 0x00000001u; + } else { + _has_bits_[0] &= ~0x00000001u; + } + parameter_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), parameter, + GetArena()); + // @@protoc_insertion_point(field_set_allocated:paddle.framework.proto.OpDesc.Var.parameter) +} + +// repeated string arguments = 2; +inline int OpDesc_Var::_internal_arguments_size() const { + return arguments_.size(); +} +inline int OpDesc_Var::arguments_size() const { + return _internal_arguments_size(); +} +inline void OpDesc_Var::clear_arguments() { + arguments_.Clear(); +} +inline std::string* OpDesc_Var::add_arguments() { + // @@protoc_insertion_point(field_add_mutable:paddle.framework.proto.OpDesc.Var.arguments) + return _internal_add_arguments(); +} +inline const std::string& OpDesc_Var::_internal_arguments(int index) const { + return arguments_.Get(index); +} +inline const std::string& OpDesc_Var::arguments(int index) const { + // @@protoc_insertion_point(field_get:paddle.framework.proto.OpDesc.Var.arguments) + return _internal_arguments(index); +} +inline std::string* OpDesc_Var::mutable_arguments(int index) { + // @@protoc_insertion_point(field_mutable:paddle.framework.proto.OpDesc.Var.arguments) + return arguments_.Mutable(index); +} +inline void OpDesc_Var::set_arguments(int index, const std::string& value) { + // @@protoc_insertion_point(field_set:paddle.framework.proto.OpDesc.Var.arguments) + arguments_.Mutable(index)->assign(value); +} +inline void OpDesc_Var::set_arguments(int index, std::string&& value) { + // @@protoc_insertion_point(field_set:paddle.framework.proto.OpDesc.Var.arguments) + arguments_.Mutable(index)->assign(std::move(value)); +} +inline void OpDesc_Var::set_arguments(int index, const char* value) { + GOOGLE_DCHECK(value != nullptr); + arguments_.Mutable(index)->assign(value); + // @@protoc_insertion_point(field_set_char:paddle.framework.proto.OpDesc.Var.arguments) +} +inline void OpDesc_Var::set_arguments(int index, const char* value, size_t size) { + arguments_.Mutable(index)->assign( + reinterpret_cast(value), size); + // @@protoc_insertion_point(field_set_pointer:paddle.framework.proto.OpDesc.Var.arguments) +} +inline std::string* OpDesc_Var::_internal_add_arguments() { + return arguments_.Add(); +} +inline void OpDesc_Var::add_arguments(const std::string& value) { + arguments_.Add()->assign(value); + // @@protoc_insertion_point(field_add:paddle.framework.proto.OpDesc.Var.arguments) +} +inline void OpDesc_Var::add_arguments(std::string&& value) { + arguments_.Add(std::move(value)); + // @@protoc_insertion_point(field_add:paddle.framework.proto.OpDesc.Var.arguments) +} +inline void OpDesc_Var::add_arguments(const char* value) { + GOOGLE_DCHECK(value != nullptr); + arguments_.Add()->assign(value); + // @@protoc_insertion_point(field_add_char:paddle.framework.proto.OpDesc.Var.arguments) +} +inline void OpDesc_Var::add_arguments(const char* value, size_t size) { + arguments_.Add()->assign(reinterpret_cast(value), size); + // @@protoc_insertion_point(field_add_pointer:paddle.framework.proto.OpDesc.Var.arguments) +} +inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField& +OpDesc_Var::arguments() const { + // @@protoc_insertion_point(field_list:paddle.framework.proto.OpDesc.Var.arguments) + return arguments_; +} +inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField* +OpDesc_Var::mutable_arguments() { + // @@protoc_insertion_point(field_mutable_list:paddle.framework.proto.OpDesc.Var.arguments) + return &arguments_; +} + +// ------------------------------------------------------------------- + +// OpDesc + +// required string type = 3; +inline bool OpDesc::_internal_has_type() const { + bool value = (_has_bits_[0] & 0x00000001u) != 0; + return value; +} +inline bool OpDesc::has_type() const { + return _internal_has_type(); +} +inline void OpDesc::clear_type() { + type_.ClearToEmpty(); + _has_bits_[0] &= ~0x00000001u; +} +inline const std::string& OpDesc::type() const { + // @@protoc_insertion_point(field_get:paddle.framework.proto.OpDesc.type) + return _internal_type(); +} +inline void OpDesc::set_type(const std::string& value) { + _internal_set_type(value); + // @@protoc_insertion_point(field_set:paddle.framework.proto.OpDesc.type) +} +inline std::string* OpDesc::mutable_type() { + // @@protoc_insertion_point(field_mutable:paddle.framework.proto.OpDesc.type) + return _internal_mutable_type(); +} +inline const std::string& OpDesc::_internal_type() const { + return type_.Get(); +} +inline void OpDesc::_internal_set_type(const std::string& value) { + _has_bits_[0] |= 0x00000001u; + type_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); +} +inline void OpDesc::set_type(std::string&& value) { + _has_bits_[0] |= 0x00000001u; + type_.Set( + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena()); + // @@protoc_insertion_point(field_set_rvalue:paddle.framework.proto.OpDesc.type) +} +inline void OpDesc::set_type(const char* value) { + GOOGLE_DCHECK(value != nullptr); + _has_bits_[0] |= 0x00000001u; + type_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena()); + // @@protoc_insertion_point(field_set_char:paddle.framework.proto.OpDesc.type) +} +inline void OpDesc::set_type(const char* value, + size_t size) { + _has_bits_[0] |= 0x00000001u; + type_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string( + reinterpret_cast(value), size), GetArena()); + // @@protoc_insertion_point(field_set_pointer:paddle.framework.proto.OpDesc.type) +} +inline std::string* OpDesc::_internal_mutable_type() { + _has_bits_[0] |= 0x00000001u; + return type_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); +} +inline std::string* OpDesc::release_type() { + // @@protoc_insertion_point(field_release:paddle.framework.proto.OpDesc.type) + if (!_internal_has_type()) { + return nullptr; + } + _has_bits_[0] &= ~0x00000001u; + return type_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); +} +inline void OpDesc::set_allocated_type(std::string* type) { + if (type != nullptr) { + _has_bits_[0] |= 0x00000001u; + } else { + _has_bits_[0] &= ~0x00000001u; + } + type_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), type, + GetArena()); + // @@protoc_insertion_point(field_set_allocated:paddle.framework.proto.OpDesc.type) +} + +// repeated .paddle.framework.proto.OpDesc.Var inputs = 1; +inline int OpDesc::_internal_inputs_size() const { + return inputs_.size(); +} +inline int OpDesc::inputs_size() const { + return _internal_inputs_size(); +} +inline void OpDesc::clear_inputs() { + inputs_.Clear(); +} +inline ::paddle::framework::proto::OpDesc_Var* OpDesc::mutable_inputs(int index) { + // @@protoc_insertion_point(field_mutable:paddle.framework.proto.OpDesc.inputs) + return inputs_.Mutable(index); +} +inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::OpDesc_Var >* +OpDesc::mutable_inputs() { + // @@protoc_insertion_point(field_mutable_list:paddle.framework.proto.OpDesc.inputs) + return &inputs_; +} +inline const ::paddle::framework::proto::OpDesc_Var& OpDesc::_internal_inputs(int index) const { + return inputs_.Get(index); +} +inline const ::paddle::framework::proto::OpDesc_Var& OpDesc::inputs(int index) const { + // @@protoc_insertion_point(field_get:paddle.framework.proto.OpDesc.inputs) + return _internal_inputs(index); +} +inline ::paddle::framework::proto::OpDesc_Var* OpDesc::_internal_add_inputs() { + return inputs_.Add(); +} +inline ::paddle::framework::proto::OpDesc_Var* OpDesc::add_inputs() { + // @@protoc_insertion_point(field_add:paddle.framework.proto.OpDesc.inputs) + return _internal_add_inputs(); +} +inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::OpDesc_Var >& +OpDesc::inputs() const { + // @@protoc_insertion_point(field_list:paddle.framework.proto.OpDesc.inputs) + return inputs_; +} + +// repeated .paddle.framework.proto.OpDesc.Var outputs = 2; +inline int OpDesc::_internal_outputs_size() const { + return outputs_.size(); +} +inline int OpDesc::outputs_size() const { + return _internal_outputs_size(); +} +inline void OpDesc::clear_outputs() { + outputs_.Clear(); +} +inline ::paddle::framework::proto::OpDesc_Var* OpDesc::mutable_outputs(int index) { + // @@protoc_insertion_point(field_mutable:paddle.framework.proto.OpDesc.outputs) + return outputs_.Mutable(index); +} +inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::OpDesc_Var >* +OpDesc::mutable_outputs() { + // @@protoc_insertion_point(field_mutable_list:paddle.framework.proto.OpDesc.outputs) + return &outputs_; +} +inline const ::paddle::framework::proto::OpDesc_Var& OpDesc::_internal_outputs(int index) const { + return outputs_.Get(index); +} +inline const ::paddle::framework::proto::OpDesc_Var& OpDesc::outputs(int index) const { + // @@protoc_insertion_point(field_get:paddle.framework.proto.OpDesc.outputs) + return _internal_outputs(index); +} +inline ::paddle::framework::proto::OpDesc_Var* OpDesc::_internal_add_outputs() { + return outputs_.Add(); +} +inline ::paddle::framework::proto::OpDesc_Var* OpDesc::add_outputs() { + // @@protoc_insertion_point(field_add:paddle.framework.proto.OpDesc.outputs) + return _internal_add_outputs(); +} +inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::OpDesc_Var >& +OpDesc::outputs() const { + // @@protoc_insertion_point(field_list:paddle.framework.proto.OpDesc.outputs) + return outputs_; +} + +// repeated .paddle.framework.proto.OpDesc.Attr attrs = 4; +inline int OpDesc::_internal_attrs_size() const { + return attrs_.size(); +} +inline int OpDesc::attrs_size() const { + return _internal_attrs_size(); +} +inline void OpDesc::clear_attrs() { + attrs_.Clear(); +} +inline ::paddle::framework::proto::OpDesc_Attr* OpDesc::mutable_attrs(int index) { + // @@protoc_insertion_point(field_mutable:paddle.framework.proto.OpDesc.attrs) + return attrs_.Mutable(index); +} +inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::OpDesc_Attr >* +OpDesc::mutable_attrs() { + // @@protoc_insertion_point(field_mutable_list:paddle.framework.proto.OpDesc.attrs) + return &attrs_; +} +inline const ::paddle::framework::proto::OpDesc_Attr& OpDesc::_internal_attrs(int index) const { + return attrs_.Get(index); +} +inline const ::paddle::framework::proto::OpDesc_Attr& OpDesc::attrs(int index) const { + // @@protoc_insertion_point(field_get:paddle.framework.proto.OpDesc.attrs) + return _internal_attrs(index); +} +inline ::paddle::framework::proto::OpDesc_Attr* OpDesc::_internal_add_attrs() { + return attrs_.Add(); +} +inline ::paddle::framework::proto::OpDesc_Attr* OpDesc::add_attrs() { + // @@protoc_insertion_point(field_add:paddle.framework.proto.OpDesc.attrs) + return _internal_add_attrs(); +} +inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::OpDesc_Attr >& +OpDesc::attrs() const { + // @@protoc_insertion_point(field_list:paddle.framework.proto.OpDesc.attrs) + return attrs_; +} + +// optional bool is_target = 5 [default = false]; +inline bool OpDesc::_internal_has_is_target() const { + bool value = (_has_bits_[0] & 0x00000002u) != 0; + return value; +} +inline bool OpDesc::has_is_target() const { + return _internal_has_is_target(); +} +inline void OpDesc::clear_is_target() { + is_target_ = false; + _has_bits_[0] &= ~0x00000002u; +} +inline bool OpDesc::_internal_is_target() const { + return is_target_; +} +inline bool OpDesc::is_target() const { + // @@protoc_insertion_point(field_get:paddle.framework.proto.OpDesc.is_target) + return _internal_is_target(); +} +inline void OpDesc::_internal_set_is_target(bool value) { + _has_bits_[0] |= 0x00000002u; + is_target_ = value; +} +inline void OpDesc::set_is_target(bool value) { + _internal_set_is_target(value); + // @@protoc_insertion_point(field_set:paddle.framework.proto.OpDesc.is_target) +} + +// ------------------------------------------------------------------- + +// OpProto_Var + +// required string name = 1; +inline bool OpProto_Var::_internal_has_name() const { + bool value = (_has_bits_[0] & 0x00000001u) != 0; + return value; +} +inline bool OpProto_Var::has_name() const { + return _internal_has_name(); +} +inline void OpProto_Var::clear_name() { + name_.ClearToEmpty(); + _has_bits_[0] &= ~0x00000001u; +} +inline const std::string& OpProto_Var::name() const { + // @@protoc_insertion_point(field_get:paddle.framework.proto.OpProto.Var.name) + return _internal_name(); +} +inline void OpProto_Var::set_name(const std::string& value) { + _internal_set_name(value); + // @@protoc_insertion_point(field_set:paddle.framework.proto.OpProto.Var.name) +} +inline std::string* OpProto_Var::mutable_name() { + // @@protoc_insertion_point(field_mutable:paddle.framework.proto.OpProto.Var.name) + return _internal_mutable_name(); +} +inline const std::string& OpProto_Var::_internal_name() const { + return name_.Get(); +} +inline void OpProto_Var::_internal_set_name(const std::string& value) { + _has_bits_[0] |= 0x00000001u; + name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); +} +inline void OpProto_Var::set_name(std::string&& value) { + _has_bits_[0] |= 0x00000001u; + name_.Set( + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena()); + // @@protoc_insertion_point(field_set_rvalue:paddle.framework.proto.OpProto.Var.name) +} +inline void OpProto_Var::set_name(const char* value) { + GOOGLE_DCHECK(value != nullptr); + _has_bits_[0] |= 0x00000001u; + name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena()); + // @@protoc_insertion_point(field_set_char:paddle.framework.proto.OpProto.Var.name) +} +inline void OpProto_Var::set_name(const char* value, + size_t size) { + _has_bits_[0] |= 0x00000001u; + name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string( + reinterpret_cast(value), size), GetArena()); + // @@protoc_insertion_point(field_set_pointer:paddle.framework.proto.OpProto.Var.name) +} +inline std::string* OpProto_Var::_internal_mutable_name() { + _has_bits_[0] |= 0x00000001u; + return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); +} +inline std::string* OpProto_Var::release_name() { + // @@protoc_insertion_point(field_release:paddle.framework.proto.OpProto.Var.name) + if (!_internal_has_name()) { + return nullptr; + } + _has_bits_[0] &= ~0x00000001u; + return name_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); +} +inline void OpProto_Var::set_allocated_name(std::string* name) { + if (name != nullptr) { + _has_bits_[0] |= 0x00000001u; + } else { + _has_bits_[0] &= ~0x00000001u; + } + name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name, + GetArena()); + // @@protoc_insertion_point(field_set_allocated:paddle.framework.proto.OpProto.Var.name) +} + +// required string comment = 2; +inline bool OpProto_Var::_internal_has_comment() const { + bool value = (_has_bits_[0] & 0x00000002u) != 0; + return value; +} +inline bool OpProto_Var::has_comment() const { + return _internal_has_comment(); +} +inline void OpProto_Var::clear_comment() { + comment_.ClearToEmpty(); + _has_bits_[0] &= ~0x00000002u; +} +inline const std::string& OpProto_Var::comment() const { + // @@protoc_insertion_point(field_get:paddle.framework.proto.OpProto.Var.comment) + return _internal_comment(); +} +inline void OpProto_Var::set_comment(const std::string& value) { + _internal_set_comment(value); + // @@protoc_insertion_point(field_set:paddle.framework.proto.OpProto.Var.comment) +} +inline std::string* OpProto_Var::mutable_comment() { + // @@protoc_insertion_point(field_mutable:paddle.framework.proto.OpProto.Var.comment) + return _internal_mutable_comment(); +} +inline const std::string& OpProto_Var::_internal_comment() const { + return comment_.Get(); +} +inline void OpProto_Var::_internal_set_comment(const std::string& value) { + _has_bits_[0] |= 0x00000002u; + comment_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); +} +inline void OpProto_Var::set_comment(std::string&& value) { + _has_bits_[0] |= 0x00000002u; + comment_.Set( + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena()); + // @@protoc_insertion_point(field_set_rvalue:paddle.framework.proto.OpProto.Var.comment) +} +inline void OpProto_Var::set_comment(const char* value) { + GOOGLE_DCHECK(value != nullptr); + _has_bits_[0] |= 0x00000002u; + comment_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena()); + // @@protoc_insertion_point(field_set_char:paddle.framework.proto.OpProto.Var.comment) +} +inline void OpProto_Var::set_comment(const char* value, + size_t size) { + _has_bits_[0] |= 0x00000002u; + comment_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string( + reinterpret_cast(value), size), GetArena()); + // @@protoc_insertion_point(field_set_pointer:paddle.framework.proto.OpProto.Var.comment) +} +inline std::string* OpProto_Var::_internal_mutable_comment() { + _has_bits_[0] |= 0x00000002u; + return comment_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); +} +inline std::string* OpProto_Var::release_comment() { + // @@protoc_insertion_point(field_release:paddle.framework.proto.OpProto.Var.comment) + if (!_internal_has_comment()) { + return nullptr; + } + _has_bits_[0] &= ~0x00000002u; + return comment_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); +} +inline void OpProto_Var::set_allocated_comment(std::string* comment) { + if (comment != nullptr) { + _has_bits_[0] |= 0x00000002u; + } else { + _has_bits_[0] &= ~0x00000002u; + } + comment_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), comment, + GetArena()); + // @@protoc_insertion_point(field_set_allocated:paddle.framework.proto.OpProto.Var.comment) +} + +// optional bool duplicable = 3 [default = false]; +inline bool OpProto_Var::_internal_has_duplicable() const { + bool value = (_has_bits_[0] & 0x00000004u) != 0; + return value; +} +inline bool OpProto_Var::has_duplicable() const { + return _internal_has_duplicable(); +} +inline void OpProto_Var::clear_duplicable() { + duplicable_ = false; + _has_bits_[0] &= ~0x00000004u; +} +inline bool OpProto_Var::_internal_duplicable() const { + return duplicable_; +} +inline bool OpProto_Var::duplicable() const { + // @@protoc_insertion_point(field_get:paddle.framework.proto.OpProto.Var.duplicable) + return _internal_duplicable(); +} +inline void OpProto_Var::_internal_set_duplicable(bool value) { + _has_bits_[0] |= 0x00000004u; + duplicable_ = value; +} +inline void OpProto_Var::set_duplicable(bool value) { + _internal_set_duplicable(value); + // @@protoc_insertion_point(field_set:paddle.framework.proto.OpProto.Var.duplicable) +} + +// optional bool intermediate = 4 [default = false]; +inline bool OpProto_Var::_internal_has_intermediate() const { + bool value = (_has_bits_[0] & 0x00000008u) != 0; + return value; +} +inline bool OpProto_Var::has_intermediate() const { + return _internal_has_intermediate(); +} +inline void OpProto_Var::clear_intermediate() { + intermediate_ = false; + _has_bits_[0] &= ~0x00000008u; +} +inline bool OpProto_Var::_internal_intermediate() const { + return intermediate_; +} +inline bool OpProto_Var::intermediate() const { + // @@protoc_insertion_point(field_get:paddle.framework.proto.OpProto.Var.intermediate) + return _internal_intermediate(); +} +inline void OpProto_Var::_internal_set_intermediate(bool value) { + _has_bits_[0] |= 0x00000008u; + intermediate_ = value; +} +inline void OpProto_Var::set_intermediate(bool value) { + _internal_set_intermediate(value); + // @@protoc_insertion_point(field_set:paddle.framework.proto.OpProto.Var.intermediate) +} + +// optional bool dispensable = 5 [default = false]; +inline bool OpProto_Var::_internal_has_dispensable() const { + bool value = (_has_bits_[0] & 0x00000010u) != 0; + return value; +} +inline bool OpProto_Var::has_dispensable() const { + return _internal_has_dispensable(); +} +inline void OpProto_Var::clear_dispensable() { + dispensable_ = false; + _has_bits_[0] &= ~0x00000010u; +} +inline bool OpProto_Var::_internal_dispensable() const { + return dispensable_; +} +inline bool OpProto_Var::dispensable() const { + // @@protoc_insertion_point(field_get:paddle.framework.proto.OpProto.Var.dispensable) + return _internal_dispensable(); +} +inline void OpProto_Var::_internal_set_dispensable(bool value) { + _has_bits_[0] |= 0x00000010u; + dispensable_ = value; +} +inline void OpProto_Var::set_dispensable(bool value) { + _internal_set_dispensable(value); + // @@protoc_insertion_point(field_set:paddle.framework.proto.OpProto.Var.dispensable) +} + +// ------------------------------------------------------------------- + +// OpProto_Attr + +// required string name = 1; +inline bool OpProto_Attr::_internal_has_name() const { + bool value = (_has_bits_[0] & 0x00000001u) != 0; + return value; +} +inline bool OpProto_Attr::has_name() const { + return _internal_has_name(); +} +inline void OpProto_Attr::clear_name() { + name_.ClearToEmpty(); + _has_bits_[0] &= ~0x00000001u; +} +inline const std::string& OpProto_Attr::name() const { + // @@protoc_insertion_point(field_get:paddle.framework.proto.OpProto.Attr.name) + return _internal_name(); +} +inline void OpProto_Attr::set_name(const std::string& value) { + _internal_set_name(value); + // @@protoc_insertion_point(field_set:paddle.framework.proto.OpProto.Attr.name) +} +inline std::string* OpProto_Attr::mutable_name() { + // @@protoc_insertion_point(field_mutable:paddle.framework.proto.OpProto.Attr.name) + return _internal_mutable_name(); +} +inline const std::string& OpProto_Attr::_internal_name() const { + return name_.Get(); +} +inline void OpProto_Attr::_internal_set_name(const std::string& value) { + _has_bits_[0] |= 0x00000001u; + name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); +} +inline void OpProto_Attr::set_name(std::string&& value) { + _has_bits_[0] |= 0x00000001u; + name_.Set( + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena()); + // @@protoc_insertion_point(field_set_rvalue:paddle.framework.proto.OpProto.Attr.name) +} +inline void OpProto_Attr::set_name(const char* value) { + GOOGLE_DCHECK(value != nullptr); + _has_bits_[0] |= 0x00000001u; + name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena()); + // @@protoc_insertion_point(field_set_char:paddle.framework.proto.OpProto.Attr.name) +} +inline void OpProto_Attr::set_name(const char* value, + size_t size) { + _has_bits_[0] |= 0x00000001u; + name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string( + reinterpret_cast(value), size), GetArena()); + // @@protoc_insertion_point(field_set_pointer:paddle.framework.proto.OpProto.Attr.name) +} +inline std::string* OpProto_Attr::_internal_mutable_name() { + _has_bits_[0] |= 0x00000001u; + return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); +} +inline std::string* OpProto_Attr::release_name() { + // @@protoc_insertion_point(field_release:paddle.framework.proto.OpProto.Attr.name) + if (!_internal_has_name()) { + return nullptr; + } + _has_bits_[0] &= ~0x00000001u; + return name_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); +} +inline void OpProto_Attr::set_allocated_name(std::string* name) { + if (name != nullptr) { + _has_bits_[0] |= 0x00000001u; + } else { + _has_bits_[0] &= ~0x00000001u; + } + name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name, + GetArena()); + // @@protoc_insertion_point(field_set_allocated:paddle.framework.proto.OpProto.Attr.name) +} + +// required .paddle.framework.proto.AttrType type = 2; +inline bool OpProto_Attr::_internal_has_type() const { + bool value = (_has_bits_[0] & 0x00000004u) != 0; + return value; +} +inline bool OpProto_Attr::has_type() const { + return _internal_has_type(); +} +inline void OpProto_Attr::clear_type() { + type_ = 0; + _has_bits_[0] &= ~0x00000004u; +} +inline ::paddle::framework::proto::AttrType OpProto_Attr::_internal_type() const { + return static_cast< ::paddle::framework::proto::AttrType >(type_); +} +inline ::paddle::framework::proto::AttrType OpProto_Attr::type() const { + // @@protoc_insertion_point(field_get:paddle.framework.proto.OpProto.Attr.type) + return _internal_type(); +} +inline void OpProto_Attr::_internal_set_type(::paddle::framework::proto::AttrType value) { + assert(::paddle::framework::proto::AttrType_IsValid(value)); + _has_bits_[0] |= 0x00000004u; + type_ = value; +} +inline void OpProto_Attr::set_type(::paddle::framework::proto::AttrType value) { + _internal_set_type(value); + // @@protoc_insertion_point(field_set:paddle.framework.proto.OpProto.Attr.type) +} + +// required string comment = 3; +inline bool OpProto_Attr::_internal_has_comment() const { + bool value = (_has_bits_[0] & 0x00000002u) != 0; + return value; +} +inline bool OpProto_Attr::has_comment() const { + return _internal_has_comment(); +} +inline void OpProto_Attr::clear_comment() { + comment_.ClearToEmpty(); + _has_bits_[0] &= ~0x00000002u; +} +inline const std::string& OpProto_Attr::comment() const { + // @@protoc_insertion_point(field_get:paddle.framework.proto.OpProto.Attr.comment) + return _internal_comment(); +} +inline void OpProto_Attr::set_comment(const std::string& value) { + _internal_set_comment(value); + // @@protoc_insertion_point(field_set:paddle.framework.proto.OpProto.Attr.comment) +} +inline std::string* OpProto_Attr::mutable_comment() { + // @@protoc_insertion_point(field_mutable:paddle.framework.proto.OpProto.Attr.comment) + return _internal_mutable_comment(); +} +inline const std::string& OpProto_Attr::_internal_comment() const { + return comment_.Get(); +} +inline void OpProto_Attr::_internal_set_comment(const std::string& value) { + _has_bits_[0] |= 0x00000002u; + comment_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); +} +inline void OpProto_Attr::set_comment(std::string&& value) { + _has_bits_[0] |= 0x00000002u; + comment_.Set( + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena()); + // @@protoc_insertion_point(field_set_rvalue:paddle.framework.proto.OpProto.Attr.comment) +} +inline void OpProto_Attr::set_comment(const char* value) { + GOOGLE_DCHECK(value != nullptr); + _has_bits_[0] |= 0x00000002u; + comment_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena()); + // @@protoc_insertion_point(field_set_char:paddle.framework.proto.OpProto.Attr.comment) +} +inline void OpProto_Attr::set_comment(const char* value, + size_t size) { + _has_bits_[0] |= 0x00000002u; + comment_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string( + reinterpret_cast(value), size), GetArena()); + // @@protoc_insertion_point(field_set_pointer:paddle.framework.proto.OpProto.Attr.comment) +} +inline std::string* OpProto_Attr::_internal_mutable_comment() { + _has_bits_[0] |= 0x00000002u; + return comment_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); +} +inline std::string* OpProto_Attr::release_comment() { + // @@protoc_insertion_point(field_release:paddle.framework.proto.OpProto.Attr.comment) + if (!_internal_has_comment()) { + return nullptr; + } + _has_bits_[0] &= ~0x00000002u; + return comment_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); +} +inline void OpProto_Attr::set_allocated_comment(std::string* comment) { + if (comment != nullptr) { + _has_bits_[0] |= 0x00000002u; + } else { + _has_bits_[0] &= ~0x00000002u; + } + comment_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), comment, + GetArena()); + // @@protoc_insertion_point(field_set_allocated:paddle.framework.proto.OpProto.Attr.comment) +} + +// optional bool generated = 4 [default = false]; +inline bool OpProto_Attr::_internal_has_generated() const { + bool value = (_has_bits_[0] & 0x00000008u) != 0; + return value; +} +inline bool OpProto_Attr::has_generated() const { + return _internal_has_generated(); +} +inline void OpProto_Attr::clear_generated() { + generated_ = false; + _has_bits_[0] &= ~0x00000008u; +} +inline bool OpProto_Attr::_internal_generated() const { + return generated_; +} +inline bool OpProto_Attr::generated() const { + // @@protoc_insertion_point(field_get:paddle.framework.proto.OpProto.Attr.generated) + return _internal_generated(); +} +inline void OpProto_Attr::_internal_set_generated(bool value) { + _has_bits_[0] |= 0x00000008u; + generated_ = value; +} +inline void OpProto_Attr::set_generated(bool value) { + _internal_set_generated(value); + // @@protoc_insertion_point(field_set:paddle.framework.proto.OpProto.Attr.generated) +} + +// ------------------------------------------------------------------- + +// OpProto + +// required string type = 1; +inline bool OpProto::_internal_has_type() const { + bool value = (_has_bits_[0] & 0x00000001u) != 0; + return value; +} +inline bool OpProto::has_type() const { + return _internal_has_type(); +} +inline void OpProto::clear_type() { + type_.ClearToEmpty(); + _has_bits_[0] &= ~0x00000001u; +} +inline const std::string& OpProto::type() const { + // @@protoc_insertion_point(field_get:paddle.framework.proto.OpProto.type) + return _internal_type(); +} +inline void OpProto::set_type(const std::string& value) { + _internal_set_type(value); + // @@protoc_insertion_point(field_set:paddle.framework.proto.OpProto.type) +} +inline std::string* OpProto::mutable_type() { + // @@protoc_insertion_point(field_mutable:paddle.framework.proto.OpProto.type) + return _internal_mutable_type(); +} +inline const std::string& OpProto::_internal_type() const { + return type_.Get(); +} +inline void OpProto::_internal_set_type(const std::string& value) { + _has_bits_[0] |= 0x00000001u; + type_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); +} +inline void OpProto::set_type(std::string&& value) { + _has_bits_[0] |= 0x00000001u; + type_.Set( + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena()); + // @@protoc_insertion_point(field_set_rvalue:paddle.framework.proto.OpProto.type) +} +inline void OpProto::set_type(const char* value) { + GOOGLE_DCHECK(value != nullptr); + _has_bits_[0] |= 0x00000001u; + type_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena()); + // @@protoc_insertion_point(field_set_char:paddle.framework.proto.OpProto.type) +} +inline void OpProto::set_type(const char* value, + size_t size) { + _has_bits_[0] |= 0x00000001u; + type_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string( + reinterpret_cast(value), size), GetArena()); + // @@protoc_insertion_point(field_set_pointer:paddle.framework.proto.OpProto.type) +} +inline std::string* OpProto::_internal_mutable_type() { + _has_bits_[0] |= 0x00000001u; + return type_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); +} +inline std::string* OpProto::release_type() { + // @@protoc_insertion_point(field_release:paddle.framework.proto.OpProto.type) + if (!_internal_has_type()) { + return nullptr; + } + _has_bits_[0] &= ~0x00000001u; + return type_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); +} +inline void OpProto::set_allocated_type(std::string* type) { + if (type != nullptr) { + _has_bits_[0] |= 0x00000001u; + } else { + _has_bits_[0] &= ~0x00000001u; + } + type_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), type, + GetArena()); + // @@protoc_insertion_point(field_set_allocated:paddle.framework.proto.OpProto.type) +} + +// repeated .paddle.framework.proto.OpProto.Var inputs = 2; +inline int OpProto::_internal_inputs_size() const { + return inputs_.size(); +} +inline int OpProto::inputs_size() const { + return _internal_inputs_size(); +} +inline void OpProto::clear_inputs() { + inputs_.Clear(); +} +inline ::paddle::framework::proto::OpProto_Var* OpProto::mutable_inputs(int index) { + // @@protoc_insertion_point(field_mutable:paddle.framework.proto.OpProto.inputs) + return inputs_.Mutable(index); +} +inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::OpProto_Var >* +OpProto::mutable_inputs() { + // @@protoc_insertion_point(field_mutable_list:paddle.framework.proto.OpProto.inputs) + return &inputs_; +} +inline const ::paddle::framework::proto::OpProto_Var& OpProto::_internal_inputs(int index) const { + return inputs_.Get(index); +} +inline const ::paddle::framework::proto::OpProto_Var& OpProto::inputs(int index) const { + // @@protoc_insertion_point(field_get:paddle.framework.proto.OpProto.inputs) + return _internal_inputs(index); +} +inline ::paddle::framework::proto::OpProto_Var* OpProto::_internal_add_inputs() { + return inputs_.Add(); +} +inline ::paddle::framework::proto::OpProto_Var* OpProto::add_inputs() { + // @@protoc_insertion_point(field_add:paddle.framework.proto.OpProto.inputs) + return _internal_add_inputs(); +} +inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::OpProto_Var >& +OpProto::inputs() const { + // @@protoc_insertion_point(field_list:paddle.framework.proto.OpProto.inputs) + return inputs_; +} + +// repeated .paddle.framework.proto.OpProto.Var outputs = 3; +inline int OpProto::_internal_outputs_size() const { + return outputs_.size(); +} +inline int OpProto::outputs_size() const { + return _internal_outputs_size(); +} +inline void OpProto::clear_outputs() { + outputs_.Clear(); +} +inline ::paddle::framework::proto::OpProto_Var* OpProto::mutable_outputs(int index) { + // @@protoc_insertion_point(field_mutable:paddle.framework.proto.OpProto.outputs) + return outputs_.Mutable(index); +} +inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::OpProto_Var >* +OpProto::mutable_outputs() { + // @@protoc_insertion_point(field_mutable_list:paddle.framework.proto.OpProto.outputs) + return &outputs_; +} +inline const ::paddle::framework::proto::OpProto_Var& OpProto::_internal_outputs(int index) const { + return outputs_.Get(index); +} +inline const ::paddle::framework::proto::OpProto_Var& OpProto::outputs(int index) const { + // @@protoc_insertion_point(field_get:paddle.framework.proto.OpProto.outputs) + return _internal_outputs(index); +} +inline ::paddle::framework::proto::OpProto_Var* OpProto::_internal_add_outputs() { + return outputs_.Add(); +} +inline ::paddle::framework::proto::OpProto_Var* OpProto::add_outputs() { + // @@protoc_insertion_point(field_add:paddle.framework.proto.OpProto.outputs) + return _internal_add_outputs(); +} +inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::OpProto_Var >& +OpProto::outputs() const { + // @@protoc_insertion_point(field_list:paddle.framework.proto.OpProto.outputs) + return outputs_; +} + +// repeated .paddle.framework.proto.OpProto.Attr attrs = 4; +inline int OpProto::_internal_attrs_size() const { + return attrs_.size(); +} +inline int OpProto::attrs_size() const { + return _internal_attrs_size(); +} +inline void OpProto::clear_attrs() { + attrs_.Clear(); +} +inline ::paddle::framework::proto::OpProto_Attr* OpProto::mutable_attrs(int index) { + // @@protoc_insertion_point(field_mutable:paddle.framework.proto.OpProto.attrs) + return attrs_.Mutable(index); +} +inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::OpProto_Attr >* +OpProto::mutable_attrs() { + // @@protoc_insertion_point(field_mutable_list:paddle.framework.proto.OpProto.attrs) + return &attrs_; +} +inline const ::paddle::framework::proto::OpProto_Attr& OpProto::_internal_attrs(int index) const { + return attrs_.Get(index); +} +inline const ::paddle::framework::proto::OpProto_Attr& OpProto::attrs(int index) const { + // @@protoc_insertion_point(field_get:paddle.framework.proto.OpProto.attrs) + return _internal_attrs(index); +} +inline ::paddle::framework::proto::OpProto_Attr* OpProto::_internal_add_attrs() { + return attrs_.Add(); +} +inline ::paddle::framework::proto::OpProto_Attr* OpProto::add_attrs() { + // @@protoc_insertion_point(field_add:paddle.framework.proto.OpProto.attrs) + return _internal_add_attrs(); +} +inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::OpProto_Attr >& +OpProto::attrs() const { + // @@protoc_insertion_point(field_list:paddle.framework.proto.OpProto.attrs) + return attrs_; +} + +// required string comment = 5; +inline bool OpProto::_internal_has_comment() const { + bool value = (_has_bits_[0] & 0x00000002u) != 0; + return value; +} +inline bool OpProto::has_comment() const { + return _internal_has_comment(); +} +inline void OpProto::clear_comment() { + comment_.ClearToEmpty(); + _has_bits_[0] &= ~0x00000002u; +} +inline const std::string& OpProto::comment() const { + // @@protoc_insertion_point(field_get:paddle.framework.proto.OpProto.comment) + return _internal_comment(); +} +inline void OpProto::set_comment(const std::string& value) { + _internal_set_comment(value); + // @@protoc_insertion_point(field_set:paddle.framework.proto.OpProto.comment) +} +inline std::string* OpProto::mutable_comment() { + // @@protoc_insertion_point(field_mutable:paddle.framework.proto.OpProto.comment) + return _internal_mutable_comment(); +} +inline const std::string& OpProto::_internal_comment() const { + return comment_.Get(); +} +inline void OpProto::_internal_set_comment(const std::string& value) { + _has_bits_[0] |= 0x00000002u; + comment_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); +} +inline void OpProto::set_comment(std::string&& value) { + _has_bits_[0] |= 0x00000002u; + comment_.Set( + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena()); + // @@protoc_insertion_point(field_set_rvalue:paddle.framework.proto.OpProto.comment) +} +inline void OpProto::set_comment(const char* value) { + GOOGLE_DCHECK(value != nullptr); + _has_bits_[0] |= 0x00000002u; + comment_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena()); + // @@protoc_insertion_point(field_set_char:paddle.framework.proto.OpProto.comment) +} +inline void OpProto::set_comment(const char* value, + size_t size) { + _has_bits_[0] |= 0x00000002u; + comment_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string( + reinterpret_cast(value), size), GetArena()); + // @@protoc_insertion_point(field_set_pointer:paddle.framework.proto.OpProto.comment) +} +inline std::string* OpProto::_internal_mutable_comment() { + _has_bits_[0] |= 0x00000002u; + return comment_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); +} +inline std::string* OpProto::release_comment() { + // @@protoc_insertion_point(field_release:paddle.framework.proto.OpProto.comment) + if (!_internal_has_comment()) { + return nullptr; + } + _has_bits_[0] &= ~0x00000002u; + return comment_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); +} +inline void OpProto::set_allocated_comment(std::string* comment) { + if (comment != nullptr) { + _has_bits_[0] |= 0x00000002u; + } else { + _has_bits_[0] &= ~0x00000002u; + } + comment_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), comment, + GetArena()); + // @@protoc_insertion_point(field_set_allocated:paddle.framework.proto.OpProto.comment) +} + +// ------------------------------------------------------------------- + +// VarType_TensorDesc + +// required .paddle.framework.proto.VarType.Type data_type = 1; +inline bool VarType_TensorDesc::_internal_has_data_type() const { + bool value = (_has_bits_[0] & 0x00000001u) != 0; + return value; +} +inline bool VarType_TensorDesc::has_data_type() const { + return _internal_has_data_type(); +} +inline void VarType_TensorDesc::clear_data_type() { + data_type_ = 0; + _has_bits_[0] &= ~0x00000001u; +} +inline ::paddle::framework::proto::VarType_Type VarType_TensorDesc::_internal_data_type() const { + return static_cast< ::paddle::framework::proto::VarType_Type >(data_type_); +} +inline ::paddle::framework::proto::VarType_Type VarType_TensorDesc::data_type() const { + // @@protoc_insertion_point(field_get:paddle.framework.proto.VarType.TensorDesc.data_type) + return _internal_data_type(); +} +inline void VarType_TensorDesc::_internal_set_data_type(::paddle::framework::proto::VarType_Type value) { + assert(::paddle::framework::proto::VarType_Type_IsValid(value)); + _has_bits_[0] |= 0x00000001u; + data_type_ = value; +} +inline void VarType_TensorDesc::set_data_type(::paddle::framework::proto::VarType_Type value) { + _internal_set_data_type(value); + // @@protoc_insertion_point(field_set:paddle.framework.proto.VarType.TensorDesc.data_type) +} + +// repeated int64 dims = 2; +inline int VarType_TensorDesc::_internal_dims_size() const { + return dims_.size(); +} +inline int VarType_TensorDesc::dims_size() const { + return _internal_dims_size(); +} +inline void VarType_TensorDesc::clear_dims() { + dims_.Clear(); +} +inline ::PROTOBUF_NAMESPACE_ID::int64 VarType_TensorDesc::_internal_dims(int index) const { + return dims_.Get(index); +} +inline ::PROTOBUF_NAMESPACE_ID::int64 VarType_TensorDesc::dims(int index) const { + // @@protoc_insertion_point(field_get:paddle.framework.proto.VarType.TensorDesc.dims) + return _internal_dims(index); +} +inline void VarType_TensorDesc::set_dims(int index, ::PROTOBUF_NAMESPACE_ID::int64 value) { + dims_.Set(index, value); + // @@protoc_insertion_point(field_set:paddle.framework.proto.VarType.TensorDesc.dims) +} +inline void VarType_TensorDesc::_internal_add_dims(::PROTOBUF_NAMESPACE_ID::int64 value) { + dims_.Add(value); +} +inline void VarType_TensorDesc::add_dims(::PROTOBUF_NAMESPACE_ID::int64 value) { + _internal_add_dims(value); + // @@protoc_insertion_point(field_add:paddle.framework.proto.VarType.TensorDesc.dims) +} +inline const ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int64 >& +VarType_TensorDesc::_internal_dims() const { + return dims_; +} +inline const ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int64 >& +VarType_TensorDesc::dims() const { + // @@protoc_insertion_point(field_list:paddle.framework.proto.VarType.TensorDesc.dims) + return _internal_dims(); +} +inline ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int64 >* +VarType_TensorDesc::_internal_mutable_dims() { + return &dims_; +} +inline ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int64 >* +VarType_TensorDesc::mutable_dims() { + // @@protoc_insertion_point(field_mutable_list:paddle.framework.proto.VarType.TensorDesc.dims) + return _internal_mutable_dims(); +} + +// ------------------------------------------------------------------- + +// VarType_LoDTensorDesc + +// required .paddle.framework.proto.VarType.TensorDesc tensor = 1; +inline bool VarType_LoDTensorDesc::_internal_has_tensor() const { + bool value = (_has_bits_[0] & 0x00000001u) != 0; + PROTOBUF_ASSUME(!value || tensor_ != nullptr); + return value; +} +inline bool VarType_LoDTensorDesc::has_tensor() const { + return _internal_has_tensor(); +} +inline void VarType_LoDTensorDesc::clear_tensor() { + if (tensor_ != nullptr) tensor_->Clear(); + _has_bits_[0] &= ~0x00000001u; +} +inline const ::paddle::framework::proto::VarType_TensorDesc& VarType_LoDTensorDesc::_internal_tensor() const { + const ::paddle::framework::proto::VarType_TensorDesc* p = tensor_; + return p != nullptr ? *p : reinterpret_cast( + ::paddle::framework::proto::_VarType_TensorDesc_default_instance_); +} +inline const ::paddle::framework::proto::VarType_TensorDesc& VarType_LoDTensorDesc::tensor() const { + // @@protoc_insertion_point(field_get:paddle.framework.proto.VarType.LoDTensorDesc.tensor) + return _internal_tensor(); +} +inline void VarType_LoDTensorDesc::unsafe_arena_set_allocated_tensor( + ::paddle::framework::proto::VarType_TensorDesc* tensor) { + if (GetArena() == nullptr) { + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(tensor_); + } + tensor_ = tensor; + if (tensor) { + _has_bits_[0] |= 0x00000001u; + } else { + _has_bits_[0] &= ~0x00000001u; + } + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:paddle.framework.proto.VarType.LoDTensorDesc.tensor) +} +inline ::paddle::framework::proto::VarType_TensorDesc* VarType_LoDTensorDesc::release_tensor() { + _has_bits_[0] &= ~0x00000001u; + ::paddle::framework::proto::VarType_TensorDesc* temp = tensor_; + tensor_ = nullptr; + if (GetArena() != nullptr) { + temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); + } + return temp; +} +inline ::paddle::framework::proto::VarType_TensorDesc* VarType_LoDTensorDesc::unsafe_arena_release_tensor() { + // @@protoc_insertion_point(field_release:paddle.framework.proto.VarType.LoDTensorDesc.tensor) + _has_bits_[0] &= ~0x00000001u; + ::paddle::framework::proto::VarType_TensorDesc* temp = tensor_; + tensor_ = nullptr; + return temp; +} +inline ::paddle::framework::proto::VarType_TensorDesc* VarType_LoDTensorDesc::_internal_mutable_tensor() { + _has_bits_[0] |= 0x00000001u; + if (tensor_ == nullptr) { + auto* p = CreateMaybeMessage<::paddle::framework::proto::VarType_TensorDesc>(GetArena()); + tensor_ = p; + } + return tensor_; +} +inline ::paddle::framework::proto::VarType_TensorDesc* VarType_LoDTensorDesc::mutable_tensor() { + // @@protoc_insertion_point(field_mutable:paddle.framework.proto.VarType.LoDTensorDesc.tensor) + return _internal_mutable_tensor(); +} +inline void VarType_LoDTensorDesc::set_allocated_tensor(::paddle::framework::proto::VarType_TensorDesc* tensor) { + ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArena(); + if (message_arena == nullptr) { + delete tensor_; + } + if (tensor) { + ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = + ::PROTOBUF_NAMESPACE_ID::Arena::GetArena(tensor); + if (message_arena != submessage_arena) { + tensor = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( + message_arena, tensor, submessage_arena); + } + _has_bits_[0] |= 0x00000001u; + } else { + _has_bits_[0] &= ~0x00000001u; + } + tensor_ = tensor; + // @@protoc_insertion_point(field_set_allocated:paddle.framework.proto.VarType.LoDTensorDesc.tensor) +} + +// optional int32 lod_level = 2 [default = 0]; +inline bool VarType_LoDTensorDesc::_internal_has_lod_level() const { + bool value = (_has_bits_[0] & 0x00000002u) != 0; + return value; +} +inline bool VarType_LoDTensorDesc::has_lod_level() const { + return _internal_has_lod_level(); +} +inline void VarType_LoDTensorDesc::clear_lod_level() { + lod_level_ = 0; + _has_bits_[0] &= ~0x00000002u; +} +inline ::PROTOBUF_NAMESPACE_ID::int32 VarType_LoDTensorDesc::_internal_lod_level() const { + return lod_level_; +} +inline ::PROTOBUF_NAMESPACE_ID::int32 VarType_LoDTensorDesc::lod_level() const { + // @@protoc_insertion_point(field_get:paddle.framework.proto.VarType.LoDTensorDesc.lod_level) + return _internal_lod_level(); +} +inline void VarType_LoDTensorDesc::_internal_set_lod_level(::PROTOBUF_NAMESPACE_ID::int32 value) { + _has_bits_[0] |= 0x00000002u; + lod_level_ = value; +} +inline void VarType_LoDTensorDesc::set_lod_level(::PROTOBUF_NAMESPACE_ID::int32 value) { + _internal_set_lod_level(value); + // @@protoc_insertion_point(field_set:paddle.framework.proto.VarType.LoDTensorDesc.lod_level) +} + +// ------------------------------------------------------------------- + +// VarType_LoDTensorArrayDesc + +// required .paddle.framework.proto.VarType.TensorDesc tensor = 1; +inline bool VarType_LoDTensorArrayDesc::_internal_has_tensor() const { + bool value = (_has_bits_[0] & 0x00000001u) != 0; + PROTOBUF_ASSUME(!value || tensor_ != nullptr); + return value; +} +inline bool VarType_LoDTensorArrayDesc::has_tensor() const { + return _internal_has_tensor(); +} +inline void VarType_LoDTensorArrayDesc::clear_tensor() { + if (tensor_ != nullptr) tensor_->Clear(); + _has_bits_[0] &= ~0x00000001u; +} +inline const ::paddle::framework::proto::VarType_TensorDesc& VarType_LoDTensorArrayDesc::_internal_tensor() const { + const ::paddle::framework::proto::VarType_TensorDesc* p = tensor_; + return p != nullptr ? *p : reinterpret_cast( + ::paddle::framework::proto::_VarType_TensorDesc_default_instance_); +} +inline const ::paddle::framework::proto::VarType_TensorDesc& VarType_LoDTensorArrayDesc::tensor() const { + // @@protoc_insertion_point(field_get:paddle.framework.proto.VarType.LoDTensorArrayDesc.tensor) + return _internal_tensor(); +} +inline void VarType_LoDTensorArrayDesc::unsafe_arena_set_allocated_tensor( + ::paddle::framework::proto::VarType_TensorDesc* tensor) { + if (GetArena() == nullptr) { + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(tensor_); + } + tensor_ = tensor; + if (tensor) { + _has_bits_[0] |= 0x00000001u; + } else { + _has_bits_[0] &= ~0x00000001u; + } + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:paddle.framework.proto.VarType.LoDTensorArrayDesc.tensor) +} +inline ::paddle::framework::proto::VarType_TensorDesc* VarType_LoDTensorArrayDesc::release_tensor() { + _has_bits_[0] &= ~0x00000001u; + ::paddle::framework::proto::VarType_TensorDesc* temp = tensor_; + tensor_ = nullptr; + if (GetArena() != nullptr) { + temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); + } + return temp; +} +inline ::paddle::framework::proto::VarType_TensorDesc* VarType_LoDTensorArrayDesc::unsafe_arena_release_tensor() { + // @@protoc_insertion_point(field_release:paddle.framework.proto.VarType.LoDTensorArrayDesc.tensor) + _has_bits_[0] &= ~0x00000001u; + ::paddle::framework::proto::VarType_TensorDesc* temp = tensor_; + tensor_ = nullptr; + return temp; +} +inline ::paddle::framework::proto::VarType_TensorDesc* VarType_LoDTensorArrayDesc::_internal_mutable_tensor() { + _has_bits_[0] |= 0x00000001u; + if (tensor_ == nullptr) { + auto* p = CreateMaybeMessage<::paddle::framework::proto::VarType_TensorDesc>(GetArena()); + tensor_ = p; + } + return tensor_; +} +inline ::paddle::framework::proto::VarType_TensorDesc* VarType_LoDTensorArrayDesc::mutable_tensor() { + // @@protoc_insertion_point(field_mutable:paddle.framework.proto.VarType.LoDTensorArrayDesc.tensor) + return _internal_mutable_tensor(); +} +inline void VarType_LoDTensorArrayDesc::set_allocated_tensor(::paddle::framework::proto::VarType_TensorDesc* tensor) { + ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArena(); + if (message_arena == nullptr) { + delete tensor_; + } + if (tensor) { + ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = + ::PROTOBUF_NAMESPACE_ID::Arena::GetArena(tensor); + if (message_arena != submessage_arena) { + tensor = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( + message_arena, tensor, submessage_arena); + } + _has_bits_[0] |= 0x00000001u; + } else { + _has_bits_[0] &= ~0x00000001u; + } + tensor_ = tensor; + // @@protoc_insertion_point(field_set_allocated:paddle.framework.proto.VarType.LoDTensorArrayDesc.tensor) +} + +// optional int32 lod_level = 2 [default = 0]; +inline bool VarType_LoDTensorArrayDesc::_internal_has_lod_level() const { + bool value = (_has_bits_[0] & 0x00000002u) != 0; + return value; +} +inline bool VarType_LoDTensorArrayDesc::has_lod_level() const { + return _internal_has_lod_level(); +} +inline void VarType_LoDTensorArrayDesc::clear_lod_level() { + lod_level_ = 0; + _has_bits_[0] &= ~0x00000002u; +} +inline ::PROTOBUF_NAMESPACE_ID::int32 VarType_LoDTensorArrayDesc::_internal_lod_level() const { + return lod_level_; +} +inline ::PROTOBUF_NAMESPACE_ID::int32 VarType_LoDTensorArrayDesc::lod_level() const { + // @@protoc_insertion_point(field_get:paddle.framework.proto.VarType.LoDTensorArrayDesc.lod_level) + return _internal_lod_level(); +} +inline void VarType_LoDTensorArrayDesc::_internal_set_lod_level(::PROTOBUF_NAMESPACE_ID::int32 value) { + _has_bits_[0] |= 0x00000002u; + lod_level_ = value; +} +inline void VarType_LoDTensorArrayDesc::set_lod_level(::PROTOBUF_NAMESPACE_ID::int32 value) { + _internal_set_lod_level(value); + // @@protoc_insertion_point(field_set:paddle.framework.proto.VarType.LoDTensorArrayDesc.lod_level) +} + +// ------------------------------------------------------------------- + +// VarType_ReaderDesc + +// repeated .paddle.framework.proto.VarType.LoDTensorDesc lod_tensor = 1; +inline int VarType_ReaderDesc::_internal_lod_tensor_size() const { + return lod_tensor_.size(); +} +inline int VarType_ReaderDesc::lod_tensor_size() const { + return _internal_lod_tensor_size(); +} +inline void VarType_ReaderDesc::clear_lod_tensor() { + lod_tensor_.Clear(); +} +inline ::paddle::framework::proto::VarType_LoDTensorDesc* VarType_ReaderDesc::mutable_lod_tensor(int index) { + // @@protoc_insertion_point(field_mutable:paddle.framework.proto.VarType.ReaderDesc.lod_tensor) + return lod_tensor_.Mutable(index); +} +inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::VarType_LoDTensorDesc >* +VarType_ReaderDesc::mutable_lod_tensor() { + // @@protoc_insertion_point(field_mutable_list:paddle.framework.proto.VarType.ReaderDesc.lod_tensor) + return &lod_tensor_; +} +inline const ::paddle::framework::proto::VarType_LoDTensorDesc& VarType_ReaderDesc::_internal_lod_tensor(int index) const { + return lod_tensor_.Get(index); +} +inline const ::paddle::framework::proto::VarType_LoDTensorDesc& VarType_ReaderDesc::lod_tensor(int index) const { + // @@protoc_insertion_point(field_get:paddle.framework.proto.VarType.ReaderDesc.lod_tensor) + return _internal_lod_tensor(index); +} +inline ::paddle::framework::proto::VarType_LoDTensorDesc* VarType_ReaderDesc::_internal_add_lod_tensor() { + return lod_tensor_.Add(); +} +inline ::paddle::framework::proto::VarType_LoDTensorDesc* VarType_ReaderDesc::add_lod_tensor() { + // @@protoc_insertion_point(field_add:paddle.framework.proto.VarType.ReaderDesc.lod_tensor) + return _internal_add_lod_tensor(); +} +inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::VarType_LoDTensorDesc >& +VarType_ReaderDesc::lod_tensor() const { + // @@protoc_insertion_point(field_list:paddle.framework.proto.VarType.ReaderDesc.lod_tensor) + return lod_tensor_; +} + +// ------------------------------------------------------------------- + +// VarType_Tuple + +// repeated .paddle.framework.proto.VarType.Type element_type = 1; +inline int VarType_Tuple::_internal_element_type_size() const { + return element_type_.size(); +} +inline int VarType_Tuple::element_type_size() const { + return _internal_element_type_size(); +} +inline void VarType_Tuple::clear_element_type() { + element_type_.Clear(); +} +inline ::paddle::framework::proto::VarType_Type VarType_Tuple::_internal_element_type(int index) const { + return static_cast< ::paddle::framework::proto::VarType_Type >(element_type_.Get(index)); +} +inline ::paddle::framework::proto::VarType_Type VarType_Tuple::element_type(int index) const { + // @@protoc_insertion_point(field_get:paddle.framework.proto.VarType.Tuple.element_type) + return _internal_element_type(index); +} +inline void VarType_Tuple::set_element_type(int index, ::paddle::framework::proto::VarType_Type value) { + assert(::paddle::framework::proto::VarType_Type_IsValid(value)); + element_type_.Set(index, value); + // @@protoc_insertion_point(field_set:paddle.framework.proto.VarType.Tuple.element_type) +} +inline void VarType_Tuple::_internal_add_element_type(::paddle::framework::proto::VarType_Type value) { + assert(::paddle::framework::proto::VarType_Type_IsValid(value)); + element_type_.Add(value); +} +inline void VarType_Tuple::add_element_type(::paddle::framework::proto::VarType_Type value) { + // @@protoc_insertion_point(field_add:paddle.framework.proto.VarType.Tuple.element_type) + _internal_add_element_type(value); +} +inline const ::PROTOBUF_NAMESPACE_ID::RepeatedField& +VarType_Tuple::element_type() const { + // @@protoc_insertion_point(field_list:paddle.framework.proto.VarType.Tuple.element_type) + return element_type_; +} +inline ::PROTOBUF_NAMESPACE_ID::RepeatedField* +VarType_Tuple::_internal_mutable_element_type() { + return &element_type_; +} +inline ::PROTOBUF_NAMESPACE_ID::RepeatedField* +VarType_Tuple::mutable_element_type() { + // @@protoc_insertion_point(field_mutable_list:paddle.framework.proto.VarType.Tuple.element_type) + return _internal_mutable_element_type(); +} + +// ------------------------------------------------------------------- + +// VarType + +// required .paddle.framework.proto.VarType.Type type = 1; +inline bool VarType::_internal_has_type() const { + bool value = (_has_bits_[0] & 0x00000020u) != 0; + return value; +} +inline bool VarType::has_type() const { + return _internal_has_type(); +} +inline void VarType::clear_type() { + type_ = 0; + _has_bits_[0] &= ~0x00000020u; +} +inline ::paddle::framework::proto::VarType_Type VarType::_internal_type() const { + return static_cast< ::paddle::framework::proto::VarType_Type >(type_); +} +inline ::paddle::framework::proto::VarType_Type VarType::type() const { + // @@protoc_insertion_point(field_get:paddle.framework.proto.VarType.type) + return _internal_type(); +} +inline void VarType::_internal_set_type(::paddle::framework::proto::VarType_Type value) { + assert(::paddle::framework::proto::VarType_Type_IsValid(value)); + _has_bits_[0] |= 0x00000020u; + type_ = value; +} +inline void VarType::set_type(::paddle::framework::proto::VarType_Type value) { + _internal_set_type(value); + // @@protoc_insertion_point(field_set:paddle.framework.proto.VarType.type) +} + +// optional .paddle.framework.proto.VarType.TensorDesc selected_rows = 2; +inline bool VarType::_internal_has_selected_rows() const { + bool value = (_has_bits_[0] & 0x00000001u) != 0; + PROTOBUF_ASSUME(!value || selected_rows_ != nullptr); + return value; +} +inline bool VarType::has_selected_rows() const { + return _internal_has_selected_rows(); +} +inline void VarType::clear_selected_rows() { + if (selected_rows_ != nullptr) selected_rows_->Clear(); + _has_bits_[0] &= ~0x00000001u; +} +inline const ::paddle::framework::proto::VarType_TensorDesc& VarType::_internal_selected_rows() const { + const ::paddle::framework::proto::VarType_TensorDesc* p = selected_rows_; + return p != nullptr ? *p : reinterpret_cast( + ::paddle::framework::proto::_VarType_TensorDesc_default_instance_); +} +inline const ::paddle::framework::proto::VarType_TensorDesc& VarType::selected_rows() const { + // @@protoc_insertion_point(field_get:paddle.framework.proto.VarType.selected_rows) + return _internal_selected_rows(); +} +inline void VarType::unsafe_arena_set_allocated_selected_rows( + ::paddle::framework::proto::VarType_TensorDesc* selected_rows) { + if (GetArena() == nullptr) { + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(selected_rows_); + } + selected_rows_ = selected_rows; + if (selected_rows) { + _has_bits_[0] |= 0x00000001u; + } else { + _has_bits_[0] &= ~0x00000001u; + } + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:paddle.framework.proto.VarType.selected_rows) +} +inline ::paddle::framework::proto::VarType_TensorDesc* VarType::release_selected_rows() { + _has_bits_[0] &= ~0x00000001u; + ::paddle::framework::proto::VarType_TensorDesc* temp = selected_rows_; + selected_rows_ = nullptr; + if (GetArena() != nullptr) { + temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); + } + return temp; +} +inline ::paddle::framework::proto::VarType_TensorDesc* VarType::unsafe_arena_release_selected_rows() { + // @@protoc_insertion_point(field_release:paddle.framework.proto.VarType.selected_rows) + _has_bits_[0] &= ~0x00000001u; + ::paddle::framework::proto::VarType_TensorDesc* temp = selected_rows_; + selected_rows_ = nullptr; + return temp; +} +inline ::paddle::framework::proto::VarType_TensorDesc* VarType::_internal_mutable_selected_rows() { + _has_bits_[0] |= 0x00000001u; + if (selected_rows_ == nullptr) { + auto* p = CreateMaybeMessage<::paddle::framework::proto::VarType_TensorDesc>(GetArena()); + selected_rows_ = p; + } + return selected_rows_; +} +inline ::paddle::framework::proto::VarType_TensorDesc* VarType::mutable_selected_rows() { + // @@protoc_insertion_point(field_mutable:paddle.framework.proto.VarType.selected_rows) + return _internal_mutable_selected_rows(); +} +inline void VarType::set_allocated_selected_rows(::paddle::framework::proto::VarType_TensorDesc* selected_rows) { + ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArena(); + if (message_arena == nullptr) { + delete selected_rows_; + } + if (selected_rows) { + ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = + ::PROTOBUF_NAMESPACE_ID::Arena::GetArena(selected_rows); + if (message_arena != submessage_arena) { + selected_rows = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( + message_arena, selected_rows, submessage_arena); + } + _has_bits_[0] |= 0x00000001u; + } else { + _has_bits_[0] &= ~0x00000001u; + } + selected_rows_ = selected_rows; + // @@protoc_insertion_point(field_set_allocated:paddle.framework.proto.VarType.selected_rows) +} + +// optional .paddle.framework.proto.VarType.LoDTensorDesc lod_tensor = 3; +inline bool VarType::_internal_has_lod_tensor() const { + bool value = (_has_bits_[0] & 0x00000002u) != 0; + PROTOBUF_ASSUME(!value || lod_tensor_ != nullptr); + return value; +} +inline bool VarType::has_lod_tensor() const { + return _internal_has_lod_tensor(); +} +inline void VarType::clear_lod_tensor() { + if (lod_tensor_ != nullptr) lod_tensor_->Clear(); + _has_bits_[0] &= ~0x00000002u; +} +inline const ::paddle::framework::proto::VarType_LoDTensorDesc& VarType::_internal_lod_tensor() const { + const ::paddle::framework::proto::VarType_LoDTensorDesc* p = lod_tensor_; + return p != nullptr ? *p : reinterpret_cast( + ::paddle::framework::proto::_VarType_LoDTensorDesc_default_instance_); +} +inline const ::paddle::framework::proto::VarType_LoDTensorDesc& VarType::lod_tensor() const { + // @@protoc_insertion_point(field_get:paddle.framework.proto.VarType.lod_tensor) + return _internal_lod_tensor(); +} +inline void VarType::unsafe_arena_set_allocated_lod_tensor( + ::paddle::framework::proto::VarType_LoDTensorDesc* lod_tensor) { + if (GetArena() == nullptr) { + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(lod_tensor_); + } + lod_tensor_ = lod_tensor; + if (lod_tensor) { + _has_bits_[0] |= 0x00000002u; + } else { + _has_bits_[0] &= ~0x00000002u; + } + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:paddle.framework.proto.VarType.lod_tensor) +} +inline ::paddle::framework::proto::VarType_LoDTensorDesc* VarType::release_lod_tensor() { + _has_bits_[0] &= ~0x00000002u; + ::paddle::framework::proto::VarType_LoDTensorDesc* temp = lod_tensor_; + lod_tensor_ = nullptr; + if (GetArena() != nullptr) { + temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); + } + return temp; +} +inline ::paddle::framework::proto::VarType_LoDTensorDesc* VarType::unsafe_arena_release_lod_tensor() { + // @@protoc_insertion_point(field_release:paddle.framework.proto.VarType.lod_tensor) + _has_bits_[0] &= ~0x00000002u; + ::paddle::framework::proto::VarType_LoDTensorDesc* temp = lod_tensor_; + lod_tensor_ = nullptr; + return temp; +} +inline ::paddle::framework::proto::VarType_LoDTensorDesc* VarType::_internal_mutable_lod_tensor() { + _has_bits_[0] |= 0x00000002u; + if (lod_tensor_ == nullptr) { + auto* p = CreateMaybeMessage<::paddle::framework::proto::VarType_LoDTensorDesc>(GetArena()); + lod_tensor_ = p; + } + return lod_tensor_; +} +inline ::paddle::framework::proto::VarType_LoDTensorDesc* VarType::mutable_lod_tensor() { + // @@protoc_insertion_point(field_mutable:paddle.framework.proto.VarType.lod_tensor) + return _internal_mutable_lod_tensor(); +} +inline void VarType::set_allocated_lod_tensor(::paddle::framework::proto::VarType_LoDTensorDesc* lod_tensor) { + ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArena(); + if (message_arena == nullptr) { + delete lod_tensor_; + } + if (lod_tensor) { + ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = + ::PROTOBUF_NAMESPACE_ID::Arena::GetArena(lod_tensor); + if (message_arena != submessage_arena) { + lod_tensor = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( + message_arena, lod_tensor, submessage_arena); + } + _has_bits_[0] |= 0x00000002u; + } else { + _has_bits_[0] &= ~0x00000002u; + } + lod_tensor_ = lod_tensor; + // @@protoc_insertion_point(field_set_allocated:paddle.framework.proto.VarType.lod_tensor) +} + +// optional .paddle.framework.proto.VarType.LoDTensorArrayDesc tensor_array = 4; +inline bool VarType::_internal_has_tensor_array() const { + bool value = (_has_bits_[0] & 0x00000004u) != 0; + PROTOBUF_ASSUME(!value || tensor_array_ != nullptr); + return value; +} +inline bool VarType::has_tensor_array() const { + return _internal_has_tensor_array(); +} +inline void VarType::clear_tensor_array() { + if (tensor_array_ != nullptr) tensor_array_->Clear(); + _has_bits_[0] &= ~0x00000004u; +} +inline const ::paddle::framework::proto::VarType_LoDTensorArrayDesc& VarType::_internal_tensor_array() const { + const ::paddle::framework::proto::VarType_LoDTensorArrayDesc* p = tensor_array_; + return p != nullptr ? *p : reinterpret_cast( + ::paddle::framework::proto::_VarType_LoDTensorArrayDesc_default_instance_); +} +inline const ::paddle::framework::proto::VarType_LoDTensorArrayDesc& VarType::tensor_array() const { + // @@protoc_insertion_point(field_get:paddle.framework.proto.VarType.tensor_array) + return _internal_tensor_array(); +} +inline void VarType::unsafe_arena_set_allocated_tensor_array( + ::paddle::framework::proto::VarType_LoDTensorArrayDesc* tensor_array) { + if (GetArena() == nullptr) { + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(tensor_array_); + } + tensor_array_ = tensor_array; + if (tensor_array) { + _has_bits_[0] |= 0x00000004u; + } else { + _has_bits_[0] &= ~0x00000004u; + } + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:paddle.framework.proto.VarType.tensor_array) +} +inline ::paddle::framework::proto::VarType_LoDTensorArrayDesc* VarType::release_tensor_array() { + _has_bits_[0] &= ~0x00000004u; + ::paddle::framework::proto::VarType_LoDTensorArrayDesc* temp = tensor_array_; + tensor_array_ = nullptr; + if (GetArena() != nullptr) { + temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); + } + return temp; +} +inline ::paddle::framework::proto::VarType_LoDTensorArrayDesc* VarType::unsafe_arena_release_tensor_array() { + // @@protoc_insertion_point(field_release:paddle.framework.proto.VarType.tensor_array) + _has_bits_[0] &= ~0x00000004u; + ::paddle::framework::proto::VarType_LoDTensorArrayDesc* temp = tensor_array_; + tensor_array_ = nullptr; + return temp; +} +inline ::paddle::framework::proto::VarType_LoDTensorArrayDesc* VarType::_internal_mutable_tensor_array() { + _has_bits_[0] |= 0x00000004u; + if (tensor_array_ == nullptr) { + auto* p = CreateMaybeMessage<::paddle::framework::proto::VarType_LoDTensorArrayDesc>(GetArena()); + tensor_array_ = p; + } + return tensor_array_; +} +inline ::paddle::framework::proto::VarType_LoDTensorArrayDesc* VarType::mutable_tensor_array() { + // @@protoc_insertion_point(field_mutable:paddle.framework.proto.VarType.tensor_array) + return _internal_mutable_tensor_array(); +} +inline void VarType::set_allocated_tensor_array(::paddle::framework::proto::VarType_LoDTensorArrayDesc* tensor_array) { + ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArena(); + if (message_arena == nullptr) { + delete tensor_array_; + } + if (tensor_array) { + ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = + ::PROTOBUF_NAMESPACE_ID::Arena::GetArena(tensor_array); + if (message_arena != submessage_arena) { + tensor_array = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( + message_arena, tensor_array, submessage_arena); + } + _has_bits_[0] |= 0x00000004u; + } else { + _has_bits_[0] &= ~0x00000004u; + } + tensor_array_ = tensor_array; + // @@protoc_insertion_point(field_set_allocated:paddle.framework.proto.VarType.tensor_array) +} + +// optional .paddle.framework.proto.VarType.ReaderDesc reader = 5; +inline bool VarType::_internal_has_reader() const { + bool value = (_has_bits_[0] & 0x00000008u) != 0; + PROTOBUF_ASSUME(!value || reader_ != nullptr); + return value; +} +inline bool VarType::has_reader() const { + return _internal_has_reader(); +} +inline void VarType::clear_reader() { + if (reader_ != nullptr) reader_->Clear(); + _has_bits_[0] &= ~0x00000008u; +} +inline const ::paddle::framework::proto::VarType_ReaderDesc& VarType::_internal_reader() const { + const ::paddle::framework::proto::VarType_ReaderDesc* p = reader_; + return p != nullptr ? *p : reinterpret_cast( + ::paddle::framework::proto::_VarType_ReaderDesc_default_instance_); +} +inline const ::paddle::framework::proto::VarType_ReaderDesc& VarType::reader() const { + // @@protoc_insertion_point(field_get:paddle.framework.proto.VarType.reader) + return _internal_reader(); +} +inline void VarType::unsafe_arena_set_allocated_reader( + ::paddle::framework::proto::VarType_ReaderDesc* reader) { + if (GetArena() == nullptr) { + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(reader_); + } + reader_ = reader; + if (reader) { + _has_bits_[0] |= 0x00000008u; + } else { + _has_bits_[0] &= ~0x00000008u; + } + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:paddle.framework.proto.VarType.reader) +} +inline ::paddle::framework::proto::VarType_ReaderDesc* VarType::release_reader() { + _has_bits_[0] &= ~0x00000008u; + ::paddle::framework::proto::VarType_ReaderDesc* temp = reader_; + reader_ = nullptr; + if (GetArena() != nullptr) { + temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); + } + return temp; +} +inline ::paddle::framework::proto::VarType_ReaderDesc* VarType::unsafe_arena_release_reader() { + // @@protoc_insertion_point(field_release:paddle.framework.proto.VarType.reader) + _has_bits_[0] &= ~0x00000008u; + ::paddle::framework::proto::VarType_ReaderDesc* temp = reader_; + reader_ = nullptr; + return temp; +} +inline ::paddle::framework::proto::VarType_ReaderDesc* VarType::_internal_mutable_reader() { + _has_bits_[0] |= 0x00000008u; + if (reader_ == nullptr) { + auto* p = CreateMaybeMessage<::paddle::framework::proto::VarType_ReaderDesc>(GetArena()); + reader_ = p; + } + return reader_; +} +inline ::paddle::framework::proto::VarType_ReaderDesc* VarType::mutable_reader() { + // @@protoc_insertion_point(field_mutable:paddle.framework.proto.VarType.reader) + return _internal_mutable_reader(); +} +inline void VarType::set_allocated_reader(::paddle::framework::proto::VarType_ReaderDesc* reader) { + ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArena(); + if (message_arena == nullptr) { + delete reader_; + } + if (reader) { + ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = + ::PROTOBUF_NAMESPACE_ID::Arena::GetArena(reader); + if (message_arena != submessage_arena) { + reader = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( + message_arena, reader, submessage_arena); + } + _has_bits_[0] |= 0x00000008u; + } else { + _has_bits_[0] &= ~0x00000008u; + } + reader_ = reader; + // @@protoc_insertion_point(field_set_allocated:paddle.framework.proto.VarType.reader) +} + +// optional .paddle.framework.proto.VarType.Tuple tuple = 7; +inline bool VarType::_internal_has_tuple() const { + bool value = (_has_bits_[0] & 0x00000010u) != 0; + PROTOBUF_ASSUME(!value || tuple_ != nullptr); + return value; +} +inline bool VarType::has_tuple() const { + return _internal_has_tuple(); +} +inline void VarType::clear_tuple() { + if (tuple_ != nullptr) tuple_->Clear(); + _has_bits_[0] &= ~0x00000010u; +} +inline const ::paddle::framework::proto::VarType_Tuple& VarType::_internal_tuple() const { + const ::paddle::framework::proto::VarType_Tuple* p = tuple_; + return p != nullptr ? *p : reinterpret_cast( + ::paddle::framework::proto::_VarType_Tuple_default_instance_); +} +inline const ::paddle::framework::proto::VarType_Tuple& VarType::tuple() const { + // @@protoc_insertion_point(field_get:paddle.framework.proto.VarType.tuple) + return _internal_tuple(); +} +inline void VarType::unsafe_arena_set_allocated_tuple( + ::paddle::framework::proto::VarType_Tuple* tuple) { + if (GetArena() == nullptr) { + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(tuple_); + } + tuple_ = tuple; + if (tuple) { + _has_bits_[0] |= 0x00000010u; + } else { + _has_bits_[0] &= ~0x00000010u; + } + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:paddle.framework.proto.VarType.tuple) +} +inline ::paddle::framework::proto::VarType_Tuple* VarType::release_tuple() { + _has_bits_[0] &= ~0x00000010u; + ::paddle::framework::proto::VarType_Tuple* temp = tuple_; + tuple_ = nullptr; + if (GetArena() != nullptr) { + temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); + } + return temp; +} +inline ::paddle::framework::proto::VarType_Tuple* VarType::unsafe_arena_release_tuple() { + // @@protoc_insertion_point(field_release:paddle.framework.proto.VarType.tuple) + _has_bits_[0] &= ~0x00000010u; + ::paddle::framework::proto::VarType_Tuple* temp = tuple_; + tuple_ = nullptr; + return temp; +} +inline ::paddle::framework::proto::VarType_Tuple* VarType::_internal_mutable_tuple() { + _has_bits_[0] |= 0x00000010u; + if (tuple_ == nullptr) { + auto* p = CreateMaybeMessage<::paddle::framework::proto::VarType_Tuple>(GetArena()); + tuple_ = p; + } + return tuple_; +} +inline ::paddle::framework::proto::VarType_Tuple* VarType::mutable_tuple() { + // @@protoc_insertion_point(field_mutable:paddle.framework.proto.VarType.tuple) + return _internal_mutable_tuple(); +} +inline void VarType::set_allocated_tuple(::paddle::framework::proto::VarType_Tuple* tuple) { + ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArena(); + if (message_arena == nullptr) { + delete tuple_; + } + if (tuple) { + ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = + ::PROTOBUF_NAMESPACE_ID::Arena::GetArena(tuple); + if (message_arena != submessage_arena) { + tuple = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( + message_arena, tuple, submessage_arena); + } + _has_bits_[0] |= 0x00000010u; + } else { + _has_bits_[0] &= ~0x00000010u; + } + tuple_ = tuple; + // @@protoc_insertion_point(field_set_allocated:paddle.framework.proto.VarType.tuple) +} + +// ------------------------------------------------------------------- + +// VarDesc + +// required string name = 1; +inline bool VarDesc::_internal_has_name() const { + bool value = (_has_bits_[0] & 0x00000001u) != 0; + return value; +} +inline bool VarDesc::has_name() const { + return _internal_has_name(); +} +inline void VarDesc::clear_name() { + name_.ClearToEmpty(); + _has_bits_[0] &= ~0x00000001u; +} +inline const std::string& VarDesc::name() const { + // @@protoc_insertion_point(field_get:paddle.framework.proto.VarDesc.name) + return _internal_name(); +} +inline void VarDesc::set_name(const std::string& value) { + _internal_set_name(value); + // @@protoc_insertion_point(field_set:paddle.framework.proto.VarDesc.name) +} +inline std::string* VarDesc::mutable_name() { + // @@protoc_insertion_point(field_mutable:paddle.framework.proto.VarDesc.name) + return _internal_mutable_name(); +} +inline const std::string& VarDesc::_internal_name() const { + return name_.Get(); +} +inline void VarDesc::_internal_set_name(const std::string& value) { + _has_bits_[0] |= 0x00000001u; + name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); +} +inline void VarDesc::set_name(std::string&& value) { + _has_bits_[0] |= 0x00000001u; + name_.Set( + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena()); + // @@protoc_insertion_point(field_set_rvalue:paddle.framework.proto.VarDesc.name) +} +inline void VarDesc::set_name(const char* value) { + GOOGLE_DCHECK(value != nullptr); + _has_bits_[0] |= 0x00000001u; + name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena()); + // @@protoc_insertion_point(field_set_char:paddle.framework.proto.VarDesc.name) +} +inline void VarDesc::set_name(const char* value, + size_t size) { + _has_bits_[0] |= 0x00000001u; + name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string( + reinterpret_cast(value), size), GetArena()); + // @@protoc_insertion_point(field_set_pointer:paddle.framework.proto.VarDesc.name) +} +inline std::string* VarDesc::_internal_mutable_name() { + _has_bits_[0] |= 0x00000001u; + return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); +} +inline std::string* VarDesc::release_name() { + // @@protoc_insertion_point(field_release:paddle.framework.proto.VarDesc.name) + if (!_internal_has_name()) { + return nullptr; + } + _has_bits_[0] &= ~0x00000001u; + return name_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); +} +inline void VarDesc::set_allocated_name(std::string* name) { + if (name != nullptr) { + _has_bits_[0] |= 0x00000001u; + } else { + _has_bits_[0] &= ~0x00000001u; + } + name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name, + GetArena()); + // @@protoc_insertion_point(field_set_allocated:paddle.framework.proto.VarDesc.name) +} + +// required .paddle.framework.proto.VarType type = 2; +inline bool VarDesc::_internal_has_type() const { + bool value = (_has_bits_[0] & 0x00000002u) != 0; + PROTOBUF_ASSUME(!value || type_ != nullptr); + return value; +} +inline bool VarDesc::has_type() const { + return _internal_has_type(); +} +inline void VarDesc::clear_type() { + if (type_ != nullptr) type_->Clear(); + _has_bits_[0] &= ~0x00000002u; +} +inline const ::paddle::framework::proto::VarType& VarDesc::_internal_type() const { + const ::paddle::framework::proto::VarType* p = type_; + return p != nullptr ? *p : reinterpret_cast( + ::paddle::framework::proto::_VarType_default_instance_); +} +inline const ::paddle::framework::proto::VarType& VarDesc::type() const { + // @@protoc_insertion_point(field_get:paddle.framework.proto.VarDesc.type) + return _internal_type(); +} +inline void VarDesc::unsafe_arena_set_allocated_type( + ::paddle::framework::proto::VarType* type) { + if (GetArena() == nullptr) { + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(type_); + } + type_ = type; + if (type) { + _has_bits_[0] |= 0x00000002u; + } else { + _has_bits_[0] &= ~0x00000002u; + } + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:paddle.framework.proto.VarDesc.type) +} +inline ::paddle::framework::proto::VarType* VarDesc::release_type() { + _has_bits_[0] &= ~0x00000002u; + ::paddle::framework::proto::VarType* temp = type_; + type_ = nullptr; + if (GetArena() != nullptr) { + temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); + } + return temp; +} +inline ::paddle::framework::proto::VarType* VarDesc::unsafe_arena_release_type() { + // @@protoc_insertion_point(field_release:paddle.framework.proto.VarDesc.type) + _has_bits_[0] &= ~0x00000002u; + ::paddle::framework::proto::VarType* temp = type_; + type_ = nullptr; + return temp; +} +inline ::paddle::framework::proto::VarType* VarDesc::_internal_mutable_type() { + _has_bits_[0] |= 0x00000002u; + if (type_ == nullptr) { + auto* p = CreateMaybeMessage<::paddle::framework::proto::VarType>(GetArena()); + type_ = p; + } + return type_; +} +inline ::paddle::framework::proto::VarType* VarDesc::mutable_type() { + // @@protoc_insertion_point(field_mutable:paddle.framework.proto.VarDesc.type) + return _internal_mutable_type(); +} +inline void VarDesc::set_allocated_type(::paddle::framework::proto::VarType* type) { + ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArena(); + if (message_arena == nullptr) { + delete type_; + } + if (type) { + ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = + ::PROTOBUF_NAMESPACE_ID::Arena::GetArena(type); + if (message_arena != submessage_arena) { + type = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( + message_arena, type, submessage_arena); + } + _has_bits_[0] |= 0x00000002u; + } else { + _has_bits_[0] &= ~0x00000002u; + } + type_ = type; + // @@protoc_insertion_point(field_set_allocated:paddle.framework.proto.VarDesc.type) +} + +// optional bool persistable = 3 [default = false]; +inline bool VarDesc::_internal_has_persistable() const { + bool value = (_has_bits_[0] & 0x00000004u) != 0; + return value; +} +inline bool VarDesc::has_persistable() const { + return _internal_has_persistable(); +} +inline void VarDesc::clear_persistable() { + persistable_ = false; + _has_bits_[0] &= ~0x00000004u; +} +inline bool VarDesc::_internal_persistable() const { + return persistable_; +} +inline bool VarDesc::persistable() const { + // @@protoc_insertion_point(field_get:paddle.framework.proto.VarDesc.persistable) + return _internal_persistable(); +} +inline void VarDesc::_internal_set_persistable(bool value) { + _has_bits_[0] |= 0x00000004u; + persistable_ = value; +} +inline void VarDesc::set_persistable(bool value) { + _internal_set_persistable(value); + // @@protoc_insertion_point(field_set:paddle.framework.proto.VarDesc.persistable) +} + +// optional bool need_check_feed = 4 [default = false]; +inline bool VarDesc::_internal_has_need_check_feed() const { + bool value = (_has_bits_[0] & 0x00000008u) != 0; + return value; +} +inline bool VarDesc::has_need_check_feed() const { + return _internal_has_need_check_feed(); +} +inline void VarDesc::clear_need_check_feed() { + need_check_feed_ = false; + _has_bits_[0] &= ~0x00000008u; +} +inline bool VarDesc::_internal_need_check_feed() const { + return need_check_feed_; +} +inline bool VarDesc::need_check_feed() const { + // @@protoc_insertion_point(field_get:paddle.framework.proto.VarDesc.need_check_feed) + return _internal_need_check_feed(); +} +inline void VarDesc::_internal_set_need_check_feed(bool value) { + _has_bits_[0] |= 0x00000008u; + need_check_feed_ = value; +} +inline void VarDesc::set_need_check_feed(bool value) { + _internal_set_need_check_feed(value); + // @@protoc_insertion_point(field_set:paddle.framework.proto.VarDesc.need_check_feed) +} + +// ------------------------------------------------------------------- + +// BlockDesc + +// required int32 idx = 1; +inline bool BlockDesc::_internal_has_idx() const { + bool value = (_has_bits_[0] & 0x00000001u) != 0; + return value; +} +inline bool BlockDesc::has_idx() const { + return _internal_has_idx(); +} +inline void BlockDesc::clear_idx() { + idx_ = 0; + _has_bits_[0] &= ~0x00000001u; +} +inline ::PROTOBUF_NAMESPACE_ID::int32 BlockDesc::_internal_idx() const { + return idx_; +} +inline ::PROTOBUF_NAMESPACE_ID::int32 BlockDesc::idx() const { + // @@protoc_insertion_point(field_get:paddle.framework.proto.BlockDesc.idx) + return _internal_idx(); +} +inline void BlockDesc::_internal_set_idx(::PROTOBUF_NAMESPACE_ID::int32 value) { + _has_bits_[0] |= 0x00000001u; + idx_ = value; +} +inline void BlockDesc::set_idx(::PROTOBUF_NAMESPACE_ID::int32 value) { + _internal_set_idx(value); + // @@protoc_insertion_point(field_set:paddle.framework.proto.BlockDesc.idx) +} + +// required int32 parent_idx = 2; +inline bool BlockDesc::_internal_has_parent_idx() const { + bool value = (_has_bits_[0] & 0x00000002u) != 0; + return value; +} +inline bool BlockDesc::has_parent_idx() const { + return _internal_has_parent_idx(); +} +inline void BlockDesc::clear_parent_idx() { + parent_idx_ = 0; + _has_bits_[0] &= ~0x00000002u; +} +inline ::PROTOBUF_NAMESPACE_ID::int32 BlockDesc::_internal_parent_idx() const { + return parent_idx_; +} +inline ::PROTOBUF_NAMESPACE_ID::int32 BlockDesc::parent_idx() const { + // @@protoc_insertion_point(field_get:paddle.framework.proto.BlockDesc.parent_idx) + return _internal_parent_idx(); +} +inline void BlockDesc::_internal_set_parent_idx(::PROTOBUF_NAMESPACE_ID::int32 value) { + _has_bits_[0] |= 0x00000002u; + parent_idx_ = value; +} +inline void BlockDesc::set_parent_idx(::PROTOBUF_NAMESPACE_ID::int32 value) { + _internal_set_parent_idx(value); + // @@protoc_insertion_point(field_set:paddle.framework.proto.BlockDesc.parent_idx) +} + +// repeated .paddle.framework.proto.VarDesc vars = 3; +inline int BlockDesc::_internal_vars_size() const { + return vars_.size(); +} +inline int BlockDesc::vars_size() const { + return _internal_vars_size(); +} +inline void BlockDesc::clear_vars() { + vars_.Clear(); +} +inline ::paddle::framework::proto::VarDesc* BlockDesc::mutable_vars(int index) { + // @@protoc_insertion_point(field_mutable:paddle.framework.proto.BlockDesc.vars) + return vars_.Mutable(index); +} +inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::VarDesc >* +BlockDesc::mutable_vars() { + // @@protoc_insertion_point(field_mutable_list:paddle.framework.proto.BlockDesc.vars) + return &vars_; +} +inline const ::paddle::framework::proto::VarDesc& BlockDesc::_internal_vars(int index) const { + return vars_.Get(index); +} +inline const ::paddle::framework::proto::VarDesc& BlockDesc::vars(int index) const { + // @@protoc_insertion_point(field_get:paddle.framework.proto.BlockDesc.vars) + return _internal_vars(index); +} +inline ::paddle::framework::proto::VarDesc* BlockDesc::_internal_add_vars() { + return vars_.Add(); +} +inline ::paddle::framework::proto::VarDesc* BlockDesc::add_vars() { + // @@protoc_insertion_point(field_add:paddle.framework.proto.BlockDesc.vars) + return _internal_add_vars(); +} +inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::VarDesc >& +BlockDesc::vars() const { + // @@protoc_insertion_point(field_list:paddle.framework.proto.BlockDesc.vars) + return vars_; +} + +// repeated .paddle.framework.proto.OpDesc ops = 4; +inline int BlockDesc::_internal_ops_size() const { + return ops_.size(); +} +inline int BlockDesc::ops_size() const { + return _internal_ops_size(); +} +inline void BlockDesc::clear_ops() { + ops_.Clear(); +} +inline ::paddle::framework::proto::OpDesc* BlockDesc::mutable_ops(int index) { + // @@protoc_insertion_point(field_mutable:paddle.framework.proto.BlockDesc.ops) + return ops_.Mutable(index); +} +inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::OpDesc >* +BlockDesc::mutable_ops() { + // @@protoc_insertion_point(field_mutable_list:paddle.framework.proto.BlockDesc.ops) + return &ops_; +} +inline const ::paddle::framework::proto::OpDesc& BlockDesc::_internal_ops(int index) const { + return ops_.Get(index); +} +inline const ::paddle::framework::proto::OpDesc& BlockDesc::ops(int index) const { + // @@protoc_insertion_point(field_get:paddle.framework.proto.BlockDesc.ops) + return _internal_ops(index); +} +inline ::paddle::framework::proto::OpDesc* BlockDesc::_internal_add_ops() { + return ops_.Add(); +} +inline ::paddle::framework::proto::OpDesc* BlockDesc::add_ops() { + // @@protoc_insertion_point(field_add:paddle.framework.proto.BlockDesc.ops) + return _internal_add_ops(); +} +inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::OpDesc >& +BlockDesc::ops() const { + // @@protoc_insertion_point(field_list:paddle.framework.proto.BlockDesc.ops) + return ops_; +} + +// optional int32 forward_block_idx = 5 [default = -1]; +inline bool BlockDesc::_internal_has_forward_block_idx() const { + bool value = (_has_bits_[0] & 0x00000004u) != 0; + return value; +} +inline bool BlockDesc::has_forward_block_idx() const { + return _internal_has_forward_block_idx(); +} +inline void BlockDesc::clear_forward_block_idx() { + forward_block_idx_ = -1; + _has_bits_[0] &= ~0x00000004u; +} +inline ::PROTOBUF_NAMESPACE_ID::int32 BlockDesc::_internal_forward_block_idx() const { + return forward_block_idx_; +} +inline ::PROTOBUF_NAMESPACE_ID::int32 BlockDesc::forward_block_idx() const { + // @@protoc_insertion_point(field_get:paddle.framework.proto.BlockDesc.forward_block_idx) + return _internal_forward_block_idx(); +} +inline void BlockDesc::_internal_set_forward_block_idx(::PROTOBUF_NAMESPACE_ID::int32 value) { + _has_bits_[0] |= 0x00000004u; + forward_block_idx_ = value; +} +inline void BlockDesc::set_forward_block_idx(::PROTOBUF_NAMESPACE_ID::int32 value) { + _internal_set_forward_block_idx(value); + // @@protoc_insertion_point(field_set:paddle.framework.proto.BlockDesc.forward_block_idx) +} + +// ------------------------------------------------------------------- + +// OpVersion + +// required int32 version = 1; +inline bool OpVersion::_internal_has_version() const { + bool value = (_has_bits_[0] & 0x00000001u) != 0; + return value; +} +inline bool OpVersion::has_version() const { + return _internal_has_version(); +} +inline void OpVersion::clear_version() { + version_ = 0; + _has_bits_[0] &= ~0x00000001u; +} +inline ::PROTOBUF_NAMESPACE_ID::int32 OpVersion::_internal_version() const { + return version_; +} +inline ::PROTOBUF_NAMESPACE_ID::int32 OpVersion::version() const { + // @@protoc_insertion_point(field_get:paddle.framework.proto.OpVersion.version) + return _internal_version(); +} +inline void OpVersion::_internal_set_version(::PROTOBUF_NAMESPACE_ID::int32 value) { + _has_bits_[0] |= 0x00000001u; + version_ = value; +} +inline void OpVersion::set_version(::PROTOBUF_NAMESPACE_ID::int32 value) { + _internal_set_version(value); + // @@protoc_insertion_point(field_set:paddle.framework.proto.OpVersion.version) +} + +// ------------------------------------------------------------------- + +// OpVersionMap_OpVersionPair + +// required string op_name = 1; +inline bool OpVersionMap_OpVersionPair::_internal_has_op_name() const { + bool value = (_has_bits_[0] & 0x00000001u) != 0; + return value; +} +inline bool OpVersionMap_OpVersionPair::has_op_name() const { + return _internal_has_op_name(); +} +inline void OpVersionMap_OpVersionPair::clear_op_name() { + op_name_.ClearToEmpty(); + _has_bits_[0] &= ~0x00000001u; +} +inline const std::string& OpVersionMap_OpVersionPair::op_name() const { + // @@protoc_insertion_point(field_get:paddle.framework.proto.OpVersionMap.OpVersionPair.op_name) + return _internal_op_name(); +} +inline void OpVersionMap_OpVersionPair::set_op_name(const std::string& value) { + _internal_set_op_name(value); + // @@protoc_insertion_point(field_set:paddle.framework.proto.OpVersionMap.OpVersionPair.op_name) +} +inline std::string* OpVersionMap_OpVersionPair::mutable_op_name() { + // @@protoc_insertion_point(field_mutable:paddle.framework.proto.OpVersionMap.OpVersionPair.op_name) + return _internal_mutable_op_name(); +} +inline const std::string& OpVersionMap_OpVersionPair::_internal_op_name() const { + return op_name_.Get(); +} +inline void OpVersionMap_OpVersionPair::_internal_set_op_name(const std::string& value) { + _has_bits_[0] |= 0x00000001u; + op_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); +} +inline void OpVersionMap_OpVersionPair::set_op_name(std::string&& value) { + _has_bits_[0] |= 0x00000001u; + op_name_.Set( + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena()); + // @@protoc_insertion_point(field_set_rvalue:paddle.framework.proto.OpVersionMap.OpVersionPair.op_name) +} +inline void OpVersionMap_OpVersionPair::set_op_name(const char* value) { + GOOGLE_DCHECK(value != nullptr); + _has_bits_[0] |= 0x00000001u; + op_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena()); + // @@protoc_insertion_point(field_set_char:paddle.framework.proto.OpVersionMap.OpVersionPair.op_name) +} +inline void OpVersionMap_OpVersionPair::set_op_name(const char* value, + size_t size) { + _has_bits_[0] |= 0x00000001u; + op_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string( + reinterpret_cast(value), size), GetArena()); + // @@protoc_insertion_point(field_set_pointer:paddle.framework.proto.OpVersionMap.OpVersionPair.op_name) +} +inline std::string* OpVersionMap_OpVersionPair::_internal_mutable_op_name() { + _has_bits_[0] |= 0x00000001u; + return op_name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); +} +inline std::string* OpVersionMap_OpVersionPair::release_op_name() { + // @@protoc_insertion_point(field_release:paddle.framework.proto.OpVersionMap.OpVersionPair.op_name) + if (!_internal_has_op_name()) { + return nullptr; + } + _has_bits_[0] &= ~0x00000001u; + return op_name_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); +} +inline void OpVersionMap_OpVersionPair::set_allocated_op_name(std::string* op_name) { + if (op_name != nullptr) { + _has_bits_[0] |= 0x00000001u; + } else { + _has_bits_[0] &= ~0x00000001u; + } + op_name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), op_name, + GetArena()); + // @@protoc_insertion_point(field_set_allocated:paddle.framework.proto.OpVersionMap.OpVersionPair.op_name) +} + +// required .paddle.framework.proto.OpVersion op_version = 2; +inline bool OpVersionMap_OpVersionPair::_internal_has_op_version() const { + bool value = (_has_bits_[0] & 0x00000002u) != 0; + PROTOBUF_ASSUME(!value || op_version_ != nullptr); + return value; +} +inline bool OpVersionMap_OpVersionPair::has_op_version() const { + return _internal_has_op_version(); +} +inline void OpVersionMap_OpVersionPair::clear_op_version() { + if (op_version_ != nullptr) op_version_->Clear(); + _has_bits_[0] &= ~0x00000002u; +} +inline const ::paddle::framework::proto::OpVersion& OpVersionMap_OpVersionPair::_internal_op_version() const { + const ::paddle::framework::proto::OpVersion* p = op_version_; + return p != nullptr ? *p : reinterpret_cast( + ::paddle::framework::proto::_OpVersion_default_instance_); +} +inline const ::paddle::framework::proto::OpVersion& OpVersionMap_OpVersionPair::op_version() const { + // @@protoc_insertion_point(field_get:paddle.framework.proto.OpVersionMap.OpVersionPair.op_version) + return _internal_op_version(); +} +inline void OpVersionMap_OpVersionPair::unsafe_arena_set_allocated_op_version( + ::paddle::framework::proto::OpVersion* op_version) { + if (GetArena() == nullptr) { + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(op_version_); + } + op_version_ = op_version; + if (op_version) { + _has_bits_[0] |= 0x00000002u; + } else { + _has_bits_[0] &= ~0x00000002u; + } + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:paddle.framework.proto.OpVersionMap.OpVersionPair.op_version) +} +inline ::paddle::framework::proto::OpVersion* OpVersionMap_OpVersionPair::release_op_version() { + _has_bits_[0] &= ~0x00000002u; + ::paddle::framework::proto::OpVersion* temp = op_version_; + op_version_ = nullptr; + if (GetArena() != nullptr) { + temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); + } + return temp; +} +inline ::paddle::framework::proto::OpVersion* OpVersionMap_OpVersionPair::unsafe_arena_release_op_version() { + // @@protoc_insertion_point(field_release:paddle.framework.proto.OpVersionMap.OpVersionPair.op_version) + _has_bits_[0] &= ~0x00000002u; + ::paddle::framework::proto::OpVersion* temp = op_version_; + op_version_ = nullptr; + return temp; +} +inline ::paddle::framework::proto::OpVersion* OpVersionMap_OpVersionPair::_internal_mutable_op_version() { + _has_bits_[0] |= 0x00000002u; + if (op_version_ == nullptr) { + auto* p = CreateMaybeMessage<::paddle::framework::proto::OpVersion>(GetArena()); + op_version_ = p; + } + return op_version_; +} +inline ::paddle::framework::proto::OpVersion* OpVersionMap_OpVersionPair::mutable_op_version() { + // @@protoc_insertion_point(field_mutable:paddle.framework.proto.OpVersionMap.OpVersionPair.op_version) + return _internal_mutable_op_version(); +} +inline void OpVersionMap_OpVersionPair::set_allocated_op_version(::paddle::framework::proto::OpVersion* op_version) { + ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArena(); + if (message_arena == nullptr) { + delete op_version_; + } + if (op_version) { + ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = + ::PROTOBUF_NAMESPACE_ID::Arena::GetArena(op_version); + if (message_arena != submessage_arena) { + op_version = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( + message_arena, op_version, submessage_arena); + } + _has_bits_[0] |= 0x00000002u; + } else { + _has_bits_[0] &= ~0x00000002u; + } + op_version_ = op_version; + // @@protoc_insertion_point(field_set_allocated:paddle.framework.proto.OpVersionMap.OpVersionPair.op_version) +} + +// ------------------------------------------------------------------- + +// OpVersionMap + +// repeated .paddle.framework.proto.OpVersionMap.OpVersionPair pair = 1; +inline int OpVersionMap::_internal_pair_size() const { + return pair_.size(); +} +inline int OpVersionMap::pair_size() const { + return _internal_pair_size(); +} +inline void OpVersionMap::clear_pair() { + pair_.Clear(); +} +inline ::paddle::framework::proto::OpVersionMap_OpVersionPair* OpVersionMap::mutable_pair(int index) { + // @@protoc_insertion_point(field_mutable:paddle.framework.proto.OpVersionMap.pair) + return pair_.Mutable(index); +} +inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::OpVersionMap_OpVersionPair >* +OpVersionMap::mutable_pair() { + // @@protoc_insertion_point(field_mutable_list:paddle.framework.proto.OpVersionMap.pair) + return &pair_; +} +inline const ::paddle::framework::proto::OpVersionMap_OpVersionPair& OpVersionMap::_internal_pair(int index) const { + return pair_.Get(index); +} +inline const ::paddle::framework::proto::OpVersionMap_OpVersionPair& OpVersionMap::pair(int index) const { + // @@protoc_insertion_point(field_get:paddle.framework.proto.OpVersionMap.pair) + return _internal_pair(index); +} +inline ::paddle::framework::proto::OpVersionMap_OpVersionPair* OpVersionMap::_internal_add_pair() { + return pair_.Add(); +} +inline ::paddle::framework::proto::OpVersionMap_OpVersionPair* OpVersionMap::add_pair() { + // @@protoc_insertion_point(field_add:paddle.framework.proto.OpVersionMap.pair) + return _internal_add_pair(); +} +inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::OpVersionMap_OpVersionPair >& +OpVersionMap::pair() const { + // @@protoc_insertion_point(field_list:paddle.framework.proto.OpVersionMap.pair) + return pair_; +} + +// ------------------------------------------------------------------- + +// ProgramDesc + +// repeated .paddle.framework.proto.BlockDesc blocks = 1; +inline int ProgramDesc::_internal_blocks_size() const { + return blocks_.size(); +} +inline int ProgramDesc::blocks_size() const { + return _internal_blocks_size(); +} +inline void ProgramDesc::clear_blocks() { + blocks_.Clear(); +} +inline ::paddle::framework::proto::BlockDesc* ProgramDesc::mutable_blocks(int index) { + // @@protoc_insertion_point(field_mutable:paddle.framework.proto.ProgramDesc.blocks) + return blocks_.Mutable(index); +} +inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::BlockDesc >* +ProgramDesc::mutable_blocks() { + // @@protoc_insertion_point(field_mutable_list:paddle.framework.proto.ProgramDesc.blocks) + return &blocks_; +} +inline const ::paddle::framework::proto::BlockDesc& ProgramDesc::_internal_blocks(int index) const { + return blocks_.Get(index); +} +inline const ::paddle::framework::proto::BlockDesc& ProgramDesc::blocks(int index) const { + // @@protoc_insertion_point(field_get:paddle.framework.proto.ProgramDesc.blocks) + return _internal_blocks(index); +} +inline ::paddle::framework::proto::BlockDesc* ProgramDesc::_internal_add_blocks() { + return blocks_.Add(); +} +inline ::paddle::framework::proto::BlockDesc* ProgramDesc::add_blocks() { + // @@protoc_insertion_point(field_add:paddle.framework.proto.ProgramDesc.blocks) + return _internal_add_blocks(); +} +inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::BlockDesc >& +ProgramDesc::blocks() const { + // @@protoc_insertion_point(field_list:paddle.framework.proto.ProgramDesc.blocks) + return blocks_; +} + +// optional .paddle.framework.proto.Version version = 4; +inline bool ProgramDesc::_internal_has_version() const { + bool value = (_has_bits_[0] & 0x00000001u) != 0; + PROTOBUF_ASSUME(!value || version_ != nullptr); + return value; +} +inline bool ProgramDesc::has_version() const { + return _internal_has_version(); +} +inline void ProgramDesc::clear_version() { + if (version_ != nullptr) version_->Clear(); + _has_bits_[0] &= ~0x00000001u; +} +inline const ::paddle::framework::proto::Version& ProgramDesc::_internal_version() const { + const ::paddle::framework::proto::Version* p = version_; + return p != nullptr ? *p : reinterpret_cast( + ::paddle::framework::proto::_Version_default_instance_); +} +inline const ::paddle::framework::proto::Version& ProgramDesc::version() const { + // @@protoc_insertion_point(field_get:paddle.framework.proto.ProgramDesc.version) + return _internal_version(); +} +inline void ProgramDesc::unsafe_arena_set_allocated_version( + ::paddle::framework::proto::Version* version) { + if (GetArena() == nullptr) { + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(version_); + } + version_ = version; + if (version) { + _has_bits_[0] |= 0x00000001u; + } else { + _has_bits_[0] &= ~0x00000001u; + } + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:paddle.framework.proto.ProgramDesc.version) +} +inline ::paddle::framework::proto::Version* ProgramDesc::release_version() { + _has_bits_[0] &= ~0x00000001u; + ::paddle::framework::proto::Version* temp = version_; + version_ = nullptr; + if (GetArena() != nullptr) { + temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); + } + return temp; +} +inline ::paddle::framework::proto::Version* ProgramDesc::unsafe_arena_release_version() { + // @@protoc_insertion_point(field_release:paddle.framework.proto.ProgramDesc.version) + _has_bits_[0] &= ~0x00000001u; + ::paddle::framework::proto::Version* temp = version_; + version_ = nullptr; + return temp; +} +inline ::paddle::framework::proto::Version* ProgramDesc::_internal_mutable_version() { + _has_bits_[0] |= 0x00000001u; + if (version_ == nullptr) { + auto* p = CreateMaybeMessage<::paddle::framework::proto::Version>(GetArena()); + version_ = p; + } + return version_; +} +inline ::paddle::framework::proto::Version* ProgramDesc::mutable_version() { + // @@protoc_insertion_point(field_mutable:paddle.framework.proto.ProgramDesc.version) + return _internal_mutable_version(); +} +inline void ProgramDesc::set_allocated_version(::paddle::framework::proto::Version* version) { + ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArena(); + if (message_arena == nullptr) { + delete version_; + } + if (version) { + ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = + ::PROTOBUF_NAMESPACE_ID::Arena::GetArena(version); + if (message_arena != submessage_arena) { + version = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( + message_arena, version, submessage_arena); + } + _has_bits_[0] |= 0x00000001u; + } else { + _has_bits_[0] &= ~0x00000001u; + } + version_ = version; + // @@protoc_insertion_point(field_set_allocated:paddle.framework.proto.ProgramDesc.version) +} + +// optional .paddle.framework.proto.OpVersionMap op_version_map = 5; +inline bool ProgramDesc::_internal_has_op_version_map() const { + bool value = (_has_bits_[0] & 0x00000002u) != 0; + PROTOBUF_ASSUME(!value || op_version_map_ != nullptr); + return value; +} +inline bool ProgramDesc::has_op_version_map() const { + return _internal_has_op_version_map(); +} +inline void ProgramDesc::clear_op_version_map() { + if (op_version_map_ != nullptr) op_version_map_->Clear(); + _has_bits_[0] &= ~0x00000002u; +} +inline const ::paddle::framework::proto::OpVersionMap& ProgramDesc::_internal_op_version_map() const { + const ::paddle::framework::proto::OpVersionMap* p = op_version_map_; + return p != nullptr ? *p : reinterpret_cast( + ::paddle::framework::proto::_OpVersionMap_default_instance_); +} +inline const ::paddle::framework::proto::OpVersionMap& ProgramDesc::op_version_map() const { + // @@protoc_insertion_point(field_get:paddle.framework.proto.ProgramDesc.op_version_map) + return _internal_op_version_map(); +} +inline void ProgramDesc::unsafe_arena_set_allocated_op_version_map( + ::paddle::framework::proto::OpVersionMap* op_version_map) { + if (GetArena() == nullptr) { + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(op_version_map_); + } + op_version_map_ = op_version_map; + if (op_version_map) { + _has_bits_[0] |= 0x00000002u; + } else { + _has_bits_[0] &= ~0x00000002u; + } + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:paddle.framework.proto.ProgramDesc.op_version_map) +} +inline ::paddle::framework::proto::OpVersionMap* ProgramDesc::release_op_version_map() { + _has_bits_[0] &= ~0x00000002u; + ::paddle::framework::proto::OpVersionMap* temp = op_version_map_; + op_version_map_ = nullptr; + if (GetArena() != nullptr) { + temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); + } + return temp; +} +inline ::paddle::framework::proto::OpVersionMap* ProgramDesc::unsafe_arena_release_op_version_map() { + // @@protoc_insertion_point(field_release:paddle.framework.proto.ProgramDesc.op_version_map) + _has_bits_[0] &= ~0x00000002u; + ::paddle::framework::proto::OpVersionMap* temp = op_version_map_; + op_version_map_ = nullptr; + return temp; +} +inline ::paddle::framework::proto::OpVersionMap* ProgramDesc::_internal_mutable_op_version_map() { + _has_bits_[0] |= 0x00000002u; + if (op_version_map_ == nullptr) { + auto* p = CreateMaybeMessage<::paddle::framework::proto::OpVersionMap>(GetArena()); + op_version_map_ = p; + } + return op_version_map_; +} +inline ::paddle::framework::proto::OpVersionMap* ProgramDesc::mutable_op_version_map() { + // @@protoc_insertion_point(field_mutable:paddle.framework.proto.ProgramDesc.op_version_map) + return _internal_mutable_op_version_map(); +} +inline void ProgramDesc::set_allocated_op_version_map(::paddle::framework::proto::OpVersionMap* op_version_map) { + ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArena(); + if (message_arena == nullptr) { + delete op_version_map_; + } + if (op_version_map) { + ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = + ::PROTOBUF_NAMESPACE_ID::Arena::GetArena(op_version_map); + if (message_arena != submessage_arena) { + op_version_map = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( + message_arena, op_version_map, submessage_arena); + } + _has_bits_[0] |= 0x00000002u; + } else { + _has_bits_[0] &= ~0x00000002u; + } + op_version_map_ = op_version_map; + // @@protoc_insertion_point(field_set_allocated:paddle.framework.proto.ProgramDesc.op_version_map) +} + +#ifdef __GNUC__ + #pragma GCC diagnostic pop +#endif // __GNUC__ +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + + +// @@protoc_insertion_point(namespace_scope) + +} // namespace proto +} // namespace framework +} // namespace paddle + +PROTOBUF_NAMESPACE_OPEN + +template <> struct is_proto_enum< ::paddle::framework::proto::VarType_Type> : ::std::true_type {}; +template <> +inline const EnumDescriptor* GetEnumDescriptor< ::paddle::framework::proto::VarType_Type>() { + return ::paddle::framework::proto::VarType_Type_descriptor(); +} +template <> struct is_proto_enum< ::paddle::framework::proto::AttrType> : ::std::true_type {}; +template <> +inline const EnumDescriptor* GetEnumDescriptor< ::paddle::framework::proto::AttrType>() { + return ::paddle::framework::proto::AttrType_descriptor(); +} + +PROTOBUF_NAMESPACE_CLOSE + +// @@protoc_insertion_point(global_scope) + +#include +#endif // GOOGLE_PROTOBUF_INCLUDED_GOOGLE_PROTOBUF_INCLUDED_framework_2eproto diff --git a/inference-engine/samples/pdpd_poc/main.cpp b/inference-engine/samples/pdpd_poc/main.cpp new file mode 100644 index 00000000000000..dd6c1ecd0b3442 --- /dev/null +++ b/inference-engine/samples/pdpd_poc/main.cpp @@ -0,0 +1,379 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "benchmark_app.hpp" +#include "framework.pb.h" + +#include +#include + +using namespace InferenceEngine; + +using namespace google; +using namespace paddle::framework; + +std::map TYPE_MAP{ + {proto::VarType_Type::VarType_Type_BOOL, ngraph::element::boolean}, + {proto::VarType_Type::VarType_Type_INT16, ngraph::element::i16}, + {proto::VarType_Type::VarType_Type_INT32, ngraph::element::i32}, + {proto::VarType_Type::VarType_Type_INT64, ngraph::element::i64}, + {proto::VarType_Type::VarType_Type_FP16, ngraph::element::f16}, + {proto::VarType_Type::VarType_Type_FP32, ngraph::element::f32}, + {proto::VarType_Type::VarType_Type_FP64, ngraph::element::f64}, + {proto::VarType_Type::VarType_Type_UINT8, ngraph::element::u8}, + {proto::VarType_Type::VarType_Type_INT8, ngraph::element::i8}, + {proto::VarType_Type::VarType_Type_BF16, ngraph::element::bf16} +}; + +bool endsWith(std::string str, std::string suffix) +{ + if (str.length() >= suffix.length()) { + return (0 == str.compare(str.length() - suffix.length(), suffix.length(), suffix)); + } + return false; +} + +protobuf::RepeatedField get_ints(proto::OpDesc op, std::string name, + protobuf::RepeatedField default = protobuf::RepeatedField()) { + std::vector attrs; + for (const auto& attr : op.attrs()) { + if (attr.name() == name) + attrs.push_back(attr); + } + if (attrs.size() == 0) + return default; + else if (attrs.size() > 1) { + // TODO: raise exception here + return default; + } + else { + return attrs[0].ints(); + } +} + +int get_int(proto::OpDesc op, std::string name, int default = 0) { + std::vector attrs; + for (const auto& attr : op.attrs()) { + if (attr.name() == name) + attrs.push_back(attr); + } + if (attrs.size() == 0) + return default; + else if (attrs.size() > 1) { + // TODO: raise exception here + return default; + } + else { + return attrs[0].i(); + } +} + +float get_float(proto::OpDesc op, std::string name, float default = 0.) { + std::vector attrs; + for (const auto& attr : op.attrs()) { + if (attr.name() == name) + attrs.push_back(attr); + } + if (attrs.size() == 0) + return default; + else if (attrs.size() > 1) { + // TODO: raise exception here + return default; + } + else { + return attrs[0].f(); + } +} + +std::string get_str(proto::OpDesc op, std::string name, std::string default = "") { + std::vector attrs; + for (const auto& attr : op.attrs()) { + if (attr.name() == name) + attrs.push_back(attr); + } + if (attrs.size() == 0) + return default; + else if (attrs.size() > 1) { + // TODO: raise exception here + return default; + } + else { + return attrs[0].s(); + } +} + +bool get_bool(proto::OpDesc op, std::string name, bool default = false) { + std::vector attrs; + for (const auto& attr : op.attrs()) { + if (attr.name() == name) + attrs.push_back(attr); + } + if (attrs.size() == 0) + return default; + else if (attrs.size() > 1) { + // TODO: raise exception here + return default; + } + else { + return attrs[0].b(); + } +} + +typedef std::shared_ptr(*CreatorFunction)(std::map>> inputs, + proto::OpDesc op, proto::BlockDesc block); + +std::shared_ptr conv2d_creator(std::map>> inputs, + proto::OpDesc op, proto::BlockDesc block) { + assert(inputs["Input"].size() == 1); + auto data = inputs["Input"][0]; + assert(inputs["Filter"].size() == 1); + auto filter = inputs["Filter"][0]; + assert(inputs["Bias"].size() == 0); + assert(inputs["ResidualData"].size() == 0); + // TODO: resolve padding according to spec + auto strides = get_ints(op, "strides"); + auto paddings = get_ints(op, "paddings"); + auto dilations = get_ints(op, "dilations"); + return std::make_shared(data, + filter, + ngraph::Strides(strides.begin(), strides.end()), + ngraph::CoordinateDiff(paddings.begin(), paddings.end()), + ngraph::CoordinateDiff(paddings.begin(), paddings.end()), + ngraph::Strides(dilations.begin(), dilations.end())); +} + + +std::shared_ptr batch_norm_creator(std::map>> inputs, + proto::OpDesc op, proto::BlockDesc block) { + assert(inputs["X"].size() == 1); + assert(inputs["Scale"].size() == 1); + assert(inputs["Bias"].size() == 1); + assert(inputs["Mean"].size() == 1); + assert(inputs["Variance"].size() == 1); + auto data = inputs["X"][0]; + auto gamma = inputs["Scale"][0]; + auto beta = inputs["Bias"][0]; + auto mean = inputs["Mean"][0]; + auto variance = inputs["Variance"][0]; + return std::make_shared(data, gamma, beta, mean, variance, get_float(op, "epsilon")); +} + + +std::shared_ptr relu_creator(std::map>> inputs, + proto::OpDesc op, proto::BlockDesc block) { + assert(inputs["X"].size() == 1); + auto data = inputs["X"][0]; + return std::make_shared(data); +} + +std::shared_ptr pool2d_creator(std::map>> inputs, + proto::OpDesc op, proto::BlockDesc block) { + assert(inputs["X"].size() == 1); + auto data = inputs["X"][0]; + // TODO : resolve padding according to spec + auto pooling_type = get_str(op, "pooling_type"); + auto global_pooling = get_bool(op, "global_pooling"); + if (pooling_type == "max" && !global_pooling) { + auto strides = get_ints(op, "strides"); + auto paddings = get_ints(op, "paddings"); + auto kernel_shape = get_ints(op, "ksize"); + return std::make_shared(data, + ngraph::Strides(strides.begin(), strides.end()), + ngraph::Shape(paddings.begin(), paddings.end()), + ngraph::Shape(paddings.begin(), paddings.end()), + ngraph::Shape(kernel_shape.begin(), kernel_shape.end())); + } + else if (pooling_type == "avg" && global_pooling) { + // TODO : resolve axes according to rank + auto axes = ngraph::opset6::Constant::create(ngraph::element::i64, { 2 }, { 2, 3 }); + return std::make_shared(data, axes, true); + } + else { + throw std::exception("Unsupported pooling type"); + } +} + +std::shared_ptr elementwise_add_creator(std::map>> inputs, + proto::OpDesc op, proto::BlockDesc block) { + assert(inputs["X"].size() == 1); + assert(inputs["Y"].size() == 1); + auto x = inputs["X"][0]; + auto y = inputs["Y"][0]; + // TODO : resolve broadcast + return std::make_shared(x, y); +} + +std::shared_ptr mul_creator(std::map>> inputs, + proto::OpDesc op, proto::BlockDesc block) { + assert(inputs["X"].size() == 1); + assert(inputs["Y"].size() == 1); + auto x = inputs["X"][0]; + auto y = inputs["Y"][0]; + assert(x->output(0).get_partial_shape().rank().is_static()); + int64_t x_rank = x->output(0).get_partial_shape().rank().get_length(); + assert(y->output(0).get_partial_shape().rank().is_static() && y->output(0).get_partial_shape().rank().get_length() == 2); + if (x_rank > 2) { + auto shape = std::make_shared(x); + int64_t x_num_col_dims = get_int(op, "x_num_col_dims"); + auto axis = ngraph::opset6::Constant::create(ngraph::element::i64, {}, { 0 }); + auto split_lengths = ngraph::opset6::Constant::create(ngraph::element::i64, {2}, { x_num_col_dims, x_rank - x_num_col_dims }); + auto split = std::make_shared(shape, axis, split_lengths); + auto f_dim_red_axis = ngraph::opset6::Constant::create(ngraph::element::i64, {}, { 0 }); + auto first_dim_reduce = std::make_shared(split->output(0), f_dim_red_axis); + auto f_dim_shape = ngraph::opset6::Constant::create(ngraph::element::i64, { 1 }, { 1 }); + auto first_dim = std::make_shared(first_dim_reduce, f_dim_shape, false); + auto s_dim_red_axis = ngraph::opset6::Constant::create(ngraph::element::i64, {}, { 0 }); + auto second_dim_reduce = std::make_shared(split->output(1), s_dim_red_axis); + auto s_dim_shape = ngraph::opset6::Constant::create(ngraph::element::i64, { 1 }, { 1 }); + auto second_dim = std::make_shared(second_dim_reduce, s_dim_shape, false); + auto out_shape = std::make_shared(ngraph::NodeVector{ first_dim, second_dim }, 0); + auto x_reshaped = std::make_shared(x, out_shape, false); + return std::make_shared(x_reshaped, y); + } + return std::make_shared(x, y); +} + +std::shared_ptr scale_creator(std::map>> inputs, + proto::OpDesc op, proto::BlockDesc block) { + assert(inputs["X"].size() == 1); + auto data = inputs["X"][0]; + auto scale = ngraph::opset6::Constant::create(ngraph::element::f32, { 1 }, { get_float(op, "scale") }); + return std::make_shared(data, scale); +} + +std::shared_ptr make_ng_node(std::map> inputs, + std::map> nodes, + paddle::framework::proto::OpDesc op, + paddle::framework::proto::BlockDesc block) { + std::map CREATORS_MAP{ + {"conv2d", conv2d_creator}, + {"batch_norm", batch_norm_creator}, + {"relu", relu_creator}, + {"pool2d", pool2d_creator}, + {"elementwise_add", elementwise_add_creator}, + {"mul", mul_creator}, + {"scale", scale_creator} + }; + assert(CREATORS_MAP.find(op.type()) != CREATORS_MAP.end()); + std::map>> inputs_preproc; + for (const auto& item : inputs) { + inputs_preproc[item.first] = std::vector>(); + for (const auto& input_name : item.second) { + // TODO: refactor to not search every time + inputs_preproc[item.first].push_back(nodes[input_name]); + } + } + return CREATORS_MAP[op.type()](inputs_preproc, op, block); +} + +std::shared_ptr read_tensor(paddle::framework::proto::VarDesc var, std::string model_dir) { + assert(var.type().type() == paddle::framework::proto::VarType::LOD_TENSOR); + auto tensor = var.type().lod_tensor().tensor(); + + std::ifstream is; + is.open(model_dir + "\\" + var.name(), std::ios::binary); + // get length of file: + is.seekg(0, std::ios::end); + auto length = is.tellg(); + auto tensor_length = std::accumulate(tensor.dims().cbegin(), tensor.dims().cend(), 1, std::multiplies()) * 4; + is.seekg((size_t)length - tensor_length, std::ios::beg); + + std::vector tensor_data(tensor_length); + is.read((char*)(&tensor_data[0]), tensor_length); + auto shape = std::vector(tensor.dims().cbegin(), tensor.dims().cend()); + return ngraph::opset6::Constant::create(ngraph::element::f32, ngraph::Shape(shape), tensor_data); +} + +std::shared_ptr convert_model(const std::string & model_dir) { + paddle::framework::proto::ProgramDesc fw_model; + std::ifstream pb_stream(model_dir + "\\model", std::ios::binary); + fw_model.ParseFromIstream(&pb_stream); + + std::map> nodes_dict; + ngraph::ParameterVector parameter_nodes; + ngraph::ResultVector result_nodes; + + const auto& global_block = fw_model.blocks()[0]; + for (const auto& var : global_block.vars()) { + if (endsWith(var.name(), "feed") || endsWith(var.name(), "fetch")) + continue; + if (!var.persistable()) + continue; + nodes_dict[var.name()] = read_tensor(var, model_dir); + } + + for (const auto& block : fw_model.blocks()) { + std::map vars_dict; + for (const auto& var : block.vars()) { + vars_dict[var.name()] = var.type(); + } + for (int i = 0; i < block.ops_size(); i++) { + const auto& op = block.ops()[i]; + std::map> outputs_dict; + for (const auto& output : op.outputs()) { + outputs_dict[output.parameter()] = output.arguments(); + } + std::map> inputs_dict; + for (const auto& input : op.inputs()) { + outputs_dict[input.parameter()] = input.arguments(); + } + if (op.type() == "feed") { + auto layer_name = outputs_dict["Out"][0]; + auto var = vars_dict[layer_name]; + assert(var.type() == paddle::framework::proto::VarType::LOD_TENSOR); + auto tensor_desc = var.lod_tensor().tensor(); + auto dtype = tensor_desc.data_type(); + auto shape = std::vector(tensor_desc.dims().cbegin(), tensor_desc.dims().cend()); + auto param = std::make_shared(TYPE_MAP[dtype], ngraph::Shape(shape)); + nodes_dict[layer_name] = param; + parameter_nodes.push_back(param); + } + else if (op.type() == "fetch") { + auto input_node = inputs_dict["X"][0]; + assert(nodes_dict.find(input_node) != nodes_dict.end()); + result_nodes.push_back(std::make_shared(nodes_dict[input_node])); + } + else { + auto node = make_ng_node(inputs_dict, nodes_dict, op, block); + for (const auto& item : outputs_dict) { + assert(item.second.size() <= 1); + if (item.second.size() == 1) { + nodes_dict[item.second[0]] = node; + } + } + } + } + } + return std::make_shared(result_nodes, parameter_nodes); +} + +int main(int argc, char* argv[]) { + try { + std::string model_path = "C:\\Dev\\resnet_v2_50_imagenet\\model"; + auto func = convert_model(model_path); + } + catch (const std::exception& ex) { + slog::err << ex.what() << slog::endl; + + return 3; + } + + return 0; +} diff --git a/tools/pdpd_poc/framework.proto b/tools/pdpd_poc/framework.proto index 84b5502ff7b369..baaecb55d06ee3 100644 --- a/tools/pdpd_poc/framework.proto +++ b/tools/pdpd_poc/framework.proto @@ -115,6 +115,9 @@ message VarType { SIZE_T = 19; UINT8 = 20; INT8 = 21; + BF16 = 22; + COMPLEX64 = 23; + COMPLEX128 = 24; // Other types that may need additional descriptions LOD_TENSOR = 7; @@ -178,29 +181,15 @@ message BlockDesc { optional int32 forward_block_idx = 5 [ default = -1 ]; } -// CompatibleInfo is used to determine if a feature is compatible and -// provides the information. -message CompatibleInfo { - enum Type { - COMPATIBLE = 0; - DEFINITELY_NOT = 1; - POSSIBLE = 2; - BUG_FIX = 3; - PRECISION_CHANGE = 4; - } - required string version = 1; - required Type type = 2; -} - -// In some cases, Paddle Fluid may perform operator definition iterations, -// and the operator uses OpCompatibleMap for compatibility testing. -message OpCompatibleMap { - message OpCompatiblePair { +// In some cases, Paddle may perform operator definition iterations, +// and the operator uses OpVersionMap for compatibility testing. +message OpVersion { required int32 version = 1; } +message OpVersionMap { + message OpVersionPair { required string op_name = 1; - required CompatibleInfo compatible_info = 2; + required OpVersion op_version = 2; } - repeated OpCompatiblePair pair = 1; - optional string default_required_version = 2; + repeated OpVersionPair pair = 1; } // Please refer to @@ -209,8 +198,8 @@ message OpCompatibleMap { // TODO(panyx0718): A model can have multiple programs. Need a // way to distinguish them. Maybe ID or name? message ProgramDesc { - reserved 2; // For backward compatibility. + reserved 2, 3; // For backward compatibility. repeated BlockDesc blocks = 1; optional Version version = 4; - optional OpCompatibleMap op_compatible_map = 3; + optional OpVersionMap op_version_map = 5; } diff --git a/tools/pdpd_poc/generate_proto.sh b/tools/pdpd_poc/generate_proto.sh index 03f40c70db4312..e8e36e348f95a8 100644 --- a/tools/pdpd_poc/generate_proto.sh +++ b/tools/pdpd_poc/generate_proto.sh @@ -1,3 +1,3 @@ #!/bin/bash -protoc --python_out=. framework.proto \ No newline at end of file +protoc --python_out=. --cpp_out=. framework.proto \ No newline at end of file diff --git a/tools/pdpd_poc/pdpd2ir.py b/tools/pdpd_poc/pdpd2ir.py index af8ac96a3066f5..89b4bb8f2337dd 100644 --- a/tools/pdpd_poc/pdpd2ir.py +++ b/tools/pdpd_poc/pdpd2ir.py @@ -209,8 +209,6 @@ def convert_model(model_dir): if __name__ == "__main__": - download_pdpd_resnet50() - import cv2 img = cv2.imread("cat3.bmp") @@ -224,8 +222,10 @@ def convert_model(model_dir): model_path = download_pdpd_resnet50() + '/model' + import paddle from paddle import fluid + paddle.enable_static() exe = fluid.Executor(fluid.CPUPlace()) exe.run(fluid.default_startup_program()) [program, feed, fetchs] = fluid.io.load_inference_model(model_path, exe) diff --git a/tools/pdpd_poc/pdpd2ir_test.py b/tools/pdpd_poc/pdpd2ir_test.py index ab9ad01ee929ec..c6e167f1f817f2 100644 --- a/tools/pdpd_poc/pdpd2ir_test.py +++ b/tools/pdpd_poc/pdpd2ir_test.py @@ -19,8 +19,10 @@ def infer_ie(func, inp_dict: dict): @staticmethod def validate(var: list, inp_dict: dict): + import paddle from paddle import fluid + paddle.enable_static() exe = fluid.Executor(fluid.CPUPlace()) exe.run(fluid.default_startup_program()) res_pdpd = exe.run(fluid.default_main_program(), fetch_list=var, feed=inp_dict) @@ -34,7 +36,9 @@ def validate(var: list, inp_dict: dict): return np.all(np.isclose(res_pdpd[0], list(res_ie.values())[0], rtol=1e-4, atol=1e-5)) def test_convert_pure_conv_model(self): + import paddle from paddle import fluid + paddle.enable_static() inp_blob = np.random.randn(1, 3, 224, 224).astype(np.float32) @@ -47,7 +51,9 @@ def test_convert_pure_conv_model(self): self.assertTrue(result) def test_convert_conv_model(self): + import paddle from paddle import fluid + paddle.enable_static() inp_blob = np.random.randn(1, 3, 224, 224).astype(np.float32) @@ -78,7 +84,9 @@ def test_convert_resnet50(self): model_path = module.directory + '/model' + import paddle from paddle import fluid + paddle.enable_static() exe = fluid.Executor(fluid.CPUPlace()) exe.run(fluid.default_startup_program()) From 007f3cabb04d279d2b87c49759aad382f15049ca Mon Sep 17 00:00:00 2001 From: "Vafin, Maxim" Date: Wed, 20 Jan 2021 13:52:28 +0300 Subject: [PATCH 015/116] Fix build --- inference-engine/samples/CMakeLists.txt | 2 +- inference-engine/samples/pdpd_poc/main.cpp | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/inference-engine/samples/CMakeLists.txt b/inference-engine/samples/CMakeLists.txt index bc10bfbf46172a..d6af3b7139d971 100644 --- a/inference-engine/samples/CMakeLists.txt +++ b/inference-engine/samples/CMakeLists.txt @@ -40,7 +40,7 @@ foreach(UPPER endforeach() # end of compatibility block -add_library(libprotobuf UNKNOWN IMPORTED) +#add_library(libprotobuf UNKNOWN IMPORTED) set_target_properties(libprotobuf PROPERTIES IMPORTED_LOCATION "${Protobuf_LIBRARY}" INTERFACE_INCLUDE_DIRECTORIES "${Protobuf_INCLUDE_DIR}" diff --git a/inference-engine/samples/pdpd_poc/main.cpp b/inference-engine/samples/pdpd_poc/main.cpp index dd6c1ecd0b3442..e8812500a83212 100644 --- a/inference-engine/samples/pdpd_poc/main.cpp +++ b/inference-engine/samples/pdpd_poc/main.cpp @@ -18,7 +18,6 @@ #include #include -#include "benchmark_app.hpp" #include "framework.pb.h" #include From 92287ba1e17f0969e0db7df9a8e74249ed4cc68e Mon Sep 17 00:00:00 2001 From: "Vafin, Maxim" Date: Wed, 20 Jan 2021 14:07:26 +0300 Subject: [PATCH 016/116] Fix codestyle --- inference-engine/samples/pdpd_poc/main.cpp | 52 +++++++++------------- 1 file changed, 21 insertions(+), 31 deletions(-) diff --git a/inference-engine/samples/pdpd_poc/main.cpp b/inference-engine/samples/pdpd_poc/main.cpp index e8812500a83212..6b40ffdeca301f 100644 --- a/inference-engine/samples/pdpd_poc/main.cpp +++ b/inference-engine/samples/pdpd_poc/main.cpp @@ -41,8 +41,7 @@ std::map TYPE_MAP {proto::VarType_Type::VarType_Type_BF16, ngraph::element::bf16} }; -bool endsWith(std::string str, std::string suffix) -{ +bool endsWith(std::string str, std::string suffix) { if (str.length() >= suffix.length()) { return (0 == str.compare(str.length() - suffix.length(), suffix.length(), suffix)); } @@ -56,13 +55,12 @@ protobuf::RepeatedField get_ints(proto::OpDesc op, std::string if (attr.name() == name) attrs.push_back(attr); } - if (attrs.size() == 0) + if (attrs.size() == 0) { return default; - else if (attrs.size() > 1) { + } else if (attrs.size() > 1) { // TODO: raise exception here return default; - } - else { + } else { return attrs[0].ints(); } } @@ -73,13 +71,12 @@ int get_int(proto::OpDesc op, std::string name, int default = 0) { if (attr.name() == name) attrs.push_back(attr); } - if (attrs.size() == 0) + if (attrs.size() == 0) { return default; - else if (attrs.size() > 1) { + } else if (attrs.size() > 1) { // TODO: raise exception here return default; - } - else { + } else { return attrs[0].i(); } } @@ -90,13 +87,12 @@ float get_float(proto::OpDesc op, std::string name, float default = 0.) { if (attr.name() == name) attrs.push_back(attr); } - if (attrs.size() == 0) + if (attrs.size() == 0) { return default; - else if (attrs.size() > 1) { + } else if (attrs.size() > 1) { // TODO: raise exception here return default; - } - else { + } else { return attrs[0].f(); } } @@ -107,13 +103,12 @@ std::string get_str(proto::OpDesc op, std::string name, std::string default = "" if (attr.name() == name) attrs.push_back(attr); } - if (attrs.size() == 0) + if (attrs.size() == 0) { return default; - else if (attrs.size() > 1) { + } else if (attrs.size() > 1) { // TODO: raise exception here return default; - } - else { + } else { return attrs[0].s(); } } @@ -124,13 +119,12 @@ bool get_bool(proto::OpDesc op, std::string name, bool default = false) { if (attr.name() == name) attrs.push_back(attr); } - if (attrs.size() == 0) + if (attrs.size() == 0) { return default; - else if (attrs.size() > 1) { + } else if (attrs.size() > 1) { // TODO: raise exception here return default; - } - else { + } else { return attrs[0].b(); } } @@ -198,13 +192,11 @@ std::shared_ptr pool2d_creator(std::map(data, axes, true); - } - else { + } else { throw std::exception("Unsupported pooling type"); } } @@ -295,7 +287,7 @@ std::shared_ptr read_tensor(paddle::framework::proto:: is.seekg((size_t)length - tensor_length, std::ios::beg); std::vector tensor_data(tensor_length); - is.read((char*)(&tensor_data[0]), tensor_length); + is.read(reinterpret_cast(&tensor_data[0]), tensor_length); auto shape = std::vector(tensor.dims().cbegin(), tensor.dims().cend()); return ngraph::opset6::Constant::create(ngraph::element::f32, ngraph::Shape(shape), tensor_data); } @@ -343,13 +335,11 @@ std::shared_ptr convert_model(const std::string & model_dir) { auto param = std::make_shared(TYPE_MAP[dtype], ngraph::Shape(shape)); nodes_dict[layer_name] = param; parameter_nodes.push_back(param); - } - else if (op.type() == "fetch") { + } else if (op.type() == "fetch") { auto input_node = inputs_dict["X"][0]; assert(nodes_dict.find(input_node) != nodes_dict.end()); result_nodes.push_back(std::make_shared(nodes_dict[input_node])); - } - else { + } else { auto node = make_ng_node(inputs_dict, nodes_dict, op, block); for (const auto& item : outputs_dict) { assert(item.second.size() <= 1); From 9438084e471ee63c09e80254155d023d20c0aa3b Mon Sep 17 00:00:00 2001 From: "Vafin, Maxim" Date: Wed, 20 Jan 2021 15:56:32 +0300 Subject: [PATCH 017/116] Fix build --- inference-engine/samples/CMakeLists.txt | 65 - .../samples/pdpd_poc/CMakeLists.txt | 13 +- .../samples/pdpd_poc/framework.pb.cc | 7018 --------------- .../samples/pdpd_poc/framework.pb.h | 7608 ----------------- .../samples/pdpd_poc/framework.proto | 205 + inference-engine/samples/pdpd_poc/main.cpp | 72 +- 6 files changed, 259 insertions(+), 14722 deletions(-) delete mode 100644 inference-engine/samples/pdpd_poc/framework.pb.cc delete mode 100644 inference-engine/samples/pdpd_poc/framework.pb.h create mode 100644 inference-engine/samples/pdpd_poc/framework.proto diff --git a/inference-engine/samples/CMakeLists.txt b/inference-engine/samples/CMakeLists.txt index d6af3b7139d971..15a795046ec9f6 100644 --- a/inference-engine/samples/CMakeLists.txt +++ b/inference-engine/samples/CMakeLists.txt @@ -9,71 +9,6 @@ cmake_policy(SET CMP0025 NEW) project(Samples) -set(HAVE_PROTOBUF FALSE) - -function(get_protobuf_version version include) - file(STRINGS "${include}/google/protobuf/stubs/common.h" ver REGEX "#define GOOGLE_PROTOBUF_VERSION [0-9]+") - string(REGEX MATCHALL "[0-9]+" ver ${ver}) - math(EXPR major "${ver} / 1000000") - math(EXPR minor "${ver} / 1000 % 1000") - math(EXPR patch "${ver} % 1000") - set(${version} "${major}.${minor}.${patch}" PARENT_SCOPE) -endfunction() - -unset(Protobuf_VERSION CACHE) -find_package(Protobuf REQUIRED) - -# Backwards compatibility -# Define camel case versions of input variables -foreach(UPPER - PROTOBUF_FOUND - PROTOBUF_LIBRARY - PROTOBUF_INCLUDE_DIR - PROTOBUF_VERSION - ) - if (DEFINED ${UPPER}) - string(REPLACE "PROTOBUF_" "Protobuf_" Camel ${UPPER}) - if (NOT DEFINED ${Camel}) - set(${Camel} ${${UPPER}}) - endif() - endif() -endforeach() -# end of compatibility block - -#add_library(libprotobuf UNKNOWN IMPORTED) -set_target_properties(libprotobuf PROPERTIES - IMPORTED_LOCATION "${Protobuf_LIBRARY}" - INTERFACE_INCLUDE_DIRECTORIES "${Protobuf_INCLUDE_DIR}" - INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${Protobuf_INCLUDE_DIR}" -) -get_protobuf_version(Protobuf_VERSION "${Protobuf_INCLUDE_DIR}") -set(Protobuf_LIBRARIES "libprotobuf") -set(HAVE_PROTOBUF TRUE) -INCLUDE_DIRECTORIES(${Protobuf_INCLUDE_DIR}) - -if(HAVE_PROTOBUF AND PROTOBUF_UPDATE_FILES AND NOT COMMAND PROTOBUF_GENERATE_CPP) - message(FATAL_ERROR "Can't configure protobuf dependency (BUILD_PROTOBUF=${BUILD_PROTOBUF} PROTOBUF_UPDATE_FILES=${PROTOBUF_UPDATE_FILES})") -endif() - -if(HAVE_PROTOBUF) - list(APPEND CUSTOM_STATUS protobuf) - if(NOT BUILD_PROTOBUF) - if(TARGET "${Protobuf_LIBRARIES}") - get_target_property(__location "${Protobuf_LIBRARIES}" IMPORTED_LOCATION_RELEASE) - if(NOT __location) - get_target_property(__location "${Protobuf_LIBRARIES}" IMPORTED_LOCATION) - endif() - elseif(Protobuf_LIBRARY) - set(__location "${Protobuf_LIBRARY}") - else() - set(__location "${Protobuf_LIBRARIES}") - endif() - endif() - list(APPEND CUSTOM_STATUS_protobuf " Protobuf:" - BUILD_PROTOBUF THEN "build (${Protobuf_VERSION})" - ELSE "${__location} (${Protobuf_VERSION})") -endif() - if (CMAKE_BUILD_TYPE STREQUAL "") message(STATUS "CMAKE_BUILD_TYPE not defined, 'Release' will be used") set(CMAKE_BUILD_TYPE "Release") diff --git a/inference-engine/samples/pdpd_poc/CMakeLists.txt b/inference-engine/samples/pdpd_poc/CMakeLists.txt index 20d03735232889..f899a85e390a99 100644 --- a/inference-engine/samples/pdpd_poc/CMakeLists.txt +++ b/inference-engine/samples/pdpd_poc/CMakeLists.txt @@ -5,8 +5,13 @@ file (GLOB SRC ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) file (GLOB HDR ${CMAKE_CURRENT_SOURCE_DIR}/*.hpp) +find_package(Protobuf REQUIRED IMPORTED) +include_directories(${Protobuf_INCLUDE_DIRS}) +protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS framework.proto) + ie_add_sample(NAME pdpd_poc - SOURCES ${SRC} - HEADERS ${HDR} - DEPENDENCIES format_reader ngraph - OPENCV_DEPENDENCIES imgcodecs) + SOURCES ${SRC} ${PROTO_SRCS} + HEADERS ${HDR} ${PROTO_HDRS} + DEPENDENCIES format_reader ngraph libprotobuf libprotoc + OPENCV_DEPENDENCIES imgcodecs + EXCLUDE_CPPLINT) diff --git a/inference-engine/samples/pdpd_poc/framework.pb.cc b/inference-engine/samples/pdpd_poc/framework.pb.cc deleted file mode 100644 index 1c84f3b1a33453..00000000000000 --- a/inference-engine/samples/pdpd_poc/framework.pb.cc +++ /dev/null @@ -1,7018 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: framework.proto - -#include "framework.pb.h" - -#include - -#include -#include -#include -#include -#include -#include -#include -// @@protoc_insertion_point(includes) -#include -extern PROTOBUF_INTERNAL_EXPORT_framework_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<2> scc_info_BlockDesc_framework_2eproto; -extern PROTOBUF_INTERNAL_EXPORT_framework_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<2> scc_info_OpDesc_framework_2eproto; -extern PROTOBUF_INTERNAL_EXPORT_framework_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_OpDesc_Attr_framework_2eproto; -extern PROTOBUF_INTERNAL_EXPORT_framework_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_OpDesc_Var_framework_2eproto; -extern PROTOBUF_INTERNAL_EXPORT_framework_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_OpProto_Attr_framework_2eproto; -extern PROTOBUF_INTERNAL_EXPORT_framework_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_OpProto_Var_framework_2eproto; -extern PROTOBUF_INTERNAL_EXPORT_framework_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_OpVersion_framework_2eproto; -extern PROTOBUF_INTERNAL_EXPORT_framework_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_OpVersionMap_framework_2eproto; -extern PROTOBUF_INTERNAL_EXPORT_framework_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_OpVersionMap_OpVersionPair_framework_2eproto; -extern PROTOBUF_INTERNAL_EXPORT_framework_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_VarDesc_framework_2eproto; -extern PROTOBUF_INTERNAL_EXPORT_framework_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<5> scc_info_VarType_framework_2eproto; -extern PROTOBUF_INTERNAL_EXPORT_framework_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_VarType_LoDTensorArrayDesc_framework_2eproto; -extern PROTOBUF_INTERNAL_EXPORT_framework_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_VarType_LoDTensorDesc_framework_2eproto; -extern PROTOBUF_INTERNAL_EXPORT_framework_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_VarType_ReaderDesc_framework_2eproto; -extern PROTOBUF_INTERNAL_EXPORT_framework_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_VarType_TensorDesc_framework_2eproto; -extern PROTOBUF_INTERNAL_EXPORT_framework_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_VarType_Tuple_framework_2eproto; -extern PROTOBUF_INTERNAL_EXPORT_framework_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_Version_framework_2eproto; -namespace paddle { -namespace framework { -namespace proto { -class VersionDefaultTypeInternal { - public: - ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; -} _Version_default_instance_; -class OpDesc_AttrDefaultTypeInternal { - public: - ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; -} _OpDesc_Attr_default_instance_; -class OpDesc_VarDefaultTypeInternal { - public: - ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; -} _OpDesc_Var_default_instance_; -class OpDescDefaultTypeInternal { - public: - ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; -} _OpDesc_default_instance_; -class OpProto_VarDefaultTypeInternal { - public: - ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; -} _OpProto_Var_default_instance_; -class OpProto_AttrDefaultTypeInternal { - public: - ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; -} _OpProto_Attr_default_instance_; -class OpProtoDefaultTypeInternal { - public: - ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; -} _OpProto_default_instance_; -class VarType_TensorDescDefaultTypeInternal { - public: - ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; -} _VarType_TensorDesc_default_instance_; -class VarType_LoDTensorDescDefaultTypeInternal { - public: - ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; -} _VarType_LoDTensorDesc_default_instance_; -class VarType_LoDTensorArrayDescDefaultTypeInternal { - public: - ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; -} _VarType_LoDTensorArrayDesc_default_instance_; -class VarType_ReaderDescDefaultTypeInternal { - public: - ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; -} _VarType_ReaderDesc_default_instance_; -class VarType_TupleDefaultTypeInternal { - public: - ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; -} _VarType_Tuple_default_instance_; -class VarTypeDefaultTypeInternal { - public: - ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; -} _VarType_default_instance_; -class VarDescDefaultTypeInternal { - public: - ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; -} _VarDesc_default_instance_; -class BlockDescDefaultTypeInternal { - public: - ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; -} _BlockDesc_default_instance_; -class OpVersionDefaultTypeInternal { - public: - ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; -} _OpVersion_default_instance_; -class OpVersionMap_OpVersionPairDefaultTypeInternal { - public: - ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; -} _OpVersionMap_OpVersionPair_default_instance_; -class OpVersionMapDefaultTypeInternal { - public: - ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; -} _OpVersionMap_default_instance_; -class ProgramDescDefaultTypeInternal { - public: - ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; -} _ProgramDesc_default_instance_; -} // namespace proto -} // namespace framework -} // namespace paddle -static void InitDefaultsscc_info_BlockDesc_framework_2eproto() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - - { - void* ptr = &::paddle::framework::proto::_BlockDesc_default_instance_; - new (ptr) ::paddle::framework::proto::BlockDesc(); - ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); - } -} - -::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<2> scc_info_BlockDesc_framework_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 2, 0, InitDefaultsscc_info_BlockDesc_framework_2eproto}, { - &scc_info_VarDesc_framework_2eproto.base, - &scc_info_OpDesc_framework_2eproto.base,}}; - -static void InitDefaultsscc_info_OpDesc_framework_2eproto() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - - { - void* ptr = &::paddle::framework::proto::_OpDesc_default_instance_; - new (ptr) ::paddle::framework::proto::OpDesc(); - ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); - } -} - -::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<2> scc_info_OpDesc_framework_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 2, 0, InitDefaultsscc_info_OpDesc_framework_2eproto}, { - &scc_info_OpDesc_Var_framework_2eproto.base, - &scc_info_OpDesc_Attr_framework_2eproto.base,}}; - -static void InitDefaultsscc_info_OpDesc_Attr_framework_2eproto() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - - { - void* ptr = &::paddle::framework::proto::_OpDesc_Attr_default_instance_; - new (ptr) ::paddle::framework::proto::OpDesc_Attr(); - ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); - } -} - -::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_OpDesc_Attr_framework_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, 0, InitDefaultsscc_info_OpDesc_Attr_framework_2eproto}, {}}; - -static void InitDefaultsscc_info_OpDesc_Var_framework_2eproto() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - - { - void* ptr = &::paddle::framework::proto::_OpDesc_Var_default_instance_; - new (ptr) ::paddle::framework::proto::OpDesc_Var(); - ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); - } -} - -::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_OpDesc_Var_framework_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, 0, InitDefaultsscc_info_OpDesc_Var_framework_2eproto}, {}}; - -static void InitDefaultsscc_info_OpProto_framework_2eproto() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - - { - void* ptr = &::paddle::framework::proto::_OpProto_default_instance_; - new (ptr) ::paddle::framework::proto::OpProto(); - ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); - } -} - -::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<2> scc_info_OpProto_framework_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 2, 0, InitDefaultsscc_info_OpProto_framework_2eproto}, { - &scc_info_OpProto_Var_framework_2eproto.base, - &scc_info_OpProto_Attr_framework_2eproto.base,}}; - -static void InitDefaultsscc_info_OpProto_Attr_framework_2eproto() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - - { - void* ptr = &::paddle::framework::proto::_OpProto_Attr_default_instance_; - new (ptr) ::paddle::framework::proto::OpProto_Attr(); - ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); - } -} - -::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_OpProto_Attr_framework_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, 0, InitDefaultsscc_info_OpProto_Attr_framework_2eproto}, {}}; - -static void InitDefaultsscc_info_OpProto_Var_framework_2eproto() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - - { - void* ptr = &::paddle::framework::proto::_OpProto_Var_default_instance_; - new (ptr) ::paddle::framework::proto::OpProto_Var(); - ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); - } -} - -::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_OpProto_Var_framework_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, 0, InitDefaultsscc_info_OpProto_Var_framework_2eproto}, {}}; - -static void InitDefaultsscc_info_OpVersion_framework_2eproto() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - - { - void* ptr = &::paddle::framework::proto::_OpVersion_default_instance_; - new (ptr) ::paddle::framework::proto::OpVersion(); - ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); - } -} - -::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_OpVersion_framework_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, 0, InitDefaultsscc_info_OpVersion_framework_2eproto}, {}}; - -static void InitDefaultsscc_info_OpVersionMap_framework_2eproto() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - - { - void* ptr = &::paddle::framework::proto::_OpVersionMap_default_instance_; - new (ptr) ::paddle::framework::proto::OpVersionMap(); - ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); - } -} - -::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_OpVersionMap_framework_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, 0, InitDefaultsscc_info_OpVersionMap_framework_2eproto}, { - &scc_info_OpVersionMap_OpVersionPair_framework_2eproto.base,}}; - -static void InitDefaultsscc_info_OpVersionMap_OpVersionPair_framework_2eproto() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - - { - void* ptr = &::paddle::framework::proto::_OpVersionMap_OpVersionPair_default_instance_; - new (ptr) ::paddle::framework::proto::OpVersionMap_OpVersionPair(); - ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); - } -} - -::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_OpVersionMap_OpVersionPair_framework_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, 0, InitDefaultsscc_info_OpVersionMap_OpVersionPair_framework_2eproto}, { - &scc_info_OpVersion_framework_2eproto.base,}}; - -static void InitDefaultsscc_info_ProgramDesc_framework_2eproto() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - - { - void* ptr = &::paddle::framework::proto::_ProgramDesc_default_instance_; - new (ptr) ::paddle::framework::proto::ProgramDesc(); - ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); - } -} - -::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<3> scc_info_ProgramDesc_framework_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 3, 0, InitDefaultsscc_info_ProgramDesc_framework_2eproto}, { - &scc_info_BlockDesc_framework_2eproto.base, - &scc_info_Version_framework_2eproto.base, - &scc_info_OpVersionMap_framework_2eproto.base,}}; - -static void InitDefaultsscc_info_VarDesc_framework_2eproto() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - - { - void* ptr = &::paddle::framework::proto::_VarDesc_default_instance_; - new (ptr) ::paddle::framework::proto::VarDesc(); - ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); - } -} - -::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_VarDesc_framework_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, 0, InitDefaultsscc_info_VarDesc_framework_2eproto}, { - &scc_info_VarType_framework_2eproto.base,}}; - -static void InitDefaultsscc_info_VarType_framework_2eproto() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - - { - void* ptr = &::paddle::framework::proto::_VarType_default_instance_; - new (ptr) ::paddle::framework::proto::VarType(); - ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); - } -} - -::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<5> scc_info_VarType_framework_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 5, 0, InitDefaultsscc_info_VarType_framework_2eproto}, { - &scc_info_VarType_TensorDesc_framework_2eproto.base, - &scc_info_VarType_LoDTensorDesc_framework_2eproto.base, - &scc_info_VarType_LoDTensorArrayDesc_framework_2eproto.base, - &scc_info_VarType_ReaderDesc_framework_2eproto.base, - &scc_info_VarType_Tuple_framework_2eproto.base,}}; - -static void InitDefaultsscc_info_VarType_LoDTensorArrayDesc_framework_2eproto() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - - { - void* ptr = &::paddle::framework::proto::_VarType_LoDTensorArrayDesc_default_instance_; - new (ptr) ::paddle::framework::proto::VarType_LoDTensorArrayDesc(); - ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); - } -} - -::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_VarType_LoDTensorArrayDesc_framework_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, 0, InitDefaultsscc_info_VarType_LoDTensorArrayDesc_framework_2eproto}, { - &scc_info_VarType_TensorDesc_framework_2eproto.base,}}; - -static void InitDefaultsscc_info_VarType_LoDTensorDesc_framework_2eproto() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - - { - void* ptr = &::paddle::framework::proto::_VarType_LoDTensorDesc_default_instance_; - new (ptr) ::paddle::framework::proto::VarType_LoDTensorDesc(); - ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); - } -} - -::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_VarType_LoDTensorDesc_framework_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, 0, InitDefaultsscc_info_VarType_LoDTensorDesc_framework_2eproto}, { - &scc_info_VarType_TensorDesc_framework_2eproto.base,}}; - -static void InitDefaultsscc_info_VarType_ReaderDesc_framework_2eproto() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - - { - void* ptr = &::paddle::framework::proto::_VarType_ReaderDesc_default_instance_; - new (ptr) ::paddle::framework::proto::VarType_ReaderDesc(); - ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); - } -} - -::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_VarType_ReaderDesc_framework_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, 0, InitDefaultsscc_info_VarType_ReaderDesc_framework_2eproto}, { - &scc_info_VarType_LoDTensorDesc_framework_2eproto.base,}}; - -static void InitDefaultsscc_info_VarType_TensorDesc_framework_2eproto() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - - { - void* ptr = &::paddle::framework::proto::_VarType_TensorDesc_default_instance_; - new (ptr) ::paddle::framework::proto::VarType_TensorDesc(); - ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); - } -} - -::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_VarType_TensorDesc_framework_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, 0, InitDefaultsscc_info_VarType_TensorDesc_framework_2eproto}, {}}; - -static void InitDefaultsscc_info_VarType_Tuple_framework_2eproto() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - - { - void* ptr = &::paddle::framework::proto::_VarType_Tuple_default_instance_; - new (ptr) ::paddle::framework::proto::VarType_Tuple(); - ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); - } -} - -::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_VarType_Tuple_framework_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, 0, InitDefaultsscc_info_VarType_Tuple_framework_2eproto}, {}}; - -static void InitDefaultsscc_info_Version_framework_2eproto() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - - { - void* ptr = &::paddle::framework::proto::_Version_default_instance_; - new (ptr) ::paddle::framework::proto::Version(); - ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); - } -} - -::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_Version_framework_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, 0, InitDefaultsscc_info_Version_framework_2eproto}, {}}; - -static ::PROTOBUF_NAMESPACE_ID::Metadata file_level_metadata_framework_2eproto[19]; -static const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* file_level_enum_descriptors_framework_2eproto[2]; -static constexpr ::PROTOBUF_NAMESPACE_ID::ServiceDescriptor const** file_level_service_descriptors_framework_2eproto = nullptr; - -const ::PROTOBUF_NAMESPACE_ID::uint32 TableStruct_framework_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::Version, _has_bits_), - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::Version, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::Version, version_), - 0, - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpDesc_Attr, _has_bits_), - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpDesc_Attr, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpDesc_Attr, name_), - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpDesc_Attr, type_), - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpDesc_Attr, i_), - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpDesc_Attr, f_), - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpDesc_Attr, s_), - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpDesc_Attr, ints_), - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpDesc_Attr, floats_), - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpDesc_Attr, strings_), - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpDesc_Attr, b_), - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpDesc_Attr, bools_), - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpDesc_Attr, block_idx_), - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpDesc_Attr, l_), - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpDesc_Attr, blocks_idx_), - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpDesc_Attr, longs_), - 0, - 2, - 3, - 4, - 1, - ~0u, - ~0u, - ~0u, - 5, - ~0u, - 7, - 6, - ~0u, - ~0u, - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpDesc_Var, _has_bits_), - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpDesc_Var, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpDesc_Var, parameter_), - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpDesc_Var, arguments_), - 0, - ~0u, - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpDesc, _has_bits_), - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpDesc, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpDesc, type_), - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpDesc, inputs_), - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpDesc, outputs_), - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpDesc, attrs_), - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpDesc, is_target_), - 0, - ~0u, - ~0u, - ~0u, - 1, - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpProto_Var, _has_bits_), - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpProto_Var, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpProto_Var, name_), - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpProto_Var, comment_), - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpProto_Var, duplicable_), - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpProto_Var, intermediate_), - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpProto_Var, dispensable_), - 0, - 1, - 2, - 3, - 4, - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpProto_Attr, _has_bits_), - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpProto_Attr, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpProto_Attr, name_), - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpProto_Attr, type_), - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpProto_Attr, comment_), - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpProto_Attr, generated_), - 0, - 2, - 1, - 3, - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpProto, _has_bits_), - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpProto, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpProto, type_), - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpProto, inputs_), - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpProto, outputs_), - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpProto, attrs_), - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpProto, comment_), - 0, - ~0u, - ~0u, - ~0u, - 1, - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::VarType_TensorDesc, _has_bits_), - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::VarType_TensorDesc, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::VarType_TensorDesc, data_type_), - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::VarType_TensorDesc, dims_), - 0, - ~0u, - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::VarType_LoDTensorDesc, _has_bits_), - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::VarType_LoDTensorDesc, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::VarType_LoDTensorDesc, tensor_), - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::VarType_LoDTensorDesc, lod_level_), - 0, - 1, - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::VarType_LoDTensorArrayDesc, _has_bits_), - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::VarType_LoDTensorArrayDesc, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::VarType_LoDTensorArrayDesc, tensor_), - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::VarType_LoDTensorArrayDesc, lod_level_), - 0, - 1, - ~0u, // no _has_bits_ - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::VarType_ReaderDesc, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::VarType_ReaderDesc, lod_tensor_), - ~0u, // no _has_bits_ - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::VarType_Tuple, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::VarType_Tuple, element_type_), - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::VarType, _has_bits_), - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::VarType, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::VarType, type_), - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::VarType, selected_rows_), - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::VarType, lod_tensor_), - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::VarType, tensor_array_), - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::VarType, reader_), - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::VarType, tuple_), - 5, - 0, - 1, - 2, - 3, - 4, - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::VarDesc, _has_bits_), - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::VarDesc, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::VarDesc, name_), - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::VarDesc, type_), - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::VarDesc, persistable_), - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::VarDesc, need_check_feed_), - 0, - 1, - 2, - 3, - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::BlockDesc, _has_bits_), - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::BlockDesc, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::BlockDesc, idx_), - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::BlockDesc, parent_idx_), - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::BlockDesc, vars_), - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::BlockDesc, ops_), - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::BlockDesc, forward_block_idx_), - 0, - 1, - ~0u, - ~0u, - 2, - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpVersion, _has_bits_), - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpVersion, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpVersion, version_), - 0, - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpVersionMap_OpVersionPair, _has_bits_), - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpVersionMap_OpVersionPair, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpVersionMap_OpVersionPair, op_name_), - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpVersionMap_OpVersionPair, op_version_), - 0, - 1, - ~0u, // no _has_bits_ - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpVersionMap, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::OpVersionMap, pair_), - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::ProgramDesc, _has_bits_), - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::ProgramDesc, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::ProgramDesc, blocks_), - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::ProgramDesc, version_), - PROTOBUF_FIELD_OFFSET(::paddle::framework::proto::ProgramDesc, op_version_map_), - ~0u, - 0, - 1, -}; -static const ::PROTOBUF_NAMESPACE_ID::internal::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { - { 0, 6, sizeof(::paddle::framework::proto::Version)}, - { 7, 26, sizeof(::paddle::framework::proto::OpDesc_Attr)}, - { 40, 47, sizeof(::paddle::framework::proto::OpDesc_Var)}, - { 49, 59, sizeof(::paddle::framework::proto::OpDesc)}, - { 64, 74, sizeof(::paddle::framework::proto::OpProto_Var)}, - { 79, 88, sizeof(::paddle::framework::proto::OpProto_Attr)}, - { 92, 102, sizeof(::paddle::framework::proto::OpProto)}, - { 107, 114, sizeof(::paddle::framework::proto::VarType_TensorDesc)}, - { 116, 123, sizeof(::paddle::framework::proto::VarType_LoDTensorDesc)}, - { 125, 132, sizeof(::paddle::framework::proto::VarType_LoDTensorArrayDesc)}, - { 134, -1, sizeof(::paddle::framework::proto::VarType_ReaderDesc)}, - { 140, -1, sizeof(::paddle::framework::proto::VarType_Tuple)}, - { 146, 157, sizeof(::paddle::framework::proto::VarType)}, - { 163, 172, sizeof(::paddle::framework::proto::VarDesc)}, - { 176, 186, sizeof(::paddle::framework::proto::BlockDesc)}, - { 191, 197, sizeof(::paddle::framework::proto::OpVersion)}, - { 198, 205, sizeof(::paddle::framework::proto::OpVersionMap_OpVersionPair)}, - { 207, -1, sizeof(::paddle::framework::proto::OpVersionMap)}, - { 213, 221, sizeof(::paddle::framework::proto::ProgramDesc)}, -}; - -static ::PROTOBUF_NAMESPACE_ID::Message const * const file_default_instances[] = { - reinterpret_cast(&::paddle::framework::proto::_Version_default_instance_), - reinterpret_cast(&::paddle::framework::proto::_OpDesc_Attr_default_instance_), - reinterpret_cast(&::paddle::framework::proto::_OpDesc_Var_default_instance_), - reinterpret_cast(&::paddle::framework::proto::_OpDesc_default_instance_), - reinterpret_cast(&::paddle::framework::proto::_OpProto_Var_default_instance_), - reinterpret_cast(&::paddle::framework::proto::_OpProto_Attr_default_instance_), - reinterpret_cast(&::paddle::framework::proto::_OpProto_default_instance_), - reinterpret_cast(&::paddle::framework::proto::_VarType_TensorDesc_default_instance_), - reinterpret_cast(&::paddle::framework::proto::_VarType_LoDTensorDesc_default_instance_), - reinterpret_cast(&::paddle::framework::proto::_VarType_LoDTensorArrayDesc_default_instance_), - reinterpret_cast(&::paddle::framework::proto::_VarType_ReaderDesc_default_instance_), - reinterpret_cast(&::paddle::framework::proto::_VarType_Tuple_default_instance_), - reinterpret_cast(&::paddle::framework::proto::_VarType_default_instance_), - reinterpret_cast(&::paddle::framework::proto::_VarDesc_default_instance_), - reinterpret_cast(&::paddle::framework::proto::_BlockDesc_default_instance_), - reinterpret_cast(&::paddle::framework::proto::_OpVersion_default_instance_), - reinterpret_cast(&::paddle::framework::proto::_OpVersionMap_OpVersionPair_default_instance_), - reinterpret_cast(&::paddle::framework::proto::_OpVersionMap_default_instance_), - reinterpret_cast(&::paddle::framework::proto::_ProgramDesc_default_instance_), -}; - -const char descriptor_table_protodef_framework_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = - "\n\017framework.proto\022\026paddle.framework.prot" - "o\"\035\n\007Version\022\022\n\007version\030\001 \001(\003:\0010\"\354\003\n\006OpD" - "esc\022\014\n\004type\030\003 \002(\t\0222\n\006inputs\030\001 \003(\0132\".padd" - "le.framework.proto.OpDesc.Var\0223\n\007outputs" - "\030\002 \003(\0132\".paddle.framework.proto.OpDesc.V" - "ar\0222\n\005attrs\030\004 \003(\0132#.paddle.framework.pro" - "to.OpDesc.Attr\022\030\n\tis_target\030\005 \001(\010:\005false" - "\032\357\001\n\004Attr\022\014\n\004name\030\001 \002(\t\022.\n\004type\030\002 \002(\0162 ." - "paddle.framework.proto.AttrType\022\t\n\001i\030\003 \001" - "(\005\022\t\n\001f\030\004 \001(\002\022\t\n\001s\030\005 \001(\t\022\014\n\004ints\030\006 \003(\005\022\016" - "\n\006floats\030\007 \003(\002\022\017\n\007strings\030\010 \003(\t\022\t\n\001b\030\n \001" - "(\010\022\r\n\005bools\030\013 \003(\010\022\021\n\tblock_idx\030\014 \001(\005\022\t\n\001" - "l\030\r \001(\003\022\022\n\nblocks_idx\030\016 \003(\005\022\r\n\005longs\030\017 \003" - "(\003\032+\n\003Var\022\021\n\tparameter\030\001 \002(\t\022\021\n\targument" - "s\030\002 \003(\t\"\263\003\n\007OpProto\022\014\n\004type\030\001 \002(\t\0223\n\006inp" - "uts\030\002 \003(\0132#.paddle.framework.proto.OpPro" - "to.Var\0224\n\007outputs\030\003 \003(\0132#.paddle.framewo" - "rk.proto.OpProto.Var\0223\n\005attrs\030\004 \003(\0132$.pa" - "ddle.framework.proto.OpProto.Attr\022\017\n\007com" - "ment\030\005 \002(\t\032x\n\003Var\022\014\n\004name\030\001 \002(\t\022\017\n\007comme" - "nt\030\002 \002(\t\022\031\n\nduplicable\030\003 \001(\010:\005false\022\033\n\014i" - "ntermediate\030\004 \001(\010:\005false\022\032\n\013dispensable\030" - "\005 \001(\010:\005false\032o\n\004Attr\022\014\n\004name\030\001 \002(\t\022.\n\004ty" - "pe\030\002 \002(\0162 .paddle.framework.proto.AttrTy" - "pe\022\017\n\007comment\030\003 \002(\t\022\030\n\tgenerated\030\004 \001(\010:\005" - "false\"\203\t\n\007VarType\0222\n\004type\030\001 \002(\0162$.paddle" - ".framework.proto.VarType.Type\022A\n\rselecte" - "d_rows\030\002 \001(\0132*.paddle.framework.proto.Va" - "rType.TensorDesc\022A\n\nlod_tensor\030\003 \001(\0132-.p" - "addle.framework.proto.VarType.LoDTensorD" - "esc\022H\n\014tensor_array\030\004 \001(\01322.paddle.frame" - "work.proto.VarType.LoDTensorArrayDesc\022:\n" - "\006reader\030\005 \001(\0132*.paddle.framework.proto.V" - "arType.ReaderDesc\0224\n\005tuple\030\007 \001(\0132%.paddl" - "e.framework.proto.VarType.Tuple\032S\n\nTenso" - "rDesc\0227\n\tdata_type\030\001 \002(\0162$.paddle.framew" - "ork.proto.VarType.Type\022\014\n\004dims\030\002 \003(\003\032a\n\r" - "LoDTensorDesc\022:\n\006tensor\030\001 \002(\0132*.paddle.f" - "ramework.proto.VarType.TensorDesc\022\024\n\tlod" - "_level\030\002 \001(\005:\0010\032f\n\022LoDTensorArrayDesc\022:\n" - "\006tensor\030\001 \002(\0132*.paddle.framework.proto.V" - "arType.TensorDesc\022\024\n\tlod_level\030\002 \001(\005:\0010\032" - "O\n\nReaderDesc\022A\n\nlod_tensor\030\001 \003(\0132-.padd" - "le.framework.proto.VarType.LoDTensorDesc" - "\032C\n\005Tuple\022:\n\014element_type\030\001 \003(\0162$.paddle" - ".framework.proto.VarType.Type\"\313\002\n\004Type\022\010" - "\n\004BOOL\020\000\022\t\n\005INT16\020\001\022\t\n\005INT32\020\002\022\t\n\005INT64\020" - "\003\022\010\n\004FP16\020\004\022\010\n\004FP32\020\005\022\010\n\004FP64\020\006\022\n\n\006SIZE_" - "T\020\023\022\t\n\005UINT8\020\024\022\010\n\004INT8\020\025\022\010\n\004BF16\020\026\022\r\n\tCO" - "MPLEX64\020\027\022\016\n\nCOMPLEX128\020\030\022\016\n\nLOD_TENSOR\020" - "\007\022\021\n\rSELECTED_ROWS\020\010\022\022\n\016FEED_MINIBATCH\020\t" - "\022\016\n\nFETCH_LIST\020\n\022\017\n\013STEP_SCOPES\020\013\022\022\n\016LOD" - "_RANK_TABLE\020\014\022\024\n\020LOD_TENSOR_ARRAY\020\r\022\016\n\nP" - "LACE_LIST\020\016\022\n\n\006READER\020\017\022\007\n\003RAW\020\021\022\t\n\005TUPL" - "E\020\022\"\202\001\n\007VarDesc\022\014\n\004name\030\001 \002(\t\022-\n\004type\030\002 " - "\002(\0132\037.paddle.framework.proto.VarType\022\032\n\013" - "persistable\030\003 \001(\010:\005false\022\036\n\017need_check_f" - "eed\030\004 \001(\010:\005false\"\247\001\n\tBlockDesc\022\013\n\003idx\030\001 " - "\002(\005\022\022\n\nparent_idx\030\002 \002(\005\022-\n\004vars\030\003 \003(\0132\037." - "paddle.framework.proto.VarDesc\022+\n\003ops\030\004 " - "\003(\0132\036.paddle.framework.proto.OpDesc\022\035\n\021f" - "orward_block_idx\030\005 \001(\005:\002-1\"\034\n\tOpVersion\022" - "\017\n\007version\030\001 \002(\005\"\251\001\n\014OpVersionMap\022@\n\004pai" - "r\030\001 \003(\01322.paddle.framework.proto.OpVersi" - "onMap.OpVersionPair\032W\n\rOpVersionPair\022\017\n\007" - "op_name\030\001 \002(\t\0225\n\nop_version\030\002 \002(\0132!.padd" - "le.framework.proto.OpVersion\"\274\001\n\013Program" - "Desc\0221\n\006blocks\030\001 \003(\0132!.paddle.framework." - "proto.BlockDesc\0220\n\007version\030\004 \001(\0132\037.paddl" - "e.framework.proto.Version\022<\n\016op_version_" - "map\030\005 \001(\0132$.paddle.framework.proto.OpVer" - "sionMapJ\004\010\002\020\003J\004\010\003\020\004*\224\001\n\010AttrType\022\007\n\003INT\020" - "\000\022\t\n\005FLOAT\020\001\022\n\n\006STRING\020\002\022\010\n\004INTS\020\003\022\n\n\006FL" - "OATS\020\004\022\013\n\007STRINGS\020\005\022\013\n\007BOOLEAN\020\006\022\014\n\010BOOL" - "EANS\020\007\022\t\n\005BLOCK\020\010\022\010\n\004LONG\020\t\022\n\n\006BLOCKS\020\n\022" - "\t\n\005LONGS\020\013" - ; -static const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable*const descriptor_table_framework_2eproto_deps[1] = { -}; -static ::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase*const descriptor_table_framework_2eproto_sccs[19] = { - &scc_info_BlockDesc_framework_2eproto.base, - &scc_info_OpDesc_framework_2eproto.base, - &scc_info_OpDesc_Attr_framework_2eproto.base, - &scc_info_OpDesc_Var_framework_2eproto.base, - &scc_info_OpProto_framework_2eproto.base, - &scc_info_OpProto_Attr_framework_2eproto.base, - &scc_info_OpProto_Var_framework_2eproto.base, - &scc_info_OpVersion_framework_2eproto.base, - &scc_info_OpVersionMap_framework_2eproto.base, - &scc_info_OpVersionMap_OpVersionPair_framework_2eproto.base, - &scc_info_ProgramDesc_framework_2eproto.base, - &scc_info_VarDesc_framework_2eproto.base, - &scc_info_VarType_framework_2eproto.base, - &scc_info_VarType_LoDTensorArrayDesc_framework_2eproto.base, - &scc_info_VarType_LoDTensorDesc_framework_2eproto.base, - &scc_info_VarType_ReaderDesc_framework_2eproto.base, - &scc_info_VarType_TensorDesc_framework_2eproto.base, - &scc_info_VarType_Tuple_framework_2eproto.base, - &scc_info_Version_framework_2eproto.base, -}; -static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_framework_2eproto_once; -const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_framework_2eproto = { - false, false, descriptor_table_protodef_framework_2eproto, "framework.proto", 3010, - &descriptor_table_framework_2eproto_once, descriptor_table_framework_2eproto_sccs, descriptor_table_framework_2eproto_deps, 19, 0, - schemas, file_default_instances, TableStruct_framework_2eproto::offsets, - file_level_metadata_framework_2eproto, 19, file_level_enum_descriptors_framework_2eproto, file_level_service_descriptors_framework_2eproto, -}; - -// Force running AddDescriptors() at dynamic initialization time. -static bool dynamic_init_dummy_framework_2eproto = (static_cast(::PROTOBUF_NAMESPACE_ID::internal::AddDescriptors(&descriptor_table_framework_2eproto)), true); -namespace paddle { -namespace framework { -namespace proto { -const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* VarType_Type_descriptor() { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_framework_2eproto); - return file_level_enum_descriptors_framework_2eproto[0]; -} -bool VarType_Type_IsValid(int value) { - switch (value) { - case 0: - case 1: - case 2: - case 3: - case 4: - case 5: - case 6: - case 7: - case 8: - case 9: - case 10: - case 11: - case 12: - case 13: - case 14: - case 15: - case 17: - case 18: - case 19: - case 20: - case 21: - case 22: - case 23: - case 24: - return true; - default: - return false; - } -} - -#if (__cplusplus < 201703) && (!defined(_MSC_VER) || _MSC_VER >= 1900) -constexpr VarType_Type VarType::BOOL; -constexpr VarType_Type VarType::INT16; -constexpr VarType_Type VarType::INT32; -constexpr VarType_Type VarType::INT64; -constexpr VarType_Type VarType::FP16; -constexpr VarType_Type VarType::FP32; -constexpr VarType_Type VarType::FP64; -constexpr VarType_Type VarType::SIZE_T; -constexpr VarType_Type VarType::UINT8; -constexpr VarType_Type VarType::INT8; -constexpr VarType_Type VarType::BF16; -constexpr VarType_Type VarType::COMPLEX64; -constexpr VarType_Type VarType::COMPLEX128; -constexpr VarType_Type VarType::LOD_TENSOR; -constexpr VarType_Type VarType::SELECTED_ROWS; -constexpr VarType_Type VarType::FEED_MINIBATCH; -constexpr VarType_Type VarType::FETCH_LIST; -constexpr VarType_Type VarType::STEP_SCOPES; -constexpr VarType_Type VarType::LOD_RANK_TABLE; -constexpr VarType_Type VarType::LOD_TENSOR_ARRAY; -constexpr VarType_Type VarType::PLACE_LIST; -constexpr VarType_Type VarType::READER; -constexpr VarType_Type VarType::RAW; -constexpr VarType_Type VarType::TUPLE; -constexpr VarType_Type VarType::Type_MIN; -constexpr VarType_Type VarType::Type_MAX; -constexpr int VarType::Type_ARRAYSIZE; -#endif // (__cplusplus < 201703) && (!defined(_MSC_VER) || _MSC_VER >= 1900) -const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* AttrType_descriptor() { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_framework_2eproto); - return file_level_enum_descriptors_framework_2eproto[1]; -} -bool AttrType_IsValid(int value) { - switch (value) { - case 0: - case 1: - case 2: - case 3: - case 4: - case 5: - case 6: - case 7: - case 8: - case 9: - case 10: - case 11: - return true; - default: - return false; - } -} - - -// =================================================================== - -class Version::_Internal { - public: - using HasBits = decltype(std::declval()._has_bits_); - static void set_has_version(HasBits* has_bits) { - (*has_bits)[0] |= 1u; - } -}; - -Version::Version(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::Message(arena) { - SharedCtor(); - RegisterArenaDtor(arena); - // @@protoc_insertion_point(arena_constructor:paddle.framework.proto.Version) -} -Version::Version(const Version& from) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _has_bits_(from._has_bits_) { - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - version_ = from.version_; - // @@protoc_insertion_point(copy_constructor:paddle.framework.proto.Version) -} - -void Version::SharedCtor() { - version_ = PROTOBUF_LONGLONG(0); -} - -Version::~Version() { - // @@protoc_insertion_point(destructor:paddle.framework.proto.Version) - SharedDtor(); - _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); -} - -void Version::SharedDtor() { - GOOGLE_DCHECK(GetArena() == nullptr); -} - -void Version::ArenaDtor(void* object) { - Version* _this = reinterpret_cast< Version* >(object); - (void)_this; -} -void Version::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { -} -void Version::SetCachedSize(int size) const { - _cached_size_.Set(size); -} -const Version& Version::default_instance() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_Version_framework_2eproto.base); - return *internal_default_instance(); -} - - -void Version::Clear() { -// @@protoc_insertion_point(message_clear_start:paddle.framework.proto.Version) - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - - version_ = PROTOBUF_LONGLONG(0); - _has_bits_.Clear(); - _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); -} - -const char* Version::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { -#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - _Internal::HasBits has_bits{}; - while (!ctx->Done(&ptr)) { - ::PROTOBUF_NAMESPACE_ID::uint32 tag; - ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); - CHK_(ptr); - switch (tag >> 3) { - // optional int64 version = 1 [default = 0]; - case 1: - if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 8)) { - _Internal::set_has_version(&has_bits); - version_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); - CHK_(ptr); - } else goto handle_unusual; - continue; - default: { - handle_unusual: - if ((tag & 7) == 4 || tag == 0) { - ctx->SetLastTag(tag); - goto success; - } - ptr = UnknownFieldParse(tag, - _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), - ptr, ctx); - CHK_(ptr != nullptr); - continue; - } - } // switch - } // while -success: - _has_bits_.Or(has_bits); - return ptr; -failure: - ptr = nullptr; - goto success; -#undef CHK_ -} - -::PROTOBUF_NAMESPACE_ID::uint8* Version::_InternalSerialize( - ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { - // @@protoc_insertion_point(serialize_to_array_start:paddle.framework.proto.Version) - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; - (void) cached_has_bits; - - cached_has_bits = _has_bits_[0]; - // optional int64 version = 1 [default = 0]; - if (cached_has_bits & 0x00000001u) { - target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt64ToArray(1, this->_internal_version(), target); - } - - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); - } - // @@protoc_insertion_point(serialize_to_array_end:paddle.framework.proto.Version) - return target; -} - -size_t Version::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:paddle.framework.proto.Version) - size_t total_size = 0; - - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - - // optional int64 version = 1 [default = 0]; - cached_has_bits = _has_bits_[0]; - if (cached_has_bits & 0x00000001u) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int64Size( - this->_internal_version()); - } - - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize( - _internal_metadata_, total_size, &_cached_size_); - } - int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size); - SetCachedSize(cached_size); - return total_size; -} - -void Version::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { -// @@protoc_insertion_point(generalized_merge_from_start:paddle.framework.proto.Version) - GOOGLE_DCHECK_NE(&from, this); - const Version* source = - ::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated( - &from); - if (source == nullptr) { - // @@protoc_insertion_point(generalized_merge_from_cast_fail:paddle.framework.proto.Version) - ::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this); - } else { - // @@protoc_insertion_point(generalized_merge_from_cast_success:paddle.framework.proto.Version) - MergeFrom(*source); - } -} - -void Version::MergeFrom(const Version& from) { -// @@protoc_insertion_point(class_specific_merge_from_start:paddle.framework.proto.Version) - GOOGLE_DCHECK_NE(&from, this); - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; - (void) cached_has_bits; - - if (from._internal_has_version()) { - _internal_set_version(from._internal_version()); - } -} - -void Version::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { -// @@protoc_insertion_point(generalized_copy_from_start:paddle.framework.proto.Version) - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -void Version::CopyFrom(const Version& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:paddle.framework.proto.Version) - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -bool Version::IsInitialized() const { - return true; -} - -void Version::InternalSwap(Version* other) { - using std::swap; - _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); - swap(_has_bits_[0], other->_has_bits_[0]); - swap(version_, other->version_); -} - -::PROTOBUF_NAMESPACE_ID::Metadata Version::GetMetadata() const { - return GetMetadataStatic(); -} - - -// =================================================================== - -class OpDesc_Attr::_Internal { - public: - using HasBits = decltype(std::declval()._has_bits_); - static void set_has_name(HasBits* has_bits) { - (*has_bits)[0] |= 1u; - } - static void set_has_type(HasBits* has_bits) { - (*has_bits)[0] |= 4u; - } - static void set_has_i(HasBits* has_bits) { - (*has_bits)[0] |= 8u; - } - static void set_has_f(HasBits* has_bits) { - (*has_bits)[0] |= 16u; - } - static void set_has_s(HasBits* has_bits) { - (*has_bits)[0] |= 2u; - } - static void set_has_b(HasBits* has_bits) { - (*has_bits)[0] |= 32u; - } - static void set_has_block_idx(HasBits* has_bits) { - (*has_bits)[0] |= 128u; - } - static void set_has_l(HasBits* has_bits) { - (*has_bits)[0] |= 64u; - } - static bool MissingRequiredFields(const HasBits& has_bits) { - return ((has_bits[0] & 0x00000005) ^ 0x00000005) != 0; - } -}; - -OpDesc_Attr::OpDesc_Attr(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::Message(arena), - ints_(arena), - floats_(arena), - strings_(arena), - bools_(arena), - blocks_idx_(arena), - longs_(arena) { - SharedCtor(); - RegisterArenaDtor(arena); - // @@protoc_insertion_point(arena_constructor:paddle.framework.proto.OpDesc.Attr) -} -OpDesc_Attr::OpDesc_Attr(const OpDesc_Attr& from) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _has_bits_(from._has_bits_), - ints_(from.ints_), - floats_(from.floats_), - strings_(from.strings_), - bools_(from.bools_), - blocks_idx_(from.blocks_idx_), - longs_(from.longs_) { - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (from._internal_has_name()) { - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(), - GetArena()); - } - s_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (from._internal_has_s()) { - s_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_s(), - GetArena()); - } - ::memcpy(&type_, &from.type_, - static_cast(reinterpret_cast(&block_idx_) - - reinterpret_cast(&type_)) + sizeof(block_idx_)); - // @@protoc_insertion_point(copy_constructor:paddle.framework.proto.OpDesc.Attr) -} - -void OpDesc_Attr::SharedCtor() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_OpDesc_Attr_framework_2eproto.base); - name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - s_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - ::memset(reinterpret_cast(this) + static_cast( - reinterpret_cast(&type_) - reinterpret_cast(this)), - 0, static_cast(reinterpret_cast(&block_idx_) - - reinterpret_cast(&type_)) + sizeof(block_idx_)); -} - -OpDesc_Attr::~OpDesc_Attr() { - // @@protoc_insertion_point(destructor:paddle.framework.proto.OpDesc.Attr) - SharedDtor(); - _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); -} - -void OpDesc_Attr::SharedDtor() { - GOOGLE_DCHECK(GetArena() == nullptr); - name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - s_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); -} - -void OpDesc_Attr::ArenaDtor(void* object) { - OpDesc_Attr* _this = reinterpret_cast< OpDesc_Attr* >(object); - (void)_this; -} -void OpDesc_Attr::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { -} -void OpDesc_Attr::SetCachedSize(int size) const { - _cached_size_.Set(size); -} -const OpDesc_Attr& OpDesc_Attr::default_instance() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_OpDesc_Attr_framework_2eproto.base); - return *internal_default_instance(); -} - - -void OpDesc_Attr::Clear() { -// @@protoc_insertion_point(message_clear_start:paddle.framework.proto.OpDesc.Attr) - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - - ints_.Clear(); - floats_.Clear(); - strings_.Clear(); - bools_.Clear(); - blocks_idx_.Clear(); - longs_.Clear(); - cached_has_bits = _has_bits_[0]; - if (cached_has_bits & 0x00000003u) { - if (cached_has_bits & 0x00000001u) { - name_.ClearNonDefaultToEmpty(); - } - if (cached_has_bits & 0x00000002u) { - s_.ClearNonDefaultToEmpty(); - } - } - if (cached_has_bits & 0x000000fcu) { - ::memset(&type_, 0, static_cast( - reinterpret_cast(&block_idx_) - - reinterpret_cast(&type_)) + sizeof(block_idx_)); - } - _has_bits_.Clear(); - _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); -} - -const char* OpDesc_Attr::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { -#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - _Internal::HasBits has_bits{}; - while (!ctx->Done(&ptr)) { - ::PROTOBUF_NAMESPACE_ID::uint32 tag; - ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); - CHK_(ptr); - switch (tag >> 3) { - // required string name = 1; - case 1: - if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) { - auto str = _internal_mutable_name(); - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); - #ifndef NDEBUG - ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "paddle.framework.proto.OpDesc.Attr.name"); - #endif // !NDEBUG - CHK_(ptr); - } else goto handle_unusual; - continue; - // required .paddle.framework.proto.AttrType type = 2; - case 2: - if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 16)) { - ::PROTOBUF_NAMESPACE_ID::uint64 val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); - CHK_(ptr); - if (PROTOBUF_PREDICT_TRUE(::paddle::framework::proto::AttrType_IsValid(val))) { - _internal_set_type(static_cast<::paddle::framework::proto::AttrType>(val)); - } else { - ::PROTOBUF_NAMESPACE_ID::internal::WriteVarint(2, val, mutable_unknown_fields()); - } - } else goto handle_unusual; - continue; - // optional int32 i = 3; - case 3: - if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 24)) { - _Internal::set_has_i(&has_bits); - i_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); - CHK_(ptr); - } else goto handle_unusual; - continue; - // optional float f = 4; - case 4: - if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 37)) { - _Internal::set_has_f(&has_bits); - f_ = ::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad(ptr); - ptr += sizeof(float); - } else goto handle_unusual; - continue; - // optional string s = 5; - case 5: - if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 42)) { - auto str = _internal_mutable_s(); - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); - #ifndef NDEBUG - ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "paddle.framework.proto.OpDesc.Attr.s"); - #endif // !NDEBUG - CHK_(ptr); - } else goto handle_unusual; - continue; - // repeated int32 ints = 6; - case 6: - if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 48)) { - ptr -= 1; - do { - ptr += 1; - _internal_add_ints(::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr)); - CHK_(ptr); - if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<48>(ptr)); - } else if (static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 50) { - ptr = ::PROTOBUF_NAMESPACE_ID::internal::PackedInt32Parser(_internal_mutable_ints(), ptr, ctx); - CHK_(ptr); - } else goto handle_unusual; - continue; - // repeated float floats = 7; - case 7: - if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 61)) { - ptr -= 1; - do { - ptr += 1; - _internal_add_floats(::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad(ptr)); - ptr += sizeof(float); - if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<61>(ptr)); - } else if (static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 58) { - ptr = ::PROTOBUF_NAMESPACE_ID::internal::PackedFloatParser(_internal_mutable_floats(), ptr, ctx); - CHK_(ptr); - } else goto handle_unusual; - continue; - // repeated string strings = 8; - case 8: - if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 66)) { - ptr -= 1; - do { - ptr += 1; - auto str = _internal_add_strings(); - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); - #ifndef NDEBUG - ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "paddle.framework.proto.OpDesc.Attr.strings"); - #endif // !NDEBUG - CHK_(ptr); - if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<66>(ptr)); - } else goto handle_unusual; - continue; - // optional bool b = 10; - case 10: - if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 80)) { - _Internal::set_has_b(&has_bits); - b_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); - CHK_(ptr); - } else goto handle_unusual; - continue; - // repeated bool bools = 11; - case 11: - if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 88)) { - ptr -= 1; - do { - ptr += 1; - _internal_add_bools(::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr)); - CHK_(ptr); - if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<88>(ptr)); - } else if (static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 90) { - ptr = ::PROTOBUF_NAMESPACE_ID::internal::PackedBoolParser(_internal_mutable_bools(), ptr, ctx); - CHK_(ptr); - } else goto handle_unusual; - continue; - // optional int32 block_idx = 12; - case 12: - if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 96)) { - _Internal::set_has_block_idx(&has_bits); - block_idx_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); - CHK_(ptr); - } else goto handle_unusual; - continue; - // optional int64 l = 13; - case 13: - if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 104)) { - _Internal::set_has_l(&has_bits); - l_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); - CHK_(ptr); - } else goto handle_unusual; - continue; - // repeated int32 blocks_idx = 14; - case 14: - if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 112)) { - ptr -= 1; - do { - ptr += 1; - _internal_add_blocks_idx(::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr)); - CHK_(ptr); - if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<112>(ptr)); - } else if (static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 114) { - ptr = ::PROTOBUF_NAMESPACE_ID::internal::PackedInt32Parser(_internal_mutable_blocks_idx(), ptr, ctx); - CHK_(ptr); - } else goto handle_unusual; - continue; - // repeated int64 longs = 15; - case 15: - if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 120)) { - ptr -= 1; - do { - ptr += 1; - _internal_add_longs(::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr)); - CHK_(ptr); - if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<120>(ptr)); - } else if (static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 122) { - ptr = ::PROTOBUF_NAMESPACE_ID::internal::PackedInt64Parser(_internal_mutable_longs(), ptr, ctx); - CHK_(ptr); - } else goto handle_unusual; - continue; - default: { - handle_unusual: - if ((tag & 7) == 4 || tag == 0) { - ctx->SetLastTag(tag); - goto success; - } - ptr = UnknownFieldParse(tag, - _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), - ptr, ctx); - CHK_(ptr != nullptr); - continue; - } - } // switch - } // while -success: - _has_bits_.Or(has_bits); - return ptr; -failure: - ptr = nullptr; - goto success; -#undef CHK_ -} - -::PROTOBUF_NAMESPACE_ID::uint8* OpDesc_Attr::_InternalSerialize( - ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { - // @@protoc_insertion_point(serialize_to_array_start:paddle.framework.proto.OpDesc.Attr) - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; - (void) cached_has_bits; - - cached_has_bits = _has_bits_[0]; - // required string name = 1; - if (cached_has_bits & 0x00000001u) { - ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->_internal_name().data(), static_cast(this->_internal_name().length()), - ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, - "paddle.framework.proto.OpDesc.Attr.name"); - target = stream->WriteStringMaybeAliased( - 1, this->_internal_name(), target); - } - - // required .paddle.framework.proto.AttrType type = 2; - if (cached_has_bits & 0x00000004u) { - target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteEnumToArray( - 2, this->_internal_type(), target); - } - - // optional int32 i = 3; - if (cached_has_bits & 0x00000008u) { - target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(3, this->_internal_i(), target); - } - - // optional float f = 4; - if (cached_has_bits & 0x00000010u) { - target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteFloatToArray(4, this->_internal_f(), target); - } - - // optional string s = 5; - if (cached_has_bits & 0x00000002u) { - ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->_internal_s().data(), static_cast(this->_internal_s().length()), - ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, - "paddle.framework.proto.OpDesc.Attr.s"); - target = stream->WriteStringMaybeAliased( - 5, this->_internal_s(), target); - } - - // repeated int32 ints = 6; - for (int i = 0, n = this->_internal_ints_size(); i < n; i++) { - target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(6, this->_internal_ints(i), target); - } - - // repeated float floats = 7; - for (int i = 0, n = this->_internal_floats_size(); i < n; i++) { - target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteFloatToArray(7, this->_internal_floats(i), target); - } - - // repeated string strings = 8; - for (int i = 0, n = this->_internal_strings_size(); i < n; i++) { - const auto& s = this->_internal_strings(i); - ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - s.data(), static_cast(s.length()), - ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, - "paddle.framework.proto.OpDesc.Attr.strings"); - target = stream->WriteString(8, s, target); - } - - // optional bool b = 10; - if (cached_has_bits & 0x00000020u) { - target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(10, this->_internal_b(), target); - } - - // repeated bool bools = 11; - for (int i = 0, n = this->_internal_bools_size(); i < n; i++) { - target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(11, this->_internal_bools(i), target); - } - - // optional int32 block_idx = 12; - if (cached_has_bits & 0x00000080u) { - target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(12, this->_internal_block_idx(), target); - } - - // optional int64 l = 13; - if (cached_has_bits & 0x00000040u) { - target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt64ToArray(13, this->_internal_l(), target); - } - - // repeated int32 blocks_idx = 14; - for (int i = 0, n = this->_internal_blocks_idx_size(); i < n; i++) { - target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(14, this->_internal_blocks_idx(i), target); - } - - // repeated int64 longs = 15; - for (int i = 0, n = this->_internal_longs_size(); i < n; i++) { - target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt64ToArray(15, this->_internal_longs(i), target); - } - - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); - } - // @@protoc_insertion_point(serialize_to_array_end:paddle.framework.proto.OpDesc.Attr) - return target; -} - -size_t OpDesc_Attr::RequiredFieldsByteSizeFallback() const { -// @@protoc_insertion_point(required_fields_byte_size_fallback_start:paddle.framework.proto.OpDesc.Attr) - size_t total_size = 0; - - if (_internal_has_name()) { - // required string name = 1; - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_name()); - } - - if (_internal_has_type()) { - // required .paddle.framework.proto.AttrType type = 2; - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::EnumSize(this->_internal_type()); - } - - return total_size; -} -size_t OpDesc_Attr::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:paddle.framework.proto.OpDesc.Attr) - size_t total_size = 0; - - if (((_has_bits_[0] & 0x00000005) ^ 0x00000005) == 0) { // All required fields are present. - // required string name = 1; - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_name()); - - // required .paddle.framework.proto.AttrType type = 2; - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::EnumSize(this->_internal_type()); - - } else { - total_size += RequiredFieldsByteSizeFallback(); - } - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - - // repeated int32 ints = 6; - { - size_t data_size = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - Int32Size(this->ints_); - total_size += 1 * - ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(this->_internal_ints_size()); - total_size += data_size; - } - - // repeated float floats = 7; - { - unsigned int count = static_cast(this->_internal_floats_size()); - size_t data_size = 4UL * count; - total_size += 1 * - ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(this->_internal_floats_size()); - total_size += data_size; - } - - // repeated string strings = 8; - total_size += 1 * - ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(strings_.size()); - for (int i = 0, n = strings_.size(); i < n; i++) { - total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - strings_.Get(i)); - } - - // repeated bool bools = 11; - { - unsigned int count = static_cast(this->_internal_bools_size()); - size_t data_size = 1UL * count; - total_size += 1 * - ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(this->_internal_bools_size()); - total_size += data_size; - } - - // repeated int32 blocks_idx = 14; - { - size_t data_size = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - Int32Size(this->blocks_idx_); - total_size += 1 * - ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(this->_internal_blocks_idx_size()); - total_size += data_size; - } - - // repeated int64 longs = 15; - { - size_t data_size = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - Int64Size(this->longs_); - total_size += 1 * - ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(this->_internal_longs_size()); - total_size += data_size; - } - - // optional string s = 5; - cached_has_bits = _has_bits_[0]; - if (cached_has_bits & 0x00000002u) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_s()); - } - - if (cached_has_bits & 0x000000f8u) { - // optional int32 i = 3; - if (cached_has_bits & 0x00000008u) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size( - this->_internal_i()); - } - - // optional float f = 4; - if (cached_has_bits & 0x00000010u) { - total_size += 1 + 4; - } - - // optional bool b = 10; - if (cached_has_bits & 0x00000020u) { - total_size += 1 + 1; - } - - // optional int64 l = 13; - if (cached_has_bits & 0x00000040u) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int64Size( - this->_internal_l()); - } - - // optional int32 block_idx = 12; - if (cached_has_bits & 0x00000080u) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size( - this->_internal_block_idx()); - } - - } - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize( - _internal_metadata_, total_size, &_cached_size_); - } - int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size); - SetCachedSize(cached_size); - return total_size; -} - -void OpDesc_Attr::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { -// @@protoc_insertion_point(generalized_merge_from_start:paddle.framework.proto.OpDesc.Attr) - GOOGLE_DCHECK_NE(&from, this); - const OpDesc_Attr* source = - ::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated( - &from); - if (source == nullptr) { - // @@protoc_insertion_point(generalized_merge_from_cast_fail:paddle.framework.proto.OpDesc.Attr) - ::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this); - } else { - // @@protoc_insertion_point(generalized_merge_from_cast_success:paddle.framework.proto.OpDesc.Attr) - MergeFrom(*source); - } -} - -void OpDesc_Attr::MergeFrom(const OpDesc_Attr& from) { -// @@protoc_insertion_point(class_specific_merge_from_start:paddle.framework.proto.OpDesc.Attr) - GOOGLE_DCHECK_NE(&from, this); - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; - (void) cached_has_bits; - - ints_.MergeFrom(from.ints_); - floats_.MergeFrom(from.floats_); - strings_.MergeFrom(from.strings_); - bools_.MergeFrom(from.bools_); - blocks_idx_.MergeFrom(from.blocks_idx_); - longs_.MergeFrom(from.longs_); - cached_has_bits = from._has_bits_[0]; - if (cached_has_bits & 0x000000ffu) { - if (cached_has_bits & 0x00000001u) { - _internal_set_name(from._internal_name()); - } - if (cached_has_bits & 0x00000002u) { - _internal_set_s(from._internal_s()); - } - if (cached_has_bits & 0x00000004u) { - type_ = from.type_; - } - if (cached_has_bits & 0x00000008u) { - i_ = from.i_; - } - if (cached_has_bits & 0x00000010u) { - f_ = from.f_; - } - if (cached_has_bits & 0x00000020u) { - b_ = from.b_; - } - if (cached_has_bits & 0x00000040u) { - l_ = from.l_; - } - if (cached_has_bits & 0x00000080u) { - block_idx_ = from.block_idx_; - } - _has_bits_[0] |= cached_has_bits; - } -} - -void OpDesc_Attr::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { -// @@protoc_insertion_point(generalized_copy_from_start:paddle.framework.proto.OpDesc.Attr) - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -void OpDesc_Attr::CopyFrom(const OpDesc_Attr& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:paddle.framework.proto.OpDesc.Attr) - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -bool OpDesc_Attr::IsInitialized() const { - if (_Internal::MissingRequiredFields(_has_bits_)) return false; - return true; -} - -void OpDesc_Attr::InternalSwap(OpDesc_Attr* other) { - using std::swap; - _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); - swap(_has_bits_[0], other->_has_bits_[0]); - ints_.InternalSwap(&other->ints_); - floats_.InternalSwap(&other->floats_); - strings_.InternalSwap(&other->strings_); - bools_.InternalSwap(&other->bools_); - blocks_idx_.InternalSwap(&other->blocks_idx_); - longs_.InternalSwap(&other->longs_); - name_.Swap(&other->name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); - s_.Swap(&other->s_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); - ::PROTOBUF_NAMESPACE_ID::internal::memswap< - PROTOBUF_FIELD_OFFSET(OpDesc_Attr, block_idx_) - + sizeof(OpDesc_Attr::block_idx_) - - PROTOBUF_FIELD_OFFSET(OpDesc_Attr, type_)>( - reinterpret_cast(&type_), - reinterpret_cast(&other->type_)); -} - -::PROTOBUF_NAMESPACE_ID::Metadata OpDesc_Attr::GetMetadata() const { - return GetMetadataStatic(); -} - - -// =================================================================== - -class OpDesc_Var::_Internal { - public: - using HasBits = decltype(std::declval()._has_bits_); - static void set_has_parameter(HasBits* has_bits) { - (*has_bits)[0] |= 1u; - } - static bool MissingRequiredFields(const HasBits& has_bits) { - return ((has_bits[0] & 0x00000001) ^ 0x00000001) != 0; - } -}; - -OpDesc_Var::OpDesc_Var(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::Message(arena), - arguments_(arena) { - SharedCtor(); - RegisterArenaDtor(arena); - // @@protoc_insertion_point(arena_constructor:paddle.framework.proto.OpDesc.Var) -} -OpDesc_Var::OpDesc_Var(const OpDesc_Var& from) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _has_bits_(from._has_bits_), - arguments_(from.arguments_) { - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - parameter_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (from._internal_has_parameter()) { - parameter_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_parameter(), - GetArena()); - } - // @@protoc_insertion_point(copy_constructor:paddle.framework.proto.OpDesc.Var) -} - -void OpDesc_Var::SharedCtor() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_OpDesc_Var_framework_2eproto.base); - parameter_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); -} - -OpDesc_Var::~OpDesc_Var() { - // @@protoc_insertion_point(destructor:paddle.framework.proto.OpDesc.Var) - SharedDtor(); - _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); -} - -void OpDesc_Var::SharedDtor() { - GOOGLE_DCHECK(GetArena() == nullptr); - parameter_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); -} - -void OpDesc_Var::ArenaDtor(void* object) { - OpDesc_Var* _this = reinterpret_cast< OpDesc_Var* >(object); - (void)_this; -} -void OpDesc_Var::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { -} -void OpDesc_Var::SetCachedSize(int size) const { - _cached_size_.Set(size); -} -const OpDesc_Var& OpDesc_Var::default_instance() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_OpDesc_Var_framework_2eproto.base); - return *internal_default_instance(); -} - - -void OpDesc_Var::Clear() { -// @@protoc_insertion_point(message_clear_start:paddle.framework.proto.OpDesc.Var) - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - - arguments_.Clear(); - cached_has_bits = _has_bits_[0]; - if (cached_has_bits & 0x00000001u) { - parameter_.ClearNonDefaultToEmpty(); - } - _has_bits_.Clear(); - _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); -} - -const char* OpDesc_Var::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { -#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - _Internal::HasBits has_bits{}; - while (!ctx->Done(&ptr)) { - ::PROTOBUF_NAMESPACE_ID::uint32 tag; - ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); - CHK_(ptr); - switch (tag >> 3) { - // required string parameter = 1; - case 1: - if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) { - auto str = _internal_mutable_parameter(); - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); - #ifndef NDEBUG - ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "paddle.framework.proto.OpDesc.Var.parameter"); - #endif // !NDEBUG - CHK_(ptr); - } else goto handle_unusual; - continue; - // repeated string arguments = 2; - case 2: - if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 18)) { - ptr -= 1; - do { - ptr += 1; - auto str = _internal_add_arguments(); - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); - #ifndef NDEBUG - ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "paddle.framework.proto.OpDesc.Var.arguments"); - #endif // !NDEBUG - CHK_(ptr); - if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<18>(ptr)); - } else goto handle_unusual; - continue; - default: { - handle_unusual: - if ((tag & 7) == 4 || tag == 0) { - ctx->SetLastTag(tag); - goto success; - } - ptr = UnknownFieldParse(tag, - _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), - ptr, ctx); - CHK_(ptr != nullptr); - continue; - } - } // switch - } // while -success: - _has_bits_.Or(has_bits); - return ptr; -failure: - ptr = nullptr; - goto success; -#undef CHK_ -} - -::PROTOBUF_NAMESPACE_ID::uint8* OpDesc_Var::_InternalSerialize( - ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { - // @@protoc_insertion_point(serialize_to_array_start:paddle.framework.proto.OpDesc.Var) - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; - (void) cached_has_bits; - - cached_has_bits = _has_bits_[0]; - // required string parameter = 1; - if (cached_has_bits & 0x00000001u) { - ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->_internal_parameter().data(), static_cast(this->_internal_parameter().length()), - ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, - "paddle.framework.proto.OpDesc.Var.parameter"); - target = stream->WriteStringMaybeAliased( - 1, this->_internal_parameter(), target); - } - - // repeated string arguments = 2; - for (int i = 0, n = this->_internal_arguments_size(); i < n; i++) { - const auto& s = this->_internal_arguments(i); - ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - s.data(), static_cast(s.length()), - ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, - "paddle.framework.proto.OpDesc.Var.arguments"); - target = stream->WriteString(2, s, target); - } - - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); - } - // @@protoc_insertion_point(serialize_to_array_end:paddle.framework.proto.OpDesc.Var) - return target; -} - -size_t OpDesc_Var::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:paddle.framework.proto.OpDesc.Var) - size_t total_size = 0; - - // required string parameter = 1; - if (_internal_has_parameter()) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_parameter()); - } - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - - // repeated string arguments = 2; - total_size += 1 * - ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(arguments_.size()); - for (int i = 0, n = arguments_.size(); i < n; i++) { - total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - arguments_.Get(i)); - } - - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize( - _internal_metadata_, total_size, &_cached_size_); - } - int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size); - SetCachedSize(cached_size); - return total_size; -} - -void OpDesc_Var::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { -// @@protoc_insertion_point(generalized_merge_from_start:paddle.framework.proto.OpDesc.Var) - GOOGLE_DCHECK_NE(&from, this); - const OpDesc_Var* source = - ::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated( - &from); - if (source == nullptr) { - // @@protoc_insertion_point(generalized_merge_from_cast_fail:paddle.framework.proto.OpDesc.Var) - ::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this); - } else { - // @@protoc_insertion_point(generalized_merge_from_cast_success:paddle.framework.proto.OpDesc.Var) - MergeFrom(*source); - } -} - -void OpDesc_Var::MergeFrom(const OpDesc_Var& from) { -// @@protoc_insertion_point(class_specific_merge_from_start:paddle.framework.proto.OpDesc.Var) - GOOGLE_DCHECK_NE(&from, this); - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; - (void) cached_has_bits; - - arguments_.MergeFrom(from.arguments_); - if (from._internal_has_parameter()) { - _internal_set_parameter(from._internal_parameter()); - } -} - -void OpDesc_Var::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { -// @@protoc_insertion_point(generalized_copy_from_start:paddle.framework.proto.OpDesc.Var) - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -void OpDesc_Var::CopyFrom(const OpDesc_Var& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:paddle.framework.proto.OpDesc.Var) - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -bool OpDesc_Var::IsInitialized() const { - if (_Internal::MissingRequiredFields(_has_bits_)) return false; - return true; -} - -void OpDesc_Var::InternalSwap(OpDesc_Var* other) { - using std::swap; - _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); - swap(_has_bits_[0], other->_has_bits_[0]); - arguments_.InternalSwap(&other->arguments_); - parameter_.Swap(&other->parameter_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); -} - -::PROTOBUF_NAMESPACE_ID::Metadata OpDesc_Var::GetMetadata() const { - return GetMetadataStatic(); -} - - -// =================================================================== - -class OpDesc::_Internal { - public: - using HasBits = decltype(std::declval()._has_bits_); - static void set_has_type(HasBits* has_bits) { - (*has_bits)[0] |= 1u; - } - static void set_has_is_target(HasBits* has_bits) { - (*has_bits)[0] |= 2u; - } - static bool MissingRequiredFields(const HasBits& has_bits) { - return ((has_bits[0] & 0x00000001) ^ 0x00000001) != 0; - } -}; - -OpDesc::OpDesc(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::Message(arena), - inputs_(arena), - outputs_(arena), - attrs_(arena) { - SharedCtor(); - RegisterArenaDtor(arena); - // @@protoc_insertion_point(arena_constructor:paddle.framework.proto.OpDesc) -} -OpDesc::OpDesc(const OpDesc& from) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _has_bits_(from._has_bits_), - inputs_(from.inputs_), - outputs_(from.outputs_), - attrs_(from.attrs_) { - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - type_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (from._internal_has_type()) { - type_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_type(), - GetArena()); - } - is_target_ = from.is_target_; - // @@protoc_insertion_point(copy_constructor:paddle.framework.proto.OpDesc) -} - -void OpDesc::SharedCtor() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_OpDesc_framework_2eproto.base); - type_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - is_target_ = false; -} - -OpDesc::~OpDesc() { - // @@protoc_insertion_point(destructor:paddle.framework.proto.OpDesc) - SharedDtor(); - _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); -} - -void OpDesc::SharedDtor() { - GOOGLE_DCHECK(GetArena() == nullptr); - type_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); -} - -void OpDesc::ArenaDtor(void* object) { - OpDesc* _this = reinterpret_cast< OpDesc* >(object); - (void)_this; -} -void OpDesc::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { -} -void OpDesc::SetCachedSize(int size) const { - _cached_size_.Set(size); -} -const OpDesc& OpDesc::default_instance() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_OpDesc_framework_2eproto.base); - return *internal_default_instance(); -} - - -void OpDesc::Clear() { -// @@protoc_insertion_point(message_clear_start:paddle.framework.proto.OpDesc) - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - - inputs_.Clear(); - outputs_.Clear(); - attrs_.Clear(); - cached_has_bits = _has_bits_[0]; - if (cached_has_bits & 0x00000001u) { - type_.ClearNonDefaultToEmpty(); - } - is_target_ = false; - _has_bits_.Clear(); - _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); -} - -const char* OpDesc::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { -#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - _Internal::HasBits has_bits{}; - while (!ctx->Done(&ptr)) { - ::PROTOBUF_NAMESPACE_ID::uint32 tag; - ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); - CHK_(ptr); - switch (tag >> 3) { - // repeated .paddle.framework.proto.OpDesc.Var inputs = 1; - case 1: - if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) { - ptr -= 1; - do { - ptr += 1; - ptr = ctx->ParseMessage(_internal_add_inputs(), ptr); - CHK_(ptr); - if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<10>(ptr)); - } else goto handle_unusual; - continue; - // repeated .paddle.framework.proto.OpDesc.Var outputs = 2; - case 2: - if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 18)) { - ptr -= 1; - do { - ptr += 1; - ptr = ctx->ParseMessage(_internal_add_outputs(), ptr); - CHK_(ptr); - if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<18>(ptr)); - } else goto handle_unusual; - continue; - // required string type = 3; - case 3: - if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 26)) { - auto str = _internal_mutable_type(); - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); - #ifndef NDEBUG - ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "paddle.framework.proto.OpDesc.type"); - #endif // !NDEBUG - CHK_(ptr); - } else goto handle_unusual; - continue; - // repeated .paddle.framework.proto.OpDesc.Attr attrs = 4; - case 4: - if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 34)) { - ptr -= 1; - do { - ptr += 1; - ptr = ctx->ParseMessage(_internal_add_attrs(), ptr); - CHK_(ptr); - if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<34>(ptr)); - } else goto handle_unusual; - continue; - // optional bool is_target = 5 [default = false]; - case 5: - if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 40)) { - _Internal::set_has_is_target(&has_bits); - is_target_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); - CHK_(ptr); - } else goto handle_unusual; - continue; - default: { - handle_unusual: - if ((tag & 7) == 4 || tag == 0) { - ctx->SetLastTag(tag); - goto success; - } - ptr = UnknownFieldParse(tag, - _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), - ptr, ctx); - CHK_(ptr != nullptr); - continue; - } - } // switch - } // while -success: - _has_bits_.Or(has_bits); - return ptr; -failure: - ptr = nullptr; - goto success; -#undef CHK_ -} - -::PROTOBUF_NAMESPACE_ID::uint8* OpDesc::_InternalSerialize( - ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { - // @@protoc_insertion_point(serialize_to_array_start:paddle.framework.proto.OpDesc) - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; - (void) cached_has_bits; - - // repeated .paddle.framework.proto.OpDesc.Var inputs = 1; - for (unsigned int i = 0, - n = static_cast(this->_internal_inputs_size()); i < n; i++) { - target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(1, this->_internal_inputs(i), target, stream); - } - - // repeated .paddle.framework.proto.OpDesc.Var outputs = 2; - for (unsigned int i = 0, - n = static_cast(this->_internal_outputs_size()); i < n; i++) { - target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(2, this->_internal_outputs(i), target, stream); - } - - cached_has_bits = _has_bits_[0]; - // required string type = 3; - if (cached_has_bits & 0x00000001u) { - ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->_internal_type().data(), static_cast(this->_internal_type().length()), - ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, - "paddle.framework.proto.OpDesc.type"); - target = stream->WriteStringMaybeAliased( - 3, this->_internal_type(), target); - } - - // repeated .paddle.framework.proto.OpDesc.Attr attrs = 4; - for (unsigned int i = 0, - n = static_cast(this->_internal_attrs_size()); i < n; i++) { - target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(4, this->_internal_attrs(i), target, stream); - } - - // optional bool is_target = 5 [default = false]; - if (cached_has_bits & 0x00000002u) { - target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(5, this->_internal_is_target(), target); - } - - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); - } - // @@protoc_insertion_point(serialize_to_array_end:paddle.framework.proto.OpDesc) - return target; -} - -size_t OpDesc::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:paddle.framework.proto.OpDesc) - size_t total_size = 0; - - // required string type = 3; - if (_internal_has_type()) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_type()); - } - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - - // repeated .paddle.framework.proto.OpDesc.Var inputs = 1; - total_size += 1UL * this->_internal_inputs_size(); - for (const auto& msg : this->inputs_) { - total_size += - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); - } - - // repeated .paddle.framework.proto.OpDesc.Var outputs = 2; - total_size += 1UL * this->_internal_outputs_size(); - for (const auto& msg : this->outputs_) { - total_size += - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); - } - - // repeated .paddle.framework.proto.OpDesc.Attr attrs = 4; - total_size += 1UL * this->_internal_attrs_size(); - for (const auto& msg : this->attrs_) { - total_size += - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); - } - - // optional bool is_target = 5 [default = false]; - cached_has_bits = _has_bits_[0]; - if (cached_has_bits & 0x00000002u) { - total_size += 1 + 1; - } - - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize( - _internal_metadata_, total_size, &_cached_size_); - } - int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size); - SetCachedSize(cached_size); - return total_size; -} - -void OpDesc::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { -// @@protoc_insertion_point(generalized_merge_from_start:paddle.framework.proto.OpDesc) - GOOGLE_DCHECK_NE(&from, this); - const OpDesc* source = - ::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated( - &from); - if (source == nullptr) { - // @@protoc_insertion_point(generalized_merge_from_cast_fail:paddle.framework.proto.OpDesc) - ::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this); - } else { - // @@protoc_insertion_point(generalized_merge_from_cast_success:paddle.framework.proto.OpDesc) - MergeFrom(*source); - } -} - -void OpDesc::MergeFrom(const OpDesc& from) { -// @@protoc_insertion_point(class_specific_merge_from_start:paddle.framework.proto.OpDesc) - GOOGLE_DCHECK_NE(&from, this); - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; - (void) cached_has_bits; - - inputs_.MergeFrom(from.inputs_); - outputs_.MergeFrom(from.outputs_); - attrs_.MergeFrom(from.attrs_); - cached_has_bits = from._has_bits_[0]; - if (cached_has_bits & 0x00000003u) { - if (cached_has_bits & 0x00000001u) { - _internal_set_type(from._internal_type()); - } - if (cached_has_bits & 0x00000002u) { - is_target_ = from.is_target_; - } - _has_bits_[0] |= cached_has_bits; - } -} - -void OpDesc::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { -// @@protoc_insertion_point(generalized_copy_from_start:paddle.framework.proto.OpDesc) - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -void OpDesc::CopyFrom(const OpDesc& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:paddle.framework.proto.OpDesc) - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -bool OpDesc::IsInitialized() const { - if (_Internal::MissingRequiredFields(_has_bits_)) return false; - if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(inputs_)) return false; - if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(outputs_)) return false; - if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(attrs_)) return false; - return true; -} - -void OpDesc::InternalSwap(OpDesc* other) { - using std::swap; - _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); - swap(_has_bits_[0], other->_has_bits_[0]); - inputs_.InternalSwap(&other->inputs_); - outputs_.InternalSwap(&other->outputs_); - attrs_.InternalSwap(&other->attrs_); - type_.Swap(&other->type_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); - swap(is_target_, other->is_target_); -} - -::PROTOBUF_NAMESPACE_ID::Metadata OpDesc::GetMetadata() const { - return GetMetadataStatic(); -} - - -// =================================================================== - -class OpProto_Var::_Internal { - public: - using HasBits = decltype(std::declval()._has_bits_); - static void set_has_name(HasBits* has_bits) { - (*has_bits)[0] |= 1u; - } - static void set_has_comment(HasBits* has_bits) { - (*has_bits)[0] |= 2u; - } - static void set_has_duplicable(HasBits* has_bits) { - (*has_bits)[0] |= 4u; - } - static void set_has_intermediate(HasBits* has_bits) { - (*has_bits)[0] |= 8u; - } - static void set_has_dispensable(HasBits* has_bits) { - (*has_bits)[0] |= 16u; - } - static bool MissingRequiredFields(const HasBits& has_bits) { - return ((has_bits[0] & 0x00000003) ^ 0x00000003) != 0; - } -}; - -OpProto_Var::OpProto_Var(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::Message(arena) { - SharedCtor(); - RegisterArenaDtor(arena); - // @@protoc_insertion_point(arena_constructor:paddle.framework.proto.OpProto.Var) -} -OpProto_Var::OpProto_Var(const OpProto_Var& from) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _has_bits_(from._has_bits_) { - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (from._internal_has_name()) { - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(), - GetArena()); - } - comment_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (from._internal_has_comment()) { - comment_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_comment(), - GetArena()); - } - ::memcpy(&duplicable_, &from.duplicable_, - static_cast(reinterpret_cast(&dispensable_) - - reinterpret_cast(&duplicable_)) + sizeof(dispensable_)); - // @@protoc_insertion_point(copy_constructor:paddle.framework.proto.OpProto.Var) -} - -void OpProto_Var::SharedCtor() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_OpProto_Var_framework_2eproto.base); - name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - comment_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - ::memset(reinterpret_cast(this) + static_cast( - reinterpret_cast(&duplicable_) - reinterpret_cast(this)), - 0, static_cast(reinterpret_cast(&dispensable_) - - reinterpret_cast(&duplicable_)) + sizeof(dispensable_)); -} - -OpProto_Var::~OpProto_Var() { - // @@protoc_insertion_point(destructor:paddle.framework.proto.OpProto.Var) - SharedDtor(); - _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); -} - -void OpProto_Var::SharedDtor() { - GOOGLE_DCHECK(GetArena() == nullptr); - name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - comment_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); -} - -void OpProto_Var::ArenaDtor(void* object) { - OpProto_Var* _this = reinterpret_cast< OpProto_Var* >(object); - (void)_this; -} -void OpProto_Var::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { -} -void OpProto_Var::SetCachedSize(int size) const { - _cached_size_.Set(size); -} -const OpProto_Var& OpProto_Var::default_instance() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_OpProto_Var_framework_2eproto.base); - return *internal_default_instance(); -} - - -void OpProto_Var::Clear() { -// @@protoc_insertion_point(message_clear_start:paddle.framework.proto.OpProto.Var) - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - - cached_has_bits = _has_bits_[0]; - if (cached_has_bits & 0x00000003u) { - if (cached_has_bits & 0x00000001u) { - name_.ClearNonDefaultToEmpty(); - } - if (cached_has_bits & 0x00000002u) { - comment_.ClearNonDefaultToEmpty(); - } - } - ::memset(&duplicable_, 0, static_cast( - reinterpret_cast(&dispensable_) - - reinterpret_cast(&duplicable_)) + sizeof(dispensable_)); - _has_bits_.Clear(); - _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); -} - -const char* OpProto_Var::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { -#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - _Internal::HasBits has_bits{}; - while (!ctx->Done(&ptr)) { - ::PROTOBUF_NAMESPACE_ID::uint32 tag; - ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); - CHK_(ptr); - switch (tag >> 3) { - // required string name = 1; - case 1: - if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) { - auto str = _internal_mutable_name(); - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); - #ifndef NDEBUG - ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "paddle.framework.proto.OpProto.Var.name"); - #endif // !NDEBUG - CHK_(ptr); - } else goto handle_unusual; - continue; - // required string comment = 2; - case 2: - if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 18)) { - auto str = _internal_mutable_comment(); - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); - #ifndef NDEBUG - ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "paddle.framework.proto.OpProto.Var.comment"); - #endif // !NDEBUG - CHK_(ptr); - } else goto handle_unusual; - continue; - // optional bool duplicable = 3 [default = false]; - case 3: - if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 24)) { - _Internal::set_has_duplicable(&has_bits); - duplicable_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); - CHK_(ptr); - } else goto handle_unusual; - continue; - // optional bool intermediate = 4 [default = false]; - case 4: - if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 32)) { - _Internal::set_has_intermediate(&has_bits); - intermediate_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); - CHK_(ptr); - } else goto handle_unusual; - continue; - // optional bool dispensable = 5 [default = false]; - case 5: - if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 40)) { - _Internal::set_has_dispensable(&has_bits); - dispensable_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); - CHK_(ptr); - } else goto handle_unusual; - continue; - default: { - handle_unusual: - if ((tag & 7) == 4 || tag == 0) { - ctx->SetLastTag(tag); - goto success; - } - ptr = UnknownFieldParse(tag, - _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), - ptr, ctx); - CHK_(ptr != nullptr); - continue; - } - } // switch - } // while -success: - _has_bits_.Or(has_bits); - return ptr; -failure: - ptr = nullptr; - goto success; -#undef CHK_ -} - -::PROTOBUF_NAMESPACE_ID::uint8* OpProto_Var::_InternalSerialize( - ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { - // @@protoc_insertion_point(serialize_to_array_start:paddle.framework.proto.OpProto.Var) - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; - (void) cached_has_bits; - - cached_has_bits = _has_bits_[0]; - // required string name = 1; - if (cached_has_bits & 0x00000001u) { - ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->_internal_name().data(), static_cast(this->_internal_name().length()), - ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, - "paddle.framework.proto.OpProto.Var.name"); - target = stream->WriteStringMaybeAliased( - 1, this->_internal_name(), target); - } - - // required string comment = 2; - if (cached_has_bits & 0x00000002u) { - ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->_internal_comment().data(), static_cast(this->_internal_comment().length()), - ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, - "paddle.framework.proto.OpProto.Var.comment"); - target = stream->WriteStringMaybeAliased( - 2, this->_internal_comment(), target); - } - - // optional bool duplicable = 3 [default = false]; - if (cached_has_bits & 0x00000004u) { - target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(3, this->_internal_duplicable(), target); - } - - // optional bool intermediate = 4 [default = false]; - if (cached_has_bits & 0x00000008u) { - target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(4, this->_internal_intermediate(), target); - } - - // optional bool dispensable = 5 [default = false]; - if (cached_has_bits & 0x00000010u) { - target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(5, this->_internal_dispensable(), target); - } - - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); - } - // @@protoc_insertion_point(serialize_to_array_end:paddle.framework.proto.OpProto.Var) - return target; -} - -size_t OpProto_Var::RequiredFieldsByteSizeFallback() const { -// @@protoc_insertion_point(required_fields_byte_size_fallback_start:paddle.framework.proto.OpProto.Var) - size_t total_size = 0; - - if (_internal_has_name()) { - // required string name = 1; - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_name()); - } - - if (_internal_has_comment()) { - // required string comment = 2; - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_comment()); - } - - return total_size; -} -size_t OpProto_Var::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:paddle.framework.proto.OpProto.Var) - size_t total_size = 0; - - if (((_has_bits_[0] & 0x00000003) ^ 0x00000003) == 0) { // All required fields are present. - // required string name = 1; - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_name()); - - // required string comment = 2; - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_comment()); - - } else { - total_size += RequiredFieldsByteSizeFallback(); - } - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - - cached_has_bits = _has_bits_[0]; - if (cached_has_bits & 0x0000001cu) { - // optional bool duplicable = 3 [default = false]; - if (cached_has_bits & 0x00000004u) { - total_size += 1 + 1; - } - - // optional bool intermediate = 4 [default = false]; - if (cached_has_bits & 0x00000008u) { - total_size += 1 + 1; - } - - // optional bool dispensable = 5 [default = false]; - if (cached_has_bits & 0x00000010u) { - total_size += 1 + 1; - } - - } - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize( - _internal_metadata_, total_size, &_cached_size_); - } - int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size); - SetCachedSize(cached_size); - return total_size; -} - -void OpProto_Var::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { -// @@protoc_insertion_point(generalized_merge_from_start:paddle.framework.proto.OpProto.Var) - GOOGLE_DCHECK_NE(&from, this); - const OpProto_Var* source = - ::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated( - &from); - if (source == nullptr) { - // @@protoc_insertion_point(generalized_merge_from_cast_fail:paddle.framework.proto.OpProto.Var) - ::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this); - } else { - // @@protoc_insertion_point(generalized_merge_from_cast_success:paddle.framework.proto.OpProto.Var) - MergeFrom(*source); - } -} - -void OpProto_Var::MergeFrom(const OpProto_Var& from) { -// @@protoc_insertion_point(class_specific_merge_from_start:paddle.framework.proto.OpProto.Var) - GOOGLE_DCHECK_NE(&from, this); - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; - (void) cached_has_bits; - - cached_has_bits = from._has_bits_[0]; - if (cached_has_bits & 0x0000001fu) { - if (cached_has_bits & 0x00000001u) { - _internal_set_name(from._internal_name()); - } - if (cached_has_bits & 0x00000002u) { - _internal_set_comment(from._internal_comment()); - } - if (cached_has_bits & 0x00000004u) { - duplicable_ = from.duplicable_; - } - if (cached_has_bits & 0x00000008u) { - intermediate_ = from.intermediate_; - } - if (cached_has_bits & 0x00000010u) { - dispensable_ = from.dispensable_; - } - _has_bits_[0] |= cached_has_bits; - } -} - -void OpProto_Var::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { -// @@protoc_insertion_point(generalized_copy_from_start:paddle.framework.proto.OpProto.Var) - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -void OpProto_Var::CopyFrom(const OpProto_Var& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:paddle.framework.proto.OpProto.Var) - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -bool OpProto_Var::IsInitialized() const { - if (_Internal::MissingRequiredFields(_has_bits_)) return false; - return true; -} - -void OpProto_Var::InternalSwap(OpProto_Var* other) { - using std::swap; - _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); - swap(_has_bits_[0], other->_has_bits_[0]); - name_.Swap(&other->name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); - comment_.Swap(&other->comment_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); - ::PROTOBUF_NAMESPACE_ID::internal::memswap< - PROTOBUF_FIELD_OFFSET(OpProto_Var, dispensable_) - + sizeof(OpProto_Var::dispensable_) - - PROTOBUF_FIELD_OFFSET(OpProto_Var, duplicable_)>( - reinterpret_cast(&duplicable_), - reinterpret_cast(&other->duplicable_)); -} - -::PROTOBUF_NAMESPACE_ID::Metadata OpProto_Var::GetMetadata() const { - return GetMetadataStatic(); -} - - -// =================================================================== - -class OpProto_Attr::_Internal { - public: - using HasBits = decltype(std::declval()._has_bits_); - static void set_has_name(HasBits* has_bits) { - (*has_bits)[0] |= 1u; - } - static void set_has_type(HasBits* has_bits) { - (*has_bits)[0] |= 4u; - } - static void set_has_comment(HasBits* has_bits) { - (*has_bits)[0] |= 2u; - } - static void set_has_generated(HasBits* has_bits) { - (*has_bits)[0] |= 8u; - } - static bool MissingRequiredFields(const HasBits& has_bits) { - return ((has_bits[0] & 0x00000007) ^ 0x00000007) != 0; - } -}; - -OpProto_Attr::OpProto_Attr(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::Message(arena) { - SharedCtor(); - RegisterArenaDtor(arena); - // @@protoc_insertion_point(arena_constructor:paddle.framework.proto.OpProto.Attr) -} -OpProto_Attr::OpProto_Attr(const OpProto_Attr& from) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _has_bits_(from._has_bits_) { - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (from._internal_has_name()) { - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(), - GetArena()); - } - comment_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (from._internal_has_comment()) { - comment_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_comment(), - GetArena()); - } - ::memcpy(&type_, &from.type_, - static_cast(reinterpret_cast(&generated_) - - reinterpret_cast(&type_)) + sizeof(generated_)); - // @@protoc_insertion_point(copy_constructor:paddle.framework.proto.OpProto.Attr) -} - -void OpProto_Attr::SharedCtor() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_OpProto_Attr_framework_2eproto.base); - name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - comment_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - ::memset(reinterpret_cast(this) + static_cast( - reinterpret_cast(&type_) - reinterpret_cast(this)), - 0, static_cast(reinterpret_cast(&generated_) - - reinterpret_cast(&type_)) + sizeof(generated_)); -} - -OpProto_Attr::~OpProto_Attr() { - // @@protoc_insertion_point(destructor:paddle.framework.proto.OpProto.Attr) - SharedDtor(); - _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); -} - -void OpProto_Attr::SharedDtor() { - GOOGLE_DCHECK(GetArena() == nullptr); - name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - comment_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); -} - -void OpProto_Attr::ArenaDtor(void* object) { - OpProto_Attr* _this = reinterpret_cast< OpProto_Attr* >(object); - (void)_this; -} -void OpProto_Attr::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { -} -void OpProto_Attr::SetCachedSize(int size) const { - _cached_size_.Set(size); -} -const OpProto_Attr& OpProto_Attr::default_instance() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_OpProto_Attr_framework_2eproto.base); - return *internal_default_instance(); -} - - -void OpProto_Attr::Clear() { -// @@protoc_insertion_point(message_clear_start:paddle.framework.proto.OpProto.Attr) - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - - cached_has_bits = _has_bits_[0]; - if (cached_has_bits & 0x00000003u) { - if (cached_has_bits & 0x00000001u) { - name_.ClearNonDefaultToEmpty(); - } - if (cached_has_bits & 0x00000002u) { - comment_.ClearNonDefaultToEmpty(); - } - } - if (cached_has_bits & 0x0000000cu) { - ::memset(&type_, 0, static_cast( - reinterpret_cast(&generated_) - - reinterpret_cast(&type_)) + sizeof(generated_)); - } - _has_bits_.Clear(); - _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); -} - -const char* OpProto_Attr::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { -#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - _Internal::HasBits has_bits{}; - while (!ctx->Done(&ptr)) { - ::PROTOBUF_NAMESPACE_ID::uint32 tag; - ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); - CHK_(ptr); - switch (tag >> 3) { - // required string name = 1; - case 1: - if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) { - auto str = _internal_mutable_name(); - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); - #ifndef NDEBUG - ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "paddle.framework.proto.OpProto.Attr.name"); - #endif // !NDEBUG - CHK_(ptr); - } else goto handle_unusual; - continue; - // required .paddle.framework.proto.AttrType type = 2; - case 2: - if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 16)) { - ::PROTOBUF_NAMESPACE_ID::uint64 val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); - CHK_(ptr); - if (PROTOBUF_PREDICT_TRUE(::paddle::framework::proto::AttrType_IsValid(val))) { - _internal_set_type(static_cast<::paddle::framework::proto::AttrType>(val)); - } else { - ::PROTOBUF_NAMESPACE_ID::internal::WriteVarint(2, val, mutable_unknown_fields()); - } - } else goto handle_unusual; - continue; - // required string comment = 3; - case 3: - if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 26)) { - auto str = _internal_mutable_comment(); - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); - #ifndef NDEBUG - ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "paddle.framework.proto.OpProto.Attr.comment"); - #endif // !NDEBUG - CHK_(ptr); - } else goto handle_unusual; - continue; - // optional bool generated = 4 [default = false]; - case 4: - if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 32)) { - _Internal::set_has_generated(&has_bits); - generated_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); - CHK_(ptr); - } else goto handle_unusual; - continue; - default: { - handle_unusual: - if ((tag & 7) == 4 || tag == 0) { - ctx->SetLastTag(tag); - goto success; - } - ptr = UnknownFieldParse(tag, - _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), - ptr, ctx); - CHK_(ptr != nullptr); - continue; - } - } // switch - } // while -success: - _has_bits_.Or(has_bits); - return ptr; -failure: - ptr = nullptr; - goto success; -#undef CHK_ -} - -::PROTOBUF_NAMESPACE_ID::uint8* OpProto_Attr::_InternalSerialize( - ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { - // @@protoc_insertion_point(serialize_to_array_start:paddle.framework.proto.OpProto.Attr) - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; - (void) cached_has_bits; - - cached_has_bits = _has_bits_[0]; - // required string name = 1; - if (cached_has_bits & 0x00000001u) { - ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->_internal_name().data(), static_cast(this->_internal_name().length()), - ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, - "paddle.framework.proto.OpProto.Attr.name"); - target = stream->WriteStringMaybeAliased( - 1, this->_internal_name(), target); - } - - // required .paddle.framework.proto.AttrType type = 2; - if (cached_has_bits & 0x00000004u) { - target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteEnumToArray( - 2, this->_internal_type(), target); - } - - // required string comment = 3; - if (cached_has_bits & 0x00000002u) { - ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->_internal_comment().data(), static_cast(this->_internal_comment().length()), - ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, - "paddle.framework.proto.OpProto.Attr.comment"); - target = stream->WriteStringMaybeAliased( - 3, this->_internal_comment(), target); - } - - // optional bool generated = 4 [default = false]; - if (cached_has_bits & 0x00000008u) { - target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(4, this->_internal_generated(), target); - } - - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); - } - // @@protoc_insertion_point(serialize_to_array_end:paddle.framework.proto.OpProto.Attr) - return target; -} - -size_t OpProto_Attr::RequiredFieldsByteSizeFallback() const { -// @@protoc_insertion_point(required_fields_byte_size_fallback_start:paddle.framework.proto.OpProto.Attr) - size_t total_size = 0; - - if (_internal_has_name()) { - // required string name = 1; - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_name()); - } - - if (_internal_has_comment()) { - // required string comment = 3; - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_comment()); - } - - if (_internal_has_type()) { - // required .paddle.framework.proto.AttrType type = 2; - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::EnumSize(this->_internal_type()); - } - - return total_size; -} -size_t OpProto_Attr::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:paddle.framework.proto.OpProto.Attr) - size_t total_size = 0; - - if (((_has_bits_[0] & 0x00000007) ^ 0x00000007) == 0) { // All required fields are present. - // required string name = 1; - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_name()); - - // required string comment = 3; - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_comment()); - - // required .paddle.framework.proto.AttrType type = 2; - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::EnumSize(this->_internal_type()); - - } else { - total_size += RequiredFieldsByteSizeFallback(); - } - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - - // optional bool generated = 4 [default = false]; - cached_has_bits = _has_bits_[0]; - if (cached_has_bits & 0x00000008u) { - total_size += 1 + 1; - } - - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize( - _internal_metadata_, total_size, &_cached_size_); - } - int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size); - SetCachedSize(cached_size); - return total_size; -} - -void OpProto_Attr::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { -// @@protoc_insertion_point(generalized_merge_from_start:paddle.framework.proto.OpProto.Attr) - GOOGLE_DCHECK_NE(&from, this); - const OpProto_Attr* source = - ::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated( - &from); - if (source == nullptr) { - // @@protoc_insertion_point(generalized_merge_from_cast_fail:paddle.framework.proto.OpProto.Attr) - ::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this); - } else { - // @@protoc_insertion_point(generalized_merge_from_cast_success:paddle.framework.proto.OpProto.Attr) - MergeFrom(*source); - } -} - -void OpProto_Attr::MergeFrom(const OpProto_Attr& from) { -// @@protoc_insertion_point(class_specific_merge_from_start:paddle.framework.proto.OpProto.Attr) - GOOGLE_DCHECK_NE(&from, this); - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; - (void) cached_has_bits; - - cached_has_bits = from._has_bits_[0]; - if (cached_has_bits & 0x0000000fu) { - if (cached_has_bits & 0x00000001u) { - _internal_set_name(from._internal_name()); - } - if (cached_has_bits & 0x00000002u) { - _internal_set_comment(from._internal_comment()); - } - if (cached_has_bits & 0x00000004u) { - type_ = from.type_; - } - if (cached_has_bits & 0x00000008u) { - generated_ = from.generated_; - } - _has_bits_[0] |= cached_has_bits; - } -} - -void OpProto_Attr::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { -// @@protoc_insertion_point(generalized_copy_from_start:paddle.framework.proto.OpProto.Attr) - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -void OpProto_Attr::CopyFrom(const OpProto_Attr& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:paddle.framework.proto.OpProto.Attr) - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -bool OpProto_Attr::IsInitialized() const { - if (_Internal::MissingRequiredFields(_has_bits_)) return false; - return true; -} - -void OpProto_Attr::InternalSwap(OpProto_Attr* other) { - using std::swap; - _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); - swap(_has_bits_[0], other->_has_bits_[0]); - name_.Swap(&other->name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); - comment_.Swap(&other->comment_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); - ::PROTOBUF_NAMESPACE_ID::internal::memswap< - PROTOBUF_FIELD_OFFSET(OpProto_Attr, generated_) - + sizeof(OpProto_Attr::generated_) - - PROTOBUF_FIELD_OFFSET(OpProto_Attr, type_)>( - reinterpret_cast(&type_), - reinterpret_cast(&other->type_)); -} - -::PROTOBUF_NAMESPACE_ID::Metadata OpProto_Attr::GetMetadata() const { - return GetMetadataStatic(); -} - - -// =================================================================== - -class OpProto::_Internal { - public: - using HasBits = decltype(std::declval()._has_bits_); - static void set_has_type(HasBits* has_bits) { - (*has_bits)[0] |= 1u; - } - static void set_has_comment(HasBits* has_bits) { - (*has_bits)[0] |= 2u; - } - static bool MissingRequiredFields(const HasBits& has_bits) { - return ((has_bits[0] & 0x00000003) ^ 0x00000003) != 0; - } -}; - -OpProto::OpProto(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::Message(arena), - inputs_(arena), - outputs_(arena), - attrs_(arena) { - SharedCtor(); - RegisterArenaDtor(arena); - // @@protoc_insertion_point(arena_constructor:paddle.framework.proto.OpProto) -} -OpProto::OpProto(const OpProto& from) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _has_bits_(from._has_bits_), - inputs_(from.inputs_), - outputs_(from.outputs_), - attrs_(from.attrs_) { - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - type_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (from._internal_has_type()) { - type_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_type(), - GetArena()); - } - comment_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (from._internal_has_comment()) { - comment_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_comment(), - GetArena()); - } - // @@protoc_insertion_point(copy_constructor:paddle.framework.proto.OpProto) -} - -void OpProto::SharedCtor() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_OpProto_framework_2eproto.base); - type_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - comment_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); -} - -OpProto::~OpProto() { - // @@protoc_insertion_point(destructor:paddle.framework.proto.OpProto) - SharedDtor(); - _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); -} - -void OpProto::SharedDtor() { - GOOGLE_DCHECK(GetArena() == nullptr); - type_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - comment_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); -} - -void OpProto::ArenaDtor(void* object) { - OpProto* _this = reinterpret_cast< OpProto* >(object); - (void)_this; -} -void OpProto::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { -} -void OpProto::SetCachedSize(int size) const { - _cached_size_.Set(size); -} -const OpProto& OpProto::default_instance() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_OpProto_framework_2eproto.base); - return *internal_default_instance(); -} - - -void OpProto::Clear() { -// @@protoc_insertion_point(message_clear_start:paddle.framework.proto.OpProto) - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - - inputs_.Clear(); - outputs_.Clear(); - attrs_.Clear(); - cached_has_bits = _has_bits_[0]; - if (cached_has_bits & 0x00000003u) { - if (cached_has_bits & 0x00000001u) { - type_.ClearNonDefaultToEmpty(); - } - if (cached_has_bits & 0x00000002u) { - comment_.ClearNonDefaultToEmpty(); - } - } - _has_bits_.Clear(); - _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); -} - -const char* OpProto::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { -#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - _Internal::HasBits has_bits{}; - while (!ctx->Done(&ptr)) { - ::PROTOBUF_NAMESPACE_ID::uint32 tag; - ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); - CHK_(ptr); - switch (tag >> 3) { - // required string type = 1; - case 1: - if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) { - auto str = _internal_mutable_type(); - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); - #ifndef NDEBUG - ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "paddle.framework.proto.OpProto.type"); - #endif // !NDEBUG - CHK_(ptr); - } else goto handle_unusual; - continue; - // repeated .paddle.framework.proto.OpProto.Var inputs = 2; - case 2: - if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 18)) { - ptr -= 1; - do { - ptr += 1; - ptr = ctx->ParseMessage(_internal_add_inputs(), ptr); - CHK_(ptr); - if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<18>(ptr)); - } else goto handle_unusual; - continue; - // repeated .paddle.framework.proto.OpProto.Var outputs = 3; - case 3: - if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 26)) { - ptr -= 1; - do { - ptr += 1; - ptr = ctx->ParseMessage(_internal_add_outputs(), ptr); - CHK_(ptr); - if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<26>(ptr)); - } else goto handle_unusual; - continue; - // repeated .paddle.framework.proto.OpProto.Attr attrs = 4; - case 4: - if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 34)) { - ptr -= 1; - do { - ptr += 1; - ptr = ctx->ParseMessage(_internal_add_attrs(), ptr); - CHK_(ptr); - if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<34>(ptr)); - } else goto handle_unusual; - continue; - // required string comment = 5; - case 5: - if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 42)) { - auto str = _internal_mutable_comment(); - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); - #ifndef NDEBUG - ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "paddle.framework.proto.OpProto.comment"); - #endif // !NDEBUG - CHK_(ptr); - } else goto handle_unusual; - continue; - default: { - handle_unusual: - if ((tag & 7) == 4 || tag == 0) { - ctx->SetLastTag(tag); - goto success; - } - ptr = UnknownFieldParse(tag, - _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), - ptr, ctx); - CHK_(ptr != nullptr); - continue; - } - } // switch - } // while -success: - _has_bits_.Or(has_bits); - return ptr; -failure: - ptr = nullptr; - goto success; -#undef CHK_ -} - -::PROTOBUF_NAMESPACE_ID::uint8* OpProto::_InternalSerialize( - ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { - // @@protoc_insertion_point(serialize_to_array_start:paddle.framework.proto.OpProto) - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; - (void) cached_has_bits; - - cached_has_bits = _has_bits_[0]; - // required string type = 1; - if (cached_has_bits & 0x00000001u) { - ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->_internal_type().data(), static_cast(this->_internal_type().length()), - ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, - "paddle.framework.proto.OpProto.type"); - target = stream->WriteStringMaybeAliased( - 1, this->_internal_type(), target); - } - - // repeated .paddle.framework.proto.OpProto.Var inputs = 2; - for (unsigned int i = 0, - n = static_cast(this->_internal_inputs_size()); i < n; i++) { - target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(2, this->_internal_inputs(i), target, stream); - } - - // repeated .paddle.framework.proto.OpProto.Var outputs = 3; - for (unsigned int i = 0, - n = static_cast(this->_internal_outputs_size()); i < n; i++) { - target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(3, this->_internal_outputs(i), target, stream); - } - - // repeated .paddle.framework.proto.OpProto.Attr attrs = 4; - for (unsigned int i = 0, - n = static_cast(this->_internal_attrs_size()); i < n; i++) { - target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(4, this->_internal_attrs(i), target, stream); - } - - // required string comment = 5; - if (cached_has_bits & 0x00000002u) { - ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->_internal_comment().data(), static_cast(this->_internal_comment().length()), - ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, - "paddle.framework.proto.OpProto.comment"); - target = stream->WriteStringMaybeAliased( - 5, this->_internal_comment(), target); - } - - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); - } - // @@protoc_insertion_point(serialize_to_array_end:paddle.framework.proto.OpProto) - return target; -} - -size_t OpProto::RequiredFieldsByteSizeFallback() const { -// @@protoc_insertion_point(required_fields_byte_size_fallback_start:paddle.framework.proto.OpProto) - size_t total_size = 0; - - if (_internal_has_type()) { - // required string type = 1; - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_type()); - } - - if (_internal_has_comment()) { - // required string comment = 5; - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_comment()); - } - - return total_size; -} -size_t OpProto::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:paddle.framework.proto.OpProto) - size_t total_size = 0; - - if (((_has_bits_[0] & 0x00000003) ^ 0x00000003) == 0) { // All required fields are present. - // required string type = 1; - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_type()); - - // required string comment = 5; - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_comment()); - - } else { - total_size += RequiredFieldsByteSizeFallback(); - } - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - - // repeated .paddle.framework.proto.OpProto.Var inputs = 2; - total_size += 1UL * this->_internal_inputs_size(); - for (const auto& msg : this->inputs_) { - total_size += - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); - } - - // repeated .paddle.framework.proto.OpProto.Var outputs = 3; - total_size += 1UL * this->_internal_outputs_size(); - for (const auto& msg : this->outputs_) { - total_size += - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); - } - - // repeated .paddle.framework.proto.OpProto.Attr attrs = 4; - total_size += 1UL * this->_internal_attrs_size(); - for (const auto& msg : this->attrs_) { - total_size += - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); - } - - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize( - _internal_metadata_, total_size, &_cached_size_); - } - int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size); - SetCachedSize(cached_size); - return total_size; -} - -void OpProto::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { -// @@protoc_insertion_point(generalized_merge_from_start:paddle.framework.proto.OpProto) - GOOGLE_DCHECK_NE(&from, this); - const OpProto* source = - ::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated( - &from); - if (source == nullptr) { - // @@protoc_insertion_point(generalized_merge_from_cast_fail:paddle.framework.proto.OpProto) - ::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this); - } else { - // @@protoc_insertion_point(generalized_merge_from_cast_success:paddle.framework.proto.OpProto) - MergeFrom(*source); - } -} - -void OpProto::MergeFrom(const OpProto& from) { -// @@protoc_insertion_point(class_specific_merge_from_start:paddle.framework.proto.OpProto) - GOOGLE_DCHECK_NE(&from, this); - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; - (void) cached_has_bits; - - inputs_.MergeFrom(from.inputs_); - outputs_.MergeFrom(from.outputs_); - attrs_.MergeFrom(from.attrs_); - cached_has_bits = from._has_bits_[0]; - if (cached_has_bits & 0x00000003u) { - if (cached_has_bits & 0x00000001u) { - _internal_set_type(from._internal_type()); - } - if (cached_has_bits & 0x00000002u) { - _internal_set_comment(from._internal_comment()); - } - } -} - -void OpProto::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { -// @@protoc_insertion_point(generalized_copy_from_start:paddle.framework.proto.OpProto) - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -void OpProto::CopyFrom(const OpProto& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:paddle.framework.proto.OpProto) - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -bool OpProto::IsInitialized() const { - if (_Internal::MissingRequiredFields(_has_bits_)) return false; - if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(inputs_)) return false; - if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(outputs_)) return false; - if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(attrs_)) return false; - return true; -} - -void OpProto::InternalSwap(OpProto* other) { - using std::swap; - _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); - swap(_has_bits_[0], other->_has_bits_[0]); - inputs_.InternalSwap(&other->inputs_); - outputs_.InternalSwap(&other->outputs_); - attrs_.InternalSwap(&other->attrs_); - type_.Swap(&other->type_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); - comment_.Swap(&other->comment_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); -} - -::PROTOBUF_NAMESPACE_ID::Metadata OpProto::GetMetadata() const { - return GetMetadataStatic(); -} - - -// =================================================================== - -class VarType_TensorDesc::_Internal { - public: - using HasBits = decltype(std::declval()._has_bits_); - static void set_has_data_type(HasBits* has_bits) { - (*has_bits)[0] |= 1u; - } - static bool MissingRequiredFields(const HasBits& has_bits) { - return ((has_bits[0] & 0x00000001) ^ 0x00000001) != 0; - } -}; - -VarType_TensorDesc::VarType_TensorDesc(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::Message(arena), - dims_(arena) { - SharedCtor(); - RegisterArenaDtor(arena); - // @@protoc_insertion_point(arena_constructor:paddle.framework.proto.VarType.TensorDesc) -} -VarType_TensorDesc::VarType_TensorDesc(const VarType_TensorDesc& from) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _has_bits_(from._has_bits_), - dims_(from.dims_) { - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - data_type_ = from.data_type_; - // @@protoc_insertion_point(copy_constructor:paddle.framework.proto.VarType.TensorDesc) -} - -void VarType_TensorDesc::SharedCtor() { - data_type_ = 0; -} - -VarType_TensorDesc::~VarType_TensorDesc() { - // @@protoc_insertion_point(destructor:paddle.framework.proto.VarType.TensorDesc) - SharedDtor(); - _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); -} - -void VarType_TensorDesc::SharedDtor() { - GOOGLE_DCHECK(GetArena() == nullptr); -} - -void VarType_TensorDesc::ArenaDtor(void* object) { - VarType_TensorDesc* _this = reinterpret_cast< VarType_TensorDesc* >(object); - (void)_this; -} -void VarType_TensorDesc::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { -} -void VarType_TensorDesc::SetCachedSize(int size) const { - _cached_size_.Set(size); -} -const VarType_TensorDesc& VarType_TensorDesc::default_instance() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_VarType_TensorDesc_framework_2eproto.base); - return *internal_default_instance(); -} - - -void VarType_TensorDesc::Clear() { -// @@protoc_insertion_point(message_clear_start:paddle.framework.proto.VarType.TensorDesc) - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - - dims_.Clear(); - data_type_ = 0; - _has_bits_.Clear(); - _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); -} - -const char* VarType_TensorDesc::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { -#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - _Internal::HasBits has_bits{}; - while (!ctx->Done(&ptr)) { - ::PROTOBUF_NAMESPACE_ID::uint32 tag; - ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); - CHK_(ptr); - switch (tag >> 3) { - // required .paddle.framework.proto.VarType.Type data_type = 1; - case 1: - if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 8)) { - ::PROTOBUF_NAMESPACE_ID::uint64 val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); - CHK_(ptr); - if (PROTOBUF_PREDICT_TRUE(::paddle::framework::proto::VarType_Type_IsValid(val))) { - _internal_set_data_type(static_cast<::paddle::framework::proto::VarType_Type>(val)); - } else { - ::PROTOBUF_NAMESPACE_ID::internal::WriteVarint(1, val, mutable_unknown_fields()); - } - } else goto handle_unusual; - continue; - // repeated int64 dims = 2; - case 2: - if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 16)) { - ptr -= 1; - do { - ptr += 1; - _internal_add_dims(::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr)); - CHK_(ptr); - if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<16>(ptr)); - } else if (static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 18) { - ptr = ::PROTOBUF_NAMESPACE_ID::internal::PackedInt64Parser(_internal_mutable_dims(), ptr, ctx); - CHK_(ptr); - } else goto handle_unusual; - continue; - default: { - handle_unusual: - if ((tag & 7) == 4 || tag == 0) { - ctx->SetLastTag(tag); - goto success; - } - ptr = UnknownFieldParse(tag, - _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), - ptr, ctx); - CHK_(ptr != nullptr); - continue; - } - } // switch - } // while -success: - _has_bits_.Or(has_bits); - return ptr; -failure: - ptr = nullptr; - goto success; -#undef CHK_ -} - -::PROTOBUF_NAMESPACE_ID::uint8* VarType_TensorDesc::_InternalSerialize( - ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { - // @@protoc_insertion_point(serialize_to_array_start:paddle.framework.proto.VarType.TensorDesc) - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; - (void) cached_has_bits; - - cached_has_bits = _has_bits_[0]; - // required .paddle.framework.proto.VarType.Type data_type = 1; - if (cached_has_bits & 0x00000001u) { - target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteEnumToArray( - 1, this->_internal_data_type(), target); - } - - // repeated int64 dims = 2; - for (int i = 0, n = this->_internal_dims_size(); i < n; i++) { - target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt64ToArray(2, this->_internal_dims(i), target); - } - - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); - } - // @@protoc_insertion_point(serialize_to_array_end:paddle.framework.proto.VarType.TensorDesc) - return target; -} - -size_t VarType_TensorDesc::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:paddle.framework.proto.VarType.TensorDesc) - size_t total_size = 0; - - // required .paddle.framework.proto.VarType.Type data_type = 1; - if (_internal_has_data_type()) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::EnumSize(this->_internal_data_type()); - } - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - - // repeated int64 dims = 2; - { - size_t data_size = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - Int64Size(this->dims_); - total_size += 1 * - ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(this->_internal_dims_size()); - total_size += data_size; - } - - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize( - _internal_metadata_, total_size, &_cached_size_); - } - int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size); - SetCachedSize(cached_size); - return total_size; -} - -void VarType_TensorDesc::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { -// @@protoc_insertion_point(generalized_merge_from_start:paddle.framework.proto.VarType.TensorDesc) - GOOGLE_DCHECK_NE(&from, this); - const VarType_TensorDesc* source = - ::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated( - &from); - if (source == nullptr) { - // @@protoc_insertion_point(generalized_merge_from_cast_fail:paddle.framework.proto.VarType.TensorDesc) - ::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this); - } else { - // @@protoc_insertion_point(generalized_merge_from_cast_success:paddle.framework.proto.VarType.TensorDesc) - MergeFrom(*source); - } -} - -void VarType_TensorDesc::MergeFrom(const VarType_TensorDesc& from) { -// @@protoc_insertion_point(class_specific_merge_from_start:paddle.framework.proto.VarType.TensorDesc) - GOOGLE_DCHECK_NE(&from, this); - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; - (void) cached_has_bits; - - dims_.MergeFrom(from.dims_); - if (from._internal_has_data_type()) { - _internal_set_data_type(from._internal_data_type()); - } -} - -void VarType_TensorDesc::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { -// @@protoc_insertion_point(generalized_copy_from_start:paddle.framework.proto.VarType.TensorDesc) - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -void VarType_TensorDesc::CopyFrom(const VarType_TensorDesc& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:paddle.framework.proto.VarType.TensorDesc) - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -bool VarType_TensorDesc::IsInitialized() const { - if (_Internal::MissingRequiredFields(_has_bits_)) return false; - return true; -} - -void VarType_TensorDesc::InternalSwap(VarType_TensorDesc* other) { - using std::swap; - _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); - swap(_has_bits_[0], other->_has_bits_[0]); - dims_.InternalSwap(&other->dims_); - swap(data_type_, other->data_type_); -} - -::PROTOBUF_NAMESPACE_ID::Metadata VarType_TensorDesc::GetMetadata() const { - return GetMetadataStatic(); -} - - -// =================================================================== - -class VarType_LoDTensorDesc::_Internal { - public: - using HasBits = decltype(std::declval()._has_bits_); - static const ::paddle::framework::proto::VarType_TensorDesc& tensor(const VarType_LoDTensorDesc* msg); - static void set_has_tensor(HasBits* has_bits) { - (*has_bits)[0] |= 1u; - } - static void set_has_lod_level(HasBits* has_bits) { - (*has_bits)[0] |= 2u; - } - static bool MissingRequiredFields(const HasBits& has_bits) { - return ((has_bits[0] & 0x00000001) ^ 0x00000001) != 0; - } -}; - -const ::paddle::framework::proto::VarType_TensorDesc& -VarType_LoDTensorDesc::_Internal::tensor(const VarType_LoDTensorDesc* msg) { - return *msg->tensor_; -} -VarType_LoDTensorDesc::VarType_LoDTensorDesc(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::Message(arena) { - SharedCtor(); - RegisterArenaDtor(arena); - // @@protoc_insertion_point(arena_constructor:paddle.framework.proto.VarType.LoDTensorDesc) -} -VarType_LoDTensorDesc::VarType_LoDTensorDesc(const VarType_LoDTensorDesc& from) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _has_bits_(from._has_bits_) { - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - if (from._internal_has_tensor()) { - tensor_ = new ::paddle::framework::proto::VarType_TensorDesc(*from.tensor_); - } else { - tensor_ = nullptr; - } - lod_level_ = from.lod_level_; - // @@protoc_insertion_point(copy_constructor:paddle.framework.proto.VarType.LoDTensorDesc) -} - -void VarType_LoDTensorDesc::SharedCtor() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_VarType_LoDTensorDesc_framework_2eproto.base); - ::memset(reinterpret_cast(this) + static_cast( - reinterpret_cast(&tensor_) - reinterpret_cast(this)), - 0, static_cast(reinterpret_cast(&lod_level_) - - reinterpret_cast(&tensor_)) + sizeof(lod_level_)); -} - -VarType_LoDTensorDesc::~VarType_LoDTensorDesc() { - // @@protoc_insertion_point(destructor:paddle.framework.proto.VarType.LoDTensorDesc) - SharedDtor(); - _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); -} - -void VarType_LoDTensorDesc::SharedDtor() { - GOOGLE_DCHECK(GetArena() == nullptr); - if (this != internal_default_instance()) delete tensor_; -} - -void VarType_LoDTensorDesc::ArenaDtor(void* object) { - VarType_LoDTensorDesc* _this = reinterpret_cast< VarType_LoDTensorDesc* >(object); - (void)_this; -} -void VarType_LoDTensorDesc::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { -} -void VarType_LoDTensorDesc::SetCachedSize(int size) const { - _cached_size_.Set(size); -} -const VarType_LoDTensorDesc& VarType_LoDTensorDesc::default_instance() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_VarType_LoDTensorDesc_framework_2eproto.base); - return *internal_default_instance(); -} - - -void VarType_LoDTensorDesc::Clear() { -// @@protoc_insertion_point(message_clear_start:paddle.framework.proto.VarType.LoDTensorDesc) - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - - cached_has_bits = _has_bits_[0]; - if (cached_has_bits & 0x00000001u) { - GOOGLE_DCHECK(tensor_ != nullptr); - tensor_->Clear(); - } - lod_level_ = 0; - _has_bits_.Clear(); - _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); -} - -const char* VarType_LoDTensorDesc::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { -#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - _Internal::HasBits has_bits{}; - while (!ctx->Done(&ptr)) { - ::PROTOBUF_NAMESPACE_ID::uint32 tag; - ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); - CHK_(ptr); - switch (tag >> 3) { - // required .paddle.framework.proto.VarType.TensorDesc tensor = 1; - case 1: - if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) { - ptr = ctx->ParseMessage(_internal_mutable_tensor(), ptr); - CHK_(ptr); - } else goto handle_unusual; - continue; - // optional int32 lod_level = 2 [default = 0]; - case 2: - if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 16)) { - _Internal::set_has_lod_level(&has_bits); - lod_level_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); - CHK_(ptr); - } else goto handle_unusual; - continue; - default: { - handle_unusual: - if ((tag & 7) == 4 || tag == 0) { - ctx->SetLastTag(tag); - goto success; - } - ptr = UnknownFieldParse(tag, - _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), - ptr, ctx); - CHK_(ptr != nullptr); - continue; - } - } // switch - } // while -success: - _has_bits_.Or(has_bits); - return ptr; -failure: - ptr = nullptr; - goto success; -#undef CHK_ -} - -::PROTOBUF_NAMESPACE_ID::uint8* VarType_LoDTensorDesc::_InternalSerialize( - ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { - // @@protoc_insertion_point(serialize_to_array_start:paddle.framework.proto.VarType.LoDTensorDesc) - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; - (void) cached_has_bits; - - cached_has_bits = _has_bits_[0]; - // required .paddle.framework.proto.VarType.TensorDesc tensor = 1; - if (cached_has_bits & 0x00000001u) { - target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage( - 1, _Internal::tensor(this), target, stream); - } - - // optional int32 lod_level = 2 [default = 0]; - if (cached_has_bits & 0x00000002u) { - target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(2, this->_internal_lod_level(), target); - } - - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); - } - // @@protoc_insertion_point(serialize_to_array_end:paddle.framework.proto.VarType.LoDTensorDesc) - return target; -} - -size_t VarType_LoDTensorDesc::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:paddle.framework.proto.VarType.LoDTensorDesc) - size_t total_size = 0; - - // required .paddle.framework.proto.VarType.TensorDesc tensor = 1; - if (_internal_has_tensor()) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - *tensor_); - } - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - - // optional int32 lod_level = 2 [default = 0]; - cached_has_bits = _has_bits_[0]; - if (cached_has_bits & 0x00000002u) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size( - this->_internal_lod_level()); - } - - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize( - _internal_metadata_, total_size, &_cached_size_); - } - int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size); - SetCachedSize(cached_size); - return total_size; -} - -void VarType_LoDTensorDesc::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { -// @@protoc_insertion_point(generalized_merge_from_start:paddle.framework.proto.VarType.LoDTensorDesc) - GOOGLE_DCHECK_NE(&from, this); - const VarType_LoDTensorDesc* source = - ::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated( - &from); - if (source == nullptr) { - // @@protoc_insertion_point(generalized_merge_from_cast_fail:paddle.framework.proto.VarType.LoDTensorDesc) - ::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this); - } else { - // @@protoc_insertion_point(generalized_merge_from_cast_success:paddle.framework.proto.VarType.LoDTensorDesc) - MergeFrom(*source); - } -} - -void VarType_LoDTensorDesc::MergeFrom(const VarType_LoDTensorDesc& from) { -// @@protoc_insertion_point(class_specific_merge_from_start:paddle.framework.proto.VarType.LoDTensorDesc) - GOOGLE_DCHECK_NE(&from, this); - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; - (void) cached_has_bits; - - cached_has_bits = from._has_bits_[0]; - if (cached_has_bits & 0x00000003u) { - if (cached_has_bits & 0x00000001u) { - _internal_mutable_tensor()->::paddle::framework::proto::VarType_TensorDesc::MergeFrom(from._internal_tensor()); - } - if (cached_has_bits & 0x00000002u) { - lod_level_ = from.lod_level_; - } - _has_bits_[0] |= cached_has_bits; - } -} - -void VarType_LoDTensorDesc::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { -// @@protoc_insertion_point(generalized_copy_from_start:paddle.framework.proto.VarType.LoDTensorDesc) - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -void VarType_LoDTensorDesc::CopyFrom(const VarType_LoDTensorDesc& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:paddle.framework.proto.VarType.LoDTensorDesc) - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -bool VarType_LoDTensorDesc::IsInitialized() const { - if (_Internal::MissingRequiredFields(_has_bits_)) return false; - if (_internal_has_tensor()) { - if (!tensor_->IsInitialized()) return false; - } - return true; -} - -void VarType_LoDTensorDesc::InternalSwap(VarType_LoDTensorDesc* other) { - using std::swap; - _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); - swap(_has_bits_[0], other->_has_bits_[0]); - ::PROTOBUF_NAMESPACE_ID::internal::memswap< - PROTOBUF_FIELD_OFFSET(VarType_LoDTensorDesc, lod_level_) - + sizeof(VarType_LoDTensorDesc::lod_level_) - - PROTOBUF_FIELD_OFFSET(VarType_LoDTensorDesc, tensor_)>( - reinterpret_cast(&tensor_), - reinterpret_cast(&other->tensor_)); -} - -::PROTOBUF_NAMESPACE_ID::Metadata VarType_LoDTensorDesc::GetMetadata() const { - return GetMetadataStatic(); -} - - -// =================================================================== - -class VarType_LoDTensorArrayDesc::_Internal { - public: - using HasBits = decltype(std::declval()._has_bits_); - static const ::paddle::framework::proto::VarType_TensorDesc& tensor(const VarType_LoDTensorArrayDesc* msg); - static void set_has_tensor(HasBits* has_bits) { - (*has_bits)[0] |= 1u; - } - static void set_has_lod_level(HasBits* has_bits) { - (*has_bits)[0] |= 2u; - } - static bool MissingRequiredFields(const HasBits& has_bits) { - return ((has_bits[0] & 0x00000001) ^ 0x00000001) != 0; - } -}; - -const ::paddle::framework::proto::VarType_TensorDesc& -VarType_LoDTensorArrayDesc::_Internal::tensor(const VarType_LoDTensorArrayDesc* msg) { - return *msg->tensor_; -} -VarType_LoDTensorArrayDesc::VarType_LoDTensorArrayDesc(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::Message(arena) { - SharedCtor(); - RegisterArenaDtor(arena); - // @@protoc_insertion_point(arena_constructor:paddle.framework.proto.VarType.LoDTensorArrayDesc) -} -VarType_LoDTensorArrayDesc::VarType_LoDTensorArrayDesc(const VarType_LoDTensorArrayDesc& from) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _has_bits_(from._has_bits_) { - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - if (from._internal_has_tensor()) { - tensor_ = new ::paddle::framework::proto::VarType_TensorDesc(*from.tensor_); - } else { - tensor_ = nullptr; - } - lod_level_ = from.lod_level_; - // @@protoc_insertion_point(copy_constructor:paddle.framework.proto.VarType.LoDTensorArrayDesc) -} - -void VarType_LoDTensorArrayDesc::SharedCtor() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_VarType_LoDTensorArrayDesc_framework_2eproto.base); - ::memset(reinterpret_cast(this) + static_cast( - reinterpret_cast(&tensor_) - reinterpret_cast(this)), - 0, static_cast(reinterpret_cast(&lod_level_) - - reinterpret_cast(&tensor_)) + sizeof(lod_level_)); -} - -VarType_LoDTensorArrayDesc::~VarType_LoDTensorArrayDesc() { - // @@protoc_insertion_point(destructor:paddle.framework.proto.VarType.LoDTensorArrayDesc) - SharedDtor(); - _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); -} - -void VarType_LoDTensorArrayDesc::SharedDtor() { - GOOGLE_DCHECK(GetArena() == nullptr); - if (this != internal_default_instance()) delete tensor_; -} - -void VarType_LoDTensorArrayDesc::ArenaDtor(void* object) { - VarType_LoDTensorArrayDesc* _this = reinterpret_cast< VarType_LoDTensorArrayDesc* >(object); - (void)_this; -} -void VarType_LoDTensorArrayDesc::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { -} -void VarType_LoDTensorArrayDesc::SetCachedSize(int size) const { - _cached_size_.Set(size); -} -const VarType_LoDTensorArrayDesc& VarType_LoDTensorArrayDesc::default_instance() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_VarType_LoDTensorArrayDesc_framework_2eproto.base); - return *internal_default_instance(); -} - - -void VarType_LoDTensorArrayDesc::Clear() { -// @@protoc_insertion_point(message_clear_start:paddle.framework.proto.VarType.LoDTensorArrayDesc) - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - - cached_has_bits = _has_bits_[0]; - if (cached_has_bits & 0x00000001u) { - GOOGLE_DCHECK(tensor_ != nullptr); - tensor_->Clear(); - } - lod_level_ = 0; - _has_bits_.Clear(); - _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); -} - -const char* VarType_LoDTensorArrayDesc::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { -#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - _Internal::HasBits has_bits{}; - while (!ctx->Done(&ptr)) { - ::PROTOBUF_NAMESPACE_ID::uint32 tag; - ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); - CHK_(ptr); - switch (tag >> 3) { - // required .paddle.framework.proto.VarType.TensorDesc tensor = 1; - case 1: - if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) { - ptr = ctx->ParseMessage(_internal_mutable_tensor(), ptr); - CHK_(ptr); - } else goto handle_unusual; - continue; - // optional int32 lod_level = 2 [default = 0]; - case 2: - if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 16)) { - _Internal::set_has_lod_level(&has_bits); - lod_level_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); - CHK_(ptr); - } else goto handle_unusual; - continue; - default: { - handle_unusual: - if ((tag & 7) == 4 || tag == 0) { - ctx->SetLastTag(tag); - goto success; - } - ptr = UnknownFieldParse(tag, - _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), - ptr, ctx); - CHK_(ptr != nullptr); - continue; - } - } // switch - } // while -success: - _has_bits_.Or(has_bits); - return ptr; -failure: - ptr = nullptr; - goto success; -#undef CHK_ -} - -::PROTOBUF_NAMESPACE_ID::uint8* VarType_LoDTensorArrayDesc::_InternalSerialize( - ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { - // @@protoc_insertion_point(serialize_to_array_start:paddle.framework.proto.VarType.LoDTensorArrayDesc) - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; - (void) cached_has_bits; - - cached_has_bits = _has_bits_[0]; - // required .paddle.framework.proto.VarType.TensorDesc tensor = 1; - if (cached_has_bits & 0x00000001u) { - target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage( - 1, _Internal::tensor(this), target, stream); - } - - // optional int32 lod_level = 2 [default = 0]; - if (cached_has_bits & 0x00000002u) { - target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(2, this->_internal_lod_level(), target); - } - - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); - } - // @@protoc_insertion_point(serialize_to_array_end:paddle.framework.proto.VarType.LoDTensorArrayDesc) - return target; -} - -size_t VarType_LoDTensorArrayDesc::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:paddle.framework.proto.VarType.LoDTensorArrayDesc) - size_t total_size = 0; - - // required .paddle.framework.proto.VarType.TensorDesc tensor = 1; - if (_internal_has_tensor()) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - *tensor_); - } - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - - // optional int32 lod_level = 2 [default = 0]; - cached_has_bits = _has_bits_[0]; - if (cached_has_bits & 0x00000002u) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size( - this->_internal_lod_level()); - } - - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize( - _internal_metadata_, total_size, &_cached_size_); - } - int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size); - SetCachedSize(cached_size); - return total_size; -} - -void VarType_LoDTensorArrayDesc::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { -// @@protoc_insertion_point(generalized_merge_from_start:paddle.framework.proto.VarType.LoDTensorArrayDesc) - GOOGLE_DCHECK_NE(&from, this); - const VarType_LoDTensorArrayDesc* source = - ::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated( - &from); - if (source == nullptr) { - // @@protoc_insertion_point(generalized_merge_from_cast_fail:paddle.framework.proto.VarType.LoDTensorArrayDesc) - ::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this); - } else { - // @@protoc_insertion_point(generalized_merge_from_cast_success:paddle.framework.proto.VarType.LoDTensorArrayDesc) - MergeFrom(*source); - } -} - -void VarType_LoDTensorArrayDesc::MergeFrom(const VarType_LoDTensorArrayDesc& from) { -// @@protoc_insertion_point(class_specific_merge_from_start:paddle.framework.proto.VarType.LoDTensorArrayDesc) - GOOGLE_DCHECK_NE(&from, this); - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; - (void) cached_has_bits; - - cached_has_bits = from._has_bits_[0]; - if (cached_has_bits & 0x00000003u) { - if (cached_has_bits & 0x00000001u) { - _internal_mutable_tensor()->::paddle::framework::proto::VarType_TensorDesc::MergeFrom(from._internal_tensor()); - } - if (cached_has_bits & 0x00000002u) { - lod_level_ = from.lod_level_; - } - _has_bits_[0] |= cached_has_bits; - } -} - -void VarType_LoDTensorArrayDesc::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { -// @@protoc_insertion_point(generalized_copy_from_start:paddle.framework.proto.VarType.LoDTensorArrayDesc) - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -void VarType_LoDTensorArrayDesc::CopyFrom(const VarType_LoDTensorArrayDesc& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:paddle.framework.proto.VarType.LoDTensorArrayDesc) - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -bool VarType_LoDTensorArrayDesc::IsInitialized() const { - if (_Internal::MissingRequiredFields(_has_bits_)) return false; - if (_internal_has_tensor()) { - if (!tensor_->IsInitialized()) return false; - } - return true; -} - -void VarType_LoDTensorArrayDesc::InternalSwap(VarType_LoDTensorArrayDesc* other) { - using std::swap; - _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); - swap(_has_bits_[0], other->_has_bits_[0]); - ::PROTOBUF_NAMESPACE_ID::internal::memswap< - PROTOBUF_FIELD_OFFSET(VarType_LoDTensorArrayDesc, lod_level_) - + sizeof(VarType_LoDTensorArrayDesc::lod_level_) - - PROTOBUF_FIELD_OFFSET(VarType_LoDTensorArrayDesc, tensor_)>( - reinterpret_cast(&tensor_), - reinterpret_cast(&other->tensor_)); -} - -::PROTOBUF_NAMESPACE_ID::Metadata VarType_LoDTensorArrayDesc::GetMetadata() const { - return GetMetadataStatic(); -} - - -// =================================================================== - -class VarType_ReaderDesc::_Internal { - public: -}; - -VarType_ReaderDesc::VarType_ReaderDesc(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::Message(arena), - lod_tensor_(arena) { - SharedCtor(); - RegisterArenaDtor(arena); - // @@protoc_insertion_point(arena_constructor:paddle.framework.proto.VarType.ReaderDesc) -} -VarType_ReaderDesc::VarType_ReaderDesc(const VarType_ReaderDesc& from) - : ::PROTOBUF_NAMESPACE_ID::Message(), - lod_tensor_(from.lod_tensor_) { - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - // @@protoc_insertion_point(copy_constructor:paddle.framework.proto.VarType.ReaderDesc) -} - -void VarType_ReaderDesc::SharedCtor() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_VarType_ReaderDesc_framework_2eproto.base); -} - -VarType_ReaderDesc::~VarType_ReaderDesc() { - // @@protoc_insertion_point(destructor:paddle.framework.proto.VarType.ReaderDesc) - SharedDtor(); - _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); -} - -void VarType_ReaderDesc::SharedDtor() { - GOOGLE_DCHECK(GetArena() == nullptr); -} - -void VarType_ReaderDesc::ArenaDtor(void* object) { - VarType_ReaderDesc* _this = reinterpret_cast< VarType_ReaderDesc* >(object); - (void)_this; -} -void VarType_ReaderDesc::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { -} -void VarType_ReaderDesc::SetCachedSize(int size) const { - _cached_size_.Set(size); -} -const VarType_ReaderDesc& VarType_ReaderDesc::default_instance() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_VarType_ReaderDesc_framework_2eproto.base); - return *internal_default_instance(); -} - - -void VarType_ReaderDesc::Clear() { -// @@protoc_insertion_point(message_clear_start:paddle.framework.proto.VarType.ReaderDesc) - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - - lod_tensor_.Clear(); - _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); -} - -const char* VarType_ReaderDesc::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { -#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - while (!ctx->Done(&ptr)) { - ::PROTOBUF_NAMESPACE_ID::uint32 tag; - ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); - CHK_(ptr); - switch (tag >> 3) { - // repeated .paddle.framework.proto.VarType.LoDTensorDesc lod_tensor = 1; - case 1: - if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) { - ptr -= 1; - do { - ptr += 1; - ptr = ctx->ParseMessage(_internal_add_lod_tensor(), ptr); - CHK_(ptr); - if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<10>(ptr)); - } else goto handle_unusual; - continue; - default: { - handle_unusual: - if ((tag & 7) == 4 || tag == 0) { - ctx->SetLastTag(tag); - goto success; - } - ptr = UnknownFieldParse(tag, - _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), - ptr, ctx); - CHK_(ptr != nullptr); - continue; - } - } // switch - } // while -success: - return ptr; -failure: - ptr = nullptr; - goto success; -#undef CHK_ -} - -::PROTOBUF_NAMESPACE_ID::uint8* VarType_ReaderDesc::_InternalSerialize( - ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { - // @@protoc_insertion_point(serialize_to_array_start:paddle.framework.proto.VarType.ReaderDesc) - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; - (void) cached_has_bits; - - // repeated .paddle.framework.proto.VarType.LoDTensorDesc lod_tensor = 1; - for (unsigned int i = 0, - n = static_cast(this->_internal_lod_tensor_size()); i < n; i++) { - target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(1, this->_internal_lod_tensor(i), target, stream); - } - - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); - } - // @@protoc_insertion_point(serialize_to_array_end:paddle.framework.proto.VarType.ReaderDesc) - return target; -} - -size_t VarType_ReaderDesc::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:paddle.framework.proto.VarType.ReaderDesc) - size_t total_size = 0; - - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - - // repeated .paddle.framework.proto.VarType.LoDTensorDesc lod_tensor = 1; - total_size += 1UL * this->_internal_lod_tensor_size(); - for (const auto& msg : this->lod_tensor_) { - total_size += - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); - } - - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize( - _internal_metadata_, total_size, &_cached_size_); - } - int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size); - SetCachedSize(cached_size); - return total_size; -} - -void VarType_ReaderDesc::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { -// @@protoc_insertion_point(generalized_merge_from_start:paddle.framework.proto.VarType.ReaderDesc) - GOOGLE_DCHECK_NE(&from, this); - const VarType_ReaderDesc* source = - ::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated( - &from); - if (source == nullptr) { - // @@protoc_insertion_point(generalized_merge_from_cast_fail:paddle.framework.proto.VarType.ReaderDesc) - ::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this); - } else { - // @@protoc_insertion_point(generalized_merge_from_cast_success:paddle.framework.proto.VarType.ReaderDesc) - MergeFrom(*source); - } -} - -void VarType_ReaderDesc::MergeFrom(const VarType_ReaderDesc& from) { -// @@protoc_insertion_point(class_specific_merge_from_start:paddle.framework.proto.VarType.ReaderDesc) - GOOGLE_DCHECK_NE(&from, this); - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; - (void) cached_has_bits; - - lod_tensor_.MergeFrom(from.lod_tensor_); -} - -void VarType_ReaderDesc::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { -// @@protoc_insertion_point(generalized_copy_from_start:paddle.framework.proto.VarType.ReaderDesc) - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -void VarType_ReaderDesc::CopyFrom(const VarType_ReaderDesc& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:paddle.framework.proto.VarType.ReaderDesc) - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -bool VarType_ReaderDesc::IsInitialized() const { - if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(lod_tensor_)) return false; - return true; -} - -void VarType_ReaderDesc::InternalSwap(VarType_ReaderDesc* other) { - using std::swap; - _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); - lod_tensor_.InternalSwap(&other->lod_tensor_); -} - -::PROTOBUF_NAMESPACE_ID::Metadata VarType_ReaderDesc::GetMetadata() const { - return GetMetadataStatic(); -} - - -// =================================================================== - -class VarType_Tuple::_Internal { - public: -}; - -VarType_Tuple::VarType_Tuple(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::Message(arena), - element_type_(arena) { - SharedCtor(); - RegisterArenaDtor(arena); - // @@protoc_insertion_point(arena_constructor:paddle.framework.proto.VarType.Tuple) -} -VarType_Tuple::VarType_Tuple(const VarType_Tuple& from) - : ::PROTOBUF_NAMESPACE_ID::Message(), - element_type_(from.element_type_) { - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - // @@protoc_insertion_point(copy_constructor:paddle.framework.proto.VarType.Tuple) -} - -void VarType_Tuple::SharedCtor() { -} - -VarType_Tuple::~VarType_Tuple() { - // @@protoc_insertion_point(destructor:paddle.framework.proto.VarType.Tuple) - SharedDtor(); - _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); -} - -void VarType_Tuple::SharedDtor() { - GOOGLE_DCHECK(GetArena() == nullptr); -} - -void VarType_Tuple::ArenaDtor(void* object) { - VarType_Tuple* _this = reinterpret_cast< VarType_Tuple* >(object); - (void)_this; -} -void VarType_Tuple::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { -} -void VarType_Tuple::SetCachedSize(int size) const { - _cached_size_.Set(size); -} -const VarType_Tuple& VarType_Tuple::default_instance() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_VarType_Tuple_framework_2eproto.base); - return *internal_default_instance(); -} - - -void VarType_Tuple::Clear() { -// @@protoc_insertion_point(message_clear_start:paddle.framework.proto.VarType.Tuple) - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - - element_type_.Clear(); - _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); -} - -const char* VarType_Tuple::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { -#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - while (!ctx->Done(&ptr)) { - ::PROTOBUF_NAMESPACE_ID::uint32 tag; - ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); - CHK_(ptr); - switch (tag >> 3) { - // repeated .paddle.framework.proto.VarType.Type element_type = 1; - case 1: - if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 8)) { - ptr -= 1; - do { - ptr += 1; - ::PROTOBUF_NAMESPACE_ID::uint64 val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); - CHK_(ptr); - if (PROTOBUF_PREDICT_TRUE(::paddle::framework::proto::VarType_Type_IsValid(val))) { - _internal_add_element_type(static_cast<::paddle::framework::proto::VarType_Type>(val)); - } else { - ::PROTOBUF_NAMESPACE_ID::internal::WriteVarint(1, val, mutable_unknown_fields()); - } - if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<8>(ptr)); - } else if (static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10) { - ptr = ::PROTOBUF_NAMESPACE_ID::internal::PackedEnumParser<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(_internal_mutable_element_type(), ptr, ctx, ::paddle::framework::proto::VarType_Type_IsValid, &_internal_metadata_, 1); - CHK_(ptr); - } else goto handle_unusual; - continue; - default: { - handle_unusual: - if ((tag & 7) == 4 || tag == 0) { - ctx->SetLastTag(tag); - goto success; - } - ptr = UnknownFieldParse(tag, - _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), - ptr, ctx); - CHK_(ptr != nullptr); - continue; - } - } // switch - } // while -success: - return ptr; -failure: - ptr = nullptr; - goto success; -#undef CHK_ -} - -::PROTOBUF_NAMESPACE_ID::uint8* VarType_Tuple::_InternalSerialize( - ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { - // @@protoc_insertion_point(serialize_to_array_start:paddle.framework.proto.VarType.Tuple) - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; - (void) cached_has_bits; - - // repeated .paddle.framework.proto.VarType.Type element_type = 1; - for (int i = 0, n = this->_internal_element_type_size(); i < n; i++) { - target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteEnumToArray( - 1, this->_internal_element_type(i), target); - } - - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); - } - // @@protoc_insertion_point(serialize_to_array_end:paddle.framework.proto.VarType.Tuple) - return target; -} - -size_t VarType_Tuple::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:paddle.framework.proto.VarType.Tuple) - size_t total_size = 0; - - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - - // repeated .paddle.framework.proto.VarType.Type element_type = 1; - { - size_t data_size = 0; - unsigned int count = static_cast(this->_internal_element_type_size());for (unsigned int i = 0; i < count; i++) { - data_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::EnumSize( - this->_internal_element_type(static_cast(i))); - } - total_size += (1UL * count) + data_size; - } - - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize( - _internal_metadata_, total_size, &_cached_size_); - } - int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size); - SetCachedSize(cached_size); - return total_size; -} - -void VarType_Tuple::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { -// @@protoc_insertion_point(generalized_merge_from_start:paddle.framework.proto.VarType.Tuple) - GOOGLE_DCHECK_NE(&from, this); - const VarType_Tuple* source = - ::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated( - &from); - if (source == nullptr) { - // @@protoc_insertion_point(generalized_merge_from_cast_fail:paddle.framework.proto.VarType.Tuple) - ::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this); - } else { - // @@protoc_insertion_point(generalized_merge_from_cast_success:paddle.framework.proto.VarType.Tuple) - MergeFrom(*source); - } -} - -void VarType_Tuple::MergeFrom(const VarType_Tuple& from) { -// @@protoc_insertion_point(class_specific_merge_from_start:paddle.framework.proto.VarType.Tuple) - GOOGLE_DCHECK_NE(&from, this); - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; - (void) cached_has_bits; - - element_type_.MergeFrom(from.element_type_); -} - -void VarType_Tuple::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { -// @@protoc_insertion_point(generalized_copy_from_start:paddle.framework.proto.VarType.Tuple) - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -void VarType_Tuple::CopyFrom(const VarType_Tuple& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:paddle.framework.proto.VarType.Tuple) - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -bool VarType_Tuple::IsInitialized() const { - return true; -} - -void VarType_Tuple::InternalSwap(VarType_Tuple* other) { - using std::swap; - _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); - element_type_.InternalSwap(&other->element_type_); -} - -::PROTOBUF_NAMESPACE_ID::Metadata VarType_Tuple::GetMetadata() const { - return GetMetadataStatic(); -} - - -// =================================================================== - -class VarType::_Internal { - public: - using HasBits = decltype(std::declval()._has_bits_); - static void set_has_type(HasBits* has_bits) { - (*has_bits)[0] |= 32u; - } - static const ::paddle::framework::proto::VarType_TensorDesc& selected_rows(const VarType* msg); - static void set_has_selected_rows(HasBits* has_bits) { - (*has_bits)[0] |= 1u; - } - static const ::paddle::framework::proto::VarType_LoDTensorDesc& lod_tensor(const VarType* msg); - static void set_has_lod_tensor(HasBits* has_bits) { - (*has_bits)[0] |= 2u; - } - static const ::paddle::framework::proto::VarType_LoDTensorArrayDesc& tensor_array(const VarType* msg); - static void set_has_tensor_array(HasBits* has_bits) { - (*has_bits)[0] |= 4u; - } - static const ::paddle::framework::proto::VarType_ReaderDesc& reader(const VarType* msg); - static void set_has_reader(HasBits* has_bits) { - (*has_bits)[0] |= 8u; - } - static const ::paddle::framework::proto::VarType_Tuple& tuple(const VarType* msg); - static void set_has_tuple(HasBits* has_bits) { - (*has_bits)[0] |= 16u; - } - static bool MissingRequiredFields(const HasBits& has_bits) { - return ((has_bits[0] & 0x00000020) ^ 0x00000020) != 0; - } -}; - -const ::paddle::framework::proto::VarType_TensorDesc& -VarType::_Internal::selected_rows(const VarType* msg) { - return *msg->selected_rows_; -} -const ::paddle::framework::proto::VarType_LoDTensorDesc& -VarType::_Internal::lod_tensor(const VarType* msg) { - return *msg->lod_tensor_; -} -const ::paddle::framework::proto::VarType_LoDTensorArrayDesc& -VarType::_Internal::tensor_array(const VarType* msg) { - return *msg->tensor_array_; -} -const ::paddle::framework::proto::VarType_ReaderDesc& -VarType::_Internal::reader(const VarType* msg) { - return *msg->reader_; -} -const ::paddle::framework::proto::VarType_Tuple& -VarType::_Internal::tuple(const VarType* msg) { - return *msg->tuple_; -} -VarType::VarType(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::Message(arena) { - SharedCtor(); - RegisterArenaDtor(arena); - // @@protoc_insertion_point(arena_constructor:paddle.framework.proto.VarType) -} -VarType::VarType(const VarType& from) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _has_bits_(from._has_bits_) { - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - if (from._internal_has_selected_rows()) { - selected_rows_ = new ::paddle::framework::proto::VarType_TensorDesc(*from.selected_rows_); - } else { - selected_rows_ = nullptr; - } - if (from._internal_has_lod_tensor()) { - lod_tensor_ = new ::paddle::framework::proto::VarType_LoDTensorDesc(*from.lod_tensor_); - } else { - lod_tensor_ = nullptr; - } - if (from._internal_has_tensor_array()) { - tensor_array_ = new ::paddle::framework::proto::VarType_LoDTensorArrayDesc(*from.tensor_array_); - } else { - tensor_array_ = nullptr; - } - if (from._internal_has_reader()) { - reader_ = new ::paddle::framework::proto::VarType_ReaderDesc(*from.reader_); - } else { - reader_ = nullptr; - } - if (from._internal_has_tuple()) { - tuple_ = new ::paddle::framework::proto::VarType_Tuple(*from.tuple_); - } else { - tuple_ = nullptr; - } - type_ = from.type_; - // @@protoc_insertion_point(copy_constructor:paddle.framework.proto.VarType) -} - -void VarType::SharedCtor() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_VarType_framework_2eproto.base); - ::memset(reinterpret_cast(this) + static_cast( - reinterpret_cast(&selected_rows_) - reinterpret_cast(this)), - 0, static_cast(reinterpret_cast(&type_) - - reinterpret_cast(&selected_rows_)) + sizeof(type_)); -} - -VarType::~VarType() { - // @@protoc_insertion_point(destructor:paddle.framework.proto.VarType) - SharedDtor(); - _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); -} - -void VarType::SharedDtor() { - GOOGLE_DCHECK(GetArena() == nullptr); - if (this != internal_default_instance()) delete selected_rows_; - if (this != internal_default_instance()) delete lod_tensor_; - if (this != internal_default_instance()) delete tensor_array_; - if (this != internal_default_instance()) delete reader_; - if (this != internal_default_instance()) delete tuple_; -} - -void VarType::ArenaDtor(void* object) { - VarType* _this = reinterpret_cast< VarType* >(object); - (void)_this; -} -void VarType::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { -} -void VarType::SetCachedSize(int size) const { - _cached_size_.Set(size); -} -const VarType& VarType::default_instance() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_VarType_framework_2eproto.base); - return *internal_default_instance(); -} - - -void VarType::Clear() { -// @@protoc_insertion_point(message_clear_start:paddle.framework.proto.VarType) - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - - cached_has_bits = _has_bits_[0]; - if (cached_has_bits & 0x0000001fu) { - if (cached_has_bits & 0x00000001u) { - GOOGLE_DCHECK(selected_rows_ != nullptr); - selected_rows_->Clear(); - } - if (cached_has_bits & 0x00000002u) { - GOOGLE_DCHECK(lod_tensor_ != nullptr); - lod_tensor_->Clear(); - } - if (cached_has_bits & 0x00000004u) { - GOOGLE_DCHECK(tensor_array_ != nullptr); - tensor_array_->Clear(); - } - if (cached_has_bits & 0x00000008u) { - GOOGLE_DCHECK(reader_ != nullptr); - reader_->Clear(); - } - if (cached_has_bits & 0x00000010u) { - GOOGLE_DCHECK(tuple_ != nullptr); - tuple_->Clear(); - } - } - type_ = 0; - _has_bits_.Clear(); - _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); -} - -const char* VarType::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { -#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - _Internal::HasBits has_bits{}; - while (!ctx->Done(&ptr)) { - ::PROTOBUF_NAMESPACE_ID::uint32 tag; - ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); - CHK_(ptr); - switch (tag >> 3) { - // required .paddle.framework.proto.VarType.Type type = 1; - case 1: - if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 8)) { - ::PROTOBUF_NAMESPACE_ID::uint64 val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); - CHK_(ptr); - if (PROTOBUF_PREDICT_TRUE(::paddle::framework::proto::VarType_Type_IsValid(val))) { - _internal_set_type(static_cast<::paddle::framework::proto::VarType_Type>(val)); - } else { - ::PROTOBUF_NAMESPACE_ID::internal::WriteVarint(1, val, mutable_unknown_fields()); - } - } else goto handle_unusual; - continue; - // optional .paddle.framework.proto.VarType.TensorDesc selected_rows = 2; - case 2: - if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 18)) { - ptr = ctx->ParseMessage(_internal_mutable_selected_rows(), ptr); - CHK_(ptr); - } else goto handle_unusual; - continue; - // optional .paddle.framework.proto.VarType.LoDTensorDesc lod_tensor = 3; - case 3: - if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 26)) { - ptr = ctx->ParseMessage(_internal_mutable_lod_tensor(), ptr); - CHK_(ptr); - } else goto handle_unusual; - continue; - // optional .paddle.framework.proto.VarType.LoDTensorArrayDesc tensor_array = 4; - case 4: - if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 34)) { - ptr = ctx->ParseMessage(_internal_mutable_tensor_array(), ptr); - CHK_(ptr); - } else goto handle_unusual; - continue; - // optional .paddle.framework.proto.VarType.ReaderDesc reader = 5; - case 5: - if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 42)) { - ptr = ctx->ParseMessage(_internal_mutable_reader(), ptr); - CHK_(ptr); - } else goto handle_unusual; - continue; - // optional .paddle.framework.proto.VarType.Tuple tuple = 7; - case 7: - if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 58)) { - ptr = ctx->ParseMessage(_internal_mutable_tuple(), ptr); - CHK_(ptr); - } else goto handle_unusual; - continue; - default: { - handle_unusual: - if ((tag & 7) == 4 || tag == 0) { - ctx->SetLastTag(tag); - goto success; - } - ptr = UnknownFieldParse(tag, - _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), - ptr, ctx); - CHK_(ptr != nullptr); - continue; - } - } // switch - } // while -success: - _has_bits_.Or(has_bits); - return ptr; -failure: - ptr = nullptr; - goto success; -#undef CHK_ -} - -::PROTOBUF_NAMESPACE_ID::uint8* VarType::_InternalSerialize( - ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { - // @@protoc_insertion_point(serialize_to_array_start:paddle.framework.proto.VarType) - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; - (void) cached_has_bits; - - cached_has_bits = _has_bits_[0]; - // required .paddle.framework.proto.VarType.Type type = 1; - if (cached_has_bits & 0x00000020u) { - target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteEnumToArray( - 1, this->_internal_type(), target); - } - - // optional .paddle.framework.proto.VarType.TensorDesc selected_rows = 2; - if (cached_has_bits & 0x00000001u) { - target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage( - 2, _Internal::selected_rows(this), target, stream); - } - - // optional .paddle.framework.proto.VarType.LoDTensorDesc lod_tensor = 3; - if (cached_has_bits & 0x00000002u) { - target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage( - 3, _Internal::lod_tensor(this), target, stream); - } - - // optional .paddle.framework.proto.VarType.LoDTensorArrayDesc tensor_array = 4; - if (cached_has_bits & 0x00000004u) { - target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage( - 4, _Internal::tensor_array(this), target, stream); - } - - // optional .paddle.framework.proto.VarType.ReaderDesc reader = 5; - if (cached_has_bits & 0x00000008u) { - target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage( - 5, _Internal::reader(this), target, stream); - } - - // optional .paddle.framework.proto.VarType.Tuple tuple = 7; - if (cached_has_bits & 0x00000010u) { - target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage( - 7, _Internal::tuple(this), target, stream); - } - - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); - } - // @@protoc_insertion_point(serialize_to_array_end:paddle.framework.proto.VarType) - return target; -} - -size_t VarType::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:paddle.framework.proto.VarType) - size_t total_size = 0; - - // required .paddle.framework.proto.VarType.Type type = 1; - if (_internal_has_type()) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::EnumSize(this->_internal_type()); - } - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - - cached_has_bits = _has_bits_[0]; - if (cached_has_bits & 0x0000001fu) { - // optional .paddle.framework.proto.VarType.TensorDesc selected_rows = 2; - if (cached_has_bits & 0x00000001u) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - *selected_rows_); - } - - // optional .paddle.framework.proto.VarType.LoDTensorDesc lod_tensor = 3; - if (cached_has_bits & 0x00000002u) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - *lod_tensor_); - } - - // optional .paddle.framework.proto.VarType.LoDTensorArrayDesc tensor_array = 4; - if (cached_has_bits & 0x00000004u) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - *tensor_array_); - } - - // optional .paddle.framework.proto.VarType.ReaderDesc reader = 5; - if (cached_has_bits & 0x00000008u) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - *reader_); - } - - // optional .paddle.framework.proto.VarType.Tuple tuple = 7; - if (cached_has_bits & 0x00000010u) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - *tuple_); - } - - } - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize( - _internal_metadata_, total_size, &_cached_size_); - } - int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size); - SetCachedSize(cached_size); - return total_size; -} - -void VarType::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { -// @@protoc_insertion_point(generalized_merge_from_start:paddle.framework.proto.VarType) - GOOGLE_DCHECK_NE(&from, this); - const VarType* source = - ::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated( - &from); - if (source == nullptr) { - // @@protoc_insertion_point(generalized_merge_from_cast_fail:paddle.framework.proto.VarType) - ::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this); - } else { - // @@protoc_insertion_point(generalized_merge_from_cast_success:paddle.framework.proto.VarType) - MergeFrom(*source); - } -} - -void VarType::MergeFrom(const VarType& from) { -// @@protoc_insertion_point(class_specific_merge_from_start:paddle.framework.proto.VarType) - GOOGLE_DCHECK_NE(&from, this); - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; - (void) cached_has_bits; - - cached_has_bits = from._has_bits_[0]; - if (cached_has_bits & 0x0000003fu) { - if (cached_has_bits & 0x00000001u) { - _internal_mutable_selected_rows()->::paddle::framework::proto::VarType_TensorDesc::MergeFrom(from._internal_selected_rows()); - } - if (cached_has_bits & 0x00000002u) { - _internal_mutable_lod_tensor()->::paddle::framework::proto::VarType_LoDTensorDesc::MergeFrom(from._internal_lod_tensor()); - } - if (cached_has_bits & 0x00000004u) { - _internal_mutable_tensor_array()->::paddle::framework::proto::VarType_LoDTensorArrayDesc::MergeFrom(from._internal_tensor_array()); - } - if (cached_has_bits & 0x00000008u) { - _internal_mutable_reader()->::paddle::framework::proto::VarType_ReaderDesc::MergeFrom(from._internal_reader()); - } - if (cached_has_bits & 0x00000010u) { - _internal_mutable_tuple()->::paddle::framework::proto::VarType_Tuple::MergeFrom(from._internal_tuple()); - } - if (cached_has_bits & 0x00000020u) { - type_ = from.type_; - } - _has_bits_[0] |= cached_has_bits; - } -} - -void VarType::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { -// @@protoc_insertion_point(generalized_copy_from_start:paddle.framework.proto.VarType) - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -void VarType::CopyFrom(const VarType& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:paddle.framework.proto.VarType) - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -bool VarType::IsInitialized() const { - if (_Internal::MissingRequiredFields(_has_bits_)) return false; - if (_internal_has_selected_rows()) { - if (!selected_rows_->IsInitialized()) return false; - } - if (_internal_has_lod_tensor()) { - if (!lod_tensor_->IsInitialized()) return false; - } - if (_internal_has_tensor_array()) { - if (!tensor_array_->IsInitialized()) return false; - } - if (_internal_has_reader()) { - if (!reader_->IsInitialized()) return false; - } - return true; -} - -void VarType::InternalSwap(VarType* other) { - using std::swap; - _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); - swap(_has_bits_[0], other->_has_bits_[0]); - ::PROTOBUF_NAMESPACE_ID::internal::memswap< - PROTOBUF_FIELD_OFFSET(VarType, type_) - + sizeof(VarType::type_) - - PROTOBUF_FIELD_OFFSET(VarType, selected_rows_)>( - reinterpret_cast(&selected_rows_), - reinterpret_cast(&other->selected_rows_)); -} - -::PROTOBUF_NAMESPACE_ID::Metadata VarType::GetMetadata() const { - return GetMetadataStatic(); -} - - -// =================================================================== - -class VarDesc::_Internal { - public: - using HasBits = decltype(std::declval()._has_bits_); - static void set_has_name(HasBits* has_bits) { - (*has_bits)[0] |= 1u; - } - static const ::paddle::framework::proto::VarType& type(const VarDesc* msg); - static void set_has_type(HasBits* has_bits) { - (*has_bits)[0] |= 2u; - } - static void set_has_persistable(HasBits* has_bits) { - (*has_bits)[0] |= 4u; - } - static void set_has_need_check_feed(HasBits* has_bits) { - (*has_bits)[0] |= 8u; - } - static bool MissingRequiredFields(const HasBits& has_bits) { - return ((has_bits[0] & 0x00000003) ^ 0x00000003) != 0; - } -}; - -const ::paddle::framework::proto::VarType& -VarDesc::_Internal::type(const VarDesc* msg) { - return *msg->type_; -} -VarDesc::VarDesc(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::Message(arena) { - SharedCtor(); - RegisterArenaDtor(arena); - // @@protoc_insertion_point(arena_constructor:paddle.framework.proto.VarDesc) -} -VarDesc::VarDesc(const VarDesc& from) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _has_bits_(from._has_bits_) { - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (from._internal_has_name()) { - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(), - GetArena()); - } - if (from._internal_has_type()) { - type_ = new ::paddle::framework::proto::VarType(*from.type_); - } else { - type_ = nullptr; - } - ::memcpy(&persistable_, &from.persistable_, - static_cast(reinterpret_cast(&need_check_feed_) - - reinterpret_cast(&persistable_)) + sizeof(need_check_feed_)); - // @@protoc_insertion_point(copy_constructor:paddle.framework.proto.VarDesc) -} - -void VarDesc::SharedCtor() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_VarDesc_framework_2eproto.base); - name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - ::memset(reinterpret_cast(this) + static_cast( - reinterpret_cast(&type_) - reinterpret_cast(this)), - 0, static_cast(reinterpret_cast(&need_check_feed_) - - reinterpret_cast(&type_)) + sizeof(need_check_feed_)); -} - -VarDesc::~VarDesc() { - // @@protoc_insertion_point(destructor:paddle.framework.proto.VarDesc) - SharedDtor(); - _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); -} - -void VarDesc::SharedDtor() { - GOOGLE_DCHECK(GetArena() == nullptr); - name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (this != internal_default_instance()) delete type_; -} - -void VarDesc::ArenaDtor(void* object) { - VarDesc* _this = reinterpret_cast< VarDesc* >(object); - (void)_this; -} -void VarDesc::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { -} -void VarDesc::SetCachedSize(int size) const { - _cached_size_.Set(size); -} -const VarDesc& VarDesc::default_instance() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_VarDesc_framework_2eproto.base); - return *internal_default_instance(); -} - - -void VarDesc::Clear() { -// @@protoc_insertion_point(message_clear_start:paddle.framework.proto.VarDesc) - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - - cached_has_bits = _has_bits_[0]; - if (cached_has_bits & 0x00000003u) { - if (cached_has_bits & 0x00000001u) { - name_.ClearNonDefaultToEmpty(); - } - if (cached_has_bits & 0x00000002u) { - GOOGLE_DCHECK(type_ != nullptr); - type_->Clear(); - } - } - ::memset(&persistable_, 0, static_cast( - reinterpret_cast(&need_check_feed_) - - reinterpret_cast(&persistable_)) + sizeof(need_check_feed_)); - _has_bits_.Clear(); - _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); -} - -const char* VarDesc::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { -#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - _Internal::HasBits has_bits{}; - while (!ctx->Done(&ptr)) { - ::PROTOBUF_NAMESPACE_ID::uint32 tag; - ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); - CHK_(ptr); - switch (tag >> 3) { - // required string name = 1; - case 1: - if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) { - auto str = _internal_mutable_name(); - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); - #ifndef NDEBUG - ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "paddle.framework.proto.VarDesc.name"); - #endif // !NDEBUG - CHK_(ptr); - } else goto handle_unusual; - continue; - // required .paddle.framework.proto.VarType type = 2; - case 2: - if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 18)) { - ptr = ctx->ParseMessage(_internal_mutable_type(), ptr); - CHK_(ptr); - } else goto handle_unusual; - continue; - // optional bool persistable = 3 [default = false]; - case 3: - if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 24)) { - _Internal::set_has_persistable(&has_bits); - persistable_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); - CHK_(ptr); - } else goto handle_unusual; - continue; - // optional bool need_check_feed = 4 [default = false]; - case 4: - if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 32)) { - _Internal::set_has_need_check_feed(&has_bits); - need_check_feed_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); - CHK_(ptr); - } else goto handle_unusual; - continue; - default: { - handle_unusual: - if ((tag & 7) == 4 || tag == 0) { - ctx->SetLastTag(tag); - goto success; - } - ptr = UnknownFieldParse(tag, - _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), - ptr, ctx); - CHK_(ptr != nullptr); - continue; - } - } // switch - } // while -success: - _has_bits_.Or(has_bits); - return ptr; -failure: - ptr = nullptr; - goto success; -#undef CHK_ -} - -::PROTOBUF_NAMESPACE_ID::uint8* VarDesc::_InternalSerialize( - ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { - // @@protoc_insertion_point(serialize_to_array_start:paddle.framework.proto.VarDesc) - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; - (void) cached_has_bits; - - cached_has_bits = _has_bits_[0]; - // required string name = 1; - if (cached_has_bits & 0x00000001u) { - ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->_internal_name().data(), static_cast(this->_internal_name().length()), - ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, - "paddle.framework.proto.VarDesc.name"); - target = stream->WriteStringMaybeAliased( - 1, this->_internal_name(), target); - } - - // required .paddle.framework.proto.VarType type = 2; - if (cached_has_bits & 0x00000002u) { - target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage( - 2, _Internal::type(this), target, stream); - } - - // optional bool persistable = 3 [default = false]; - if (cached_has_bits & 0x00000004u) { - target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(3, this->_internal_persistable(), target); - } - - // optional bool need_check_feed = 4 [default = false]; - if (cached_has_bits & 0x00000008u) { - target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(4, this->_internal_need_check_feed(), target); - } - - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); - } - // @@protoc_insertion_point(serialize_to_array_end:paddle.framework.proto.VarDesc) - return target; -} - -size_t VarDesc::RequiredFieldsByteSizeFallback() const { -// @@protoc_insertion_point(required_fields_byte_size_fallback_start:paddle.framework.proto.VarDesc) - size_t total_size = 0; - - if (_internal_has_name()) { - // required string name = 1; - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_name()); - } - - if (_internal_has_type()) { - // required .paddle.framework.proto.VarType type = 2; - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - *type_); - } - - return total_size; -} -size_t VarDesc::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:paddle.framework.proto.VarDesc) - size_t total_size = 0; - - if (((_has_bits_[0] & 0x00000003) ^ 0x00000003) == 0) { // All required fields are present. - // required string name = 1; - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_name()); - - // required .paddle.framework.proto.VarType type = 2; - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - *type_); - - } else { - total_size += RequiredFieldsByteSizeFallback(); - } - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - - cached_has_bits = _has_bits_[0]; - if (cached_has_bits & 0x0000000cu) { - // optional bool persistable = 3 [default = false]; - if (cached_has_bits & 0x00000004u) { - total_size += 1 + 1; - } - - // optional bool need_check_feed = 4 [default = false]; - if (cached_has_bits & 0x00000008u) { - total_size += 1 + 1; - } - - } - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize( - _internal_metadata_, total_size, &_cached_size_); - } - int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size); - SetCachedSize(cached_size); - return total_size; -} - -void VarDesc::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { -// @@protoc_insertion_point(generalized_merge_from_start:paddle.framework.proto.VarDesc) - GOOGLE_DCHECK_NE(&from, this); - const VarDesc* source = - ::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated( - &from); - if (source == nullptr) { - // @@protoc_insertion_point(generalized_merge_from_cast_fail:paddle.framework.proto.VarDesc) - ::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this); - } else { - // @@protoc_insertion_point(generalized_merge_from_cast_success:paddle.framework.proto.VarDesc) - MergeFrom(*source); - } -} - -void VarDesc::MergeFrom(const VarDesc& from) { -// @@protoc_insertion_point(class_specific_merge_from_start:paddle.framework.proto.VarDesc) - GOOGLE_DCHECK_NE(&from, this); - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; - (void) cached_has_bits; - - cached_has_bits = from._has_bits_[0]; - if (cached_has_bits & 0x0000000fu) { - if (cached_has_bits & 0x00000001u) { - _internal_set_name(from._internal_name()); - } - if (cached_has_bits & 0x00000002u) { - _internal_mutable_type()->::paddle::framework::proto::VarType::MergeFrom(from._internal_type()); - } - if (cached_has_bits & 0x00000004u) { - persistable_ = from.persistable_; - } - if (cached_has_bits & 0x00000008u) { - need_check_feed_ = from.need_check_feed_; - } - _has_bits_[0] |= cached_has_bits; - } -} - -void VarDesc::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { -// @@protoc_insertion_point(generalized_copy_from_start:paddle.framework.proto.VarDesc) - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -void VarDesc::CopyFrom(const VarDesc& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:paddle.framework.proto.VarDesc) - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -bool VarDesc::IsInitialized() const { - if (_Internal::MissingRequiredFields(_has_bits_)) return false; - if (_internal_has_type()) { - if (!type_->IsInitialized()) return false; - } - return true; -} - -void VarDesc::InternalSwap(VarDesc* other) { - using std::swap; - _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); - swap(_has_bits_[0], other->_has_bits_[0]); - name_.Swap(&other->name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); - ::PROTOBUF_NAMESPACE_ID::internal::memswap< - PROTOBUF_FIELD_OFFSET(VarDesc, need_check_feed_) - + sizeof(VarDesc::need_check_feed_) - - PROTOBUF_FIELD_OFFSET(VarDesc, type_)>( - reinterpret_cast(&type_), - reinterpret_cast(&other->type_)); -} - -::PROTOBUF_NAMESPACE_ID::Metadata VarDesc::GetMetadata() const { - return GetMetadataStatic(); -} - - -// =================================================================== - -class BlockDesc::_Internal { - public: - using HasBits = decltype(std::declval()._has_bits_); - static void set_has_idx(HasBits* has_bits) { - (*has_bits)[0] |= 1u; - } - static void set_has_parent_idx(HasBits* has_bits) { - (*has_bits)[0] |= 2u; - } - static void set_has_forward_block_idx(HasBits* has_bits) { - (*has_bits)[0] |= 4u; - } - static bool MissingRequiredFields(const HasBits& has_bits) { - return ((has_bits[0] & 0x00000003) ^ 0x00000003) != 0; - } -}; - -BlockDesc::BlockDesc(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::Message(arena), - vars_(arena), - ops_(arena) { - SharedCtor(); - RegisterArenaDtor(arena); - // @@protoc_insertion_point(arena_constructor:paddle.framework.proto.BlockDesc) -} -BlockDesc::BlockDesc(const BlockDesc& from) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _has_bits_(from._has_bits_), - vars_(from.vars_), - ops_(from.ops_) { - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - ::memcpy(&idx_, &from.idx_, - static_cast(reinterpret_cast(&forward_block_idx_) - - reinterpret_cast(&idx_)) + sizeof(forward_block_idx_)); - // @@protoc_insertion_point(copy_constructor:paddle.framework.proto.BlockDesc) -} - -void BlockDesc::SharedCtor() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_BlockDesc_framework_2eproto.base); - ::memset(reinterpret_cast(this) + static_cast( - reinterpret_cast(&idx_) - reinterpret_cast(this)), - 0, static_cast(reinterpret_cast(&parent_idx_) - - reinterpret_cast(&idx_)) + sizeof(parent_idx_)); - forward_block_idx_ = -1; -} - -BlockDesc::~BlockDesc() { - // @@protoc_insertion_point(destructor:paddle.framework.proto.BlockDesc) - SharedDtor(); - _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); -} - -void BlockDesc::SharedDtor() { - GOOGLE_DCHECK(GetArena() == nullptr); -} - -void BlockDesc::ArenaDtor(void* object) { - BlockDesc* _this = reinterpret_cast< BlockDesc* >(object); - (void)_this; -} -void BlockDesc::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { -} -void BlockDesc::SetCachedSize(int size) const { - _cached_size_.Set(size); -} -const BlockDesc& BlockDesc::default_instance() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_BlockDesc_framework_2eproto.base); - return *internal_default_instance(); -} - - -void BlockDesc::Clear() { -// @@protoc_insertion_point(message_clear_start:paddle.framework.proto.BlockDesc) - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - - vars_.Clear(); - ops_.Clear(); - cached_has_bits = _has_bits_[0]; - if (cached_has_bits & 0x00000007u) { - ::memset(&idx_, 0, static_cast( - reinterpret_cast(&parent_idx_) - - reinterpret_cast(&idx_)) + sizeof(parent_idx_)); - forward_block_idx_ = -1; - } - _has_bits_.Clear(); - _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); -} - -const char* BlockDesc::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { -#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - _Internal::HasBits has_bits{}; - while (!ctx->Done(&ptr)) { - ::PROTOBUF_NAMESPACE_ID::uint32 tag; - ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); - CHK_(ptr); - switch (tag >> 3) { - // required int32 idx = 1; - case 1: - if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 8)) { - _Internal::set_has_idx(&has_bits); - idx_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); - CHK_(ptr); - } else goto handle_unusual; - continue; - // required int32 parent_idx = 2; - case 2: - if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 16)) { - _Internal::set_has_parent_idx(&has_bits); - parent_idx_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); - CHK_(ptr); - } else goto handle_unusual; - continue; - // repeated .paddle.framework.proto.VarDesc vars = 3; - case 3: - if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 26)) { - ptr -= 1; - do { - ptr += 1; - ptr = ctx->ParseMessage(_internal_add_vars(), ptr); - CHK_(ptr); - if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<26>(ptr)); - } else goto handle_unusual; - continue; - // repeated .paddle.framework.proto.OpDesc ops = 4; - case 4: - if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 34)) { - ptr -= 1; - do { - ptr += 1; - ptr = ctx->ParseMessage(_internal_add_ops(), ptr); - CHK_(ptr); - if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<34>(ptr)); - } else goto handle_unusual; - continue; - // optional int32 forward_block_idx = 5 [default = -1]; - case 5: - if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 40)) { - _Internal::set_has_forward_block_idx(&has_bits); - forward_block_idx_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); - CHK_(ptr); - } else goto handle_unusual; - continue; - default: { - handle_unusual: - if ((tag & 7) == 4 || tag == 0) { - ctx->SetLastTag(tag); - goto success; - } - ptr = UnknownFieldParse(tag, - _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), - ptr, ctx); - CHK_(ptr != nullptr); - continue; - } - } // switch - } // while -success: - _has_bits_.Or(has_bits); - return ptr; -failure: - ptr = nullptr; - goto success; -#undef CHK_ -} - -::PROTOBUF_NAMESPACE_ID::uint8* BlockDesc::_InternalSerialize( - ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { - // @@protoc_insertion_point(serialize_to_array_start:paddle.framework.proto.BlockDesc) - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; - (void) cached_has_bits; - - cached_has_bits = _has_bits_[0]; - // required int32 idx = 1; - if (cached_has_bits & 0x00000001u) { - target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(1, this->_internal_idx(), target); - } - - // required int32 parent_idx = 2; - if (cached_has_bits & 0x00000002u) { - target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(2, this->_internal_parent_idx(), target); - } - - // repeated .paddle.framework.proto.VarDesc vars = 3; - for (unsigned int i = 0, - n = static_cast(this->_internal_vars_size()); i < n; i++) { - target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(3, this->_internal_vars(i), target, stream); - } - - // repeated .paddle.framework.proto.OpDesc ops = 4; - for (unsigned int i = 0, - n = static_cast(this->_internal_ops_size()); i < n; i++) { - target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(4, this->_internal_ops(i), target, stream); - } - - // optional int32 forward_block_idx = 5 [default = -1]; - if (cached_has_bits & 0x00000004u) { - target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(5, this->_internal_forward_block_idx(), target); - } - - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); - } - // @@protoc_insertion_point(serialize_to_array_end:paddle.framework.proto.BlockDesc) - return target; -} - -size_t BlockDesc::RequiredFieldsByteSizeFallback() const { -// @@protoc_insertion_point(required_fields_byte_size_fallback_start:paddle.framework.proto.BlockDesc) - size_t total_size = 0; - - if (_internal_has_idx()) { - // required int32 idx = 1; - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size( - this->_internal_idx()); - } - - if (_internal_has_parent_idx()) { - // required int32 parent_idx = 2; - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size( - this->_internal_parent_idx()); - } - - return total_size; -} -size_t BlockDesc::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:paddle.framework.proto.BlockDesc) - size_t total_size = 0; - - if (((_has_bits_[0] & 0x00000003) ^ 0x00000003) == 0) { // All required fields are present. - // required int32 idx = 1; - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size( - this->_internal_idx()); - - // required int32 parent_idx = 2; - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size( - this->_internal_parent_idx()); - - } else { - total_size += RequiredFieldsByteSizeFallback(); - } - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - - // repeated .paddle.framework.proto.VarDesc vars = 3; - total_size += 1UL * this->_internal_vars_size(); - for (const auto& msg : this->vars_) { - total_size += - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); - } - - // repeated .paddle.framework.proto.OpDesc ops = 4; - total_size += 1UL * this->_internal_ops_size(); - for (const auto& msg : this->ops_) { - total_size += - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); - } - - // optional int32 forward_block_idx = 5 [default = -1]; - cached_has_bits = _has_bits_[0]; - if (cached_has_bits & 0x00000004u) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size( - this->_internal_forward_block_idx()); - } - - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize( - _internal_metadata_, total_size, &_cached_size_); - } - int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size); - SetCachedSize(cached_size); - return total_size; -} - -void BlockDesc::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { -// @@protoc_insertion_point(generalized_merge_from_start:paddle.framework.proto.BlockDesc) - GOOGLE_DCHECK_NE(&from, this); - const BlockDesc* source = - ::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated( - &from); - if (source == nullptr) { - // @@protoc_insertion_point(generalized_merge_from_cast_fail:paddle.framework.proto.BlockDesc) - ::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this); - } else { - // @@protoc_insertion_point(generalized_merge_from_cast_success:paddle.framework.proto.BlockDesc) - MergeFrom(*source); - } -} - -void BlockDesc::MergeFrom(const BlockDesc& from) { -// @@protoc_insertion_point(class_specific_merge_from_start:paddle.framework.proto.BlockDesc) - GOOGLE_DCHECK_NE(&from, this); - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; - (void) cached_has_bits; - - vars_.MergeFrom(from.vars_); - ops_.MergeFrom(from.ops_); - cached_has_bits = from._has_bits_[0]; - if (cached_has_bits & 0x00000007u) { - if (cached_has_bits & 0x00000001u) { - idx_ = from.idx_; - } - if (cached_has_bits & 0x00000002u) { - parent_idx_ = from.parent_idx_; - } - if (cached_has_bits & 0x00000004u) { - forward_block_idx_ = from.forward_block_idx_; - } - _has_bits_[0] |= cached_has_bits; - } -} - -void BlockDesc::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { -// @@protoc_insertion_point(generalized_copy_from_start:paddle.framework.proto.BlockDesc) - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -void BlockDesc::CopyFrom(const BlockDesc& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:paddle.framework.proto.BlockDesc) - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -bool BlockDesc::IsInitialized() const { - if (_Internal::MissingRequiredFields(_has_bits_)) return false; - if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(vars_)) return false; - if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(ops_)) return false; - return true; -} - -void BlockDesc::InternalSwap(BlockDesc* other) { - using std::swap; - _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); - swap(_has_bits_[0], other->_has_bits_[0]); - vars_.InternalSwap(&other->vars_); - ops_.InternalSwap(&other->ops_); - ::PROTOBUF_NAMESPACE_ID::internal::memswap< - PROTOBUF_FIELD_OFFSET(BlockDesc, parent_idx_) - + sizeof(BlockDesc::parent_idx_) - - PROTOBUF_FIELD_OFFSET(BlockDesc, idx_)>( - reinterpret_cast(&idx_), - reinterpret_cast(&other->idx_)); - swap(forward_block_idx_, other->forward_block_idx_); -} - -::PROTOBUF_NAMESPACE_ID::Metadata BlockDesc::GetMetadata() const { - return GetMetadataStatic(); -} - - -// =================================================================== - -class OpVersion::_Internal { - public: - using HasBits = decltype(std::declval()._has_bits_); - static void set_has_version(HasBits* has_bits) { - (*has_bits)[0] |= 1u; - } - static bool MissingRequiredFields(const HasBits& has_bits) { - return ((has_bits[0] & 0x00000001) ^ 0x00000001) != 0; - } -}; - -OpVersion::OpVersion(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::Message(arena) { - SharedCtor(); - RegisterArenaDtor(arena); - // @@protoc_insertion_point(arena_constructor:paddle.framework.proto.OpVersion) -} -OpVersion::OpVersion(const OpVersion& from) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _has_bits_(from._has_bits_) { - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - version_ = from.version_; - // @@protoc_insertion_point(copy_constructor:paddle.framework.proto.OpVersion) -} - -void OpVersion::SharedCtor() { - version_ = 0; -} - -OpVersion::~OpVersion() { - // @@protoc_insertion_point(destructor:paddle.framework.proto.OpVersion) - SharedDtor(); - _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); -} - -void OpVersion::SharedDtor() { - GOOGLE_DCHECK(GetArena() == nullptr); -} - -void OpVersion::ArenaDtor(void* object) { - OpVersion* _this = reinterpret_cast< OpVersion* >(object); - (void)_this; -} -void OpVersion::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { -} -void OpVersion::SetCachedSize(int size) const { - _cached_size_.Set(size); -} -const OpVersion& OpVersion::default_instance() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_OpVersion_framework_2eproto.base); - return *internal_default_instance(); -} - - -void OpVersion::Clear() { -// @@protoc_insertion_point(message_clear_start:paddle.framework.proto.OpVersion) - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - - version_ = 0; - _has_bits_.Clear(); - _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); -} - -const char* OpVersion::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { -#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - _Internal::HasBits has_bits{}; - while (!ctx->Done(&ptr)) { - ::PROTOBUF_NAMESPACE_ID::uint32 tag; - ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); - CHK_(ptr); - switch (tag >> 3) { - // required int32 version = 1; - case 1: - if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 8)) { - _Internal::set_has_version(&has_bits); - version_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); - CHK_(ptr); - } else goto handle_unusual; - continue; - default: { - handle_unusual: - if ((tag & 7) == 4 || tag == 0) { - ctx->SetLastTag(tag); - goto success; - } - ptr = UnknownFieldParse(tag, - _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), - ptr, ctx); - CHK_(ptr != nullptr); - continue; - } - } // switch - } // while -success: - _has_bits_.Or(has_bits); - return ptr; -failure: - ptr = nullptr; - goto success; -#undef CHK_ -} - -::PROTOBUF_NAMESPACE_ID::uint8* OpVersion::_InternalSerialize( - ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { - // @@protoc_insertion_point(serialize_to_array_start:paddle.framework.proto.OpVersion) - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; - (void) cached_has_bits; - - cached_has_bits = _has_bits_[0]; - // required int32 version = 1; - if (cached_has_bits & 0x00000001u) { - target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(1, this->_internal_version(), target); - } - - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); - } - // @@protoc_insertion_point(serialize_to_array_end:paddle.framework.proto.OpVersion) - return target; -} - -size_t OpVersion::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:paddle.framework.proto.OpVersion) - size_t total_size = 0; - - // required int32 version = 1; - if (_internal_has_version()) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size( - this->_internal_version()); - } - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize( - _internal_metadata_, total_size, &_cached_size_); - } - int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size); - SetCachedSize(cached_size); - return total_size; -} - -void OpVersion::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { -// @@protoc_insertion_point(generalized_merge_from_start:paddle.framework.proto.OpVersion) - GOOGLE_DCHECK_NE(&from, this); - const OpVersion* source = - ::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated( - &from); - if (source == nullptr) { - // @@protoc_insertion_point(generalized_merge_from_cast_fail:paddle.framework.proto.OpVersion) - ::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this); - } else { - // @@protoc_insertion_point(generalized_merge_from_cast_success:paddle.framework.proto.OpVersion) - MergeFrom(*source); - } -} - -void OpVersion::MergeFrom(const OpVersion& from) { -// @@protoc_insertion_point(class_specific_merge_from_start:paddle.framework.proto.OpVersion) - GOOGLE_DCHECK_NE(&from, this); - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; - (void) cached_has_bits; - - if (from._internal_has_version()) { - _internal_set_version(from._internal_version()); - } -} - -void OpVersion::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { -// @@protoc_insertion_point(generalized_copy_from_start:paddle.framework.proto.OpVersion) - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -void OpVersion::CopyFrom(const OpVersion& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:paddle.framework.proto.OpVersion) - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -bool OpVersion::IsInitialized() const { - if (_Internal::MissingRequiredFields(_has_bits_)) return false; - return true; -} - -void OpVersion::InternalSwap(OpVersion* other) { - using std::swap; - _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); - swap(_has_bits_[0], other->_has_bits_[0]); - swap(version_, other->version_); -} - -::PROTOBUF_NAMESPACE_ID::Metadata OpVersion::GetMetadata() const { - return GetMetadataStatic(); -} - - -// =================================================================== - -class OpVersionMap_OpVersionPair::_Internal { - public: - using HasBits = decltype(std::declval()._has_bits_); - static void set_has_op_name(HasBits* has_bits) { - (*has_bits)[0] |= 1u; - } - static const ::paddle::framework::proto::OpVersion& op_version(const OpVersionMap_OpVersionPair* msg); - static void set_has_op_version(HasBits* has_bits) { - (*has_bits)[0] |= 2u; - } - static bool MissingRequiredFields(const HasBits& has_bits) { - return ((has_bits[0] & 0x00000003) ^ 0x00000003) != 0; - } -}; - -const ::paddle::framework::proto::OpVersion& -OpVersionMap_OpVersionPair::_Internal::op_version(const OpVersionMap_OpVersionPair* msg) { - return *msg->op_version_; -} -OpVersionMap_OpVersionPair::OpVersionMap_OpVersionPair(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::Message(arena) { - SharedCtor(); - RegisterArenaDtor(arena); - // @@protoc_insertion_point(arena_constructor:paddle.framework.proto.OpVersionMap.OpVersionPair) -} -OpVersionMap_OpVersionPair::OpVersionMap_OpVersionPair(const OpVersionMap_OpVersionPair& from) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _has_bits_(from._has_bits_) { - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - op_name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (from._internal_has_op_name()) { - op_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_op_name(), - GetArena()); - } - if (from._internal_has_op_version()) { - op_version_ = new ::paddle::framework::proto::OpVersion(*from.op_version_); - } else { - op_version_ = nullptr; - } - // @@protoc_insertion_point(copy_constructor:paddle.framework.proto.OpVersionMap.OpVersionPair) -} - -void OpVersionMap_OpVersionPair::SharedCtor() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_OpVersionMap_OpVersionPair_framework_2eproto.base); - op_name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - op_version_ = nullptr; -} - -OpVersionMap_OpVersionPair::~OpVersionMap_OpVersionPair() { - // @@protoc_insertion_point(destructor:paddle.framework.proto.OpVersionMap.OpVersionPair) - SharedDtor(); - _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); -} - -void OpVersionMap_OpVersionPair::SharedDtor() { - GOOGLE_DCHECK(GetArena() == nullptr); - op_name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (this != internal_default_instance()) delete op_version_; -} - -void OpVersionMap_OpVersionPair::ArenaDtor(void* object) { - OpVersionMap_OpVersionPair* _this = reinterpret_cast< OpVersionMap_OpVersionPair* >(object); - (void)_this; -} -void OpVersionMap_OpVersionPair::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { -} -void OpVersionMap_OpVersionPair::SetCachedSize(int size) const { - _cached_size_.Set(size); -} -const OpVersionMap_OpVersionPair& OpVersionMap_OpVersionPair::default_instance() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_OpVersionMap_OpVersionPair_framework_2eproto.base); - return *internal_default_instance(); -} - - -void OpVersionMap_OpVersionPair::Clear() { -// @@protoc_insertion_point(message_clear_start:paddle.framework.proto.OpVersionMap.OpVersionPair) - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - - cached_has_bits = _has_bits_[0]; - if (cached_has_bits & 0x00000003u) { - if (cached_has_bits & 0x00000001u) { - op_name_.ClearNonDefaultToEmpty(); - } - if (cached_has_bits & 0x00000002u) { - GOOGLE_DCHECK(op_version_ != nullptr); - op_version_->Clear(); - } - } - _has_bits_.Clear(); - _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); -} - -const char* OpVersionMap_OpVersionPair::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { -#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - _Internal::HasBits has_bits{}; - while (!ctx->Done(&ptr)) { - ::PROTOBUF_NAMESPACE_ID::uint32 tag; - ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); - CHK_(ptr); - switch (tag >> 3) { - // required string op_name = 1; - case 1: - if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) { - auto str = _internal_mutable_op_name(); - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); - #ifndef NDEBUG - ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "paddle.framework.proto.OpVersionMap.OpVersionPair.op_name"); - #endif // !NDEBUG - CHK_(ptr); - } else goto handle_unusual; - continue; - // required .paddle.framework.proto.OpVersion op_version = 2; - case 2: - if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 18)) { - ptr = ctx->ParseMessage(_internal_mutable_op_version(), ptr); - CHK_(ptr); - } else goto handle_unusual; - continue; - default: { - handle_unusual: - if ((tag & 7) == 4 || tag == 0) { - ctx->SetLastTag(tag); - goto success; - } - ptr = UnknownFieldParse(tag, - _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), - ptr, ctx); - CHK_(ptr != nullptr); - continue; - } - } // switch - } // while -success: - _has_bits_.Or(has_bits); - return ptr; -failure: - ptr = nullptr; - goto success; -#undef CHK_ -} - -::PROTOBUF_NAMESPACE_ID::uint8* OpVersionMap_OpVersionPair::_InternalSerialize( - ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { - // @@protoc_insertion_point(serialize_to_array_start:paddle.framework.proto.OpVersionMap.OpVersionPair) - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; - (void) cached_has_bits; - - cached_has_bits = _has_bits_[0]; - // required string op_name = 1; - if (cached_has_bits & 0x00000001u) { - ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->_internal_op_name().data(), static_cast(this->_internal_op_name().length()), - ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, - "paddle.framework.proto.OpVersionMap.OpVersionPair.op_name"); - target = stream->WriteStringMaybeAliased( - 1, this->_internal_op_name(), target); - } - - // required .paddle.framework.proto.OpVersion op_version = 2; - if (cached_has_bits & 0x00000002u) { - target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage( - 2, _Internal::op_version(this), target, stream); - } - - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); - } - // @@protoc_insertion_point(serialize_to_array_end:paddle.framework.proto.OpVersionMap.OpVersionPair) - return target; -} - -size_t OpVersionMap_OpVersionPair::RequiredFieldsByteSizeFallback() const { -// @@protoc_insertion_point(required_fields_byte_size_fallback_start:paddle.framework.proto.OpVersionMap.OpVersionPair) - size_t total_size = 0; - - if (_internal_has_op_name()) { - // required string op_name = 1; - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_op_name()); - } - - if (_internal_has_op_version()) { - // required .paddle.framework.proto.OpVersion op_version = 2; - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - *op_version_); - } - - return total_size; -} -size_t OpVersionMap_OpVersionPair::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:paddle.framework.proto.OpVersionMap.OpVersionPair) - size_t total_size = 0; - - if (((_has_bits_[0] & 0x00000003) ^ 0x00000003) == 0) { // All required fields are present. - // required string op_name = 1; - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_op_name()); - - // required .paddle.framework.proto.OpVersion op_version = 2; - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - *op_version_); - - } else { - total_size += RequiredFieldsByteSizeFallback(); - } - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize( - _internal_metadata_, total_size, &_cached_size_); - } - int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size); - SetCachedSize(cached_size); - return total_size; -} - -void OpVersionMap_OpVersionPair::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { -// @@protoc_insertion_point(generalized_merge_from_start:paddle.framework.proto.OpVersionMap.OpVersionPair) - GOOGLE_DCHECK_NE(&from, this); - const OpVersionMap_OpVersionPair* source = - ::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated( - &from); - if (source == nullptr) { - // @@protoc_insertion_point(generalized_merge_from_cast_fail:paddle.framework.proto.OpVersionMap.OpVersionPair) - ::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this); - } else { - // @@protoc_insertion_point(generalized_merge_from_cast_success:paddle.framework.proto.OpVersionMap.OpVersionPair) - MergeFrom(*source); - } -} - -void OpVersionMap_OpVersionPair::MergeFrom(const OpVersionMap_OpVersionPair& from) { -// @@protoc_insertion_point(class_specific_merge_from_start:paddle.framework.proto.OpVersionMap.OpVersionPair) - GOOGLE_DCHECK_NE(&from, this); - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; - (void) cached_has_bits; - - cached_has_bits = from._has_bits_[0]; - if (cached_has_bits & 0x00000003u) { - if (cached_has_bits & 0x00000001u) { - _internal_set_op_name(from._internal_op_name()); - } - if (cached_has_bits & 0x00000002u) { - _internal_mutable_op_version()->::paddle::framework::proto::OpVersion::MergeFrom(from._internal_op_version()); - } - } -} - -void OpVersionMap_OpVersionPair::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { -// @@protoc_insertion_point(generalized_copy_from_start:paddle.framework.proto.OpVersionMap.OpVersionPair) - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -void OpVersionMap_OpVersionPair::CopyFrom(const OpVersionMap_OpVersionPair& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:paddle.framework.proto.OpVersionMap.OpVersionPair) - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -bool OpVersionMap_OpVersionPair::IsInitialized() const { - if (_Internal::MissingRequiredFields(_has_bits_)) return false; - if (_internal_has_op_version()) { - if (!op_version_->IsInitialized()) return false; - } - return true; -} - -void OpVersionMap_OpVersionPair::InternalSwap(OpVersionMap_OpVersionPair* other) { - using std::swap; - _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); - swap(_has_bits_[0], other->_has_bits_[0]); - op_name_.Swap(&other->op_name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); - swap(op_version_, other->op_version_); -} - -::PROTOBUF_NAMESPACE_ID::Metadata OpVersionMap_OpVersionPair::GetMetadata() const { - return GetMetadataStatic(); -} - - -// =================================================================== - -class OpVersionMap::_Internal { - public: -}; - -OpVersionMap::OpVersionMap(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::Message(arena), - pair_(arena) { - SharedCtor(); - RegisterArenaDtor(arena); - // @@protoc_insertion_point(arena_constructor:paddle.framework.proto.OpVersionMap) -} -OpVersionMap::OpVersionMap(const OpVersionMap& from) - : ::PROTOBUF_NAMESPACE_ID::Message(), - pair_(from.pair_) { - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - // @@protoc_insertion_point(copy_constructor:paddle.framework.proto.OpVersionMap) -} - -void OpVersionMap::SharedCtor() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_OpVersionMap_framework_2eproto.base); -} - -OpVersionMap::~OpVersionMap() { - // @@protoc_insertion_point(destructor:paddle.framework.proto.OpVersionMap) - SharedDtor(); - _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); -} - -void OpVersionMap::SharedDtor() { - GOOGLE_DCHECK(GetArena() == nullptr); -} - -void OpVersionMap::ArenaDtor(void* object) { - OpVersionMap* _this = reinterpret_cast< OpVersionMap* >(object); - (void)_this; -} -void OpVersionMap::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { -} -void OpVersionMap::SetCachedSize(int size) const { - _cached_size_.Set(size); -} -const OpVersionMap& OpVersionMap::default_instance() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_OpVersionMap_framework_2eproto.base); - return *internal_default_instance(); -} - - -void OpVersionMap::Clear() { -// @@protoc_insertion_point(message_clear_start:paddle.framework.proto.OpVersionMap) - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - - pair_.Clear(); - _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); -} - -const char* OpVersionMap::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { -#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - while (!ctx->Done(&ptr)) { - ::PROTOBUF_NAMESPACE_ID::uint32 tag; - ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); - CHK_(ptr); - switch (tag >> 3) { - // repeated .paddle.framework.proto.OpVersionMap.OpVersionPair pair = 1; - case 1: - if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) { - ptr -= 1; - do { - ptr += 1; - ptr = ctx->ParseMessage(_internal_add_pair(), ptr); - CHK_(ptr); - if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<10>(ptr)); - } else goto handle_unusual; - continue; - default: { - handle_unusual: - if ((tag & 7) == 4 || tag == 0) { - ctx->SetLastTag(tag); - goto success; - } - ptr = UnknownFieldParse(tag, - _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), - ptr, ctx); - CHK_(ptr != nullptr); - continue; - } - } // switch - } // while -success: - return ptr; -failure: - ptr = nullptr; - goto success; -#undef CHK_ -} - -::PROTOBUF_NAMESPACE_ID::uint8* OpVersionMap::_InternalSerialize( - ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { - // @@protoc_insertion_point(serialize_to_array_start:paddle.framework.proto.OpVersionMap) - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; - (void) cached_has_bits; - - // repeated .paddle.framework.proto.OpVersionMap.OpVersionPair pair = 1; - for (unsigned int i = 0, - n = static_cast(this->_internal_pair_size()); i < n; i++) { - target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(1, this->_internal_pair(i), target, stream); - } - - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); - } - // @@protoc_insertion_point(serialize_to_array_end:paddle.framework.proto.OpVersionMap) - return target; -} - -size_t OpVersionMap::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:paddle.framework.proto.OpVersionMap) - size_t total_size = 0; - - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - - // repeated .paddle.framework.proto.OpVersionMap.OpVersionPair pair = 1; - total_size += 1UL * this->_internal_pair_size(); - for (const auto& msg : this->pair_) { - total_size += - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); - } - - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize( - _internal_metadata_, total_size, &_cached_size_); - } - int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size); - SetCachedSize(cached_size); - return total_size; -} - -void OpVersionMap::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { -// @@protoc_insertion_point(generalized_merge_from_start:paddle.framework.proto.OpVersionMap) - GOOGLE_DCHECK_NE(&from, this); - const OpVersionMap* source = - ::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated( - &from); - if (source == nullptr) { - // @@protoc_insertion_point(generalized_merge_from_cast_fail:paddle.framework.proto.OpVersionMap) - ::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this); - } else { - // @@protoc_insertion_point(generalized_merge_from_cast_success:paddle.framework.proto.OpVersionMap) - MergeFrom(*source); - } -} - -void OpVersionMap::MergeFrom(const OpVersionMap& from) { -// @@protoc_insertion_point(class_specific_merge_from_start:paddle.framework.proto.OpVersionMap) - GOOGLE_DCHECK_NE(&from, this); - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; - (void) cached_has_bits; - - pair_.MergeFrom(from.pair_); -} - -void OpVersionMap::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { -// @@protoc_insertion_point(generalized_copy_from_start:paddle.framework.proto.OpVersionMap) - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -void OpVersionMap::CopyFrom(const OpVersionMap& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:paddle.framework.proto.OpVersionMap) - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -bool OpVersionMap::IsInitialized() const { - if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(pair_)) return false; - return true; -} - -void OpVersionMap::InternalSwap(OpVersionMap* other) { - using std::swap; - _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); - pair_.InternalSwap(&other->pair_); -} - -::PROTOBUF_NAMESPACE_ID::Metadata OpVersionMap::GetMetadata() const { - return GetMetadataStatic(); -} - - -// =================================================================== - -class ProgramDesc::_Internal { - public: - using HasBits = decltype(std::declval()._has_bits_); - static const ::paddle::framework::proto::Version& version(const ProgramDesc* msg); - static void set_has_version(HasBits* has_bits) { - (*has_bits)[0] |= 1u; - } - static const ::paddle::framework::proto::OpVersionMap& op_version_map(const ProgramDesc* msg); - static void set_has_op_version_map(HasBits* has_bits) { - (*has_bits)[0] |= 2u; - } -}; - -const ::paddle::framework::proto::Version& -ProgramDesc::_Internal::version(const ProgramDesc* msg) { - return *msg->version_; -} -const ::paddle::framework::proto::OpVersionMap& -ProgramDesc::_Internal::op_version_map(const ProgramDesc* msg) { - return *msg->op_version_map_; -} -ProgramDesc::ProgramDesc(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::Message(arena), - blocks_(arena) { - SharedCtor(); - RegisterArenaDtor(arena); - // @@protoc_insertion_point(arena_constructor:paddle.framework.proto.ProgramDesc) -} -ProgramDesc::ProgramDesc(const ProgramDesc& from) - : ::PROTOBUF_NAMESPACE_ID::Message(), - _has_bits_(from._has_bits_), - blocks_(from.blocks_) { - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - if (from._internal_has_version()) { - version_ = new ::paddle::framework::proto::Version(*from.version_); - } else { - version_ = nullptr; - } - if (from._internal_has_op_version_map()) { - op_version_map_ = new ::paddle::framework::proto::OpVersionMap(*from.op_version_map_); - } else { - op_version_map_ = nullptr; - } - // @@protoc_insertion_point(copy_constructor:paddle.framework.proto.ProgramDesc) -} - -void ProgramDesc::SharedCtor() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_ProgramDesc_framework_2eproto.base); - ::memset(reinterpret_cast(this) + static_cast( - reinterpret_cast(&version_) - reinterpret_cast(this)), - 0, static_cast(reinterpret_cast(&op_version_map_) - - reinterpret_cast(&version_)) + sizeof(op_version_map_)); -} - -ProgramDesc::~ProgramDesc() { - // @@protoc_insertion_point(destructor:paddle.framework.proto.ProgramDesc) - SharedDtor(); - _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); -} - -void ProgramDesc::SharedDtor() { - GOOGLE_DCHECK(GetArena() == nullptr); - if (this != internal_default_instance()) delete version_; - if (this != internal_default_instance()) delete op_version_map_; -} - -void ProgramDesc::ArenaDtor(void* object) { - ProgramDesc* _this = reinterpret_cast< ProgramDesc* >(object); - (void)_this; -} -void ProgramDesc::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { -} -void ProgramDesc::SetCachedSize(int size) const { - _cached_size_.Set(size); -} -const ProgramDesc& ProgramDesc::default_instance() { - ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_ProgramDesc_framework_2eproto.base); - return *internal_default_instance(); -} - - -void ProgramDesc::Clear() { -// @@protoc_insertion_point(message_clear_start:paddle.framework.proto.ProgramDesc) - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - - blocks_.Clear(); - cached_has_bits = _has_bits_[0]; - if (cached_has_bits & 0x00000003u) { - if (cached_has_bits & 0x00000001u) { - GOOGLE_DCHECK(version_ != nullptr); - version_->Clear(); - } - if (cached_has_bits & 0x00000002u) { - GOOGLE_DCHECK(op_version_map_ != nullptr); - op_version_map_->Clear(); - } - } - _has_bits_.Clear(); - _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); -} - -const char* ProgramDesc::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { -#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure - _Internal::HasBits has_bits{}; - while (!ctx->Done(&ptr)) { - ::PROTOBUF_NAMESPACE_ID::uint32 tag; - ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); - CHK_(ptr); - switch (tag >> 3) { - // repeated .paddle.framework.proto.BlockDesc blocks = 1; - case 1: - if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) { - ptr -= 1; - do { - ptr += 1; - ptr = ctx->ParseMessage(_internal_add_blocks(), ptr); - CHK_(ptr); - if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<10>(ptr)); - } else goto handle_unusual; - continue; - // optional .paddle.framework.proto.Version version = 4; - case 4: - if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 34)) { - ptr = ctx->ParseMessage(_internal_mutable_version(), ptr); - CHK_(ptr); - } else goto handle_unusual; - continue; - // optional .paddle.framework.proto.OpVersionMap op_version_map = 5; - case 5: - if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 42)) { - ptr = ctx->ParseMessage(_internal_mutable_op_version_map(), ptr); - CHK_(ptr); - } else goto handle_unusual; - continue; - default: { - handle_unusual: - if ((tag & 7) == 4 || tag == 0) { - ctx->SetLastTag(tag); - goto success; - } - ptr = UnknownFieldParse(tag, - _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), - ptr, ctx); - CHK_(ptr != nullptr); - continue; - } - } // switch - } // while -success: - _has_bits_.Or(has_bits); - return ptr; -failure: - ptr = nullptr; - goto success; -#undef CHK_ -} - -::PROTOBUF_NAMESPACE_ID::uint8* ProgramDesc::_InternalSerialize( - ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { - // @@protoc_insertion_point(serialize_to_array_start:paddle.framework.proto.ProgramDesc) - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; - (void) cached_has_bits; - - // repeated .paddle.framework.proto.BlockDesc blocks = 1; - for (unsigned int i = 0, - n = static_cast(this->_internal_blocks_size()); i < n; i++) { - target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(1, this->_internal_blocks(i), target, stream); - } - - cached_has_bits = _has_bits_[0]; - // optional .paddle.framework.proto.Version version = 4; - if (cached_has_bits & 0x00000001u) { - target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage( - 4, _Internal::version(this), target, stream); - } - - // optional .paddle.framework.proto.OpVersionMap op_version_map = 5; - if (cached_has_bits & 0x00000002u) { - target = stream->EnsureSpace(target); - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage( - 5, _Internal::op_version_map(this), target, stream); - } - - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( - _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); - } - // @@protoc_insertion_point(serialize_to_array_end:paddle.framework.proto.ProgramDesc) - return target; -} - -size_t ProgramDesc::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:paddle.framework.proto.ProgramDesc) - size_t total_size = 0; - - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - - // repeated .paddle.framework.proto.BlockDesc blocks = 1; - total_size += 1UL * this->_internal_blocks_size(); - for (const auto& msg : this->blocks_) { - total_size += - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); - } - - cached_has_bits = _has_bits_[0]; - if (cached_has_bits & 0x00000003u) { - // optional .paddle.framework.proto.Version version = 4; - if (cached_has_bits & 0x00000001u) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - *version_); - } - - // optional .paddle.framework.proto.OpVersionMap op_version_map = 5; - if (cached_has_bits & 0x00000002u) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - *op_version_map_); - } - - } - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { - return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize( - _internal_metadata_, total_size, &_cached_size_); - } - int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size); - SetCachedSize(cached_size); - return total_size; -} - -void ProgramDesc::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { -// @@protoc_insertion_point(generalized_merge_from_start:paddle.framework.proto.ProgramDesc) - GOOGLE_DCHECK_NE(&from, this); - const ProgramDesc* source = - ::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated( - &from); - if (source == nullptr) { - // @@protoc_insertion_point(generalized_merge_from_cast_fail:paddle.framework.proto.ProgramDesc) - ::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this); - } else { - // @@protoc_insertion_point(generalized_merge_from_cast_success:paddle.framework.proto.ProgramDesc) - MergeFrom(*source); - } -} - -void ProgramDesc::MergeFrom(const ProgramDesc& from) { -// @@protoc_insertion_point(class_specific_merge_from_start:paddle.framework.proto.ProgramDesc) - GOOGLE_DCHECK_NE(&from, this); - _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; - (void) cached_has_bits; - - blocks_.MergeFrom(from.blocks_); - cached_has_bits = from._has_bits_[0]; - if (cached_has_bits & 0x00000003u) { - if (cached_has_bits & 0x00000001u) { - _internal_mutable_version()->::paddle::framework::proto::Version::MergeFrom(from._internal_version()); - } - if (cached_has_bits & 0x00000002u) { - _internal_mutable_op_version_map()->::paddle::framework::proto::OpVersionMap::MergeFrom(from._internal_op_version_map()); - } - } -} - -void ProgramDesc::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { -// @@protoc_insertion_point(generalized_copy_from_start:paddle.framework.proto.ProgramDesc) - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -void ProgramDesc::CopyFrom(const ProgramDesc& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:paddle.framework.proto.ProgramDesc) - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -bool ProgramDesc::IsInitialized() const { - if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(blocks_)) return false; - if (_internal_has_op_version_map()) { - if (!op_version_map_->IsInitialized()) return false; - } - return true; -} - -void ProgramDesc::InternalSwap(ProgramDesc* other) { - using std::swap; - _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); - swap(_has_bits_[0], other->_has_bits_[0]); - blocks_.InternalSwap(&other->blocks_); - ::PROTOBUF_NAMESPACE_ID::internal::memswap< - PROTOBUF_FIELD_OFFSET(ProgramDesc, op_version_map_) - + sizeof(ProgramDesc::op_version_map_) - - PROTOBUF_FIELD_OFFSET(ProgramDesc, version_)>( - reinterpret_cast(&version_), - reinterpret_cast(&other->version_)); -} - -::PROTOBUF_NAMESPACE_ID::Metadata ProgramDesc::GetMetadata() const { - return GetMetadataStatic(); -} - - -// @@protoc_insertion_point(namespace_scope) -} // namespace proto -} // namespace framework -} // namespace paddle -PROTOBUF_NAMESPACE_OPEN -template<> PROTOBUF_NOINLINE ::paddle::framework::proto::Version* Arena::CreateMaybeMessage< ::paddle::framework::proto::Version >(Arena* arena) { - return Arena::CreateMessageInternal< ::paddle::framework::proto::Version >(arena); -} -template<> PROTOBUF_NOINLINE ::paddle::framework::proto::OpDesc_Attr* Arena::CreateMaybeMessage< ::paddle::framework::proto::OpDesc_Attr >(Arena* arena) { - return Arena::CreateMessageInternal< ::paddle::framework::proto::OpDesc_Attr >(arena); -} -template<> PROTOBUF_NOINLINE ::paddle::framework::proto::OpDesc_Var* Arena::CreateMaybeMessage< ::paddle::framework::proto::OpDesc_Var >(Arena* arena) { - return Arena::CreateMessageInternal< ::paddle::framework::proto::OpDesc_Var >(arena); -} -template<> PROTOBUF_NOINLINE ::paddle::framework::proto::OpDesc* Arena::CreateMaybeMessage< ::paddle::framework::proto::OpDesc >(Arena* arena) { - return Arena::CreateMessageInternal< ::paddle::framework::proto::OpDesc >(arena); -} -template<> PROTOBUF_NOINLINE ::paddle::framework::proto::OpProto_Var* Arena::CreateMaybeMessage< ::paddle::framework::proto::OpProto_Var >(Arena* arena) { - return Arena::CreateMessageInternal< ::paddle::framework::proto::OpProto_Var >(arena); -} -template<> PROTOBUF_NOINLINE ::paddle::framework::proto::OpProto_Attr* Arena::CreateMaybeMessage< ::paddle::framework::proto::OpProto_Attr >(Arena* arena) { - return Arena::CreateMessageInternal< ::paddle::framework::proto::OpProto_Attr >(arena); -} -template<> PROTOBUF_NOINLINE ::paddle::framework::proto::OpProto* Arena::CreateMaybeMessage< ::paddle::framework::proto::OpProto >(Arena* arena) { - return Arena::CreateMessageInternal< ::paddle::framework::proto::OpProto >(arena); -} -template<> PROTOBUF_NOINLINE ::paddle::framework::proto::VarType_TensorDesc* Arena::CreateMaybeMessage< ::paddle::framework::proto::VarType_TensorDesc >(Arena* arena) { - return Arena::CreateMessageInternal< ::paddle::framework::proto::VarType_TensorDesc >(arena); -} -template<> PROTOBUF_NOINLINE ::paddle::framework::proto::VarType_LoDTensorDesc* Arena::CreateMaybeMessage< ::paddle::framework::proto::VarType_LoDTensorDesc >(Arena* arena) { - return Arena::CreateMessageInternal< ::paddle::framework::proto::VarType_LoDTensorDesc >(arena); -} -template<> PROTOBUF_NOINLINE ::paddle::framework::proto::VarType_LoDTensorArrayDesc* Arena::CreateMaybeMessage< ::paddle::framework::proto::VarType_LoDTensorArrayDesc >(Arena* arena) { - return Arena::CreateMessageInternal< ::paddle::framework::proto::VarType_LoDTensorArrayDesc >(arena); -} -template<> PROTOBUF_NOINLINE ::paddle::framework::proto::VarType_ReaderDesc* Arena::CreateMaybeMessage< ::paddle::framework::proto::VarType_ReaderDesc >(Arena* arena) { - return Arena::CreateMessageInternal< ::paddle::framework::proto::VarType_ReaderDesc >(arena); -} -template<> PROTOBUF_NOINLINE ::paddle::framework::proto::VarType_Tuple* Arena::CreateMaybeMessage< ::paddle::framework::proto::VarType_Tuple >(Arena* arena) { - return Arena::CreateMessageInternal< ::paddle::framework::proto::VarType_Tuple >(arena); -} -template<> PROTOBUF_NOINLINE ::paddle::framework::proto::VarType* Arena::CreateMaybeMessage< ::paddle::framework::proto::VarType >(Arena* arena) { - return Arena::CreateMessageInternal< ::paddle::framework::proto::VarType >(arena); -} -template<> PROTOBUF_NOINLINE ::paddle::framework::proto::VarDesc* Arena::CreateMaybeMessage< ::paddle::framework::proto::VarDesc >(Arena* arena) { - return Arena::CreateMessageInternal< ::paddle::framework::proto::VarDesc >(arena); -} -template<> PROTOBUF_NOINLINE ::paddle::framework::proto::BlockDesc* Arena::CreateMaybeMessage< ::paddle::framework::proto::BlockDesc >(Arena* arena) { - return Arena::CreateMessageInternal< ::paddle::framework::proto::BlockDesc >(arena); -} -template<> PROTOBUF_NOINLINE ::paddle::framework::proto::OpVersion* Arena::CreateMaybeMessage< ::paddle::framework::proto::OpVersion >(Arena* arena) { - return Arena::CreateMessageInternal< ::paddle::framework::proto::OpVersion >(arena); -} -template<> PROTOBUF_NOINLINE ::paddle::framework::proto::OpVersionMap_OpVersionPair* Arena::CreateMaybeMessage< ::paddle::framework::proto::OpVersionMap_OpVersionPair >(Arena* arena) { - return Arena::CreateMessageInternal< ::paddle::framework::proto::OpVersionMap_OpVersionPair >(arena); -} -template<> PROTOBUF_NOINLINE ::paddle::framework::proto::OpVersionMap* Arena::CreateMaybeMessage< ::paddle::framework::proto::OpVersionMap >(Arena* arena) { - return Arena::CreateMessageInternal< ::paddle::framework::proto::OpVersionMap >(arena); -} -template<> PROTOBUF_NOINLINE ::paddle::framework::proto::ProgramDesc* Arena::CreateMaybeMessage< ::paddle::framework::proto::ProgramDesc >(Arena* arena) { - return Arena::CreateMessageInternal< ::paddle::framework::proto::ProgramDesc >(arena); -} -PROTOBUF_NAMESPACE_CLOSE - -// @@protoc_insertion_point(global_scope) -#include diff --git a/inference-engine/samples/pdpd_poc/framework.pb.h b/inference-engine/samples/pdpd_poc/framework.pb.h deleted file mode 100644 index ed6855ea28330c..00000000000000 --- a/inference-engine/samples/pdpd_poc/framework.pb.h +++ /dev/null @@ -1,7608 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: framework.proto - -#ifndef GOOGLE_PROTOBUF_INCLUDED_framework_2eproto -#define GOOGLE_PROTOBUF_INCLUDED_framework_2eproto - -#include -#include - -#include -#if PROTOBUF_VERSION < 3014000 -#error This file was generated by a newer version of protoc which is -#error incompatible with your Protocol Buffer headers. Please update -#error your headers. -#endif -#if 3014000 < PROTOBUF_MIN_PROTOC_VERSION -#error This file was generated by an older version of protoc which is -#error incompatible with your Protocol Buffer headers. Please -#error regenerate this file with a newer version of protoc. -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include // IWYU pragma: export -#include // IWYU pragma: export -#include -#include -// @@protoc_insertion_point(includes) -#include -#define PROTOBUF_INTERNAL_EXPORT_framework_2eproto -PROTOBUF_NAMESPACE_OPEN -namespace internal { -class AnyMetadata; -} // namespace internal -PROTOBUF_NAMESPACE_CLOSE - -// Internal implementation detail -- do not use these members. -struct TableStruct_framework_2eproto { - static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTableField entries[] - PROTOBUF_SECTION_VARIABLE(protodesc_cold); - static const ::PROTOBUF_NAMESPACE_ID::internal::AuxiliaryParseTableField aux[] - PROTOBUF_SECTION_VARIABLE(protodesc_cold); - static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTable schema[19] - PROTOBUF_SECTION_VARIABLE(protodesc_cold); - static const ::PROTOBUF_NAMESPACE_ID::internal::FieldMetadata field_metadata[]; - static const ::PROTOBUF_NAMESPACE_ID::internal::SerializationTable serialization_table[]; - static const ::PROTOBUF_NAMESPACE_ID::uint32 offsets[]; -}; -extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_framework_2eproto; -namespace paddle { -namespace framework { -namespace proto { -class BlockDesc; -class BlockDescDefaultTypeInternal; -extern BlockDescDefaultTypeInternal _BlockDesc_default_instance_; -class OpDesc; -class OpDescDefaultTypeInternal; -extern OpDescDefaultTypeInternal _OpDesc_default_instance_; -class OpDesc_Attr; -class OpDesc_AttrDefaultTypeInternal; -extern OpDesc_AttrDefaultTypeInternal _OpDesc_Attr_default_instance_; -class OpDesc_Var; -class OpDesc_VarDefaultTypeInternal; -extern OpDesc_VarDefaultTypeInternal _OpDesc_Var_default_instance_; -class OpProto; -class OpProtoDefaultTypeInternal; -extern OpProtoDefaultTypeInternal _OpProto_default_instance_; -class OpProto_Attr; -class OpProto_AttrDefaultTypeInternal; -extern OpProto_AttrDefaultTypeInternal _OpProto_Attr_default_instance_; -class OpProto_Var; -class OpProto_VarDefaultTypeInternal; -extern OpProto_VarDefaultTypeInternal _OpProto_Var_default_instance_; -class OpVersion; -class OpVersionDefaultTypeInternal; -extern OpVersionDefaultTypeInternal _OpVersion_default_instance_; -class OpVersionMap; -class OpVersionMapDefaultTypeInternal; -extern OpVersionMapDefaultTypeInternal _OpVersionMap_default_instance_; -class OpVersionMap_OpVersionPair; -class OpVersionMap_OpVersionPairDefaultTypeInternal; -extern OpVersionMap_OpVersionPairDefaultTypeInternal _OpVersionMap_OpVersionPair_default_instance_; -class ProgramDesc; -class ProgramDescDefaultTypeInternal; -extern ProgramDescDefaultTypeInternal _ProgramDesc_default_instance_; -class VarDesc; -class VarDescDefaultTypeInternal; -extern VarDescDefaultTypeInternal _VarDesc_default_instance_; -class VarType; -class VarTypeDefaultTypeInternal; -extern VarTypeDefaultTypeInternal _VarType_default_instance_; -class VarType_LoDTensorArrayDesc; -class VarType_LoDTensorArrayDescDefaultTypeInternal; -extern VarType_LoDTensorArrayDescDefaultTypeInternal _VarType_LoDTensorArrayDesc_default_instance_; -class VarType_LoDTensorDesc; -class VarType_LoDTensorDescDefaultTypeInternal; -extern VarType_LoDTensorDescDefaultTypeInternal _VarType_LoDTensorDesc_default_instance_; -class VarType_ReaderDesc; -class VarType_ReaderDescDefaultTypeInternal; -extern VarType_ReaderDescDefaultTypeInternal _VarType_ReaderDesc_default_instance_; -class VarType_TensorDesc; -class VarType_TensorDescDefaultTypeInternal; -extern VarType_TensorDescDefaultTypeInternal _VarType_TensorDesc_default_instance_; -class VarType_Tuple; -class VarType_TupleDefaultTypeInternal; -extern VarType_TupleDefaultTypeInternal _VarType_Tuple_default_instance_; -class Version; -class VersionDefaultTypeInternal; -extern VersionDefaultTypeInternal _Version_default_instance_; -} // namespace proto -} // namespace framework -} // namespace paddle -PROTOBUF_NAMESPACE_OPEN -template<> ::paddle::framework::proto::BlockDesc* Arena::CreateMaybeMessage<::paddle::framework::proto::BlockDesc>(Arena*); -template<> ::paddle::framework::proto::OpDesc* Arena::CreateMaybeMessage<::paddle::framework::proto::OpDesc>(Arena*); -template<> ::paddle::framework::proto::OpDesc_Attr* Arena::CreateMaybeMessage<::paddle::framework::proto::OpDesc_Attr>(Arena*); -template<> ::paddle::framework::proto::OpDesc_Var* Arena::CreateMaybeMessage<::paddle::framework::proto::OpDesc_Var>(Arena*); -template<> ::paddle::framework::proto::OpProto* Arena::CreateMaybeMessage<::paddle::framework::proto::OpProto>(Arena*); -template<> ::paddle::framework::proto::OpProto_Attr* Arena::CreateMaybeMessage<::paddle::framework::proto::OpProto_Attr>(Arena*); -template<> ::paddle::framework::proto::OpProto_Var* Arena::CreateMaybeMessage<::paddle::framework::proto::OpProto_Var>(Arena*); -template<> ::paddle::framework::proto::OpVersion* Arena::CreateMaybeMessage<::paddle::framework::proto::OpVersion>(Arena*); -template<> ::paddle::framework::proto::OpVersionMap* Arena::CreateMaybeMessage<::paddle::framework::proto::OpVersionMap>(Arena*); -template<> ::paddle::framework::proto::OpVersionMap_OpVersionPair* Arena::CreateMaybeMessage<::paddle::framework::proto::OpVersionMap_OpVersionPair>(Arena*); -template<> ::paddle::framework::proto::ProgramDesc* Arena::CreateMaybeMessage<::paddle::framework::proto::ProgramDesc>(Arena*); -template<> ::paddle::framework::proto::VarDesc* Arena::CreateMaybeMessage<::paddle::framework::proto::VarDesc>(Arena*); -template<> ::paddle::framework::proto::VarType* Arena::CreateMaybeMessage<::paddle::framework::proto::VarType>(Arena*); -template<> ::paddle::framework::proto::VarType_LoDTensorArrayDesc* Arena::CreateMaybeMessage<::paddle::framework::proto::VarType_LoDTensorArrayDesc>(Arena*); -template<> ::paddle::framework::proto::VarType_LoDTensorDesc* Arena::CreateMaybeMessage<::paddle::framework::proto::VarType_LoDTensorDesc>(Arena*); -template<> ::paddle::framework::proto::VarType_ReaderDesc* Arena::CreateMaybeMessage<::paddle::framework::proto::VarType_ReaderDesc>(Arena*); -template<> ::paddle::framework::proto::VarType_TensorDesc* Arena::CreateMaybeMessage<::paddle::framework::proto::VarType_TensorDesc>(Arena*); -template<> ::paddle::framework::proto::VarType_Tuple* Arena::CreateMaybeMessage<::paddle::framework::proto::VarType_Tuple>(Arena*); -template<> ::paddle::framework::proto::Version* Arena::CreateMaybeMessage<::paddle::framework::proto::Version>(Arena*); -PROTOBUF_NAMESPACE_CLOSE -namespace paddle { -namespace framework { -namespace proto { - -enum VarType_Type : int { - VarType_Type_BOOL = 0, - VarType_Type_INT16 = 1, - VarType_Type_INT32 = 2, - VarType_Type_INT64 = 3, - VarType_Type_FP16 = 4, - VarType_Type_FP32 = 5, - VarType_Type_FP64 = 6, - VarType_Type_SIZE_T = 19, - VarType_Type_UINT8 = 20, - VarType_Type_INT8 = 21, - VarType_Type_BF16 = 22, - VarType_Type_COMPLEX64 = 23, - VarType_Type_COMPLEX128 = 24, - VarType_Type_LOD_TENSOR = 7, - VarType_Type_SELECTED_ROWS = 8, - VarType_Type_FEED_MINIBATCH = 9, - VarType_Type_FETCH_LIST = 10, - VarType_Type_STEP_SCOPES = 11, - VarType_Type_LOD_RANK_TABLE = 12, - VarType_Type_LOD_TENSOR_ARRAY = 13, - VarType_Type_PLACE_LIST = 14, - VarType_Type_READER = 15, - VarType_Type_RAW = 17, - VarType_Type_TUPLE = 18 -}; -bool VarType_Type_IsValid(int value); -constexpr VarType_Type VarType_Type_Type_MIN = VarType_Type_BOOL; -constexpr VarType_Type VarType_Type_Type_MAX = VarType_Type_COMPLEX128; -constexpr int VarType_Type_Type_ARRAYSIZE = VarType_Type_Type_MAX + 1; - -const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* VarType_Type_descriptor(); -template -inline const std::string& VarType_Type_Name(T enum_t_value) { - static_assert(::std::is_same::value || - ::std::is_integral::value, - "Incorrect type passed to function VarType_Type_Name."); - return ::PROTOBUF_NAMESPACE_ID::internal::NameOfEnum( - VarType_Type_descriptor(), enum_t_value); -} -inline bool VarType_Type_Parse( - ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, VarType_Type* value) { - return ::PROTOBUF_NAMESPACE_ID::internal::ParseNamedEnum( - VarType_Type_descriptor(), name, value); -} -enum AttrType : int { - INT = 0, - FLOAT = 1, - STRING = 2, - INTS = 3, - FLOATS = 4, - STRINGS = 5, - BOOLEAN = 6, - BOOLEANS = 7, - BLOCK = 8, - LONG = 9, - BLOCKS = 10, - LONGS = 11 -}; -bool AttrType_IsValid(int value); -constexpr AttrType AttrType_MIN = INT; -constexpr AttrType AttrType_MAX = LONGS; -constexpr int AttrType_ARRAYSIZE = AttrType_MAX + 1; - -const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* AttrType_descriptor(); -template -inline const std::string& AttrType_Name(T enum_t_value) { - static_assert(::std::is_same::value || - ::std::is_integral::value, - "Incorrect type passed to function AttrType_Name."); - return ::PROTOBUF_NAMESPACE_ID::internal::NameOfEnum( - AttrType_descriptor(), enum_t_value); -} -inline bool AttrType_Parse( - ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, AttrType* value) { - return ::PROTOBUF_NAMESPACE_ID::internal::ParseNamedEnum( - AttrType_descriptor(), name, value); -} -// =================================================================== - -class Version PROTOBUF_FINAL : - public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:paddle.framework.proto.Version) */ { - public: - inline Version() : Version(nullptr) {} - virtual ~Version(); - - Version(const Version& from); - Version(Version&& from) noexcept - : Version() { - *this = ::std::move(from); - } - - inline Version& operator=(const Version& from) { - CopyFrom(from); - return *this; - } - inline Version& operator=(Version&& from) noexcept { - if (GetArena() == from.GetArena()) { - if (this != &from) InternalSwap(&from); - } else { - CopyFrom(from); - } - return *this; - } - - inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { - return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); - } - inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); - } - - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { - return GetDescriptor(); - } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return GetMetadataStatic().descriptor; - } - static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return GetMetadataStatic().reflection; - } - static const Version& default_instance(); - - static inline const Version* internal_default_instance() { - return reinterpret_cast( - &_Version_default_instance_); - } - static constexpr int kIndexInFileMessages = - 0; - - friend void swap(Version& a, Version& b) { - a.Swap(&b); - } - inline void Swap(Version* other) { - if (other == this) return; - if (GetArena() == other->GetArena()) { - InternalSwap(other); - } else { - ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); - } - } - void UnsafeArenaSwap(Version* other) { - if (other == this) return; - GOOGLE_DCHECK(GetArena() == other->GetArena()); - InternalSwap(other); - } - - // implements Message ---------------------------------------------- - - inline Version* New() const final { - return CreateMaybeMessage(nullptr); - } - - Version* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { - return CreateMaybeMessage(arena); - } - void CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; - void MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; - void CopyFrom(const Version& from); - void MergeFrom(const Version& from); - PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; - bool IsInitialized() const final; - - size_t ByteSizeLong() const final; - const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; - ::PROTOBUF_NAMESPACE_ID::uint8* _InternalSerialize( - ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _cached_size_.Get(); } - - private: - inline void SharedCtor(); - inline void SharedDtor(); - void SetCachedSize(int size) const final; - void InternalSwap(Version* other); - friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; - static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { - return "paddle.framework.proto.Version"; - } - protected: - explicit Version(::PROTOBUF_NAMESPACE_ID::Arena* arena); - private: - static void ArenaDtor(void* object); - inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); - public: - - ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - private: - static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_framework_2eproto); - return ::descriptor_table_framework_2eproto.file_level_metadata[kIndexInFileMessages]; - } - - public: - - // nested types ---------------------------------------------------- - - // accessors ------------------------------------------------------- - - enum : int { - kVersionFieldNumber = 1, - }; - // optional int64 version = 1 [default = 0]; - bool has_version() const; - private: - bool _internal_has_version() const; - public: - void clear_version(); - ::PROTOBUF_NAMESPACE_ID::int64 version() const; - void set_version(::PROTOBUF_NAMESPACE_ID::int64 value); - private: - ::PROTOBUF_NAMESPACE_ID::int64 _internal_version() const; - void _internal_set_version(::PROTOBUF_NAMESPACE_ID::int64 value); - public: - - // @@protoc_insertion_point(class_scope:paddle.framework.proto.Version) - private: - class _Internal; - - template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; - typedef void InternalArenaConstructable_; - typedef void DestructorSkippable_; - ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::PROTOBUF_NAMESPACE_ID::int64 version_; - friend struct ::TableStruct_framework_2eproto; -}; -// ------------------------------------------------------------------- - -class OpDesc_Attr PROTOBUF_FINAL : - public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:paddle.framework.proto.OpDesc.Attr) */ { - public: - inline OpDesc_Attr() : OpDesc_Attr(nullptr) {} - virtual ~OpDesc_Attr(); - - OpDesc_Attr(const OpDesc_Attr& from); - OpDesc_Attr(OpDesc_Attr&& from) noexcept - : OpDesc_Attr() { - *this = ::std::move(from); - } - - inline OpDesc_Attr& operator=(const OpDesc_Attr& from) { - CopyFrom(from); - return *this; - } - inline OpDesc_Attr& operator=(OpDesc_Attr&& from) noexcept { - if (GetArena() == from.GetArena()) { - if (this != &from) InternalSwap(&from); - } else { - CopyFrom(from); - } - return *this; - } - - inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { - return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); - } - inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); - } - - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { - return GetDescriptor(); - } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return GetMetadataStatic().descriptor; - } - static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return GetMetadataStatic().reflection; - } - static const OpDesc_Attr& default_instance(); - - static inline const OpDesc_Attr* internal_default_instance() { - return reinterpret_cast( - &_OpDesc_Attr_default_instance_); - } - static constexpr int kIndexInFileMessages = - 1; - - friend void swap(OpDesc_Attr& a, OpDesc_Attr& b) { - a.Swap(&b); - } - inline void Swap(OpDesc_Attr* other) { - if (other == this) return; - if (GetArena() == other->GetArena()) { - InternalSwap(other); - } else { - ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); - } - } - void UnsafeArenaSwap(OpDesc_Attr* other) { - if (other == this) return; - GOOGLE_DCHECK(GetArena() == other->GetArena()); - InternalSwap(other); - } - - // implements Message ---------------------------------------------- - - inline OpDesc_Attr* New() const final { - return CreateMaybeMessage(nullptr); - } - - OpDesc_Attr* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { - return CreateMaybeMessage(arena); - } - void CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; - void MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; - void CopyFrom(const OpDesc_Attr& from); - void MergeFrom(const OpDesc_Attr& from); - PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; - bool IsInitialized() const final; - - size_t ByteSizeLong() const final; - const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; - ::PROTOBUF_NAMESPACE_ID::uint8* _InternalSerialize( - ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _cached_size_.Get(); } - - private: - inline void SharedCtor(); - inline void SharedDtor(); - void SetCachedSize(int size) const final; - void InternalSwap(OpDesc_Attr* other); - friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; - static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { - return "paddle.framework.proto.OpDesc.Attr"; - } - protected: - explicit OpDesc_Attr(::PROTOBUF_NAMESPACE_ID::Arena* arena); - private: - static void ArenaDtor(void* object); - inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); - public: - - ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - private: - static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_framework_2eproto); - return ::descriptor_table_framework_2eproto.file_level_metadata[kIndexInFileMessages]; - } - - public: - - // nested types ---------------------------------------------------- - - // accessors ------------------------------------------------------- - - enum : int { - kIntsFieldNumber = 6, - kFloatsFieldNumber = 7, - kStringsFieldNumber = 8, - kBoolsFieldNumber = 11, - kBlocksIdxFieldNumber = 14, - kLongsFieldNumber = 15, - kNameFieldNumber = 1, - kSFieldNumber = 5, - kTypeFieldNumber = 2, - kIFieldNumber = 3, - kFFieldNumber = 4, - kBFieldNumber = 10, - kLFieldNumber = 13, - kBlockIdxFieldNumber = 12, - }; - // repeated int32 ints = 6; - int ints_size() const; - private: - int _internal_ints_size() const; - public: - void clear_ints(); - private: - ::PROTOBUF_NAMESPACE_ID::int32 _internal_ints(int index) const; - const ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int32 >& - _internal_ints() const; - void _internal_add_ints(::PROTOBUF_NAMESPACE_ID::int32 value); - ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int32 >* - _internal_mutable_ints(); - public: - ::PROTOBUF_NAMESPACE_ID::int32 ints(int index) const; - void set_ints(int index, ::PROTOBUF_NAMESPACE_ID::int32 value); - void add_ints(::PROTOBUF_NAMESPACE_ID::int32 value); - const ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int32 >& - ints() const; - ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int32 >* - mutable_ints(); - - // repeated float floats = 7; - int floats_size() const; - private: - int _internal_floats_size() const; - public: - void clear_floats(); - private: - float _internal_floats(int index) const; - const ::PROTOBUF_NAMESPACE_ID::RepeatedField< float >& - _internal_floats() const; - void _internal_add_floats(float value); - ::PROTOBUF_NAMESPACE_ID::RepeatedField< float >* - _internal_mutable_floats(); - public: - float floats(int index) const; - void set_floats(int index, float value); - void add_floats(float value); - const ::PROTOBUF_NAMESPACE_ID::RepeatedField< float >& - floats() const; - ::PROTOBUF_NAMESPACE_ID::RepeatedField< float >* - mutable_floats(); - - // repeated string strings = 8; - int strings_size() const; - private: - int _internal_strings_size() const; - public: - void clear_strings(); - const std::string& strings(int index) const; - std::string* mutable_strings(int index); - void set_strings(int index, const std::string& value); - void set_strings(int index, std::string&& value); - void set_strings(int index, const char* value); - void set_strings(int index, const char* value, size_t size); - std::string* add_strings(); - void add_strings(const std::string& value); - void add_strings(std::string&& value); - void add_strings(const char* value); - void add_strings(const char* value, size_t size); - const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField& strings() const; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField* mutable_strings(); - private: - const std::string& _internal_strings(int index) const; - std::string* _internal_add_strings(); - public: - - // repeated bool bools = 11; - int bools_size() const; - private: - int _internal_bools_size() const; - public: - void clear_bools(); - private: - bool _internal_bools(int index) const; - const ::PROTOBUF_NAMESPACE_ID::RepeatedField< bool >& - _internal_bools() const; - void _internal_add_bools(bool value); - ::PROTOBUF_NAMESPACE_ID::RepeatedField< bool >* - _internal_mutable_bools(); - public: - bool bools(int index) const; - void set_bools(int index, bool value); - void add_bools(bool value); - const ::PROTOBUF_NAMESPACE_ID::RepeatedField< bool >& - bools() const; - ::PROTOBUF_NAMESPACE_ID::RepeatedField< bool >* - mutable_bools(); - - // repeated int32 blocks_idx = 14; - int blocks_idx_size() const; - private: - int _internal_blocks_idx_size() const; - public: - void clear_blocks_idx(); - private: - ::PROTOBUF_NAMESPACE_ID::int32 _internal_blocks_idx(int index) const; - const ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int32 >& - _internal_blocks_idx() const; - void _internal_add_blocks_idx(::PROTOBUF_NAMESPACE_ID::int32 value); - ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int32 >* - _internal_mutable_blocks_idx(); - public: - ::PROTOBUF_NAMESPACE_ID::int32 blocks_idx(int index) const; - void set_blocks_idx(int index, ::PROTOBUF_NAMESPACE_ID::int32 value); - void add_blocks_idx(::PROTOBUF_NAMESPACE_ID::int32 value); - const ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int32 >& - blocks_idx() const; - ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int32 >* - mutable_blocks_idx(); - - // repeated int64 longs = 15; - int longs_size() const; - private: - int _internal_longs_size() const; - public: - void clear_longs(); - private: - ::PROTOBUF_NAMESPACE_ID::int64 _internal_longs(int index) const; - const ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int64 >& - _internal_longs() const; - void _internal_add_longs(::PROTOBUF_NAMESPACE_ID::int64 value); - ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int64 >* - _internal_mutable_longs(); - public: - ::PROTOBUF_NAMESPACE_ID::int64 longs(int index) const; - void set_longs(int index, ::PROTOBUF_NAMESPACE_ID::int64 value); - void add_longs(::PROTOBUF_NAMESPACE_ID::int64 value); - const ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int64 >& - longs() const; - ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int64 >* - mutable_longs(); - - // required string name = 1; - bool has_name() const; - private: - bool _internal_has_name() const; - public: - void clear_name(); - const std::string& name() const; - void set_name(const std::string& value); - void set_name(std::string&& value); - void set_name(const char* value); - void set_name(const char* value, size_t size); - std::string* mutable_name(); - std::string* release_name(); - void set_allocated_name(std::string* name); - private: - const std::string& _internal_name() const; - void _internal_set_name(const std::string& value); - std::string* _internal_mutable_name(); - public: - - // optional string s = 5; - bool has_s() const; - private: - bool _internal_has_s() const; - public: - void clear_s(); - const std::string& s() const; - void set_s(const std::string& value); - void set_s(std::string&& value); - void set_s(const char* value); - void set_s(const char* value, size_t size); - std::string* mutable_s(); - std::string* release_s(); - void set_allocated_s(std::string* s); - private: - const std::string& _internal_s() const; - void _internal_set_s(const std::string& value); - std::string* _internal_mutable_s(); - public: - - // required .paddle.framework.proto.AttrType type = 2; - bool has_type() const; - private: - bool _internal_has_type() const; - public: - void clear_type(); - ::paddle::framework::proto::AttrType type() const; - void set_type(::paddle::framework::proto::AttrType value); - private: - ::paddle::framework::proto::AttrType _internal_type() const; - void _internal_set_type(::paddle::framework::proto::AttrType value); - public: - - // optional int32 i = 3; - bool has_i() const; - private: - bool _internal_has_i() const; - public: - void clear_i(); - ::PROTOBUF_NAMESPACE_ID::int32 i() const; - void set_i(::PROTOBUF_NAMESPACE_ID::int32 value); - private: - ::PROTOBUF_NAMESPACE_ID::int32 _internal_i() const; - void _internal_set_i(::PROTOBUF_NAMESPACE_ID::int32 value); - public: - - // optional float f = 4; - bool has_f() const; - private: - bool _internal_has_f() const; - public: - void clear_f(); - float f() const; - void set_f(float value); - private: - float _internal_f() const; - void _internal_set_f(float value); - public: - - // optional bool b = 10; - bool has_b() const; - private: - bool _internal_has_b() const; - public: - void clear_b(); - bool b() const; - void set_b(bool value); - private: - bool _internal_b() const; - void _internal_set_b(bool value); - public: - - // optional int64 l = 13; - bool has_l() const; - private: - bool _internal_has_l() const; - public: - void clear_l(); - ::PROTOBUF_NAMESPACE_ID::int64 l() const; - void set_l(::PROTOBUF_NAMESPACE_ID::int64 value); - private: - ::PROTOBUF_NAMESPACE_ID::int64 _internal_l() const; - void _internal_set_l(::PROTOBUF_NAMESPACE_ID::int64 value); - public: - - // optional int32 block_idx = 12; - bool has_block_idx() const; - private: - bool _internal_has_block_idx() const; - public: - void clear_block_idx(); - ::PROTOBUF_NAMESPACE_ID::int32 block_idx() const; - void set_block_idx(::PROTOBUF_NAMESPACE_ID::int32 value); - private: - ::PROTOBUF_NAMESPACE_ID::int32 _internal_block_idx() const; - void _internal_set_block_idx(::PROTOBUF_NAMESPACE_ID::int32 value); - public: - - // @@protoc_insertion_point(class_scope:paddle.framework.proto.OpDesc.Attr) - private: - class _Internal; - - // helper for ByteSizeLong() - size_t RequiredFieldsByteSizeFallback() const; - - template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; - typedef void InternalArenaConstructable_; - typedef void DestructorSkippable_; - ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int32 > ints_; - ::PROTOBUF_NAMESPACE_ID::RepeatedField< float > floats_; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField strings_; - ::PROTOBUF_NAMESPACE_ID::RepeatedField< bool > bools_; - ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int32 > blocks_idx_; - ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int64 > longs_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr name_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr s_; - int type_; - ::PROTOBUF_NAMESPACE_ID::int32 i_; - float f_; - bool b_; - ::PROTOBUF_NAMESPACE_ID::int64 l_; - ::PROTOBUF_NAMESPACE_ID::int32 block_idx_; - friend struct ::TableStruct_framework_2eproto; -}; -// ------------------------------------------------------------------- - -class OpDesc_Var PROTOBUF_FINAL : - public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:paddle.framework.proto.OpDesc.Var) */ { - public: - inline OpDesc_Var() : OpDesc_Var(nullptr) {} - virtual ~OpDesc_Var(); - - OpDesc_Var(const OpDesc_Var& from); - OpDesc_Var(OpDesc_Var&& from) noexcept - : OpDesc_Var() { - *this = ::std::move(from); - } - - inline OpDesc_Var& operator=(const OpDesc_Var& from) { - CopyFrom(from); - return *this; - } - inline OpDesc_Var& operator=(OpDesc_Var&& from) noexcept { - if (GetArena() == from.GetArena()) { - if (this != &from) InternalSwap(&from); - } else { - CopyFrom(from); - } - return *this; - } - - inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { - return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); - } - inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); - } - - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { - return GetDescriptor(); - } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return GetMetadataStatic().descriptor; - } - static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return GetMetadataStatic().reflection; - } - static const OpDesc_Var& default_instance(); - - static inline const OpDesc_Var* internal_default_instance() { - return reinterpret_cast( - &_OpDesc_Var_default_instance_); - } - static constexpr int kIndexInFileMessages = - 2; - - friend void swap(OpDesc_Var& a, OpDesc_Var& b) { - a.Swap(&b); - } - inline void Swap(OpDesc_Var* other) { - if (other == this) return; - if (GetArena() == other->GetArena()) { - InternalSwap(other); - } else { - ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); - } - } - void UnsafeArenaSwap(OpDesc_Var* other) { - if (other == this) return; - GOOGLE_DCHECK(GetArena() == other->GetArena()); - InternalSwap(other); - } - - // implements Message ---------------------------------------------- - - inline OpDesc_Var* New() const final { - return CreateMaybeMessage(nullptr); - } - - OpDesc_Var* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { - return CreateMaybeMessage(arena); - } - void CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; - void MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; - void CopyFrom(const OpDesc_Var& from); - void MergeFrom(const OpDesc_Var& from); - PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; - bool IsInitialized() const final; - - size_t ByteSizeLong() const final; - const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; - ::PROTOBUF_NAMESPACE_ID::uint8* _InternalSerialize( - ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _cached_size_.Get(); } - - private: - inline void SharedCtor(); - inline void SharedDtor(); - void SetCachedSize(int size) const final; - void InternalSwap(OpDesc_Var* other); - friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; - static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { - return "paddle.framework.proto.OpDesc.Var"; - } - protected: - explicit OpDesc_Var(::PROTOBUF_NAMESPACE_ID::Arena* arena); - private: - static void ArenaDtor(void* object); - inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); - public: - - ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - private: - static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_framework_2eproto); - return ::descriptor_table_framework_2eproto.file_level_metadata[kIndexInFileMessages]; - } - - public: - - // nested types ---------------------------------------------------- - - // accessors ------------------------------------------------------- - - enum : int { - kArgumentsFieldNumber = 2, - kParameterFieldNumber = 1, - }; - // repeated string arguments = 2; - int arguments_size() const; - private: - int _internal_arguments_size() const; - public: - void clear_arguments(); - const std::string& arguments(int index) const; - std::string* mutable_arguments(int index); - void set_arguments(int index, const std::string& value); - void set_arguments(int index, std::string&& value); - void set_arguments(int index, const char* value); - void set_arguments(int index, const char* value, size_t size); - std::string* add_arguments(); - void add_arguments(const std::string& value); - void add_arguments(std::string&& value); - void add_arguments(const char* value); - void add_arguments(const char* value, size_t size); - const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField& arguments() const; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField* mutable_arguments(); - private: - const std::string& _internal_arguments(int index) const; - std::string* _internal_add_arguments(); - public: - - // required string parameter = 1; - bool has_parameter() const; - private: - bool _internal_has_parameter() const; - public: - void clear_parameter(); - const std::string& parameter() const; - void set_parameter(const std::string& value); - void set_parameter(std::string&& value); - void set_parameter(const char* value); - void set_parameter(const char* value, size_t size); - std::string* mutable_parameter(); - std::string* release_parameter(); - void set_allocated_parameter(std::string* parameter); - private: - const std::string& _internal_parameter() const; - void _internal_set_parameter(const std::string& value); - std::string* _internal_mutable_parameter(); - public: - - // @@protoc_insertion_point(class_scope:paddle.framework.proto.OpDesc.Var) - private: - class _Internal; - - template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; - typedef void InternalArenaConstructable_; - typedef void DestructorSkippable_; - ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField arguments_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr parameter_; - friend struct ::TableStruct_framework_2eproto; -}; -// ------------------------------------------------------------------- - -class OpDesc PROTOBUF_FINAL : - public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:paddle.framework.proto.OpDesc) */ { - public: - inline OpDesc() : OpDesc(nullptr) {} - virtual ~OpDesc(); - - OpDesc(const OpDesc& from); - OpDesc(OpDesc&& from) noexcept - : OpDesc() { - *this = ::std::move(from); - } - - inline OpDesc& operator=(const OpDesc& from) { - CopyFrom(from); - return *this; - } - inline OpDesc& operator=(OpDesc&& from) noexcept { - if (GetArena() == from.GetArena()) { - if (this != &from) InternalSwap(&from); - } else { - CopyFrom(from); - } - return *this; - } - - inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { - return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); - } - inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); - } - - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { - return GetDescriptor(); - } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return GetMetadataStatic().descriptor; - } - static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return GetMetadataStatic().reflection; - } - static const OpDesc& default_instance(); - - static inline const OpDesc* internal_default_instance() { - return reinterpret_cast( - &_OpDesc_default_instance_); - } - static constexpr int kIndexInFileMessages = - 3; - - friend void swap(OpDesc& a, OpDesc& b) { - a.Swap(&b); - } - inline void Swap(OpDesc* other) { - if (other == this) return; - if (GetArena() == other->GetArena()) { - InternalSwap(other); - } else { - ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); - } - } - void UnsafeArenaSwap(OpDesc* other) { - if (other == this) return; - GOOGLE_DCHECK(GetArena() == other->GetArena()); - InternalSwap(other); - } - - // implements Message ---------------------------------------------- - - inline OpDesc* New() const final { - return CreateMaybeMessage(nullptr); - } - - OpDesc* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { - return CreateMaybeMessage(arena); - } - void CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; - void MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; - void CopyFrom(const OpDesc& from); - void MergeFrom(const OpDesc& from); - PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; - bool IsInitialized() const final; - - size_t ByteSizeLong() const final; - const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; - ::PROTOBUF_NAMESPACE_ID::uint8* _InternalSerialize( - ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _cached_size_.Get(); } - - private: - inline void SharedCtor(); - inline void SharedDtor(); - void SetCachedSize(int size) const final; - void InternalSwap(OpDesc* other); - friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; - static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { - return "paddle.framework.proto.OpDesc"; - } - protected: - explicit OpDesc(::PROTOBUF_NAMESPACE_ID::Arena* arena); - private: - static void ArenaDtor(void* object); - inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); - public: - - ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - private: - static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_framework_2eproto); - return ::descriptor_table_framework_2eproto.file_level_metadata[kIndexInFileMessages]; - } - - public: - - // nested types ---------------------------------------------------- - - typedef OpDesc_Attr Attr; - typedef OpDesc_Var Var; - - // accessors ------------------------------------------------------- - - enum : int { - kInputsFieldNumber = 1, - kOutputsFieldNumber = 2, - kAttrsFieldNumber = 4, - kTypeFieldNumber = 3, - kIsTargetFieldNumber = 5, - }; - // repeated .paddle.framework.proto.OpDesc.Var inputs = 1; - int inputs_size() const; - private: - int _internal_inputs_size() const; - public: - void clear_inputs(); - ::paddle::framework::proto::OpDesc_Var* mutable_inputs(int index); - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::OpDesc_Var >* - mutable_inputs(); - private: - const ::paddle::framework::proto::OpDesc_Var& _internal_inputs(int index) const; - ::paddle::framework::proto::OpDesc_Var* _internal_add_inputs(); - public: - const ::paddle::framework::proto::OpDesc_Var& inputs(int index) const; - ::paddle::framework::proto::OpDesc_Var* add_inputs(); - const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::OpDesc_Var >& - inputs() const; - - // repeated .paddle.framework.proto.OpDesc.Var outputs = 2; - int outputs_size() const; - private: - int _internal_outputs_size() const; - public: - void clear_outputs(); - ::paddle::framework::proto::OpDesc_Var* mutable_outputs(int index); - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::OpDesc_Var >* - mutable_outputs(); - private: - const ::paddle::framework::proto::OpDesc_Var& _internal_outputs(int index) const; - ::paddle::framework::proto::OpDesc_Var* _internal_add_outputs(); - public: - const ::paddle::framework::proto::OpDesc_Var& outputs(int index) const; - ::paddle::framework::proto::OpDesc_Var* add_outputs(); - const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::OpDesc_Var >& - outputs() const; - - // repeated .paddle.framework.proto.OpDesc.Attr attrs = 4; - int attrs_size() const; - private: - int _internal_attrs_size() const; - public: - void clear_attrs(); - ::paddle::framework::proto::OpDesc_Attr* mutable_attrs(int index); - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::OpDesc_Attr >* - mutable_attrs(); - private: - const ::paddle::framework::proto::OpDesc_Attr& _internal_attrs(int index) const; - ::paddle::framework::proto::OpDesc_Attr* _internal_add_attrs(); - public: - const ::paddle::framework::proto::OpDesc_Attr& attrs(int index) const; - ::paddle::framework::proto::OpDesc_Attr* add_attrs(); - const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::OpDesc_Attr >& - attrs() const; - - // required string type = 3; - bool has_type() const; - private: - bool _internal_has_type() const; - public: - void clear_type(); - const std::string& type() const; - void set_type(const std::string& value); - void set_type(std::string&& value); - void set_type(const char* value); - void set_type(const char* value, size_t size); - std::string* mutable_type(); - std::string* release_type(); - void set_allocated_type(std::string* type); - private: - const std::string& _internal_type() const; - void _internal_set_type(const std::string& value); - std::string* _internal_mutable_type(); - public: - - // optional bool is_target = 5 [default = false]; - bool has_is_target() const; - private: - bool _internal_has_is_target() const; - public: - void clear_is_target(); - bool is_target() const; - void set_is_target(bool value); - private: - bool _internal_is_target() const; - void _internal_set_is_target(bool value); - public: - - // @@protoc_insertion_point(class_scope:paddle.framework.proto.OpDesc) - private: - class _Internal; - - template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; - typedef void InternalArenaConstructable_; - typedef void DestructorSkippable_; - ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::OpDesc_Var > inputs_; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::OpDesc_Var > outputs_; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::OpDesc_Attr > attrs_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr type_; - bool is_target_; - friend struct ::TableStruct_framework_2eproto; -}; -// ------------------------------------------------------------------- - -class OpProto_Var PROTOBUF_FINAL : - public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:paddle.framework.proto.OpProto.Var) */ { - public: - inline OpProto_Var() : OpProto_Var(nullptr) {} - virtual ~OpProto_Var(); - - OpProto_Var(const OpProto_Var& from); - OpProto_Var(OpProto_Var&& from) noexcept - : OpProto_Var() { - *this = ::std::move(from); - } - - inline OpProto_Var& operator=(const OpProto_Var& from) { - CopyFrom(from); - return *this; - } - inline OpProto_Var& operator=(OpProto_Var&& from) noexcept { - if (GetArena() == from.GetArena()) { - if (this != &from) InternalSwap(&from); - } else { - CopyFrom(from); - } - return *this; - } - - inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { - return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); - } - inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); - } - - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { - return GetDescriptor(); - } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return GetMetadataStatic().descriptor; - } - static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return GetMetadataStatic().reflection; - } - static const OpProto_Var& default_instance(); - - static inline const OpProto_Var* internal_default_instance() { - return reinterpret_cast( - &_OpProto_Var_default_instance_); - } - static constexpr int kIndexInFileMessages = - 4; - - friend void swap(OpProto_Var& a, OpProto_Var& b) { - a.Swap(&b); - } - inline void Swap(OpProto_Var* other) { - if (other == this) return; - if (GetArena() == other->GetArena()) { - InternalSwap(other); - } else { - ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); - } - } - void UnsafeArenaSwap(OpProto_Var* other) { - if (other == this) return; - GOOGLE_DCHECK(GetArena() == other->GetArena()); - InternalSwap(other); - } - - // implements Message ---------------------------------------------- - - inline OpProto_Var* New() const final { - return CreateMaybeMessage(nullptr); - } - - OpProto_Var* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { - return CreateMaybeMessage(arena); - } - void CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; - void MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; - void CopyFrom(const OpProto_Var& from); - void MergeFrom(const OpProto_Var& from); - PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; - bool IsInitialized() const final; - - size_t ByteSizeLong() const final; - const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; - ::PROTOBUF_NAMESPACE_ID::uint8* _InternalSerialize( - ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _cached_size_.Get(); } - - private: - inline void SharedCtor(); - inline void SharedDtor(); - void SetCachedSize(int size) const final; - void InternalSwap(OpProto_Var* other); - friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; - static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { - return "paddle.framework.proto.OpProto.Var"; - } - protected: - explicit OpProto_Var(::PROTOBUF_NAMESPACE_ID::Arena* arena); - private: - static void ArenaDtor(void* object); - inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); - public: - - ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - private: - static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_framework_2eproto); - return ::descriptor_table_framework_2eproto.file_level_metadata[kIndexInFileMessages]; - } - - public: - - // nested types ---------------------------------------------------- - - // accessors ------------------------------------------------------- - - enum : int { - kNameFieldNumber = 1, - kCommentFieldNumber = 2, - kDuplicableFieldNumber = 3, - kIntermediateFieldNumber = 4, - kDispensableFieldNumber = 5, - }; - // required string name = 1; - bool has_name() const; - private: - bool _internal_has_name() const; - public: - void clear_name(); - const std::string& name() const; - void set_name(const std::string& value); - void set_name(std::string&& value); - void set_name(const char* value); - void set_name(const char* value, size_t size); - std::string* mutable_name(); - std::string* release_name(); - void set_allocated_name(std::string* name); - private: - const std::string& _internal_name() const; - void _internal_set_name(const std::string& value); - std::string* _internal_mutable_name(); - public: - - // required string comment = 2; - bool has_comment() const; - private: - bool _internal_has_comment() const; - public: - void clear_comment(); - const std::string& comment() const; - void set_comment(const std::string& value); - void set_comment(std::string&& value); - void set_comment(const char* value); - void set_comment(const char* value, size_t size); - std::string* mutable_comment(); - std::string* release_comment(); - void set_allocated_comment(std::string* comment); - private: - const std::string& _internal_comment() const; - void _internal_set_comment(const std::string& value); - std::string* _internal_mutable_comment(); - public: - - // optional bool duplicable = 3 [default = false]; - bool has_duplicable() const; - private: - bool _internal_has_duplicable() const; - public: - void clear_duplicable(); - bool duplicable() const; - void set_duplicable(bool value); - private: - bool _internal_duplicable() const; - void _internal_set_duplicable(bool value); - public: - - // optional bool intermediate = 4 [default = false]; - bool has_intermediate() const; - private: - bool _internal_has_intermediate() const; - public: - void clear_intermediate(); - bool intermediate() const; - void set_intermediate(bool value); - private: - bool _internal_intermediate() const; - void _internal_set_intermediate(bool value); - public: - - // optional bool dispensable = 5 [default = false]; - bool has_dispensable() const; - private: - bool _internal_has_dispensable() const; - public: - void clear_dispensable(); - bool dispensable() const; - void set_dispensable(bool value); - private: - bool _internal_dispensable() const; - void _internal_set_dispensable(bool value); - public: - - // @@protoc_insertion_point(class_scope:paddle.framework.proto.OpProto.Var) - private: - class _Internal; - - // helper for ByteSizeLong() - size_t RequiredFieldsByteSizeFallback() const; - - template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; - typedef void InternalArenaConstructable_; - typedef void DestructorSkippable_; - ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr name_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr comment_; - bool duplicable_; - bool intermediate_; - bool dispensable_; - friend struct ::TableStruct_framework_2eproto; -}; -// ------------------------------------------------------------------- - -class OpProto_Attr PROTOBUF_FINAL : - public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:paddle.framework.proto.OpProto.Attr) */ { - public: - inline OpProto_Attr() : OpProto_Attr(nullptr) {} - virtual ~OpProto_Attr(); - - OpProto_Attr(const OpProto_Attr& from); - OpProto_Attr(OpProto_Attr&& from) noexcept - : OpProto_Attr() { - *this = ::std::move(from); - } - - inline OpProto_Attr& operator=(const OpProto_Attr& from) { - CopyFrom(from); - return *this; - } - inline OpProto_Attr& operator=(OpProto_Attr&& from) noexcept { - if (GetArena() == from.GetArena()) { - if (this != &from) InternalSwap(&from); - } else { - CopyFrom(from); - } - return *this; - } - - inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { - return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); - } - inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); - } - - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { - return GetDescriptor(); - } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return GetMetadataStatic().descriptor; - } - static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return GetMetadataStatic().reflection; - } - static const OpProto_Attr& default_instance(); - - static inline const OpProto_Attr* internal_default_instance() { - return reinterpret_cast( - &_OpProto_Attr_default_instance_); - } - static constexpr int kIndexInFileMessages = - 5; - - friend void swap(OpProto_Attr& a, OpProto_Attr& b) { - a.Swap(&b); - } - inline void Swap(OpProto_Attr* other) { - if (other == this) return; - if (GetArena() == other->GetArena()) { - InternalSwap(other); - } else { - ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); - } - } - void UnsafeArenaSwap(OpProto_Attr* other) { - if (other == this) return; - GOOGLE_DCHECK(GetArena() == other->GetArena()); - InternalSwap(other); - } - - // implements Message ---------------------------------------------- - - inline OpProto_Attr* New() const final { - return CreateMaybeMessage(nullptr); - } - - OpProto_Attr* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { - return CreateMaybeMessage(arena); - } - void CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; - void MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; - void CopyFrom(const OpProto_Attr& from); - void MergeFrom(const OpProto_Attr& from); - PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; - bool IsInitialized() const final; - - size_t ByteSizeLong() const final; - const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; - ::PROTOBUF_NAMESPACE_ID::uint8* _InternalSerialize( - ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _cached_size_.Get(); } - - private: - inline void SharedCtor(); - inline void SharedDtor(); - void SetCachedSize(int size) const final; - void InternalSwap(OpProto_Attr* other); - friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; - static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { - return "paddle.framework.proto.OpProto.Attr"; - } - protected: - explicit OpProto_Attr(::PROTOBUF_NAMESPACE_ID::Arena* arena); - private: - static void ArenaDtor(void* object); - inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); - public: - - ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - private: - static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_framework_2eproto); - return ::descriptor_table_framework_2eproto.file_level_metadata[kIndexInFileMessages]; - } - - public: - - // nested types ---------------------------------------------------- - - // accessors ------------------------------------------------------- - - enum : int { - kNameFieldNumber = 1, - kCommentFieldNumber = 3, - kTypeFieldNumber = 2, - kGeneratedFieldNumber = 4, - }; - // required string name = 1; - bool has_name() const; - private: - bool _internal_has_name() const; - public: - void clear_name(); - const std::string& name() const; - void set_name(const std::string& value); - void set_name(std::string&& value); - void set_name(const char* value); - void set_name(const char* value, size_t size); - std::string* mutable_name(); - std::string* release_name(); - void set_allocated_name(std::string* name); - private: - const std::string& _internal_name() const; - void _internal_set_name(const std::string& value); - std::string* _internal_mutable_name(); - public: - - // required string comment = 3; - bool has_comment() const; - private: - bool _internal_has_comment() const; - public: - void clear_comment(); - const std::string& comment() const; - void set_comment(const std::string& value); - void set_comment(std::string&& value); - void set_comment(const char* value); - void set_comment(const char* value, size_t size); - std::string* mutable_comment(); - std::string* release_comment(); - void set_allocated_comment(std::string* comment); - private: - const std::string& _internal_comment() const; - void _internal_set_comment(const std::string& value); - std::string* _internal_mutable_comment(); - public: - - // required .paddle.framework.proto.AttrType type = 2; - bool has_type() const; - private: - bool _internal_has_type() const; - public: - void clear_type(); - ::paddle::framework::proto::AttrType type() const; - void set_type(::paddle::framework::proto::AttrType value); - private: - ::paddle::framework::proto::AttrType _internal_type() const; - void _internal_set_type(::paddle::framework::proto::AttrType value); - public: - - // optional bool generated = 4 [default = false]; - bool has_generated() const; - private: - bool _internal_has_generated() const; - public: - void clear_generated(); - bool generated() const; - void set_generated(bool value); - private: - bool _internal_generated() const; - void _internal_set_generated(bool value); - public: - - // @@protoc_insertion_point(class_scope:paddle.framework.proto.OpProto.Attr) - private: - class _Internal; - - // helper for ByteSizeLong() - size_t RequiredFieldsByteSizeFallback() const; - - template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; - typedef void InternalArenaConstructable_; - typedef void DestructorSkippable_; - ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr name_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr comment_; - int type_; - bool generated_; - friend struct ::TableStruct_framework_2eproto; -}; -// ------------------------------------------------------------------- - -class OpProto PROTOBUF_FINAL : - public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:paddle.framework.proto.OpProto) */ { - public: - inline OpProto() : OpProto(nullptr) {} - virtual ~OpProto(); - - OpProto(const OpProto& from); - OpProto(OpProto&& from) noexcept - : OpProto() { - *this = ::std::move(from); - } - - inline OpProto& operator=(const OpProto& from) { - CopyFrom(from); - return *this; - } - inline OpProto& operator=(OpProto&& from) noexcept { - if (GetArena() == from.GetArena()) { - if (this != &from) InternalSwap(&from); - } else { - CopyFrom(from); - } - return *this; - } - - inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { - return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); - } - inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); - } - - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { - return GetDescriptor(); - } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return GetMetadataStatic().descriptor; - } - static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return GetMetadataStatic().reflection; - } - static const OpProto& default_instance(); - - static inline const OpProto* internal_default_instance() { - return reinterpret_cast( - &_OpProto_default_instance_); - } - static constexpr int kIndexInFileMessages = - 6; - - friend void swap(OpProto& a, OpProto& b) { - a.Swap(&b); - } - inline void Swap(OpProto* other) { - if (other == this) return; - if (GetArena() == other->GetArena()) { - InternalSwap(other); - } else { - ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); - } - } - void UnsafeArenaSwap(OpProto* other) { - if (other == this) return; - GOOGLE_DCHECK(GetArena() == other->GetArena()); - InternalSwap(other); - } - - // implements Message ---------------------------------------------- - - inline OpProto* New() const final { - return CreateMaybeMessage(nullptr); - } - - OpProto* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { - return CreateMaybeMessage(arena); - } - void CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; - void MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; - void CopyFrom(const OpProto& from); - void MergeFrom(const OpProto& from); - PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; - bool IsInitialized() const final; - - size_t ByteSizeLong() const final; - const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; - ::PROTOBUF_NAMESPACE_ID::uint8* _InternalSerialize( - ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _cached_size_.Get(); } - - private: - inline void SharedCtor(); - inline void SharedDtor(); - void SetCachedSize(int size) const final; - void InternalSwap(OpProto* other); - friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; - static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { - return "paddle.framework.proto.OpProto"; - } - protected: - explicit OpProto(::PROTOBUF_NAMESPACE_ID::Arena* arena); - private: - static void ArenaDtor(void* object); - inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); - public: - - ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - private: - static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_framework_2eproto); - return ::descriptor_table_framework_2eproto.file_level_metadata[kIndexInFileMessages]; - } - - public: - - // nested types ---------------------------------------------------- - - typedef OpProto_Var Var; - typedef OpProto_Attr Attr; - - // accessors ------------------------------------------------------- - - enum : int { - kInputsFieldNumber = 2, - kOutputsFieldNumber = 3, - kAttrsFieldNumber = 4, - kTypeFieldNumber = 1, - kCommentFieldNumber = 5, - }; - // repeated .paddle.framework.proto.OpProto.Var inputs = 2; - int inputs_size() const; - private: - int _internal_inputs_size() const; - public: - void clear_inputs(); - ::paddle::framework::proto::OpProto_Var* mutable_inputs(int index); - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::OpProto_Var >* - mutable_inputs(); - private: - const ::paddle::framework::proto::OpProto_Var& _internal_inputs(int index) const; - ::paddle::framework::proto::OpProto_Var* _internal_add_inputs(); - public: - const ::paddle::framework::proto::OpProto_Var& inputs(int index) const; - ::paddle::framework::proto::OpProto_Var* add_inputs(); - const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::OpProto_Var >& - inputs() const; - - // repeated .paddle.framework.proto.OpProto.Var outputs = 3; - int outputs_size() const; - private: - int _internal_outputs_size() const; - public: - void clear_outputs(); - ::paddle::framework::proto::OpProto_Var* mutable_outputs(int index); - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::OpProto_Var >* - mutable_outputs(); - private: - const ::paddle::framework::proto::OpProto_Var& _internal_outputs(int index) const; - ::paddle::framework::proto::OpProto_Var* _internal_add_outputs(); - public: - const ::paddle::framework::proto::OpProto_Var& outputs(int index) const; - ::paddle::framework::proto::OpProto_Var* add_outputs(); - const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::OpProto_Var >& - outputs() const; - - // repeated .paddle.framework.proto.OpProto.Attr attrs = 4; - int attrs_size() const; - private: - int _internal_attrs_size() const; - public: - void clear_attrs(); - ::paddle::framework::proto::OpProto_Attr* mutable_attrs(int index); - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::OpProto_Attr >* - mutable_attrs(); - private: - const ::paddle::framework::proto::OpProto_Attr& _internal_attrs(int index) const; - ::paddle::framework::proto::OpProto_Attr* _internal_add_attrs(); - public: - const ::paddle::framework::proto::OpProto_Attr& attrs(int index) const; - ::paddle::framework::proto::OpProto_Attr* add_attrs(); - const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::OpProto_Attr >& - attrs() const; - - // required string type = 1; - bool has_type() const; - private: - bool _internal_has_type() const; - public: - void clear_type(); - const std::string& type() const; - void set_type(const std::string& value); - void set_type(std::string&& value); - void set_type(const char* value); - void set_type(const char* value, size_t size); - std::string* mutable_type(); - std::string* release_type(); - void set_allocated_type(std::string* type); - private: - const std::string& _internal_type() const; - void _internal_set_type(const std::string& value); - std::string* _internal_mutable_type(); - public: - - // required string comment = 5; - bool has_comment() const; - private: - bool _internal_has_comment() const; - public: - void clear_comment(); - const std::string& comment() const; - void set_comment(const std::string& value); - void set_comment(std::string&& value); - void set_comment(const char* value); - void set_comment(const char* value, size_t size); - std::string* mutable_comment(); - std::string* release_comment(); - void set_allocated_comment(std::string* comment); - private: - const std::string& _internal_comment() const; - void _internal_set_comment(const std::string& value); - std::string* _internal_mutable_comment(); - public: - - // @@protoc_insertion_point(class_scope:paddle.framework.proto.OpProto) - private: - class _Internal; - - // helper for ByteSizeLong() - size_t RequiredFieldsByteSizeFallback() const; - - template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; - typedef void InternalArenaConstructable_; - typedef void DestructorSkippable_; - ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::OpProto_Var > inputs_; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::OpProto_Var > outputs_; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::OpProto_Attr > attrs_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr type_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr comment_; - friend struct ::TableStruct_framework_2eproto; -}; -// ------------------------------------------------------------------- - -class VarType_TensorDesc PROTOBUF_FINAL : - public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:paddle.framework.proto.VarType.TensorDesc) */ { - public: - inline VarType_TensorDesc() : VarType_TensorDesc(nullptr) {} - virtual ~VarType_TensorDesc(); - - VarType_TensorDesc(const VarType_TensorDesc& from); - VarType_TensorDesc(VarType_TensorDesc&& from) noexcept - : VarType_TensorDesc() { - *this = ::std::move(from); - } - - inline VarType_TensorDesc& operator=(const VarType_TensorDesc& from) { - CopyFrom(from); - return *this; - } - inline VarType_TensorDesc& operator=(VarType_TensorDesc&& from) noexcept { - if (GetArena() == from.GetArena()) { - if (this != &from) InternalSwap(&from); - } else { - CopyFrom(from); - } - return *this; - } - - inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { - return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); - } - inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); - } - - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { - return GetDescriptor(); - } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return GetMetadataStatic().descriptor; - } - static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return GetMetadataStatic().reflection; - } - static const VarType_TensorDesc& default_instance(); - - static inline const VarType_TensorDesc* internal_default_instance() { - return reinterpret_cast( - &_VarType_TensorDesc_default_instance_); - } - static constexpr int kIndexInFileMessages = - 7; - - friend void swap(VarType_TensorDesc& a, VarType_TensorDesc& b) { - a.Swap(&b); - } - inline void Swap(VarType_TensorDesc* other) { - if (other == this) return; - if (GetArena() == other->GetArena()) { - InternalSwap(other); - } else { - ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); - } - } - void UnsafeArenaSwap(VarType_TensorDesc* other) { - if (other == this) return; - GOOGLE_DCHECK(GetArena() == other->GetArena()); - InternalSwap(other); - } - - // implements Message ---------------------------------------------- - - inline VarType_TensorDesc* New() const final { - return CreateMaybeMessage(nullptr); - } - - VarType_TensorDesc* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { - return CreateMaybeMessage(arena); - } - void CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; - void MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; - void CopyFrom(const VarType_TensorDesc& from); - void MergeFrom(const VarType_TensorDesc& from); - PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; - bool IsInitialized() const final; - - size_t ByteSizeLong() const final; - const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; - ::PROTOBUF_NAMESPACE_ID::uint8* _InternalSerialize( - ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _cached_size_.Get(); } - - private: - inline void SharedCtor(); - inline void SharedDtor(); - void SetCachedSize(int size) const final; - void InternalSwap(VarType_TensorDesc* other); - friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; - static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { - return "paddle.framework.proto.VarType.TensorDesc"; - } - protected: - explicit VarType_TensorDesc(::PROTOBUF_NAMESPACE_ID::Arena* arena); - private: - static void ArenaDtor(void* object); - inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); - public: - - ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - private: - static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_framework_2eproto); - return ::descriptor_table_framework_2eproto.file_level_metadata[kIndexInFileMessages]; - } - - public: - - // nested types ---------------------------------------------------- - - // accessors ------------------------------------------------------- - - enum : int { - kDimsFieldNumber = 2, - kDataTypeFieldNumber = 1, - }; - // repeated int64 dims = 2; - int dims_size() const; - private: - int _internal_dims_size() const; - public: - void clear_dims(); - private: - ::PROTOBUF_NAMESPACE_ID::int64 _internal_dims(int index) const; - const ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int64 >& - _internal_dims() const; - void _internal_add_dims(::PROTOBUF_NAMESPACE_ID::int64 value); - ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int64 >* - _internal_mutable_dims(); - public: - ::PROTOBUF_NAMESPACE_ID::int64 dims(int index) const; - void set_dims(int index, ::PROTOBUF_NAMESPACE_ID::int64 value); - void add_dims(::PROTOBUF_NAMESPACE_ID::int64 value); - const ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int64 >& - dims() const; - ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int64 >* - mutable_dims(); - - // required .paddle.framework.proto.VarType.Type data_type = 1; - bool has_data_type() const; - private: - bool _internal_has_data_type() const; - public: - void clear_data_type(); - ::paddle::framework::proto::VarType_Type data_type() const; - void set_data_type(::paddle::framework::proto::VarType_Type value); - private: - ::paddle::framework::proto::VarType_Type _internal_data_type() const; - void _internal_set_data_type(::paddle::framework::proto::VarType_Type value); - public: - - // @@protoc_insertion_point(class_scope:paddle.framework.proto.VarType.TensorDesc) - private: - class _Internal; - - template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; - typedef void InternalArenaConstructable_; - typedef void DestructorSkippable_; - ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int64 > dims_; - int data_type_; - friend struct ::TableStruct_framework_2eproto; -}; -// ------------------------------------------------------------------- - -class VarType_LoDTensorDesc PROTOBUF_FINAL : - public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:paddle.framework.proto.VarType.LoDTensorDesc) */ { - public: - inline VarType_LoDTensorDesc() : VarType_LoDTensorDesc(nullptr) {} - virtual ~VarType_LoDTensorDesc(); - - VarType_LoDTensorDesc(const VarType_LoDTensorDesc& from); - VarType_LoDTensorDesc(VarType_LoDTensorDesc&& from) noexcept - : VarType_LoDTensorDesc() { - *this = ::std::move(from); - } - - inline VarType_LoDTensorDesc& operator=(const VarType_LoDTensorDesc& from) { - CopyFrom(from); - return *this; - } - inline VarType_LoDTensorDesc& operator=(VarType_LoDTensorDesc&& from) noexcept { - if (GetArena() == from.GetArena()) { - if (this != &from) InternalSwap(&from); - } else { - CopyFrom(from); - } - return *this; - } - - inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { - return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); - } - inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); - } - - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { - return GetDescriptor(); - } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return GetMetadataStatic().descriptor; - } - static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return GetMetadataStatic().reflection; - } - static const VarType_LoDTensorDesc& default_instance(); - - static inline const VarType_LoDTensorDesc* internal_default_instance() { - return reinterpret_cast( - &_VarType_LoDTensorDesc_default_instance_); - } - static constexpr int kIndexInFileMessages = - 8; - - friend void swap(VarType_LoDTensorDesc& a, VarType_LoDTensorDesc& b) { - a.Swap(&b); - } - inline void Swap(VarType_LoDTensorDesc* other) { - if (other == this) return; - if (GetArena() == other->GetArena()) { - InternalSwap(other); - } else { - ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); - } - } - void UnsafeArenaSwap(VarType_LoDTensorDesc* other) { - if (other == this) return; - GOOGLE_DCHECK(GetArena() == other->GetArena()); - InternalSwap(other); - } - - // implements Message ---------------------------------------------- - - inline VarType_LoDTensorDesc* New() const final { - return CreateMaybeMessage(nullptr); - } - - VarType_LoDTensorDesc* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { - return CreateMaybeMessage(arena); - } - void CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; - void MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; - void CopyFrom(const VarType_LoDTensorDesc& from); - void MergeFrom(const VarType_LoDTensorDesc& from); - PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; - bool IsInitialized() const final; - - size_t ByteSizeLong() const final; - const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; - ::PROTOBUF_NAMESPACE_ID::uint8* _InternalSerialize( - ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _cached_size_.Get(); } - - private: - inline void SharedCtor(); - inline void SharedDtor(); - void SetCachedSize(int size) const final; - void InternalSwap(VarType_LoDTensorDesc* other); - friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; - static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { - return "paddle.framework.proto.VarType.LoDTensorDesc"; - } - protected: - explicit VarType_LoDTensorDesc(::PROTOBUF_NAMESPACE_ID::Arena* arena); - private: - static void ArenaDtor(void* object); - inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); - public: - - ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - private: - static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_framework_2eproto); - return ::descriptor_table_framework_2eproto.file_level_metadata[kIndexInFileMessages]; - } - - public: - - // nested types ---------------------------------------------------- - - // accessors ------------------------------------------------------- - - enum : int { - kTensorFieldNumber = 1, - kLodLevelFieldNumber = 2, - }; - // required .paddle.framework.proto.VarType.TensorDesc tensor = 1; - bool has_tensor() const; - private: - bool _internal_has_tensor() const; - public: - void clear_tensor(); - const ::paddle::framework::proto::VarType_TensorDesc& tensor() const; - ::paddle::framework::proto::VarType_TensorDesc* release_tensor(); - ::paddle::framework::proto::VarType_TensorDesc* mutable_tensor(); - void set_allocated_tensor(::paddle::framework::proto::VarType_TensorDesc* tensor); - private: - const ::paddle::framework::proto::VarType_TensorDesc& _internal_tensor() const; - ::paddle::framework::proto::VarType_TensorDesc* _internal_mutable_tensor(); - public: - void unsafe_arena_set_allocated_tensor( - ::paddle::framework::proto::VarType_TensorDesc* tensor); - ::paddle::framework::proto::VarType_TensorDesc* unsafe_arena_release_tensor(); - - // optional int32 lod_level = 2 [default = 0]; - bool has_lod_level() const; - private: - bool _internal_has_lod_level() const; - public: - void clear_lod_level(); - ::PROTOBUF_NAMESPACE_ID::int32 lod_level() const; - void set_lod_level(::PROTOBUF_NAMESPACE_ID::int32 value); - private: - ::PROTOBUF_NAMESPACE_ID::int32 _internal_lod_level() const; - void _internal_set_lod_level(::PROTOBUF_NAMESPACE_ID::int32 value); - public: - - // @@protoc_insertion_point(class_scope:paddle.framework.proto.VarType.LoDTensorDesc) - private: - class _Internal; - - template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; - typedef void InternalArenaConstructable_; - typedef void DestructorSkippable_; - ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::paddle::framework::proto::VarType_TensorDesc* tensor_; - ::PROTOBUF_NAMESPACE_ID::int32 lod_level_; - friend struct ::TableStruct_framework_2eproto; -}; -// ------------------------------------------------------------------- - -class VarType_LoDTensorArrayDesc PROTOBUF_FINAL : - public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:paddle.framework.proto.VarType.LoDTensorArrayDesc) */ { - public: - inline VarType_LoDTensorArrayDesc() : VarType_LoDTensorArrayDesc(nullptr) {} - virtual ~VarType_LoDTensorArrayDesc(); - - VarType_LoDTensorArrayDesc(const VarType_LoDTensorArrayDesc& from); - VarType_LoDTensorArrayDesc(VarType_LoDTensorArrayDesc&& from) noexcept - : VarType_LoDTensorArrayDesc() { - *this = ::std::move(from); - } - - inline VarType_LoDTensorArrayDesc& operator=(const VarType_LoDTensorArrayDesc& from) { - CopyFrom(from); - return *this; - } - inline VarType_LoDTensorArrayDesc& operator=(VarType_LoDTensorArrayDesc&& from) noexcept { - if (GetArena() == from.GetArena()) { - if (this != &from) InternalSwap(&from); - } else { - CopyFrom(from); - } - return *this; - } - - inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { - return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); - } - inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); - } - - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { - return GetDescriptor(); - } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return GetMetadataStatic().descriptor; - } - static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return GetMetadataStatic().reflection; - } - static const VarType_LoDTensorArrayDesc& default_instance(); - - static inline const VarType_LoDTensorArrayDesc* internal_default_instance() { - return reinterpret_cast( - &_VarType_LoDTensorArrayDesc_default_instance_); - } - static constexpr int kIndexInFileMessages = - 9; - - friend void swap(VarType_LoDTensorArrayDesc& a, VarType_LoDTensorArrayDesc& b) { - a.Swap(&b); - } - inline void Swap(VarType_LoDTensorArrayDesc* other) { - if (other == this) return; - if (GetArena() == other->GetArena()) { - InternalSwap(other); - } else { - ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); - } - } - void UnsafeArenaSwap(VarType_LoDTensorArrayDesc* other) { - if (other == this) return; - GOOGLE_DCHECK(GetArena() == other->GetArena()); - InternalSwap(other); - } - - // implements Message ---------------------------------------------- - - inline VarType_LoDTensorArrayDesc* New() const final { - return CreateMaybeMessage(nullptr); - } - - VarType_LoDTensorArrayDesc* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { - return CreateMaybeMessage(arena); - } - void CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; - void MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; - void CopyFrom(const VarType_LoDTensorArrayDesc& from); - void MergeFrom(const VarType_LoDTensorArrayDesc& from); - PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; - bool IsInitialized() const final; - - size_t ByteSizeLong() const final; - const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; - ::PROTOBUF_NAMESPACE_ID::uint8* _InternalSerialize( - ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _cached_size_.Get(); } - - private: - inline void SharedCtor(); - inline void SharedDtor(); - void SetCachedSize(int size) const final; - void InternalSwap(VarType_LoDTensorArrayDesc* other); - friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; - static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { - return "paddle.framework.proto.VarType.LoDTensorArrayDesc"; - } - protected: - explicit VarType_LoDTensorArrayDesc(::PROTOBUF_NAMESPACE_ID::Arena* arena); - private: - static void ArenaDtor(void* object); - inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); - public: - - ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - private: - static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_framework_2eproto); - return ::descriptor_table_framework_2eproto.file_level_metadata[kIndexInFileMessages]; - } - - public: - - // nested types ---------------------------------------------------- - - // accessors ------------------------------------------------------- - - enum : int { - kTensorFieldNumber = 1, - kLodLevelFieldNumber = 2, - }; - // required .paddle.framework.proto.VarType.TensorDesc tensor = 1; - bool has_tensor() const; - private: - bool _internal_has_tensor() const; - public: - void clear_tensor(); - const ::paddle::framework::proto::VarType_TensorDesc& tensor() const; - ::paddle::framework::proto::VarType_TensorDesc* release_tensor(); - ::paddle::framework::proto::VarType_TensorDesc* mutable_tensor(); - void set_allocated_tensor(::paddle::framework::proto::VarType_TensorDesc* tensor); - private: - const ::paddle::framework::proto::VarType_TensorDesc& _internal_tensor() const; - ::paddle::framework::proto::VarType_TensorDesc* _internal_mutable_tensor(); - public: - void unsafe_arena_set_allocated_tensor( - ::paddle::framework::proto::VarType_TensorDesc* tensor); - ::paddle::framework::proto::VarType_TensorDesc* unsafe_arena_release_tensor(); - - // optional int32 lod_level = 2 [default = 0]; - bool has_lod_level() const; - private: - bool _internal_has_lod_level() const; - public: - void clear_lod_level(); - ::PROTOBUF_NAMESPACE_ID::int32 lod_level() const; - void set_lod_level(::PROTOBUF_NAMESPACE_ID::int32 value); - private: - ::PROTOBUF_NAMESPACE_ID::int32 _internal_lod_level() const; - void _internal_set_lod_level(::PROTOBUF_NAMESPACE_ID::int32 value); - public: - - // @@protoc_insertion_point(class_scope:paddle.framework.proto.VarType.LoDTensorArrayDesc) - private: - class _Internal; - - template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; - typedef void InternalArenaConstructable_; - typedef void DestructorSkippable_; - ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::paddle::framework::proto::VarType_TensorDesc* tensor_; - ::PROTOBUF_NAMESPACE_ID::int32 lod_level_; - friend struct ::TableStruct_framework_2eproto; -}; -// ------------------------------------------------------------------- - -class VarType_ReaderDesc PROTOBUF_FINAL : - public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:paddle.framework.proto.VarType.ReaderDesc) */ { - public: - inline VarType_ReaderDesc() : VarType_ReaderDesc(nullptr) {} - virtual ~VarType_ReaderDesc(); - - VarType_ReaderDesc(const VarType_ReaderDesc& from); - VarType_ReaderDesc(VarType_ReaderDesc&& from) noexcept - : VarType_ReaderDesc() { - *this = ::std::move(from); - } - - inline VarType_ReaderDesc& operator=(const VarType_ReaderDesc& from) { - CopyFrom(from); - return *this; - } - inline VarType_ReaderDesc& operator=(VarType_ReaderDesc&& from) noexcept { - if (GetArena() == from.GetArena()) { - if (this != &from) InternalSwap(&from); - } else { - CopyFrom(from); - } - return *this; - } - - inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { - return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); - } - inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); - } - - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { - return GetDescriptor(); - } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return GetMetadataStatic().descriptor; - } - static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return GetMetadataStatic().reflection; - } - static const VarType_ReaderDesc& default_instance(); - - static inline const VarType_ReaderDesc* internal_default_instance() { - return reinterpret_cast( - &_VarType_ReaderDesc_default_instance_); - } - static constexpr int kIndexInFileMessages = - 10; - - friend void swap(VarType_ReaderDesc& a, VarType_ReaderDesc& b) { - a.Swap(&b); - } - inline void Swap(VarType_ReaderDesc* other) { - if (other == this) return; - if (GetArena() == other->GetArena()) { - InternalSwap(other); - } else { - ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); - } - } - void UnsafeArenaSwap(VarType_ReaderDesc* other) { - if (other == this) return; - GOOGLE_DCHECK(GetArena() == other->GetArena()); - InternalSwap(other); - } - - // implements Message ---------------------------------------------- - - inline VarType_ReaderDesc* New() const final { - return CreateMaybeMessage(nullptr); - } - - VarType_ReaderDesc* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { - return CreateMaybeMessage(arena); - } - void CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; - void MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; - void CopyFrom(const VarType_ReaderDesc& from); - void MergeFrom(const VarType_ReaderDesc& from); - PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; - bool IsInitialized() const final; - - size_t ByteSizeLong() const final; - const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; - ::PROTOBUF_NAMESPACE_ID::uint8* _InternalSerialize( - ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _cached_size_.Get(); } - - private: - inline void SharedCtor(); - inline void SharedDtor(); - void SetCachedSize(int size) const final; - void InternalSwap(VarType_ReaderDesc* other); - friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; - static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { - return "paddle.framework.proto.VarType.ReaderDesc"; - } - protected: - explicit VarType_ReaderDesc(::PROTOBUF_NAMESPACE_ID::Arena* arena); - private: - static void ArenaDtor(void* object); - inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); - public: - - ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - private: - static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_framework_2eproto); - return ::descriptor_table_framework_2eproto.file_level_metadata[kIndexInFileMessages]; - } - - public: - - // nested types ---------------------------------------------------- - - // accessors ------------------------------------------------------- - - enum : int { - kLodTensorFieldNumber = 1, - }; - // repeated .paddle.framework.proto.VarType.LoDTensorDesc lod_tensor = 1; - int lod_tensor_size() const; - private: - int _internal_lod_tensor_size() const; - public: - void clear_lod_tensor(); - ::paddle::framework::proto::VarType_LoDTensorDesc* mutable_lod_tensor(int index); - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::VarType_LoDTensorDesc >* - mutable_lod_tensor(); - private: - const ::paddle::framework::proto::VarType_LoDTensorDesc& _internal_lod_tensor(int index) const; - ::paddle::framework::proto::VarType_LoDTensorDesc* _internal_add_lod_tensor(); - public: - const ::paddle::framework::proto::VarType_LoDTensorDesc& lod_tensor(int index) const; - ::paddle::framework::proto::VarType_LoDTensorDesc* add_lod_tensor(); - const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::VarType_LoDTensorDesc >& - lod_tensor() const; - - // @@protoc_insertion_point(class_scope:paddle.framework.proto.VarType.ReaderDesc) - private: - class _Internal; - - template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; - typedef void InternalArenaConstructable_; - typedef void DestructorSkippable_; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::VarType_LoDTensorDesc > lod_tensor_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - friend struct ::TableStruct_framework_2eproto; -}; -// ------------------------------------------------------------------- - -class VarType_Tuple PROTOBUF_FINAL : - public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:paddle.framework.proto.VarType.Tuple) */ { - public: - inline VarType_Tuple() : VarType_Tuple(nullptr) {} - virtual ~VarType_Tuple(); - - VarType_Tuple(const VarType_Tuple& from); - VarType_Tuple(VarType_Tuple&& from) noexcept - : VarType_Tuple() { - *this = ::std::move(from); - } - - inline VarType_Tuple& operator=(const VarType_Tuple& from) { - CopyFrom(from); - return *this; - } - inline VarType_Tuple& operator=(VarType_Tuple&& from) noexcept { - if (GetArena() == from.GetArena()) { - if (this != &from) InternalSwap(&from); - } else { - CopyFrom(from); - } - return *this; - } - - inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { - return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); - } - inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); - } - - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { - return GetDescriptor(); - } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return GetMetadataStatic().descriptor; - } - static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return GetMetadataStatic().reflection; - } - static const VarType_Tuple& default_instance(); - - static inline const VarType_Tuple* internal_default_instance() { - return reinterpret_cast( - &_VarType_Tuple_default_instance_); - } - static constexpr int kIndexInFileMessages = - 11; - - friend void swap(VarType_Tuple& a, VarType_Tuple& b) { - a.Swap(&b); - } - inline void Swap(VarType_Tuple* other) { - if (other == this) return; - if (GetArena() == other->GetArena()) { - InternalSwap(other); - } else { - ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); - } - } - void UnsafeArenaSwap(VarType_Tuple* other) { - if (other == this) return; - GOOGLE_DCHECK(GetArena() == other->GetArena()); - InternalSwap(other); - } - - // implements Message ---------------------------------------------- - - inline VarType_Tuple* New() const final { - return CreateMaybeMessage(nullptr); - } - - VarType_Tuple* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { - return CreateMaybeMessage(arena); - } - void CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; - void MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; - void CopyFrom(const VarType_Tuple& from); - void MergeFrom(const VarType_Tuple& from); - PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; - bool IsInitialized() const final; - - size_t ByteSizeLong() const final; - const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; - ::PROTOBUF_NAMESPACE_ID::uint8* _InternalSerialize( - ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _cached_size_.Get(); } - - private: - inline void SharedCtor(); - inline void SharedDtor(); - void SetCachedSize(int size) const final; - void InternalSwap(VarType_Tuple* other); - friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; - static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { - return "paddle.framework.proto.VarType.Tuple"; - } - protected: - explicit VarType_Tuple(::PROTOBUF_NAMESPACE_ID::Arena* arena); - private: - static void ArenaDtor(void* object); - inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); - public: - - ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - private: - static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_framework_2eproto); - return ::descriptor_table_framework_2eproto.file_level_metadata[kIndexInFileMessages]; - } - - public: - - // nested types ---------------------------------------------------- - - // accessors ------------------------------------------------------- - - enum : int { - kElementTypeFieldNumber = 1, - }; - // repeated .paddle.framework.proto.VarType.Type element_type = 1; - int element_type_size() const; - private: - int _internal_element_type_size() const; - public: - void clear_element_type(); - private: - ::paddle::framework::proto::VarType_Type _internal_element_type(int index) const; - void _internal_add_element_type(::paddle::framework::proto::VarType_Type value); - ::PROTOBUF_NAMESPACE_ID::RepeatedField* _internal_mutable_element_type(); - public: - ::paddle::framework::proto::VarType_Type element_type(int index) const; - void set_element_type(int index, ::paddle::framework::proto::VarType_Type value); - void add_element_type(::paddle::framework::proto::VarType_Type value); - const ::PROTOBUF_NAMESPACE_ID::RepeatedField& element_type() const; - ::PROTOBUF_NAMESPACE_ID::RepeatedField* mutable_element_type(); - - // @@protoc_insertion_point(class_scope:paddle.framework.proto.VarType.Tuple) - private: - class _Internal; - - template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; - typedef void InternalArenaConstructable_; - typedef void DestructorSkippable_; - ::PROTOBUF_NAMESPACE_ID::RepeatedField element_type_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - friend struct ::TableStruct_framework_2eproto; -}; -// ------------------------------------------------------------------- - -class VarType PROTOBUF_FINAL : - public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:paddle.framework.proto.VarType) */ { - public: - inline VarType() : VarType(nullptr) {} - virtual ~VarType(); - - VarType(const VarType& from); - VarType(VarType&& from) noexcept - : VarType() { - *this = ::std::move(from); - } - - inline VarType& operator=(const VarType& from) { - CopyFrom(from); - return *this; - } - inline VarType& operator=(VarType&& from) noexcept { - if (GetArena() == from.GetArena()) { - if (this != &from) InternalSwap(&from); - } else { - CopyFrom(from); - } - return *this; - } - - inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { - return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); - } - inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); - } - - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { - return GetDescriptor(); - } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return GetMetadataStatic().descriptor; - } - static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return GetMetadataStatic().reflection; - } - static const VarType& default_instance(); - - static inline const VarType* internal_default_instance() { - return reinterpret_cast( - &_VarType_default_instance_); - } - static constexpr int kIndexInFileMessages = - 12; - - friend void swap(VarType& a, VarType& b) { - a.Swap(&b); - } - inline void Swap(VarType* other) { - if (other == this) return; - if (GetArena() == other->GetArena()) { - InternalSwap(other); - } else { - ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); - } - } - void UnsafeArenaSwap(VarType* other) { - if (other == this) return; - GOOGLE_DCHECK(GetArena() == other->GetArena()); - InternalSwap(other); - } - - // implements Message ---------------------------------------------- - - inline VarType* New() const final { - return CreateMaybeMessage(nullptr); - } - - VarType* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { - return CreateMaybeMessage(arena); - } - void CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; - void MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; - void CopyFrom(const VarType& from); - void MergeFrom(const VarType& from); - PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; - bool IsInitialized() const final; - - size_t ByteSizeLong() const final; - const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; - ::PROTOBUF_NAMESPACE_ID::uint8* _InternalSerialize( - ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _cached_size_.Get(); } - - private: - inline void SharedCtor(); - inline void SharedDtor(); - void SetCachedSize(int size) const final; - void InternalSwap(VarType* other); - friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; - static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { - return "paddle.framework.proto.VarType"; - } - protected: - explicit VarType(::PROTOBUF_NAMESPACE_ID::Arena* arena); - private: - static void ArenaDtor(void* object); - inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); - public: - - ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - private: - static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_framework_2eproto); - return ::descriptor_table_framework_2eproto.file_level_metadata[kIndexInFileMessages]; - } - - public: - - // nested types ---------------------------------------------------- - - typedef VarType_TensorDesc TensorDesc; - typedef VarType_LoDTensorDesc LoDTensorDesc; - typedef VarType_LoDTensorArrayDesc LoDTensorArrayDesc; - typedef VarType_ReaderDesc ReaderDesc; - typedef VarType_Tuple Tuple; - - typedef VarType_Type Type; - static constexpr Type BOOL = - VarType_Type_BOOL; - static constexpr Type INT16 = - VarType_Type_INT16; - static constexpr Type INT32 = - VarType_Type_INT32; - static constexpr Type INT64 = - VarType_Type_INT64; - static constexpr Type FP16 = - VarType_Type_FP16; - static constexpr Type FP32 = - VarType_Type_FP32; - static constexpr Type FP64 = - VarType_Type_FP64; - static constexpr Type SIZE_T = - VarType_Type_SIZE_T; - static constexpr Type UINT8 = - VarType_Type_UINT8; - static constexpr Type INT8 = - VarType_Type_INT8; - static constexpr Type BF16 = - VarType_Type_BF16; - static constexpr Type COMPLEX64 = - VarType_Type_COMPLEX64; - static constexpr Type COMPLEX128 = - VarType_Type_COMPLEX128; - static constexpr Type LOD_TENSOR = - VarType_Type_LOD_TENSOR; - static constexpr Type SELECTED_ROWS = - VarType_Type_SELECTED_ROWS; - static constexpr Type FEED_MINIBATCH = - VarType_Type_FEED_MINIBATCH; - static constexpr Type FETCH_LIST = - VarType_Type_FETCH_LIST; - static constexpr Type STEP_SCOPES = - VarType_Type_STEP_SCOPES; - static constexpr Type LOD_RANK_TABLE = - VarType_Type_LOD_RANK_TABLE; - static constexpr Type LOD_TENSOR_ARRAY = - VarType_Type_LOD_TENSOR_ARRAY; - static constexpr Type PLACE_LIST = - VarType_Type_PLACE_LIST; - static constexpr Type READER = - VarType_Type_READER; - static constexpr Type RAW = - VarType_Type_RAW; - static constexpr Type TUPLE = - VarType_Type_TUPLE; - static inline bool Type_IsValid(int value) { - return VarType_Type_IsValid(value); - } - static constexpr Type Type_MIN = - VarType_Type_Type_MIN; - static constexpr Type Type_MAX = - VarType_Type_Type_MAX; - static constexpr int Type_ARRAYSIZE = - VarType_Type_Type_ARRAYSIZE; - static inline const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* - Type_descriptor() { - return VarType_Type_descriptor(); - } - template - static inline const std::string& Type_Name(T enum_t_value) { - static_assert(::std::is_same::value || - ::std::is_integral::value, - "Incorrect type passed to function Type_Name."); - return VarType_Type_Name(enum_t_value); - } - static inline bool Type_Parse(::PROTOBUF_NAMESPACE_ID::ConstStringParam name, - Type* value) { - return VarType_Type_Parse(name, value); - } - - // accessors ------------------------------------------------------- - - enum : int { - kSelectedRowsFieldNumber = 2, - kLodTensorFieldNumber = 3, - kTensorArrayFieldNumber = 4, - kReaderFieldNumber = 5, - kTupleFieldNumber = 7, - kTypeFieldNumber = 1, - }; - // optional .paddle.framework.proto.VarType.TensorDesc selected_rows = 2; - bool has_selected_rows() const; - private: - bool _internal_has_selected_rows() const; - public: - void clear_selected_rows(); - const ::paddle::framework::proto::VarType_TensorDesc& selected_rows() const; - ::paddle::framework::proto::VarType_TensorDesc* release_selected_rows(); - ::paddle::framework::proto::VarType_TensorDesc* mutable_selected_rows(); - void set_allocated_selected_rows(::paddle::framework::proto::VarType_TensorDesc* selected_rows); - private: - const ::paddle::framework::proto::VarType_TensorDesc& _internal_selected_rows() const; - ::paddle::framework::proto::VarType_TensorDesc* _internal_mutable_selected_rows(); - public: - void unsafe_arena_set_allocated_selected_rows( - ::paddle::framework::proto::VarType_TensorDesc* selected_rows); - ::paddle::framework::proto::VarType_TensorDesc* unsafe_arena_release_selected_rows(); - - // optional .paddle.framework.proto.VarType.LoDTensorDesc lod_tensor = 3; - bool has_lod_tensor() const; - private: - bool _internal_has_lod_tensor() const; - public: - void clear_lod_tensor(); - const ::paddle::framework::proto::VarType_LoDTensorDesc& lod_tensor() const; - ::paddle::framework::proto::VarType_LoDTensorDesc* release_lod_tensor(); - ::paddle::framework::proto::VarType_LoDTensorDesc* mutable_lod_tensor(); - void set_allocated_lod_tensor(::paddle::framework::proto::VarType_LoDTensorDesc* lod_tensor); - private: - const ::paddle::framework::proto::VarType_LoDTensorDesc& _internal_lod_tensor() const; - ::paddle::framework::proto::VarType_LoDTensorDesc* _internal_mutable_lod_tensor(); - public: - void unsafe_arena_set_allocated_lod_tensor( - ::paddle::framework::proto::VarType_LoDTensorDesc* lod_tensor); - ::paddle::framework::proto::VarType_LoDTensorDesc* unsafe_arena_release_lod_tensor(); - - // optional .paddle.framework.proto.VarType.LoDTensorArrayDesc tensor_array = 4; - bool has_tensor_array() const; - private: - bool _internal_has_tensor_array() const; - public: - void clear_tensor_array(); - const ::paddle::framework::proto::VarType_LoDTensorArrayDesc& tensor_array() const; - ::paddle::framework::proto::VarType_LoDTensorArrayDesc* release_tensor_array(); - ::paddle::framework::proto::VarType_LoDTensorArrayDesc* mutable_tensor_array(); - void set_allocated_tensor_array(::paddle::framework::proto::VarType_LoDTensorArrayDesc* tensor_array); - private: - const ::paddle::framework::proto::VarType_LoDTensorArrayDesc& _internal_tensor_array() const; - ::paddle::framework::proto::VarType_LoDTensorArrayDesc* _internal_mutable_tensor_array(); - public: - void unsafe_arena_set_allocated_tensor_array( - ::paddle::framework::proto::VarType_LoDTensorArrayDesc* tensor_array); - ::paddle::framework::proto::VarType_LoDTensorArrayDesc* unsafe_arena_release_tensor_array(); - - // optional .paddle.framework.proto.VarType.ReaderDesc reader = 5; - bool has_reader() const; - private: - bool _internal_has_reader() const; - public: - void clear_reader(); - const ::paddle::framework::proto::VarType_ReaderDesc& reader() const; - ::paddle::framework::proto::VarType_ReaderDesc* release_reader(); - ::paddle::framework::proto::VarType_ReaderDesc* mutable_reader(); - void set_allocated_reader(::paddle::framework::proto::VarType_ReaderDesc* reader); - private: - const ::paddle::framework::proto::VarType_ReaderDesc& _internal_reader() const; - ::paddle::framework::proto::VarType_ReaderDesc* _internal_mutable_reader(); - public: - void unsafe_arena_set_allocated_reader( - ::paddle::framework::proto::VarType_ReaderDesc* reader); - ::paddle::framework::proto::VarType_ReaderDesc* unsafe_arena_release_reader(); - - // optional .paddle.framework.proto.VarType.Tuple tuple = 7; - bool has_tuple() const; - private: - bool _internal_has_tuple() const; - public: - void clear_tuple(); - const ::paddle::framework::proto::VarType_Tuple& tuple() const; - ::paddle::framework::proto::VarType_Tuple* release_tuple(); - ::paddle::framework::proto::VarType_Tuple* mutable_tuple(); - void set_allocated_tuple(::paddle::framework::proto::VarType_Tuple* tuple); - private: - const ::paddle::framework::proto::VarType_Tuple& _internal_tuple() const; - ::paddle::framework::proto::VarType_Tuple* _internal_mutable_tuple(); - public: - void unsafe_arena_set_allocated_tuple( - ::paddle::framework::proto::VarType_Tuple* tuple); - ::paddle::framework::proto::VarType_Tuple* unsafe_arena_release_tuple(); - - // required .paddle.framework.proto.VarType.Type type = 1; - bool has_type() const; - private: - bool _internal_has_type() const; - public: - void clear_type(); - ::paddle::framework::proto::VarType_Type type() const; - void set_type(::paddle::framework::proto::VarType_Type value); - private: - ::paddle::framework::proto::VarType_Type _internal_type() const; - void _internal_set_type(::paddle::framework::proto::VarType_Type value); - public: - - // @@protoc_insertion_point(class_scope:paddle.framework.proto.VarType) - private: - class _Internal; - - template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; - typedef void InternalArenaConstructable_; - typedef void DestructorSkippable_; - ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::paddle::framework::proto::VarType_TensorDesc* selected_rows_; - ::paddle::framework::proto::VarType_LoDTensorDesc* lod_tensor_; - ::paddle::framework::proto::VarType_LoDTensorArrayDesc* tensor_array_; - ::paddle::framework::proto::VarType_ReaderDesc* reader_; - ::paddle::framework::proto::VarType_Tuple* tuple_; - int type_; - friend struct ::TableStruct_framework_2eproto; -}; -// ------------------------------------------------------------------- - -class VarDesc PROTOBUF_FINAL : - public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:paddle.framework.proto.VarDesc) */ { - public: - inline VarDesc() : VarDesc(nullptr) {} - virtual ~VarDesc(); - - VarDesc(const VarDesc& from); - VarDesc(VarDesc&& from) noexcept - : VarDesc() { - *this = ::std::move(from); - } - - inline VarDesc& operator=(const VarDesc& from) { - CopyFrom(from); - return *this; - } - inline VarDesc& operator=(VarDesc&& from) noexcept { - if (GetArena() == from.GetArena()) { - if (this != &from) InternalSwap(&from); - } else { - CopyFrom(from); - } - return *this; - } - - inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { - return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); - } - inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); - } - - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { - return GetDescriptor(); - } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return GetMetadataStatic().descriptor; - } - static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return GetMetadataStatic().reflection; - } - static const VarDesc& default_instance(); - - static inline const VarDesc* internal_default_instance() { - return reinterpret_cast( - &_VarDesc_default_instance_); - } - static constexpr int kIndexInFileMessages = - 13; - - friend void swap(VarDesc& a, VarDesc& b) { - a.Swap(&b); - } - inline void Swap(VarDesc* other) { - if (other == this) return; - if (GetArena() == other->GetArena()) { - InternalSwap(other); - } else { - ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); - } - } - void UnsafeArenaSwap(VarDesc* other) { - if (other == this) return; - GOOGLE_DCHECK(GetArena() == other->GetArena()); - InternalSwap(other); - } - - // implements Message ---------------------------------------------- - - inline VarDesc* New() const final { - return CreateMaybeMessage(nullptr); - } - - VarDesc* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { - return CreateMaybeMessage(arena); - } - void CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; - void MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; - void CopyFrom(const VarDesc& from); - void MergeFrom(const VarDesc& from); - PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; - bool IsInitialized() const final; - - size_t ByteSizeLong() const final; - const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; - ::PROTOBUF_NAMESPACE_ID::uint8* _InternalSerialize( - ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _cached_size_.Get(); } - - private: - inline void SharedCtor(); - inline void SharedDtor(); - void SetCachedSize(int size) const final; - void InternalSwap(VarDesc* other); - friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; - static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { - return "paddle.framework.proto.VarDesc"; - } - protected: - explicit VarDesc(::PROTOBUF_NAMESPACE_ID::Arena* arena); - private: - static void ArenaDtor(void* object); - inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); - public: - - ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - private: - static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_framework_2eproto); - return ::descriptor_table_framework_2eproto.file_level_metadata[kIndexInFileMessages]; - } - - public: - - // nested types ---------------------------------------------------- - - // accessors ------------------------------------------------------- - - enum : int { - kNameFieldNumber = 1, - kTypeFieldNumber = 2, - kPersistableFieldNumber = 3, - kNeedCheckFeedFieldNumber = 4, - }; - // required string name = 1; - bool has_name() const; - private: - bool _internal_has_name() const; - public: - void clear_name(); - const std::string& name() const; - void set_name(const std::string& value); - void set_name(std::string&& value); - void set_name(const char* value); - void set_name(const char* value, size_t size); - std::string* mutable_name(); - std::string* release_name(); - void set_allocated_name(std::string* name); - private: - const std::string& _internal_name() const; - void _internal_set_name(const std::string& value); - std::string* _internal_mutable_name(); - public: - - // required .paddle.framework.proto.VarType type = 2; - bool has_type() const; - private: - bool _internal_has_type() const; - public: - void clear_type(); - const ::paddle::framework::proto::VarType& type() const; - ::paddle::framework::proto::VarType* release_type(); - ::paddle::framework::proto::VarType* mutable_type(); - void set_allocated_type(::paddle::framework::proto::VarType* type); - private: - const ::paddle::framework::proto::VarType& _internal_type() const; - ::paddle::framework::proto::VarType* _internal_mutable_type(); - public: - void unsafe_arena_set_allocated_type( - ::paddle::framework::proto::VarType* type); - ::paddle::framework::proto::VarType* unsafe_arena_release_type(); - - // optional bool persistable = 3 [default = false]; - bool has_persistable() const; - private: - bool _internal_has_persistable() const; - public: - void clear_persistable(); - bool persistable() const; - void set_persistable(bool value); - private: - bool _internal_persistable() const; - void _internal_set_persistable(bool value); - public: - - // optional bool need_check_feed = 4 [default = false]; - bool has_need_check_feed() const; - private: - bool _internal_has_need_check_feed() const; - public: - void clear_need_check_feed(); - bool need_check_feed() const; - void set_need_check_feed(bool value); - private: - bool _internal_need_check_feed() const; - void _internal_set_need_check_feed(bool value); - public: - - // @@protoc_insertion_point(class_scope:paddle.framework.proto.VarDesc) - private: - class _Internal; - - // helper for ByteSizeLong() - size_t RequiredFieldsByteSizeFallback() const; - - template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; - typedef void InternalArenaConstructable_; - typedef void DestructorSkippable_; - ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr name_; - ::paddle::framework::proto::VarType* type_; - bool persistable_; - bool need_check_feed_; - friend struct ::TableStruct_framework_2eproto; -}; -// ------------------------------------------------------------------- - -class BlockDesc PROTOBUF_FINAL : - public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:paddle.framework.proto.BlockDesc) */ { - public: - inline BlockDesc() : BlockDesc(nullptr) {} - virtual ~BlockDesc(); - - BlockDesc(const BlockDesc& from); - BlockDesc(BlockDesc&& from) noexcept - : BlockDesc() { - *this = ::std::move(from); - } - - inline BlockDesc& operator=(const BlockDesc& from) { - CopyFrom(from); - return *this; - } - inline BlockDesc& operator=(BlockDesc&& from) noexcept { - if (GetArena() == from.GetArena()) { - if (this != &from) InternalSwap(&from); - } else { - CopyFrom(from); - } - return *this; - } - - inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { - return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); - } - inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); - } - - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { - return GetDescriptor(); - } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return GetMetadataStatic().descriptor; - } - static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return GetMetadataStatic().reflection; - } - static const BlockDesc& default_instance(); - - static inline const BlockDesc* internal_default_instance() { - return reinterpret_cast( - &_BlockDesc_default_instance_); - } - static constexpr int kIndexInFileMessages = - 14; - - friend void swap(BlockDesc& a, BlockDesc& b) { - a.Swap(&b); - } - inline void Swap(BlockDesc* other) { - if (other == this) return; - if (GetArena() == other->GetArena()) { - InternalSwap(other); - } else { - ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); - } - } - void UnsafeArenaSwap(BlockDesc* other) { - if (other == this) return; - GOOGLE_DCHECK(GetArena() == other->GetArena()); - InternalSwap(other); - } - - // implements Message ---------------------------------------------- - - inline BlockDesc* New() const final { - return CreateMaybeMessage(nullptr); - } - - BlockDesc* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { - return CreateMaybeMessage(arena); - } - void CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; - void MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; - void CopyFrom(const BlockDesc& from); - void MergeFrom(const BlockDesc& from); - PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; - bool IsInitialized() const final; - - size_t ByteSizeLong() const final; - const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; - ::PROTOBUF_NAMESPACE_ID::uint8* _InternalSerialize( - ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _cached_size_.Get(); } - - private: - inline void SharedCtor(); - inline void SharedDtor(); - void SetCachedSize(int size) const final; - void InternalSwap(BlockDesc* other); - friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; - static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { - return "paddle.framework.proto.BlockDesc"; - } - protected: - explicit BlockDesc(::PROTOBUF_NAMESPACE_ID::Arena* arena); - private: - static void ArenaDtor(void* object); - inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); - public: - - ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - private: - static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_framework_2eproto); - return ::descriptor_table_framework_2eproto.file_level_metadata[kIndexInFileMessages]; - } - - public: - - // nested types ---------------------------------------------------- - - // accessors ------------------------------------------------------- - - enum : int { - kVarsFieldNumber = 3, - kOpsFieldNumber = 4, - kIdxFieldNumber = 1, - kParentIdxFieldNumber = 2, - kForwardBlockIdxFieldNumber = 5, - }; - // repeated .paddle.framework.proto.VarDesc vars = 3; - int vars_size() const; - private: - int _internal_vars_size() const; - public: - void clear_vars(); - ::paddle::framework::proto::VarDesc* mutable_vars(int index); - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::VarDesc >* - mutable_vars(); - private: - const ::paddle::framework::proto::VarDesc& _internal_vars(int index) const; - ::paddle::framework::proto::VarDesc* _internal_add_vars(); - public: - const ::paddle::framework::proto::VarDesc& vars(int index) const; - ::paddle::framework::proto::VarDesc* add_vars(); - const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::VarDesc >& - vars() const; - - // repeated .paddle.framework.proto.OpDesc ops = 4; - int ops_size() const; - private: - int _internal_ops_size() const; - public: - void clear_ops(); - ::paddle::framework::proto::OpDesc* mutable_ops(int index); - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::OpDesc >* - mutable_ops(); - private: - const ::paddle::framework::proto::OpDesc& _internal_ops(int index) const; - ::paddle::framework::proto::OpDesc* _internal_add_ops(); - public: - const ::paddle::framework::proto::OpDesc& ops(int index) const; - ::paddle::framework::proto::OpDesc* add_ops(); - const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::OpDesc >& - ops() const; - - // required int32 idx = 1; - bool has_idx() const; - private: - bool _internal_has_idx() const; - public: - void clear_idx(); - ::PROTOBUF_NAMESPACE_ID::int32 idx() const; - void set_idx(::PROTOBUF_NAMESPACE_ID::int32 value); - private: - ::PROTOBUF_NAMESPACE_ID::int32 _internal_idx() const; - void _internal_set_idx(::PROTOBUF_NAMESPACE_ID::int32 value); - public: - - // required int32 parent_idx = 2; - bool has_parent_idx() const; - private: - bool _internal_has_parent_idx() const; - public: - void clear_parent_idx(); - ::PROTOBUF_NAMESPACE_ID::int32 parent_idx() const; - void set_parent_idx(::PROTOBUF_NAMESPACE_ID::int32 value); - private: - ::PROTOBUF_NAMESPACE_ID::int32 _internal_parent_idx() const; - void _internal_set_parent_idx(::PROTOBUF_NAMESPACE_ID::int32 value); - public: - - // optional int32 forward_block_idx = 5 [default = -1]; - bool has_forward_block_idx() const; - private: - bool _internal_has_forward_block_idx() const; - public: - void clear_forward_block_idx(); - ::PROTOBUF_NAMESPACE_ID::int32 forward_block_idx() const; - void set_forward_block_idx(::PROTOBUF_NAMESPACE_ID::int32 value); - private: - ::PROTOBUF_NAMESPACE_ID::int32 _internal_forward_block_idx() const; - void _internal_set_forward_block_idx(::PROTOBUF_NAMESPACE_ID::int32 value); - public: - - // @@protoc_insertion_point(class_scope:paddle.framework.proto.BlockDesc) - private: - class _Internal; - - // helper for ByteSizeLong() - size_t RequiredFieldsByteSizeFallback() const; - - template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; - typedef void InternalArenaConstructable_; - typedef void DestructorSkippable_; - ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::VarDesc > vars_; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::OpDesc > ops_; - ::PROTOBUF_NAMESPACE_ID::int32 idx_; - ::PROTOBUF_NAMESPACE_ID::int32 parent_idx_; - ::PROTOBUF_NAMESPACE_ID::int32 forward_block_idx_; - friend struct ::TableStruct_framework_2eproto; -}; -// ------------------------------------------------------------------- - -class OpVersion PROTOBUF_FINAL : - public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:paddle.framework.proto.OpVersion) */ { - public: - inline OpVersion() : OpVersion(nullptr) {} - virtual ~OpVersion(); - - OpVersion(const OpVersion& from); - OpVersion(OpVersion&& from) noexcept - : OpVersion() { - *this = ::std::move(from); - } - - inline OpVersion& operator=(const OpVersion& from) { - CopyFrom(from); - return *this; - } - inline OpVersion& operator=(OpVersion&& from) noexcept { - if (GetArena() == from.GetArena()) { - if (this != &from) InternalSwap(&from); - } else { - CopyFrom(from); - } - return *this; - } - - inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { - return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); - } - inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); - } - - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { - return GetDescriptor(); - } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return GetMetadataStatic().descriptor; - } - static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return GetMetadataStatic().reflection; - } - static const OpVersion& default_instance(); - - static inline const OpVersion* internal_default_instance() { - return reinterpret_cast( - &_OpVersion_default_instance_); - } - static constexpr int kIndexInFileMessages = - 15; - - friend void swap(OpVersion& a, OpVersion& b) { - a.Swap(&b); - } - inline void Swap(OpVersion* other) { - if (other == this) return; - if (GetArena() == other->GetArena()) { - InternalSwap(other); - } else { - ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); - } - } - void UnsafeArenaSwap(OpVersion* other) { - if (other == this) return; - GOOGLE_DCHECK(GetArena() == other->GetArena()); - InternalSwap(other); - } - - // implements Message ---------------------------------------------- - - inline OpVersion* New() const final { - return CreateMaybeMessage(nullptr); - } - - OpVersion* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { - return CreateMaybeMessage(arena); - } - void CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; - void MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; - void CopyFrom(const OpVersion& from); - void MergeFrom(const OpVersion& from); - PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; - bool IsInitialized() const final; - - size_t ByteSizeLong() const final; - const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; - ::PROTOBUF_NAMESPACE_ID::uint8* _InternalSerialize( - ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _cached_size_.Get(); } - - private: - inline void SharedCtor(); - inline void SharedDtor(); - void SetCachedSize(int size) const final; - void InternalSwap(OpVersion* other); - friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; - static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { - return "paddle.framework.proto.OpVersion"; - } - protected: - explicit OpVersion(::PROTOBUF_NAMESPACE_ID::Arena* arena); - private: - static void ArenaDtor(void* object); - inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); - public: - - ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - private: - static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_framework_2eproto); - return ::descriptor_table_framework_2eproto.file_level_metadata[kIndexInFileMessages]; - } - - public: - - // nested types ---------------------------------------------------- - - // accessors ------------------------------------------------------- - - enum : int { - kVersionFieldNumber = 1, - }; - // required int32 version = 1; - bool has_version() const; - private: - bool _internal_has_version() const; - public: - void clear_version(); - ::PROTOBUF_NAMESPACE_ID::int32 version() const; - void set_version(::PROTOBUF_NAMESPACE_ID::int32 value); - private: - ::PROTOBUF_NAMESPACE_ID::int32 _internal_version() const; - void _internal_set_version(::PROTOBUF_NAMESPACE_ID::int32 value); - public: - - // @@protoc_insertion_point(class_scope:paddle.framework.proto.OpVersion) - private: - class _Internal; - - template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; - typedef void InternalArenaConstructable_; - typedef void DestructorSkippable_; - ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::PROTOBUF_NAMESPACE_ID::int32 version_; - friend struct ::TableStruct_framework_2eproto; -}; -// ------------------------------------------------------------------- - -class OpVersionMap_OpVersionPair PROTOBUF_FINAL : - public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:paddle.framework.proto.OpVersionMap.OpVersionPair) */ { - public: - inline OpVersionMap_OpVersionPair() : OpVersionMap_OpVersionPair(nullptr) {} - virtual ~OpVersionMap_OpVersionPair(); - - OpVersionMap_OpVersionPair(const OpVersionMap_OpVersionPair& from); - OpVersionMap_OpVersionPair(OpVersionMap_OpVersionPair&& from) noexcept - : OpVersionMap_OpVersionPair() { - *this = ::std::move(from); - } - - inline OpVersionMap_OpVersionPair& operator=(const OpVersionMap_OpVersionPair& from) { - CopyFrom(from); - return *this; - } - inline OpVersionMap_OpVersionPair& operator=(OpVersionMap_OpVersionPair&& from) noexcept { - if (GetArena() == from.GetArena()) { - if (this != &from) InternalSwap(&from); - } else { - CopyFrom(from); - } - return *this; - } - - inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { - return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); - } - inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); - } - - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { - return GetDescriptor(); - } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return GetMetadataStatic().descriptor; - } - static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return GetMetadataStatic().reflection; - } - static const OpVersionMap_OpVersionPair& default_instance(); - - static inline const OpVersionMap_OpVersionPair* internal_default_instance() { - return reinterpret_cast( - &_OpVersionMap_OpVersionPair_default_instance_); - } - static constexpr int kIndexInFileMessages = - 16; - - friend void swap(OpVersionMap_OpVersionPair& a, OpVersionMap_OpVersionPair& b) { - a.Swap(&b); - } - inline void Swap(OpVersionMap_OpVersionPair* other) { - if (other == this) return; - if (GetArena() == other->GetArena()) { - InternalSwap(other); - } else { - ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); - } - } - void UnsafeArenaSwap(OpVersionMap_OpVersionPair* other) { - if (other == this) return; - GOOGLE_DCHECK(GetArena() == other->GetArena()); - InternalSwap(other); - } - - // implements Message ---------------------------------------------- - - inline OpVersionMap_OpVersionPair* New() const final { - return CreateMaybeMessage(nullptr); - } - - OpVersionMap_OpVersionPair* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { - return CreateMaybeMessage(arena); - } - void CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; - void MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; - void CopyFrom(const OpVersionMap_OpVersionPair& from); - void MergeFrom(const OpVersionMap_OpVersionPair& from); - PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; - bool IsInitialized() const final; - - size_t ByteSizeLong() const final; - const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; - ::PROTOBUF_NAMESPACE_ID::uint8* _InternalSerialize( - ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _cached_size_.Get(); } - - private: - inline void SharedCtor(); - inline void SharedDtor(); - void SetCachedSize(int size) const final; - void InternalSwap(OpVersionMap_OpVersionPair* other); - friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; - static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { - return "paddle.framework.proto.OpVersionMap.OpVersionPair"; - } - protected: - explicit OpVersionMap_OpVersionPair(::PROTOBUF_NAMESPACE_ID::Arena* arena); - private: - static void ArenaDtor(void* object); - inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); - public: - - ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - private: - static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_framework_2eproto); - return ::descriptor_table_framework_2eproto.file_level_metadata[kIndexInFileMessages]; - } - - public: - - // nested types ---------------------------------------------------- - - // accessors ------------------------------------------------------- - - enum : int { - kOpNameFieldNumber = 1, - kOpVersionFieldNumber = 2, - }; - // required string op_name = 1; - bool has_op_name() const; - private: - bool _internal_has_op_name() const; - public: - void clear_op_name(); - const std::string& op_name() const; - void set_op_name(const std::string& value); - void set_op_name(std::string&& value); - void set_op_name(const char* value); - void set_op_name(const char* value, size_t size); - std::string* mutable_op_name(); - std::string* release_op_name(); - void set_allocated_op_name(std::string* op_name); - private: - const std::string& _internal_op_name() const; - void _internal_set_op_name(const std::string& value); - std::string* _internal_mutable_op_name(); - public: - - // required .paddle.framework.proto.OpVersion op_version = 2; - bool has_op_version() const; - private: - bool _internal_has_op_version() const; - public: - void clear_op_version(); - const ::paddle::framework::proto::OpVersion& op_version() const; - ::paddle::framework::proto::OpVersion* release_op_version(); - ::paddle::framework::proto::OpVersion* mutable_op_version(); - void set_allocated_op_version(::paddle::framework::proto::OpVersion* op_version); - private: - const ::paddle::framework::proto::OpVersion& _internal_op_version() const; - ::paddle::framework::proto::OpVersion* _internal_mutable_op_version(); - public: - void unsafe_arena_set_allocated_op_version( - ::paddle::framework::proto::OpVersion* op_version); - ::paddle::framework::proto::OpVersion* unsafe_arena_release_op_version(); - - // @@protoc_insertion_point(class_scope:paddle.framework.proto.OpVersionMap.OpVersionPair) - private: - class _Internal; - - // helper for ByteSizeLong() - size_t RequiredFieldsByteSizeFallback() const; - - template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; - typedef void InternalArenaConstructable_; - typedef void DestructorSkippable_; - ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr op_name_; - ::paddle::framework::proto::OpVersion* op_version_; - friend struct ::TableStruct_framework_2eproto; -}; -// ------------------------------------------------------------------- - -class OpVersionMap PROTOBUF_FINAL : - public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:paddle.framework.proto.OpVersionMap) */ { - public: - inline OpVersionMap() : OpVersionMap(nullptr) {} - virtual ~OpVersionMap(); - - OpVersionMap(const OpVersionMap& from); - OpVersionMap(OpVersionMap&& from) noexcept - : OpVersionMap() { - *this = ::std::move(from); - } - - inline OpVersionMap& operator=(const OpVersionMap& from) { - CopyFrom(from); - return *this; - } - inline OpVersionMap& operator=(OpVersionMap&& from) noexcept { - if (GetArena() == from.GetArena()) { - if (this != &from) InternalSwap(&from); - } else { - CopyFrom(from); - } - return *this; - } - - inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { - return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); - } - inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); - } - - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { - return GetDescriptor(); - } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return GetMetadataStatic().descriptor; - } - static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return GetMetadataStatic().reflection; - } - static const OpVersionMap& default_instance(); - - static inline const OpVersionMap* internal_default_instance() { - return reinterpret_cast( - &_OpVersionMap_default_instance_); - } - static constexpr int kIndexInFileMessages = - 17; - - friend void swap(OpVersionMap& a, OpVersionMap& b) { - a.Swap(&b); - } - inline void Swap(OpVersionMap* other) { - if (other == this) return; - if (GetArena() == other->GetArena()) { - InternalSwap(other); - } else { - ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); - } - } - void UnsafeArenaSwap(OpVersionMap* other) { - if (other == this) return; - GOOGLE_DCHECK(GetArena() == other->GetArena()); - InternalSwap(other); - } - - // implements Message ---------------------------------------------- - - inline OpVersionMap* New() const final { - return CreateMaybeMessage(nullptr); - } - - OpVersionMap* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { - return CreateMaybeMessage(arena); - } - void CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; - void MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; - void CopyFrom(const OpVersionMap& from); - void MergeFrom(const OpVersionMap& from); - PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; - bool IsInitialized() const final; - - size_t ByteSizeLong() const final; - const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; - ::PROTOBUF_NAMESPACE_ID::uint8* _InternalSerialize( - ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _cached_size_.Get(); } - - private: - inline void SharedCtor(); - inline void SharedDtor(); - void SetCachedSize(int size) const final; - void InternalSwap(OpVersionMap* other); - friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; - static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { - return "paddle.framework.proto.OpVersionMap"; - } - protected: - explicit OpVersionMap(::PROTOBUF_NAMESPACE_ID::Arena* arena); - private: - static void ArenaDtor(void* object); - inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); - public: - - ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - private: - static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_framework_2eproto); - return ::descriptor_table_framework_2eproto.file_level_metadata[kIndexInFileMessages]; - } - - public: - - // nested types ---------------------------------------------------- - - typedef OpVersionMap_OpVersionPair OpVersionPair; - - // accessors ------------------------------------------------------- - - enum : int { - kPairFieldNumber = 1, - }; - // repeated .paddle.framework.proto.OpVersionMap.OpVersionPair pair = 1; - int pair_size() const; - private: - int _internal_pair_size() const; - public: - void clear_pair(); - ::paddle::framework::proto::OpVersionMap_OpVersionPair* mutable_pair(int index); - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::OpVersionMap_OpVersionPair >* - mutable_pair(); - private: - const ::paddle::framework::proto::OpVersionMap_OpVersionPair& _internal_pair(int index) const; - ::paddle::framework::proto::OpVersionMap_OpVersionPair* _internal_add_pair(); - public: - const ::paddle::framework::proto::OpVersionMap_OpVersionPair& pair(int index) const; - ::paddle::framework::proto::OpVersionMap_OpVersionPair* add_pair(); - const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::OpVersionMap_OpVersionPair >& - pair() const; - - // @@protoc_insertion_point(class_scope:paddle.framework.proto.OpVersionMap) - private: - class _Internal; - - template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; - typedef void InternalArenaConstructable_; - typedef void DestructorSkippable_; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::OpVersionMap_OpVersionPair > pair_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - friend struct ::TableStruct_framework_2eproto; -}; -// ------------------------------------------------------------------- - -class ProgramDesc PROTOBUF_FINAL : - public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:paddle.framework.proto.ProgramDesc) */ { - public: - inline ProgramDesc() : ProgramDesc(nullptr) {} - virtual ~ProgramDesc(); - - ProgramDesc(const ProgramDesc& from); - ProgramDesc(ProgramDesc&& from) noexcept - : ProgramDesc() { - *this = ::std::move(from); - } - - inline ProgramDesc& operator=(const ProgramDesc& from) { - CopyFrom(from); - return *this; - } - inline ProgramDesc& operator=(ProgramDesc&& from) noexcept { - if (GetArena() == from.GetArena()) { - if (this != &from) InternalSwap(&from); - } else { - CopyFrom(from); - } - return *this; - } - - inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { - return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); - } - inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { - return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); - } - - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { - return GetDescriptor(); - } - static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { - return GetMetadataStatic().descriptor; - } - static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { - return GetMetadataStatic().reflection; - } - static const ProgramDesc& default_instance(); - - static inline const ProgramDesc* internal_default_instance() { - return reinterpret_cast( - &_ProgramDesc_default_instance_); - } - static constexpr int kIndexInFileMessages = - 18; - - friend void swap(ProgramDesc& a, ProgramDesc& b) { - a.Swap(&b); - } - inline void Swap(ProgramDesc* other) { - if (other == this) return; - if (GetArena() == other->GetArena()) { - InternalSwap(other); - } else { - ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); - } - } - void UnsafeArenaSwap(ProgramDesc* other) { - if (other == this) return; - GOOGLE_DCHECK(GetArena() == other->GetArena()); - InternalSwap(other); - } - - // implements Message ---------------------------------------------- - - inline ProgramDesc* New() const final { - return CreateMaybeMessage(nullptr); - } - - ProgramDesc* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { - return CreateMaybeMessage(arena); - } - void CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; - void MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; - void CopyFrom(const ProgramDesc& from); - void MergeFrom(const ProgramDesc& from); - PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; - bool IsInitialized() const final; - - size_t ByteSizeLong() const final; - const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; - ::PROTOBUF_NAMESPACE_ID::uint8* _InternalSerialize( - ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; - int GetCachedSize() const final { return _cached_size_.Get(); } - - private: - inline void SharedCtor(); - inline void SharedDtor(); - void SetCachedSize(int size) const final; - void InternalSwap(ProgramDesc* other); - friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; - static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { - return "paddle.framework.proto.ProgramDesc"; - } - protected: - explicit ProgramDesc(::PROTOBUF_NAMESPACE_ID::Arena* arena); - private: - static void ArenaDtor(void* object); - inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); - public: - - ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - private: - static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { - ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_framework_2eproto); - return ::descriptor_table_framework_2eproto.file_level_metadata[kIndexInFileMessages]; - } - - public: - - // nested types ---------------------------------------------------- - - // accessors ------------------------------------------------------- - - enum : int { - kBlocksFieldNumber = 1, - kVersionFieldNumber = 4, - kOpVersionMapFieldNumber = 5, - }; - // repeated .paddle.framework.proto.BlockDesc blocks = 1; - int blocks_size() const; - private: - int _internal_blocks_size() const; - public: - void clear_blocks(); - ::paddle::framework::proto::BlockDesc* mutable_blocks(int index); - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::BlockDesc >* - mutable_blocks(); - private: - const ::paddle::framework::proto::BlockDesc& _internal_blocks(int index) const; - ::paddle::framework::proto::BlockDesc* _internal_add_blocks(); - public: - const ::paddle::framework::proto::BlockDesc& blocks(int index) const; - ::paddle::framework::proto::BlockDesc* add_blocks(); - const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::BlockDesc >& - blocks() const; - - // optional .paddle.framework.proto.Version version = 4; - bool has_version() const; - private: - bool _internal_has_version() const; - public: - void clear_version(); - const ::paddle::framework::proto::Version& version() const; - ::paddle::framework::proto::Version* release_version(); - ::paddle::framework::proto::Version* mutable_version(); - void set_allocated_version(::paddle::framework::proto::Version* version); - private: - const ::paddle::framework::proto::Version& _internal_version() const; - ::paddle::framework::proto::Version* _internal_mutable_version(); - public: - void unsafe_arena_set_allocated_version( - ::paddle::framework::proto::Version* version); - ::paddle::framework::proto::Version* unsafe_arena_release_version(); - - // optional .paddle.framework.proto.OpVersionMap op_version_map = 5; - bool has_op_version_map() const; - private: - bool _internal_has_op_version_map() const; - public: - void clear_op_version_map(); - const ::paddle::framework::proto::OpVersionMap& op_version_map() const; - ::paddle::framework::proto::OpVersionMap* release_op_version_map(); - ::paddle::framework::proto::OpVersionMap* mutable_op_version_map(); - void set_allocated_op_version_map(::paddle::framework::proto::OpVersionMap* op_version_map); - private: - const ::paddle::framework::proto::OpVersionMap& _internal_op_version_map() const; - ::paddle::framework::proto::OpVersionMap* _internal_mutable_op_version_map(); - public: - void unsafe_arena_set_allocated_op_version_map( - ::paddle::framework::proto::OpVersionMap* op_version_map); - ::paddle::framework::proto::OpVersionMap* unsafe_arena_release_op_version_map(); - - // @@protoc_insertion_point(class_scope:paddle.framework.proto.ProgramDesc) - private: - class _Internal; - - template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; - typedef void InternalArenaConstructable_; - typedef void DestructorSkippable_; - ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; - mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::BlockDesc > blocks_; - ::paddle::framework::proto::Version* version_; - ::paddle::framework::proto::OpVersionMap* op_version_map_; - friend struct ::TableStruct_framework_2eproto; -}; -// =================================================================== - - -// =================================================================== - -#ifdef __GNUC__ - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wstrict-aliasing" -#endif // __GNUC__ -// Version - -// optional int64 version = 1 [default = 0]; -inline bool Version::_internal_has_version() const { - bool value = (_has_bits_[0] & 0x00000001u) != 0; - return value; -} -inline bool Version::has_version() const { - return _internal_has_version(); -} -inline void Version::clear_version() { - version_ = PROTOBUF_LONGLONG(0); - _has_bits_[0] &= ~0x00000001u; -} -inline ::PROTOBUF_NAMESPACE_ID::int64 Version::_internal_version() const { - return version_; -} -inline ::PROTOBUF_NAMESPACE_ID::int64 Version::version() const { - // @@protoc_insertion_point(field_get:paddle.framework.proto.Version.version) - return _internal_version(); -} -inline void Version::_internal_set_version(::PROTOBUF_NAMESPACE_ID::int64 value) { - _has_bits_[0] |= 0x00000001u; - version_ = value; -} -inline void Version::set_version(::PROTOBUF_NAMESPACE_ID::int64 value) { - _internal_set_version(value); - // @@protoc_insertion_point(field_set:paddle.framework.proto.Version.version) -} - -// ------------------------------------------------------------------- - -// OpDesc_Attr - -// required string name = 1; -inline bool OpDesc_Attr::_internal_has_name() const { - bool value = (_has_bits_[0] & 0x00000001u) != 0; - return value; -} -inline bool OpDesc_Attr::has_name() const { - return _internal_has_name(); -} -inline void OpDesc_Attr::clear_name() { - name_.ClearToEmpty(); - _has_bits_[0] &= ~0x00000001u; -} -inline const std::string& OpDesc_Attr::name() const { - // @@protoc_insertion_point(field_get:paddle.framework.proto.OpDesc.Attr.name) - return _internal_name(); -} -inline void OpDesc_Attr::set_name(const std::string& value) { - _internal_set_name(value); - // @@protoc_insertion_point(field_set:paddle.framework.proto.OpDesc.Attr.name) -} -inline std::string* OpDesc_Attr::mutable_name() { - // @@protoc_insertion_point(field_mutable:paddle.framework.proto.OpDesc.Attr.name) - return _internal_mutable_name(); -} -inline const std::string& OpDesc_Attr::_internal_name() const { - return name_.Get(); -} -inline void OpDesc_Attr::_internal_set_name(const std::string& value) { - _has_bits_[0] |= 0x00000001u; - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); -} -inline void OpDesc_Attr::set_name(std::string&& value) { - _has_bits_[0] |= 0x00000001u; - name_.Set( - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena()); - // @@protoc_insertion_point(field_set_rvalue:paddle.framework.proto.OpDesc.Attr.name) -} -inline void OpDesc_Attr::set_name(const char* value) { - GOOGLE_DCHECK(value != nullptr); - _has_bits_[0] |= 0x00000001u; - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena()); - // @@protoc_insertion_point(field_set_char:paddle.framework.proto.OpDesc.Attr.name) -} -inline void OpDesc_Attr::set_name(const char* value, - size_t size) { - _has_bits_[0] |= 0x00000001u; - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string( - reinterpret_cast(value), size), GetArena()); - // @@protoc_insertion_point(field_set_pointer:paddle.framework.proto.OpDesc.Attr.name) -} -inline std::string* OpDesc_Attr::_internal_mutable_name() { - _has_bits_[0] |= 0x00000001u; - return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); -} -inline std::string* OpDesc_Attr::release_name() { - // @@protoc_insertion_point(field_release:paddle.framework.proto.OpDesc.Attr.name) - if (!_internal_has_name()) { - return nullptr; - } - _has_bits_[0] &= ~0x00000001u; - return name_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); -} -inline void OpDesc_Attr::set_allocated_name(std::string* name) { - if (name != nullptr) { - _has_bits_[0] |= 0x00000001u; - } else { - _has_bits_[0] &= ~0x00000001u; - } - name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name, - GetArena()); - // @@protoc_insertion_point(field_set_allocated:paddle.framework.proto.OpDesc.Attr.name) -} - -// required .paddle.framework.proto.AttrType type = 2; -inline bool OpDesc_Attr::_internal_has_type() const { - bool value = (_has_bits_[0] & 0x00000004u) != 0; - return value; -} -inline bool OpDesc_Attr::has_type() const { - return _internal_has_type(); -} -inline void OpDesc_Attr::clear_type() { - type_ = 0; - _has_bits_[0] &= ~0x00000004u; -} -inline ::paddle::framework::proto::AttrType OpDesc_Attr::_internal_type() const { - return static_cast< ::paddle::framework::proto::AttrType >(type_); -} -inline ::paddle::framework::proto::AttrType OpDesc_Attr::type() const { - // @@protoc_insertion_point(field_get:paddle.framework.proto.OpDesc.Attr.type) - return _internal_type(); -} -inline void OpDesc_Attr::_internal_set_type(::paddle::framework::proto::AttrType value) { - assert(::paddle::framework::proto::AttrType_IsValid(value)); - _has_bits_[0] |= 0x00000004u; - type_ = value; -} -inline void OpDesc_Attr::set_type(::paddle::framework::proto::AttrType value) { - _internal_set_type(value); - // @@protoc_insertion_point(field_set:paddle.framework.proto.OpDesc.Attr.type) -} - -// optional int32 i = 3; -inline bool OpDesc_Attr::_internal_has_i() const { - bool value = (_has_bits_[0] & 0x00000008u) != 0; - return value; -} -inline bool OpDesc_Attr::has_i() const { - return _internal_has_i(); -} -inline void OpDesc_Attr::clear_i() { - i_ = 0; - _has_bits_[0] &= ~0x00000008u; -} -inline ::PROTOBUF_NAMESPACE_ID::int32 OpDesc_Attr::_internal_i() const { - return i_; -} -inline ::PROTOBUF_NAMESPACE_ID::int32 OpDesc_Attr::i() const { - // @@protoc_insertion_point(field_get:paddle.framework.proto.OpDesc.Attr.i) - return _internal_i(); -} -inline void OpDesc_Attr::_internal_set_i(::PROTOBUF_NAMESPACE_ID::int32 value) { - _has_bits_[0] |= 0x00000008u; - i_ = value; -} -inline void OpDesc_Attr::set_i(::PROTOBUF_NAMESPACE_ID::int32 value) { - _internal_set_i(value); - // @@protoc_insertion_point(field_set:paddle.framework.proto.OpDesc.Attr.i) -} - -// optional float f = 4; -inline bool OpDesc_Attr::_internal_has_f() const { - bool value = (_has_bits_[0] & 0x00000010u) != 0; - return value; -} -inline bool OpDesc_Attr::has_f() const { - return _internal_has_f(); -} -inline void OpDesc_Attr::clear_f() { - f_ = 0; - _has_bits_[0] &= ~0x00000010u; -} -inline float OpDesc_Attr::_internal_f() const { - return f_; -} -inline float OpDesc_Attr::f() const { - // @@protoc_insertion_point(field_get:paddle.framework.proto.OpDesc.Attr.f) - return _internal_f(); -} -inline void OpDesc_Attr::_internal_set_f(float value) { - _has_bits_[0] |= 0x00000010u; - f_ = value; -} -inline void OpDesc_Attr::set_f(float value) { - _internal_set_f(value); - // @@protoc_insertion_point(field_set:paddle.framework.proto.OpDesc.Attr.f) -} - -// optional string s = 5; -inline bool OpDesc_Attr::_internal_has_s() const { - bool value = (_has_bits_[0] & 0x00000002u) != 0; - return value; -} -inline bool OpDesc_Attr::has_s() const { - return _internal_has_s(); -} -inline void OpDesc_Attr::clear_s() { - s_.ClearToEmpty(); - _has_bits_[0] &= ~0x00000002u; -} -inline const std::string& OpDesc_Attr::s() const { - // @@protoc_insertion_point(field_get:paddle.framework.proto.OpDesc.Attr.s) - return _internal_s(); -} -inline void OpDesc_Attr::set_s(const std::string& value) { - _internal_set_s(value); - // @@protoc_insertion_point(field_set:paddle.framework.proto.OpDesc.Attr.s) -} -inline std::string* OpDesc_Attr::mutable_s() { - // @@protoc_insertion_point(field_mutable:paddle.framework.proto.OpDesc.Attr.s) - return _internal_mutable_s(); -} -inline const std::string& OpDesc_Attr::_internal_s() const { - return s_.Get(); -} -inline void OpDesc_Attr::_internal_set_s(const std::string& value) { - _has_bits_[0] |= 0x00000002u; - s_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); -} -inline void OpDesc_Attr::set_s(std::string&& value) { - _has_bits_[0] |= 0x00000002u; - s_.Set( - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena()); - // @@protoc_insertion_point(field_set_rvalue:paddle.framework.proto.OpDesc.Attr.s) -} -inline void OpDesc_Attr::set_s(const char* value) { - GOOGLE_DCHECK(value != nullptr); - _has_bits_[0] |= 0x00000002u; - s_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena()); - // @@protoc_insertion_point(field_set_char:paddle.framework.proto.OpDesc.Attr.s) -} -inline void OpDesc_Attr::set_s(const char* value, - size_t size) { - _has_bits_[0] |= 0x00000002u; - s_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string( - reinterpret_cast(value), size), GetArena()); - // @@protoc_insertion_point(field_set_pointer:paddle.framework.proto.OpDesc.Attr.s) -} -inline std::string* OpDesc_Attr::_internal_mutable_s() { - _has_bits_[0] |= 0x00000002u; - return s_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); -} -inline std::string* OpDesc_Attr::release_s() { - // @@protoc_insertion_point(field_release:paddle.framework.proto.OpDesc.Attr.s) - if (!_internal_has_s()) { - return nullptr; - } - _has_bits_[0] &= ~0x00000002u; - return s_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); -} -inline void OpDesc_Attr::set_allocated_s(std::string* s) { - if (s != nullptr) { - _has_bits_[0] |= 0x00000002u; - } else { - _has_bits_[0] &= ~0x00000002u; - } - s_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), s, - GetArena()); - // @@protoc_insertion_point(field_set_allocated:paddle.framework.proto.OpDesc.Attr.s) -} - -// repeated int32 ints = 6; -inline int OpDesc_Attr::_internal_ints_size() const { - return ints_.size(); -} -inline int OpDesc_Attr::ints_size() const { - return _internal_ints_size(); -} -inline void OpDesc_Attr::clear_ints() { - ints_.Clear(); -} -inline ::PROTOBUF_NAMESPACE_ID::int32 OpDesc_Attr::_internal_ints(int index) const { - return ints_.Get(index); -} -inline ::PROTOBUF_NAMESPACE_ID::int32 OpDesc_Attr::ints(int index) const { - // @@protoc_insertion_point(field_get:paddle.framework.proto.OpDesc.Attr.ints) - return _internal_ints(index); -} -inline void OpDesc_Attr::set_ints(int index, ::PROTOBUF_NAMESPACE_ID::int32 value) { - ints_.Set(index, value); - // @@protoc_insertion_point(field_set:paddle.framework.proto.OpDesc.Attr.ints) -} -inline void OpDesc_Attr::_internal_add_ints(::PROTOBUF_NAMESPACE_ID::int32 value) { - ints_.Add(value); -} -inline void OpDesc_Attr::add_ints(::PROTOBUF_NAMESPACE_ID::int32 value) { - _internal_add_ints(value); - // @@protoc_insertion_point(field_add:paddle.framework.proto.OpDesc.Attr.ints) -} -inline const ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int32 >& -OpDesc_Attr::_internal_ints() const { - return ints_; -} -inline const ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int32 >& -OpDesc_Attr::ints() const { - // @@protoc_insertion_point(field_list:paddle.framework.proto.OpDesc.Attr.ints) - return _internal_ints(); -} -inline ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int32 >* -OpDesc_Attr::_internal_mutable_ints() { - return &ints_; -} -inline ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int32 >* -OpDesc_Attr::mutable_ints() { - // @@protoc_insertion_point(field_mutable_list:paddle.framework.proto.OpDesc.Attr.ints) - return _internal_mutable_ints(); -} - -// repeated float floats = 7; -inline int OpDesc_Attr::_internal_floats_size() const { - return floats_.size(); -} -inline int OpDesc_Attr::floats_size() const { - return _internal_floats_size(); -} -inline void OpDesc_Attr::clear_floats() { - floats_.Clear(); -} -inline float OpDesc_Attr::_internal_floats(int index) const { - return floats_.Get(index); -} -inline float OpDesc_Attr::floats(int index) const { - // @@protoc_insertion_point(field_get:paddle.framework.proto.OpDesc.Attr.floats) - return _internal_floats(index); -} -inline void OpDesc_Attr::set_floats(int index, float value) { - floats_.Set(index, value); - // @@protoc_insertion_point(field_set:paddle.framework.proto.OpDesc.Attr.floats) -} -inline void OpDesc_Attr::_internal_add_floats(float value) { - floats_.Add(value); -} -inline void OpDesc_Attr::add_floats(float value) { - _internal_add_floats(value); - // @@protoc_insertion_point(field_add:paddle.framework.proto.OpDesc.Attr.floats) -} -inline const ::PROTOBUF_NAMESPACE_ID::RepeatedField< float >& -OpDesc_Attr::_internal_floats() const { - return floats_; -} -inline const ::PROTOBUF_NAMESPACE_ID::RepeatedField< float >& -OpDesc_Attr::floats() const { - // @@protoc_insertion_point(field_list:paddle.framework.proto.OpDesc.Attr.floats) - return _internal_floats(); -} -inline ::PROTOBUF_NAMESPACE_ID::RepeatedField< float >* -OpDesc_Attr::_internal_mutable_floats() { - return &floats_; -} -inline ::PROTOBUF_NAMESPACE_ID::RepeatedField< float >* -OpDesc_Attr::mutable_floats() { - // @@protoc_insertion_point(field_mutable_list:paddle.framework.proto.OpDesc.Attr.floats) - return _internal_mutable_floats(); -} - -// repeated string strings = 8; -inline int OpDesc_Attr::_internal_strings_size() const { - return strings_.size(); -} -inline int OpDesc_Attr::strings_size() const { - return _internal_strings_size(); -} -inline void OpDesc_Attr::clear_strings() { - strings_.Clear(); -} -inline std::string* OpDesc_Attr::add_strings() { - // @@protoc_insertion_point(field_add_mutable:paddle.framework.proto.OpDesc.Attr.strings) - return _internal_add_strings(); -} -inline const std::string& OpDesc_Attr::_internal_strings(int index) const { - return strings_.Get(index); -} -inline const std::string& OpDesc_Attr::strings(int index) const { - // @@protoc_insertion_point(field_get:paddle.framework.proto.OpDesc.Attr.strings) - return _internal_strings(index); -} -inline std::string* OpDesc_Attr::mutable_strings(int index) { - // @@protoc_insertion_point(field_mutable:paddle.framework.proto.OpDesc.Attr.strings) - return strings_.Mutable(index); -} -inline void OpDesc_Attr::set_strings(int index, const std::string& value) { - // @@protoc_insertion_point(field_set:paddle.framework.proto.OpDesc.Attr.strings) - strings_.Mutable(index)->assign(value); -} -inline void OpDesc_Attr::set_strings(int index, std::string&& value) { - // @@protoc_insertion_point(field_set:paddle.framework.proto.OpDesc.Attr.strings) - strings_.Mutable(index)->assign(std::move(value)); -} -inline void OpDesc_Attr::set_strings(int index, const char* value) { - GOOGLE_DCHECK(value != nullptr); - strings_.Mutable(index)->assign(value); - // @@protoc_insertion_point(field_set_char:paddle.framework.proto.OpDesc.Attr.strings) -} -inline void OpDesc_Attr::set_strings(int index, const char* value, size_t size) { - strings_.Mutable(index)->assign( - reinterpret_cast(value), size); - // @@protoc_insertion_point(field_set_pointer:paddle.framework.proto.OpDesc.Attr.strings) -} -inline std::string* OpDesc_Attr::_internal_add_strings() { - return strings_.Add(); -} -inline void OpDesc_Attr::add_strings(const std::string& value) { - strings_.Add()->assign(value); - // @@protoc_insertion_point(field_add:paddle.framework.proto.OpDesc.Attr.strings) -} -inline void OpDesc_Attr::add_strings(std::string&& value) { - strings_.Add(std::move(value)); - // @@protoc_insertion_point(field_add:paddle.framework.proto.OpDesc.Attr.strings) -} -inline void OpDesc_Attr::add_strings(const char* value) { - GOOGLE_DCHECK(value != nullptr); - strings_.Add()->assign(value); - // @@protoc_insertion_point(field_add_char:paddle.framework.proto.OpDesc.Attr.strings) -} -inline void OpDesc_Attr::add_strings(const char* value, size_t size) { - strings_.Add()->assign(reinterpret_cast(value), size); - // @@protoc_insertion_point(field_add_pointer:paddle.framework.proto.OpDesc.Attr.strings) -} -inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField& -OpDesc_Attr::strings() const { - // @@protoc_insertion_point(field_list:paddle.framework.proto.OpDesc.Attr.strings) - return strings_; -} -inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField* -OpDesc_Attr::mutable_strings() { - // @@protoc_insertion_point(field_mutable_list:paddle.framework.proto.OpDesc.Attr.strings) - return &strings_; -} - -// optional bool b = 10; -inline bool OpDesc_Attr::_internal_has_b() const { - bool value = (_has_bits_[0] & 0x00000020u) != 0; - return value; -} -inline bool OpDesc_Attr::has_b() const { - return _internal_has_b(); -} -inline void OpDesc_Attr::clear_b() { - b_ = false; - _has_bits_[0] &= ~0x00000020u; -} -inline bool OpDesc_Attr::_internal_b() const { - return b_; -} -inline bool OpDesc_Attr::b() const { - // @@protoc_insertion_point(field_get:paddle.framework.proto.OpDesc.Attr.b) - return _internal_b(); -} -inline void OpDesc_Attr::_internal_set_b(bool value) { - _has_bits_[0] |= 0x00000020u; - b_ = value; -} -inline void OpDesc_Attr::set_b(bool value) { - _internal_set_b(value); - // @@protoc_insertion_point(field_set:paddle.framework.proto.OpDesc.Attr.b) -} - -// repeated bool bools = 11; -inline int OpDesc_Attr::_internal_bools_size() const { - return bools_.size(); -} -inline int OpDesc_Attr::bools_size() const { - return _internal_bools_size(); -} -inline void OpDesc_Attr::clear_bools() { - bools_.Clear(); -} -inline bool OpDesc_Attr::_internal_bools(int index) const { - return bools_.Get(index); -} -inline bool OpDesc_Attr::bools(int index) const { - // @@protoc_insertion_point(field_get:paddle.framework.proto.OpDesc.Attr.bools) - return _internal_bools(index); -} -inline void OpDesc_Attr::set_bools(int index, bool value) { - bools_.Set(index, value); - // @@protoc_insertion_point(field_set:paddle.framework.proto.OpDesc.Attr.bools) -} -inline void OpDesc_Attr::_internal_add_bools(bool value) { - bools_.Add(value); -} -inline void OpDesc_Attr::add_bools(bool value) { - _internal_add_bools(value); - // @@protoc_insertion_point(field_add:paddle.framework.proto.OpDesc.Attr.bools) -} -inline const ::PROTOBUF_NAMESPACE_ID::RepeatedField< bool >& -OpDesc_Attr::_internal_bools() const { - return bools_; -} -inline const ::PROTOBUF_NAMESPACE_ID::RepeatedField< bool >& -OpDesc_Attr::bools() const { - // @@protoc_insertion_point(field_list:paddle.framework.proto.OpDesc.Attr.bools) - return _internal_bools(); -} -inline ::PROTOBUF_NAMESPACE_ID::RepeatedField< bool >* -OpDesc_Attr::_internal_mutable_bools() { - return &bools_; -} -inline ::PROTOBUF_NAMESPACE_ID::RepeatedField< bool >* -OpDesc_Attr::mutable_bools() { - // @@protoc_insertion_point(field_mutable_list:paddle.framework.proto.OpDesc.Attr.bools) - return _internal_mutable_bools(); -} - -// optional int32 block_idx = 12; -inline bool OpDesc_Attr::_internal_has_block_idx() const { - bool value = (_has_bits_[0] & 0x00000080u) != 0; - return value; -} -inline bool OpDesc_Attr::has_block_idx() const { - return _internal_has_block_idx(); -} -inline void OpDesc_Attr::clear_block_idx() { - block_idx_ = 0; - _has_bits_[0] &= ~0x00000080u; -} -inline ::PROTOBUF_NAMESPACE_ID::int32 OpDesc_Attr::_internal_block_idx() const { - return block_idx_; -} -inline ::PROTOBUF_NAMESPACE_ID::int32 OpDesc_Attr::block_idx() const { - // @@protoc_insertion_point(field_get:paddle.framework.proto.OpDesc.Attr.block_idx) - return _internal_block_idx(); -} -inline void OpDesc_Attr::_internal_set_block_idx(::PROTOBUF_NAMESPACE_ID::int32 value) { - _has_bits_[0] |= 0x00000080u; - block_idx_ = value; -} -inline void OpDesc_Attr::set_block_idx(::PROTOBUF_NAMESPACE_ID::int32 value) { - _internal_set_block_idx(value); - // @@protoc_insertion_point(field_set:paddle.framework.proto.OpDesc.Attr.block_idx) -} - -// optional int64 l = 13; -inline bool OpDesc_Attr::_internal_has_l() const { - bool value = (_has_bits_[0] & 0x00000040u) != 0; - return value; -} -inline bool OpDesc_Attr::has_l() const { - return _internal_has_l(); -} -inline void OpDesc_Attr::clear_l() { - l_ = PROTOBUF_LONGLONG(0); - _has_bits_[0] &= ~0x00000040u; -} -inline ::PROTOBUF_NAMESPACE_ID::int64 OpDesc_Attr::_internal_l() const { - return l_; -} -inline ::PROTOBUF_NAMESPACE_ID::int64 OpDesc_Attr::l() const { - // @@protoc_insertion_point(field_get:paddle.framework.proto.OpDesc.Attr.l) - return _internal_l(); -} -inline void OpDesc_Attr::_internal_set_l(::PROTOBUF_NAMESPACE_ID::int64 value) { - _has_bits_[0] |= 0x00000040u; - l_ = value; -} -inline void OpDesc_Attr::set_l(::PROTOBUF_NAMESPACE_ID::int64 value) { - _internal_set_l(value); - // @@protoc_insertion_point(field_set:paddle.framework.proto.OpDesc.Attr.l) -} - -// repeated int32 blocks_idx = 14; -inline int OpDesc_Attr::_internal_blocks_idx_size() const { - return blocks_idx_.size(); -} -inline int OpDesc_Attr::blocks_idx_size() const { - return _internal_blocks_idx_size(); -} -inline void OpDesc_Attr::clear_blocks_idx() { - blocks_idx_.Clear(); -} -inline ::PROTOBUF_NAMESPACE_ID::int32 OpDesc_Attr::_internal_blocks_idx(int index) const { - return blocks_idx_.Get(index); -} -inline ::PROTOBUF_NAMESPACE_ID::int32 OpDesc_Attr::blocks_idx(int index) const { - // @@protoc_insertion_point(field_get:paddle.framework.proto.OpDesc.Attr.blocks_idx) - return _internal_blocks_idx(index); -} -inline void OpDesc_Attr::set_blocks_idx(int index, ::PROTOBUF_NAMESPACE_ID::int32 value) { - blocks_idx_.Set(index, value); - // @@protoc_insertion_point(field_set:paddle.framework.proto.OpDesc.Attr.blocks_idx) -} -inline void OpDesc_Attr::_internal_add_blocks_idx(::PROTOBUF_NAMESPACE_ID::int32 value) { - blocks_idx_.Add(value); -} -inline void OpDesc_Attr::add_blocks_idx(::PROTOBUF_NAMESPACE_ID::int32 value) { - _internal_add_blocks_idx(value); - // @@protoc_insertion_point(field_add:paddle.framework.proto.OpDesc.Attr.blocks_idx) -} -inline const ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int32 >& -OpDesc_Attr::_internal_blocks_idx() const { - return blocks_idx_; -} -inline const ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int32 >& -OpDesc_Attr::blocks_idx() const { - // @@protoc_insertion_point(field_list:paddle.framework.proto.OpDesc.Attr.blocks_idx) - return _internal_blocks_idx(); -} -inline ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int32 >* -OpDesc_Attr::_internal_mutable_blocks_idx() { - return &blocks_idx_; -} -inline ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int32 >* -OpDesc_Attr::mutable_blocks_idx() { - // @@protoc_insertion_point(field_mutable_list:paddle.framework.proto.OpDesc.Attr.blocks_idx) - return _internal_mutable_blocks_idx(); -} - -// repeated int64 longs = 15; -inline int OpDesc_Attr::_internal_longs_size() const { - return longs_.size(); -} -inline int OpDesc_Attr::longs_size() const { - return _internal_longs_size(); -} -inline void OpDesc_Attr::clear_longs() { - longs_.Clear(); -} -inline ::PROTOBUF_NAMESPACE_ID::int64 OpDesc_Attr::_internal_longs(int index) const { - return longs_.Get(index); -} -inline ::PROTOBUF_NAMESPACE_ID::int64 OpDesc_Attr::longs(int index) const { - // @@protoc_insertion_point(field_get:paddle.framework.proto.OpDesc.Attr.longs) - return _internal_longs(index); -} -inline void OpDesc_Attr::set_longs(int index, ::PROTOBUF_NAMESPACE_ID::int64 value) { - longs_.Set(index, value); - // @@protoc_insertion_point(field_set:paddle.framework.proto.OpDesc.Attr.longs) -} -inline void OpDesc_Attr::_internal_add_longs(::PROTOBUF_NAMESPACE_ID::int64 value) { - longs_.Add(value); -} -inline void OpDesc_Attr::add_longs(::PROTOBUF_NAMESPACE_ID::int64 value) { - _internal_add_longs(value); - // @@protoc_insertion_point(field_add:paddle.framework.proto.OpDesc.Attr.longs) -} -inline const ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int64 >& -OpDesc_Attr::_internal_longs() const { - return longs_; -} -inline const ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int64 >& -OpDesc_Attr::longs() const { - // @@protoc_insertion_point(field_list:paddle.framework.proto.OpDesc.Attr.longs) - return _internal_longs(); -} -inline ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int64 >* -OpDesc_Attr::_internal_mutable_longs() { - return &longs_; -} -inline ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int64 >* -OpDesc_Attr::mutable_longs() { - // @@protoc_insertion_point(field_mutable_list:paddle.framework.proto.OpDesc.Attr.longs) - return _internal_mutable_longs(); -} - -// ------------------------------------------------------------------- - -// OpDesc_Var - -// required string parameter = 1; -inline bool OpDesc_Var::_internal_has_parameter() const { - bool value = (_has_bits_[0] & 0x00000001u) != 0; - return value; -} -inline bool OpDesc_Var::has_parameter() const { - return _internal_has_parameter(); -} -inline void OpDesc_Var::clear_parameter() { - parameter_.ClearToEmpty(); - _has_bits_[0] &= ~0x00000001u; -} -inline const std::string& OpDesc_Var::parameter() const { - // @@protoc_insertion_point(field_get:paddle.framework.proto.OpDesc.Var.parameter) - return _internal_parameter(); -} -inline void OpDesc_Var::set_parameter(const std::string& value) { - _internal_set_parameter(value); - // @@protoc_insertion_point(field_set:paddle.framework.proto.OpDesc.Var.parameter) -} -inline std::string* OpDesc_Var::mutable_parameter() { - // @@protoc_insertion_point(field_mutable:paddle.framework.proto.OpDesc.Var.parameter) - return _internal_mutable_parameter(); -} -inline const std::string& OpDesc_Var::_internal_parameter() const { - return parameter_.Get(); -} -inline void OpDesc_Var::_internal_set_parameter(const std::string& value) { - _has_bits_[0] |= 0x00000001u; - parameter_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); -} -inline void OpDesc_Var::set_parameter(std::string&& value) { - _has_bits_[0] |= 0x00000001u; - parameter_.Set( - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena()); - // @@protoc_insertion_point(field_set_rvalue:paddle.framework.proto.OpDesc.Var.parameter) -} -inline void OpDesc_Var::set_parameter(const char* value) { - GOOGLE_DCHECK(value != nullptr); - _has_bits_[0] |= 0x00000001u; - parameter_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena()); - // @@protoc_insertion_point(field_set_char:paddle.framework.proto.OpDesc.Var.parameter) -} -inline void OpDesc_Var::set_parameter(const char* value, - size_t size) { - _has_bits_[0] |= 0x00000001u; - parameter_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string( - reinterpret_cast(value), size), GetArena()); - // @@protoc_insertion_point(field_set_pointer:paddle.framework.proto.OpDesc.Var.parameter) -} -inline std::string* OpDesc_Var::_internal_mutable_parameter() { - _has_bits_[0] |= 0x00000001u; - return parameter_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); -} -inline std::string* OpDesc_Var::release_parameter() { - // @@protoc_insertion_point(field_release:paddle.framework.proto.OpDesc.Var.parameter) - if (!_internal_has_parameter()) { - return nullptr; - } - _has_bits_[0] &= ~0x00000001u; - return parameter_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); -} -inline void OpDesc_Var::set_allocated_parameter(std::string* parameter) { - if (parameter != nullptr) { - _has_bits_[0] |= 0x00000001u; - } else { - _has_bits_[0] &= ~0x00000001u; - } - parameter_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), parameter, - GetArena()); - // @@protoc_insertion_point(field_set_allocated:paddle.framework.proto.OpDesc.Var.parameter) -} - -// repeated string arguments = 2; -inline int OpDesc_Var::_internal_arguments_size() const { - return arguments_.size(); -} -inline int OpDesc_Var::arguments_size() const { - return _internal_arguments_size(); -} -inline void OpDesc_Var::clear_arguments() { - arguments_.Clear(); -} -inline std::string* OpDesc_Var::add_arguments() { - // @@protoc_insertion_point(field_add_mutable:paddle.framework.proto.OpDesc.Var.arguments) - return _internal_add_arguments(); -} -inline const std::string& OpDesc_Var::_internal_arguments(int index) const { - return arguments_.Get(index); -} -inline const std::string& OpDesc_Var::arguments(int index) const { - // @@protoc_insertion_point(field_get:paddle.framework.proto.OpDesc.Var.arguments) - return _internal_arguments(index); -} -inline std::string* OpDesc_Var::mutable_arguments(int index) { - // @@protoc_insertion_point(field_mutable:paddle.framework.proto.OpDesc.Var.arguments) - return arguments_.Mutable(index); -} -inline void OpDesc_Var::set_arguments(int index, const std::string& value) { - // @@protoc_insertion_point(field_set:paddle.framework.proto.OpDesc.Var.arguments) - arguments_.Mutable(index)->assign(value); -} -inline void OpDesc_Var::set_arguments(int index, std::string&& value) { - // @@protoc_insertion_point(field_set:paddle.framework.proto.OpDesc.Var.arguments) - arguments_.Mutable(index)->assign(std::move(value)); -} -inline void OpDesc_Var::set_arguments(int index, const char* value) { - GOOGLE_DCHECK(value != nullptr); - arguments_.Mutable(index)->assign(value); - // @@protoc_insertion_point(field_set_char:paddle.framework.proto.OpDesc.Var.arguments) -} -inline void OpDesc_Var::set_arguments(int index, const char* value, size_t size) { - arguments_.Mutable(index)->assign( - reinterpret_cast(value), size); - // @@protoc_insertion_point(field_set_pointer:paddle.framework.proto.OpDesc.Var.arguments) -} -inline std::string* OpDesc_Var::_internal_add_arguments() { - return arguments_.Add(); -} -inline void OpDesc_Var::add_arguments(const std::string& value) { - arguments_.Add()->assign(value); - // @@protoc_insertion_point(field_add:paddle.framework.proto.OpDesc.Var.arguments) -} -inline void OpDesc_Var::add_arguments(std::string&& value) { - arguments_.Add(std::move(value)); - // @@protoc_insertion_point(field_add:paddle.framework.proto.OpDesc.Var.arguments) -} -inline void OpDesc_Var::add_arguments(const char* value) { - GOOGLE_DCHECK(value != nullptr); - arguments_.Add()->assign(value); - // @@protoc_insertion_point(field_add_char:paddle.framework.proto.OpDesc.Var.arguments) -} -inline void OpDesc_Var::add_arguments(const char* value, size_t size) { - arguments_.Add()->assign(reinterpret_cast(value), size); - // @@protoc_insertion_point(field_add_pointer:paddle.framework.proto.OpDesc.Var.arguments) -} -inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField& -OpDesc_Var::arguments() const { - // @@protoc_insertion_point(field_list:paddle.framework.proto.OpDesc.Var.arguments) - return arguments_; -} -inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField* -OpDesc_Var::mutable_arguments() { - // @@protoc_insertion_point(field_mutable_list:paddle.framework.proto.OpDesc.Var.arguments) - return &arguments_; -} - -// ------------------------------------------------------------------- - -// OpDesc - -// required string type = 3; -inline bool OpDesc::_internal_has_type() const { - bool value = (_has_bits_[0] & 0x00000001u) != 0; - return value; -} -inline bool OpDesc::has_type() const { - return _internal_has_type(); -} -inline void OpDesc::clear_type() { - type_.ClearToEmpty(); - _has_bits_[0] &= ~0x00000001u; -} -inline const std::string& OpDesc::type() const { - // @@protoc_insertion_point(field_get:paddle.framework.proto.OpDesc.type) - return _internal_type(); -} -inline void OpDesc::set_type(const std::string& value) { - _internal_set_type(value); - // @@protoc_insertion_point(field_set:paddle.framework.proto.OpDesc.type) -} -inline std::string* OpDesc::mutable_type() { - // @@protoc_insertion_point(field_mutable:paddle.framework.proto.OpDesc.type) - return _internal_mutable_type(); -} -inline const std::string& OpDesc::_internal_type() const { - return type_.Get(); -} -inline void OpDesc::_internal_set_type(const std::string& value) { - _has_bits_[0] |= 0x00000001u; - type_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); -} -inline void OpDesc::set_type(std::string&& value) { - _has_bits_[0] |= 0x00000001u; - type_.Set( - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena()); - // @@protoc_insertion_point(field_set_rvalue:paddle.framework.proto.OpDesc.type) -} -inline void OpDesc::set_type(const char* value) { - GOOGLE_DCHECK(value != nullptr); - _has_bits_[0] |= 0x00000001u; - type_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena()); - // @@protoc_insertion_point(field_set_char:paddle.framework.proto.OpDesc.type) -} -inline void OpDesc::set_type(const char* value, - size_t size) { - _has_bits_[0] |= 0x00000001u; - type_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string( - reinterpret_cast(value), size), GetArena()); - // @@protoc_insertion_point(field_set_pointer:paddle.framework.proto.OpDesc.type) -} -inline std::string* OpDesc::_internal_mutable_type() { - _has_bits_[0] |= 0x00000001u; - return type_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); -} -inline std::string* OpDesc::release_type() { - // @@protoc_insertion_point(field_release:paddle.framework.proto.OpDesc.type) - if (!_internal_has_type()) { - return nullptr; - } - _has_bits_[0] &= ~0x00000001u; - return type_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); -} -inline void OpDesc::set_allocated_type(std::string* type) { - if (type != nullptr) { - _has_bits_[0] |= 0x00000001u; - } else { - _has_bits_[0] &= ~0x00000001u; - } - type_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), type, - GetArena()); - // @@protoc_insertion_point(field_set_allocated:paddle.framework.proto.OpDesc.type) -} - -// repeated .paddle.framework.proto.OpDesc.Var inputs = 1; -inline int OpDesc::_internal_inputs_size() const { - return inputs_.size(); -} -inline int OpDesc::inputs_size() const { - return _internal_inputs_size(); -} -inline void OpDesc::clear_inputs() { - inputs_.Clear(); -} -inline ::paddle::framework::proto::OpDesc_Var* OpDesc::mutable_inputs(int index) { - // @@protoc_insertion_point(field_mutable:paddle.framework.proto.OpDesc.inputs) - return inputs_.Mutable(index); -} -inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::OpDesc_Var >* -OpDesc::mutable_inputs() { - // @@protoc_insertion_point(field_mutable_list:paddle.framework.proto.OpDesc.inputs) - return &inputs_; -} -inline const ::paddle::framework::proto::OpDesc_Var& OpDesc::_internal_inputs(int index) const { - return inputs_.Get(index); -} -inline const ::paddle::framework::proto::OpDesc_Var& OpDesc::inputs(int index) const { - // @@protoc_insertion_point(field_get:paddle.framework.proto.OpDesc.inputs) - return _internal_inputs(index); -} -inline ::paddle::framework::proto::OpDesc_Var* OpDesc::_internal_add_inputs() { - return inputs_.Add(); -} -inline ::paddle::framework::proto::OpDesc_Var* OpDesc::add_inputs() { - // @@protoc_insertion_point(field_add:paddle.framework.proto.OpDesc.inputs) - return _internal_add_inputs(); -} -inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::OpDesc_Var >& -OpDesc::inputs() const { - // @@protoc_insertion_point(field_list:paddle.framework.proto.OpDesc.inputs) - return inputs_; -} - -// repeated .paddle.framework.proto.OpDesc.Var outputs = 2; -inline int OpDesc::_internal_outputs_size() const { - return outputs_.size(); -} -inline int OpDesc::outputs_size() const { - return _internal_outputs_size(); -} -inline void OpDesc::clear_outputs() { - outputs_.Clear(); -} -inline ::paddle::framework::proto::OpDesc_Var* OpDesc::mutable_outputs(int index) { - // @@protoc_insertion_point(field_mutable:paddle.framework.proto.OpDesc.outputs) - return outputs_.Mutable(index); -} -inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::OpDesc_Var >* -OpDesc::mutable_outputs() { - // @@protoc_insertion_point(field_mutable_list:paddle.framework.proto.OpDesc.outputs) - return &outputs_; -} -inline const ::paddle::framework::proto::OpDesc_Var& OpDesc::_internal_outputs(int index) const { - return outputs_.Get(index); -} -inline const ::paddle::framework::proto::OpDesc_Var& OpDesc::outputs(int index) const { - // @@protoc_insertion_point(field_get:paddle.framework.proto.OpDesc.outputs) - return _internal_outputs(index); -} -inline ::paddle::framework::proto::OpDesc_Var* OpDesc::_internal_add_outputs() { - return outputs_.Add(); -} -inline ::paddle::framework::proto::OpDesc_Var* OpDesc::add_outputs() { - // @@protoc_insertion_point(field_add:paddle.framework.proto.OpDesc.outputs) - return _internal_add_outputs(); -} -inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::OpDesc_Var >& -OpDesc::outputs() const { - // @@protoc_insertion_point(field_list:paddle.framework.proto.OpDesc.outputs) - return outputs_; -} - -// repeated .paddle.framework.proto.OpDesc.Attr attrs = 4; -inline int OpDesc::_internal_attrs_size() const { - return attrs_.size(); -} -inline int OpDesc::attrs_size() const { - return _internal_attrs_size(); -} -inline void OpDesc::clear_attrs() { - attrs_.Clear(); -} -inline ::paddle::framework::proto::OpDesc_Attr* OpDesc::mutable_attrs(int index) { - // @@protoc_insertion_point(field_mutable:paddle.framework.proto.OpDesc.attrs) - return attrs_.Mutable(index); -} -inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::OpDesc_Attr >* -OpDesc::mutable_attrs() { - // @@protoc_insertion_point(field_mutable_list:paddle.framework.proto.OpDesc.attrs) - return &attrs_; -} -inline const ::paddle::framework::proto::OpDesc_Attr& OpDesc::_internal_attrs(int index) const { - return attrs_.Get(index); -} -inline const ::paddle::framework::proto::OpDesc_Attr& OpDesc::attrs(int index) const { - // @@protoc_insertion_point(field_get:paddle.framework.proto.OpDesc.attrs) - return _internal_attrs(index); -} -inline ::paddle::framework::proto::OpDesc_Attr* OpDesc::_internal_add_attrs() { - return attrs_.Add(); -} -inline ::paddle::framework::proto::OpDesc_Attr* OpDesc::add_attrs() { - // @@protoc_insertion_point(field_add:paddle.framework.proto.OpDesc.attrs) - return _internal_add_attrs(); -} -inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::OpDesc_Attr >& -OpDesc::attrs() const { - // @@protoc_insertion_point(field_list:paddle.framework.proto.OpDesc.attrs) - return attrs_; -} - -// optional bool is_target = 5 [default = false]; -inline bool OpDesc::_internal_has_is_target() const { - bool value = (_has_bits_[0] & 0x00000002u) != 0; - return value; -} -inline bool OpDesc::has_is_target() const { - return _internal_has_is_target(); -} -inline void OpDesc::clear_is_target() { - is_target_ = false; - _has_bits_[0] &= ~0x00000002u; -} -inline bool OpDesc::_internal_is_target() const { - return is_target_; -} -inline bool OpDesc::is_target() const { - // @@protoc_insertion_point(field_get:paddle.framework.proto.OpDesc.is_target) - return _internal_is_target(); -} -inline void OpDesc::_internal_set_is_target(bool value) { - _has_bits_[0] |= 0x00000002u; - is_target_ = value; -} -inline void OpDesc::set_is_target(bool value) { - _internal_set_is_target(value); - // @@protoc_insertion_point(field_set:paddle.framework.proto.OpDesc.is_target) -} - -// ------------------------------------------------------------------- - -// OpProto_Var - -// required string name = 1; -inline bool OpProto_Var::_internal_has_name() const { - bool value = (_has_bits_[0] & 0x00000001u) != 0; - return value; -} -inline bool OpProto_Var::has_name() const { - return _internal_has_name(); -} -inline void OpProto_Var::clear_name() { - name_.ClearToEmpty(); - _has_bits_[0] &= ~0x00000001u; -} -inline const std::string& OpProto_Var::name() const { - // @@protoc_insertion_point(field_get:paddle.framework.proto.OpProto.Var.name) - return _internal_name(); -} -inline void OpProto_Var::set_name(const std::string& value) { - _internal_set_name(value); - // @@protoc_insertion_point(field_set:paddle.framework.proto.OpProto.Var.name) -} -inline std::string* OpProto_Var::mutable_name() { - // @@protoc_insertion_point(field_mutable:paddle.framework.proto.OpProto.Var.name) - return _internal_mutable_name(); -} -inline const std::string& OpProto_Var::_internal_name() const { - return name_.Get(); -} -inline void OpProto_Var::_internal_set_name(const std::string& value) { - _has_bits_[0] |= 0x00000001u; - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); -} -inline void OpProto_Var::set_name(std::string&& value) { - _has_bits_[0] |= 0x00000001u; - name_.Set( - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena()); - // @@protoc_insertion_point(field_set_rvalue:paddle.framework.proto.OpProto.Var.name) -} -inline void OpProto_Var::set_name(const char* value) { - GOOGLE_DCHECK(value != nullptr); - _has_bits_[0] |= 0x00000001u; - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena()); - // @@protoc_insertion_point(field_set_char:paddle.framework.proto.OpProto.Var.name) -} -inline void OpProto_Var::set_name(const char* value, - size_t size) { - _has_bits_[0] |= 0x00000001u; - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string( - reinterpret_cast(value), size), GetArena()); - // @@protoc_insertion_point(field_set_pointer:paddle.framework.proto.OpProto.Var.name) -} -inline std::string* OpProto_Var::_internal_mutable_name() { - _has_bits_[0] |= 0x00000001u; - return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); -} -inline std::string* OpProto_Var::release_name() { - // @@protoc_insertion_point(field_release:paddle.framework.proto.OpProto.Var.name) - if (!_internal_has_name()) { - return nullptr; - } - _has_bits_[0] &= ~0x00000001u; - return name_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); -} -inline void OpProto_Var::set_allocated_name(std::string* name) { - if (name != nullptr) { - _has_bits_[0] |= 0x00000001u; - } else { - _has_bits_[0] &= ~0x00000001u; - } - name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name, - GetArena()); - // @@protoc_insertion_point(field_set_allocated:paddle.framework.proto.OpProto.Var.name) -} - -// required string comment = 2; -inline bool OpProto_Var::_internal_has_comment() const { - bool value = (_has_bits_[0] & 0x00000002u) != 0; - return value; -} -inline bool OpProto_Var::has_comment() const { - return _internal_has_comment(); -} -inline void OpProto_Var::clear_comment() { - comment_.ClearToEmpty(); - _has_bits_[0] &= ~0x00000002u; -} -inline const std::string& OpProto_Var::comment() const { - // @@protoc_insertion_point(field_get:paddle.framework.proto.OpProto.Var.comment) - return _internal_comment(); -} -inline void OpProto_Var::set_comment(const std::string& value) { - _internal_set_comment(value); - // @@protoc_insertion_point(field_set:paddle.framework.proto.OpProto.Var.comment) -} -inline std::string* OpProto_Var::mutable_comment() { - // @@protoc_insertion_point(field_mutable:paddle.framework.proto.OpProto.Var.comment) - return _internal_mutable_comment(); -} -inline const std::string& OpProto_Var::_internal_comment() const { - return comment_.Get(); -} -inline void OpProto_Var::_internal_set_comment(const std::string& value) { - _has_bits_[0] |= 0x00000002u; - comment_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); -} -inline void OpProto_Var::set_comment(std::string&& value) { - _has_bits_[0] |= 0x00000002u; - comment_.Set( - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena()); - // @@protoc_insertion_point(field_set_rvalue:paddle.framework.proto.OpProto.Var.comment) -} -inline void OpProto_Var::set_comment(const char* value) { - GOOGLE_DCHECK(value != nullptr); - _has_bits_[0] |= 0x00000002u; - comment_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena()); - // @@protoc_insertion_point(field_set_char:paddle.framework.proto.OpProto.Var.comment) -} -inline void OpProto_Var::set_comment(const char* value, - size_t size) { - _has_bits_[0] |= 0x00000002u; - comment_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string( - reinterpret_cast(value), size), GetArena()); - // @@protoc_insertion_point(field_set_pointer:paddle.framework.proto.OpProto.Var.comment) -} -inline std::string* OpProto_Var::_internal_mutable_comment() { - _has_bits_[0] |= 0x00000002u; - return comment_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); -} -inline std::string* OpProto_Var::release_comment() { - // @@protoc_insertion_point(field_release:paddle.framework.proto.OpProto.Var.comment) - if (!_internal_has_comment()) { - return nullptr; - } - _has_bits_[0] &= ~0x00000002u; - return comment_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); -} -inline void OpProto_Var::set_allocated_comment(std::string* comment) { - if (comment != nullptr) { - _has_bits_[0] |= 0x00000002u; - } else { - _has_bits_[0] &= ~0x00000002u; - } - comment_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), comment, - GetArena()); - // @@protoc_insertion_point(field_set_allocated:paddle.framework.proto.OpProto.Var.comment) -} - -// optional bool duplicable = 3 [default = false]; -inline bool OpProto_Var::_internal_has_duplicable() const { - bool value = (_has_bits_[0] & 0x00000004u) != 0; - return value; -} -inline bool OpProto_Var::has_duplicable() const { - return _internal_has_duplicable(); -} -inline void OpProto_Var::clear_duplicable() { - duplicable_ = false; - _has_bits_[0] &= ~0x00000004u; -} -inline bool OpProto_Var::_internal_duplicable() const { - return duplicable_; -} -inline bool OpProto_Var::duplicable() const { - // @@protoc_insertion_point(field_get:paddle.framework.proto.OpProto.Var.duplicable) - return _internal_duplicable(); -} -inline void OpProto_Var::_internal_set_duplicable(bool value) { - _has_bits_[0] |= 0x00000004u; - duplicable_ = value; -} -inline void OpProto_Var::set_duplicable(bool value) { - _internal_set_duplicable(value); - // @@protoc_insertion_point(field_set:paddle.framework.proto.OpProto.Var.duplicable) -} - -// optional bool intermediate = 4 [default = false]; -inline bool OpProto_Var::_internal_has_intermediate() const { - bool value = (_has_bits_[0] & 0x00000008u) != 0; - return value; -} -inline bool OpProto_Var::has_intermediate() const { - return _internal_has_intermediate(); -} -inline void OpProto_Var::clear_intermediate() { - intermediate_ = false; - _has_bits_[0] &= ~0x00000008u; -} -inline bool OpProto_Var::_internal_intermediate() const { - return intermediate_; -} -inline bool OpProto_Var::intermediate() const { - // @@protoc_insertion_point(field_get:paddle.framework.proto.OpProto.Var.intermediate) - return _internal_intermediate(); -} -inline void OpProto_Var::_internal_set_intermediate(bool value) { - _has_bits_[0] |= 0x00000008u; - intermediate_ = value; -} -inline void OpProto_Var::set_intermediate(bool value) { - _internal_set_intermediate(value); - // @@protoc_insertion_point(field_set:paddle.framework.proto.OpProto.Var.intermediate) -} - -// optional bool dispensable = 5 [default = false]; -inline bool OpProto_Var::_internal_has_dispensable() const { - bool value = (_has_bits_[0] & 0x00000010u) != 0; - return value; -} -inline bool OpProto_Var::has_dispensable() const { - return _internal_has_dispensable(); -} -inline void OpProto_Var::clear_dispensable() { - dispensable_ = false; - _has_bits_[0] &= ~0x00000010u; -} -inline bool OpProto_Var::_internal_dispensable() const { - return dispensable_; -} -inline bool OpProto_Var::dispensable() const { - // @@protoc_insertion_point(field_get:paddle.framework.proto.OpProto.Var.dispensable) - return _internal_dispensable(); -} -inline void OpProto_Var::_internal_set_dispensable(bool value) { - _has_bits_[0] |= 0x00000010u; - dispensable_ = value; -} -inline void OpProto_Var::set_dispensable(bool value) { - _internal_set_dispensable(value); - // @@protoc_insertion_point(field_set:paddle.framework.proto.OpProto.Var.dispensable) -} - -// ------------------------------------------------------------------- - -// OpProto_Attr - -// required string name = 1; -inline bool OpProto_Attr::_internal_has_name() const { - bool value = (_has_bits_[0] & 0x00000001u) != 0; - return value; -} -inline bool OpProto_Attr::has_name() const { - return _internal_has_name(); -} -inline void OpProto_Attr::clear_name() { - name_.ClearToEmpty(); - _has_bits_[0] &= ~0x00000001u; -} -inline const std::string& OpProto_Attr::name() const { - // @@protoc_insertion_point(field_get:paddle.framework.proto.OpProto.Attr.name) - return _internal_name(); -} -inline void OpProto_Attr::set_name(const std::string& value) { - _internal_set_name(value); - // @@protoc_insertion_point(field_set:paddle.framework.proto.OpProto.Attr.name) -} -inline std::string* OpProto_Attr::mutable_name() { - // @@protoc_insertion_point(field_mutable:paddle.framework.proto.OpProto.Attr.name) - return _internal_mutable_name(); -} -inline const std::string& OpProto_Attr::_internal_name() const { - return name_.Get(); -} -inline void OpProto_Attr::_internal_set_name(const std::string& value) { - _has_bits_[0] |= 0x00000001u; - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); -} -inline void OpProto_Attr::set_name(std::string&& value) { - _has_bits_[0] |= 0x00000001u; - name_.Set( - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena()); - // @@protoc_insertion_point(field_set_rvalue:paddle.framework.proto.OpProto.Attr.name) -} -inline void OpProto_Attr::set_name(const char* value) { - GOOGLE_DCHECK(value != nullptr); - _has_bits_[0] |= 0x00000001u; - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena()); - // @@protoc_insertion_point(field_set_char:paddle.framework.proto.OpProto.Attr.name) -} -inline void OpProto_Attr::set_name(const char* value, - size_t size) { - _has_bits_[0] |= 0x00000001u; - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string( - reinterpret_cast(value), size), GetArena()); - // @@protoc_insertion_point(field_set_pointer:paddle.framework.proto.OpProto.Attr.name) -} -inline std::string* OpProto_Attr::_internal_mutable_name() { - _has_bits_[0] |= 0x00000001u; - return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); -} -inline std::string* OpProto_Attr::release_name() { - // @@protoc_insertion_point(field_release:paddle.framework.proto.OpProto.Attr.name) - if (!_internal_has_name()) { - return nullptr; - } - _has_bits_[0] &= ~0x00000001u; - return name_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); -} -inline void OpProto_Attr::set_allocated_name(std::string* name) { - if (name != nullptr) { - _has_bits_[0] |= 0x00000001u; - } else { - _has_bits_[0] &= ~0x00000001u; - } - name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name, - GetArena()); - // @@protoc_insertion_point(field_set_allocated:paddle.framework.proto.OpProto.Attr.name) -} - -// required .paddle.framework.proto.AttrType type = 2; -inline bool OpProto_Attr::_internal_has_type() const { - bool value = (_has_bits_[0] & 0x00000004u) != 0; - return value; -} -inline bool OpProto_Attr::has_type() const { - return _internal_has_type(); -} -inline void OpProto_Attr::clear_type() { - type_ = 0; - _has_bits_[0] &= ~0x00000004u; -} -inline ::paddle::framework::proto::AttrType OpProto_Attr::_internal_type() const { - return static_cast< ::paddle::framework::proto::AttrType >(type_); -} -inline ::paddle::framework::proto::AttrType OpProto_Attr::type() const { - // @@protoc_insertion_point(field_get:paddle.framework.proto.OpProto.Attr.type) - return _internal_type(); -} -inline void OpProto_Attr::_internal_set_type(::paddle::framework::proto::AttrType value) { - assert(::paddle::framework::proto::AttrType_IsValid(value)); - _has_bits_[0] |= 0x00000004u; - type_ = value; -} -inline void OpProto_Attr::set_type(::paddle::framework::proto::AttrType value) { - _internal_set_type(value); - // @@protoc_insertion_point(field_set:paddle.framework.proto.OpProto.Attr.type) -} - -// required string comment = 3; -inline bool OpProto_Attr::_internal_has_comment() const { - bool value = (_has_bits_[0] & 0x00000002u) != 0; - return value; -} -inline bool OpProto_Attr::has_comment() const { - return _internal_has_comment(); -} -inline void OpProto_Attr::clear_comment() { - comment_.ClearToEmpty(); - _has_bits_[0] &= ~0x00000002u; -} -inline const std::string& OpProto_Attr::comment() const { - // @@protoc_insertion_point(field_get:paddle.framework.proto.OpProto.Attr.comment) - return _internal_comment(); -} -inline void OpProto_Attr::set_comment(const std::string& value) { - _internal_set_comment(value); - // @@protoc_insertion_point(field_set:paddle.framework.proto.OpProto.Attr.comment) -} -inline std::string* OpProto_Attr::mutable_comment() { - // @@protoc_insertion_point(field_mutable:paddle.framework.proto.OpProto.Attr.comment) - return _internal_mutable_comment(); -} -inline const std::string& OpProto_Attr::_internal_comment() const { - return comment_.Get(); -} -inline void OpProto_Attr::_internal_set_comment(const std::string& value) { - _has_bits_[0] |= 0x00000002u; - comment_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); -} -inline void OpProto_Attr::set_comment(std::string&& value) { - _has_bits_[0] |= 0x00000002u; - comment_.Set( - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena()); - // @@protoc_insertion_point(field_set_rvalue:paddle.framework.proto.OpProto.Attr.comment) -} -inline void OpProto_Attr::set_comment(const char* value) { - GOOGLE_DCHECK(value != nullptr); - _has_bits_[0] |= 0x00000002u; - comment_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena()); - // @@protoc_insertion_point(field_set_char:paddle.framework.proto.OpProto.Attr.comment) -} -inline void OpProto_Attr::set_comment(const char* value, - size_t size) { - _has_bits_[0] |= 0x00000002u; - comment_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string( - reinterpret_cast(value), size), GetArena()); - // @@protoc_insertion_point(field_set_pointer:paddle.framework.proto.OpProto.Attr.comment) -} -inline std::string* OpProto_Attr::_internal_mutable_comment() { - _has_bits_[0] |= 0x00000002u; - return comment_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); -} -inline std::string* OpProto_Attr::release_comment() { - // @@protoc_insertion_point(field_release:paddle.framework.proto.OpProto.Attr.comment) - if (!_internal_has_comment()) { - return nullptr; - } - _has_bits_[0] &= ~0x00000002u; - return comment_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); -} -inline void OpProto_Attr::set_allocated_comment(std::string* comment) { - if (comment != nullptr) { - _has_bits_[0] |= 0x00000002u; - } else { - _has_bits_[0] &= ~0x00000002u; - } - comment_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), comment, - GetArena()); - // @@protoc_insertion_point(field_set_allocated:paddle.framework.proto.OpProto.Attr.comment) -} - -// optional bool generated = 4 [default = false]; -inline bool OpProto_Attr::_internal_has_generated() const { - bool value = (_has_bits_[0] & 0x00000008u) != 0; - return value; -} -inline bool OpProto_Attr::has_generated() const { - return _internal_has_generated(); -} -inline void OpProto_Attr::clear_generated() { - generated_ = false; - _has_bits_[0] &= ~0x00000008u; -} -inline bool OpProto_Attr::_internal_generated() const { - return generated_; -} -inline bool OpProto_Attr::generated() const { - // @@protoc_insertion_point(field_get:paddle.framework.proto.OpProto.Attr.generated) - return _internal_generated(); -} -inline void OpProto_Attr::_internal_set_generated(bool value) { - _has_bits_[0] |= 0x00000008u; - generated_ = value; -} -inline void OpProto_Attr::set_generated(bool value) { - _internal_set_generated(value); - // @@protoc_insertion_point(field_set:paddle.framework.proto.OpProto.Attr.generated) -} - -// ------------------------------------------------------------------- - -// OpProto - -// required string type = 1; -inline bool OpProto::_internal_has_type() const { - bool value = (_has_bits_[0] & 0x00000001u) != 0; - return value; -} -inline bool OpProto::has_type() const { - return _internal_has_type(); -} -inline void OpProto::clear_type() { - type_.ClearToEmpty(); - _has_bits_[0] &= ~0x00000001u; -} -inline const std::string& OpProto::type() const { - // @@protoc_insertion_point(field_get:paddle.framework.proto.OpProto.type) - return _internal_type(); -} -inline void OpProto::set_type(const std::string& value) { - _internal_set_type(value); - // @@protoc_insertion_point(field_set:paddle.framework.proto.OpProto.type) -} -inline std::string* OpProto::mutable_type() { - // @@protoc_insertion_point(field_mutable:paddle.framework.proto.OpProto.type) - return _internal_mutable_type(); -} -inline const std::string& OpProto::_internal_type() const { - return type_.Get(); -} -inline void OpProto::_internal_set_type(const std::string& value) { - _has_bits_[0] |= 0x00000001u; - type_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); -} -inline void OpProto::set_type(std::string&& value) { - _has_bits_[0] |= 0x00000001u; - type_.Set( - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena()); - // @@protoc_insertion_point(field_set_rvalue:paddle.framework.proto.OpProto.type) -} -inline void OpProto::set_type(const char* value) { - GOOGLE_DCHECK(value != nullptr); - _has_bits_[0] |= 0x00000001u; - type_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena()); - // @@protoc_insertion_point(field_set_char:paddle.framework.proto.OpProto.type) -} -inline void OpProto::set_type(const char* value, - size_t size) { - _has_bits_[0] |= 0x00000001u; - type_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string( - reinterpret_cast(value), size), GetArena()); - // @@protoc_insertion_point(field_set_pointer:paddle.framework.proto.OpProto.type) -} -inline std::string* OpProto::_internal_mutable_type() { - _has_bits_[0] |= 0x00000001u; - return type_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); -} -inline std::string* OpProto::release_type() { - // @@protoc_insertion_point(field_release:paddle.framework.proto.OpProto.type) - if (!_internal_has_type()) { - return nullptr; - } - _has_bits_[0] &= ~0x00000001u; - return type_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); -} -inline void OpProto::set_allocated_type(std::string* type) { - if (type != nullptr) { - _has_bits_[0] |= 0x00000001u; - } else { - _has_bits_[0] &= ~0x00000001u; - } - type_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), type, - GetArena()); - // @@protoc_insertion_point(field_set_allocated:paddle.framework.proto.OpProto.type) -} - -// repeated .paddle.framework.proto.OpProto.Var inputs = 2; -inline int OpProto::_internal_inputs_size() const { - return inputs_.size(); -} -inline int OpProto::inputs_size() const { - return _internal_inputs_size(); -} -inline void OpProto::clear_inputs() { - inputs_.Clear(); -} -inline ::paddle::framework::proto::OpProto_Var* OpProto::mutable_inputs(int index) { - // @@protoc_insertion_point(field_mutable:paddle.framework.proto.OpProto.inputs) - return inputs_.Mutable(index); -} -inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::OpProto_Var >* -OpProto::mutable_inputs() { - // @@protoc_insertion_point(field_mutable_list:paddle.framework.proto.OpProto.inputs) - return &inputs_; -} -inline const ::paddle::framework::proto::OpProto_Var& OpProto::_internal_inputs(int index) const { - return inputs_.Get(index); -} -inline const ::paddle::framework::proto::OpProto_Var& OpProto::inputs(int index) const { - // @@protoc_insertion_point(field_get:paddle.framework.proto.OpProto.inputs) - return _internal_inputs(index); -} -inline ::paddle::framework::proto::OpProto_Var* OpProto::_internal_add_inputs() { - return inputs_.Add(); -} -inline ::paddle::framework::proto::OpProto_Var* OpProto::add_inputs() { - // @@protoc_insertion_point(field_add:paddle.framework.proto.OpProto.inputs) - return _internal_add_inputs(); -} -inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::OpProto_Var >& -OpProto::inputs() const { - // @@protoc_insertion_point(field_list:paddle.framework.proto.OpProto.inputs) - return inputs_; -} - -// repeated .paddle.framework.proto.OpProto.Var outputs = 3; -inline int OpProto::_internal_outputs_size() const { - return outputs_.size(); -} -inline int OpProto::outputs_size() const { - return _internal_outputs_size(); -} -inline void OpProto::clear_outputs() { - outputs_.Clear(); -} -inline ::paddle::framework::proto::OpProto_Var* OpProto::mutable_outputs(int index) { - // @@protoc_insertion_point(field_mutable:paddle.framework.proto.OpProto.outputs) - return outputs_.Mutable(index); -} -inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::OpProto_Var >* -OpProto::mutable_outputs() { - // @@protoc_insertion_point(field_mutable_list:paddle.framework.proto.OpProto.outputs) - return &outputs_; -} -inline const ::paddle::framework::proto::OpProto_Var& OpProto::_internal_outputs(int index) const { - return outputs_.Get(index); -} -inline const ::paddle::framework::proto::OpProto_Var& OpProto::outputs(int index) const { - // @@protoc_insertion_point(field_get:paddle.framework.proto.OpProto.outputs) - return _internal_outputs(index); -} -inline ::paddle::framework::proto::OpProto_Var* OpProto::_internal_add_outputs() { - return outputs_.Add(); -} -inline ::paddle::framework::proto::OpProto_Var* OpProto::add_outputs() { - // @@protoc_insertion_point(field_add:paddle.framework.proto.OpProto.outputs) - return _internal_add_outputs(); -} -inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::OpProto_Var >& -OpProto::outputs() const { - // @@protoc_insertion_point(field_list:paddle.framework.proto.OpProto.outputs) - return outputs_; -} - -// repeated .paddle.framework.proto.OpProto.Attr attrs = 4; -inline int OpProto::_internal_attrs_size() const { - return attrs_.size(); -} -inline int OpProto::attrs_size() const { - return _internal_attrs_size(); -} -inline void OpProto::clear_attrs() { - attrs_.Clear(); -} -inline ::paddle::framework::proto::OpProto_Attr* OpProto::mutable_attrs(int index) { - // @@protoc_insertion_point(field_mutable:paddle.framework.proto.OpProto.attrs) - return attrs_.Mutable(index); -} -inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::OpProto_Attr >* -OpProto::mutable_attrs() { - // @@protoc_insertion_point(field_mutable_list:paddle.framework.proto.OpProto.attrs) - return &attrs_; -} -inline const ::paddle::framework::proto::OpProto_Attr& OpProto::_internal_attrs(int index) const { - return attrs_.Get(index); -} -inline const ::paddle::framework::proto::OpProto_Attr& OpProto::attrs(int index) const { - // @@protoc_insertion_point(field_get:paddle.framework.proto.OpProto.attrs) - return _internal_attrs(index); -} -inline ::paddle::framework::proto::OpProto_Attr* OpProto::_internal_add_attrs() { - return attrs_.Add(); -} -inline ::paddle::framework::proto::OpProto_Attr* OpProto::add_attrs() { - // @@protoc_insertion_point(field_add:paddle.framework.proto.OpProto.attrs) - return _internal_add_attrs(); -} -inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::OpProto_Attr >& -OpProto::attrs() const { - // @@protoc_insertion_point(field_list:paddle.framework.proto.OpProto.attrs) - return attrs_; -} - -// required string comment = 5; -inline bool OpProto::_internal_has_comment() const { - bool value = (_has_bits_[0] & 0x00000002u) != 0; - return value; -} -inline bool OpProto::has_comment() const { - return _internal_has_comment(); -} -inline void OpProto::clear_comment() { - comment_.ClearToEmpty(); - _has_bits_[0] &= ~0x00000002u; -} -inline const std::string& OpProto::comment() const { - // @@protoc_insertion_point(field_get:paddle.framework.proto.OpProto.comment) - return _internal_comment(); -} -inline void OpProto::set_comment(const std::string& value) { - _internal_set_comment(value); - // @@protoc_insertion_point(field_set:paddle.framework.proto.OpProto.comment) -} -inline std::string* OpProto::mutable_comment() { - // @@protoc_insertion_point(field_mutable:paddle.framework.proto.OpProto.comment) - return _internal_mutable_comment(); -} -inline const std::string& OpProto::_internal_comment() const { - return comment_.Get(); -} -inline void OpProto::_internal_set_comment(const std::string& value) { - _has_bits_[0] |= 0x00000002u; - comment_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); -} -inline void OpProto::set_comment(std::string&& value) { - _has_bits_[0] |= 0x00000002u; - comment_.Set( - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena()); - // @@protoc_insertion_point(field_set_rvalue:paddle.framework.proto.OpProto.comment) -} -inline void OpProto::set_comment(const char* value) { - GOOGLE_DCHECK(value != nullptr); - _has_bits_[0] |= 0x00000002u; - comment_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena()); - // @@protoc_insertion_point(field_set_char:paddle.framework.proto.OpProto.comment) -} -inline void OpProto::set_comment(const char* value, - size_t size) { - _has_bits_[0] |= 0x00000002u; - comment_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string( - reinterpret_cast(value), size), GetArena()); - // @@protoc_insertion_point(field_set_pointer:paddle.framework.proto.OpProto.comment) -} -inline std::string* OpProto::_internal_mutable_comment() { - _has_bits_[0] |= 0x00000002u; - return comment_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); -} -inline std::string* OpProto::release_comment() { - // @@protoc_insertion_point(field_release:paddle.framework.proto.OpProto.comment) - if (!_internal_has_comment()) { - return nullptr; - } - _has_bits_[0] &= ~0x00000002u; - return comment_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); -} -inline void OpProto::set_allocated_comment(std::string* comment) { - if (comment != nullptr) { - _has_bits_[0] |= 0x00000002u; - } else { - _has_bits_[0] &= ~0x00000002u; - } - comment_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), comment, - GetArena()); - // @@protoc_insertion_point(field_set_allocated:paddle.framework.proto.OpProto.comment) -} - -// ------------------------------------------------------------------- - -// VarType_TensorDesc - -// required .paddle.framework.proto.VarType.Type data_type = 1; -inline bool VarType_TensorDesc::_internal_has_data_type() const { - bool value = (_has_bits_[0] & 0x00000001u) != 0; - return value; -} -inline bool VarType_TensorDesc::has_data_type() const { - return _internal_has_data_type(); -} -inline void VarType_TensorDesc::clear_data_type() { - data_type_ = 0; - _has_bits_[0] &= ~0x00000001u; -} -inline ::paddle::framework::proto::VarType_Type VarType_TensorDesc::_internal_data_type() const { - return static_cast< ::paddle::framework::proto::VarType_Type >(data_type_); -} -inline ::paddle::framework::proto::VarType_Type VarType_TensorDesc::data_type() const { - // @@protoc_insertion_point(field_get:paddle.framework.proto.VarType.TensorDesc.data_type) - return _internal_data_type(); -} -inline void VarType_TensorDesc::_internal_set_data_type(::paddle::framework::proto::VarType_Type value) { - assert(::paddle::framework::proto::VarType_Type_IsValid(value)); - _has_bits_[0] |= 0x00000001u; - data_type_ = value; -} -inline void VarType_TensorDesc::set_data_type(::paddle::framework::proto::VarType_Type value) { - _internal_set_data_type(value); - // @@protoc_insertion_point(field_set:paddle.framework.proto.VarType.TensorDesc.data_type) -} - -// repeated int64 dims = 2; -inline int VarType_TensorDesc::_internal_dims_size() const { - return dims_.size(); -} -inline int VarType_TensorDesc::dims_size() const { - return _internal_dims_size(); -} -inline void VarType_TensorDesc::clear_dims() { - dims_.Clear(); -} -inline ::PROTOBUF_NAMESPACE_ID::int64 VarType_TensorDesc::_internal_dims(int index) const { - return dims_.Get(index); -} -inline ::PROTOBUF_NAMESPACE_ID::int64 VarType_TensorDesc::dims(int index) const { - // @@protoc_insertion_point(field_get:paddle.framework.proto.VarType.TensorDesc.dims) - return _internal_dims(index); -} -inline void VarType_TensorDesc::set_dims(int index, ::PROTOBUF_NAMESPACE_ID::int64 value) { - dims_.Set(index, value); - // @@protoc_insertion_point(field_set:paddle.framework.proto.VarType.TensorDesc.dims) -} -inline void VarType_TensorDesc::_internal_add_dims(::PROTOBUF_NAMESPACE_ID::int64 value) { - dims_.Add(value); -} -inline void VarType_TensorDesc::add_dims(::PROTOBUF_NAMESPACE_ID::int64 value) { - _internal_add_dims(value); - // @@protoc_insertion_point(field_add:paddle.framework.proto.VarType.TensorDesc.dims) -} -inline const ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int64 >& -VarType_TensorDesc::_internal_dims() const { - return dims_; -} -inline const ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int64 >& -VarType_TensorDesc::dims() const { - // @@protoc_insertion_point(field_list:paddle.framework.proto.VarType.TensorDesc.dims) - return _internal_dims(); -} -inline ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int64 >* -VarType_TensorDesc::_internal_mutable_dims() { - return &dims_; -} -inline ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int64 >* -VarType_TensorDesc::mutable_dims() { - // @@protoc_insertion_point(field_mutable_list:paddle.framework.proto.VarType.TensorDesc.dims) - return _internal_mutable_dims(); -} - -// ------------------------------------------------------------------- - -// VarType_LoDTensorDesc - -// required .paddle.framework.proto.VarType.TensorDesc tensor = 1; -inline bool VarType_LoDTensorDesc::_internal_has_tensor() const { - bool value = (_has_bits_[0] & 0x00000001u) != 0; - PROTOBUF_ASSUME(!value || tensor_ != nullptr); - return value; -} -inline bool VarType_LoDTensorDesc::has_tensor() const { - return _internal_has_tensor(); -} -inline void VarType_LoDTensorDesc::clear_tensor() { - if (tensor_ != nullptr) tensor_->Clear(); - _has_bits_[0] &= ~0x00000001u; -} -inline const ::paddle::framework::proto::VarType_TensorDesc& VarType_LoDTensorDesc::_internal_tensor() const { - const ::paddle::framework::proto::VarType_TensorDesc* p = tensor_; - return p != nullptr ? *p : reinterpret_cast( - ::paddle::framework::proto::_VarType_TensorDesc_default_instance_); -} -inline const ::paddle::framework::proto::VarType_TensorDesc& VarType_LoDTensorDesc::tensor() const { - // @@protoc_insertion_point(field_get:paddle.framework.proto.VarType.LoDTensorDesc.tensor) - return _internal_tensor(); -} -inline void VarType_LoDTensorDesc::unsafe_arena_set_allocated_tensor( - ::paddle::framework::proto::VarType_TensorDesc* tensor) { - if (GetArena() == nullptr) { - delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(tensor_); - } - tensor_ = tensor; - if (tensor) { - _has_bits_[0] |= 0x00000001u; - } else { - _has_bits_[0] &= ~0x00000001u; - } - // @@protoc_insertion_point(field_unsafe_arena_set_allocated:paddle.framework.proto.VarType.LoDTensorDesc.tensor) -} -inline ::paddle::framework::proto::VarType_TensorDesc* VarType_LoDTensorDesc::release_tensor() { - _has_bits_[0] &= ~0x00000001u; - ::paddle::framework::proto::VarType_TensorDesc* temp = tensor_; - tensor_ = nullptr; - if (GetArena() != nullptr) { - temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); - } - return temp; -} -inline ::paddle::framework::proto::VarType_TensorDesc* VarType_LoDTensorDesc::unsafe_arena_release_tensor() { - // @@protoc_insertion_point(field_release:paddle.framework.proto.VarType.LoDTensorDesc.tensor) - _has_bits_[0] &= ~0x00000001u; - ::paddle::framework::proto::VarType_TensorDesc* temp = tensor_; - tensor_ = nullptr; - return temp; -} -inline ::paddle::framework::proto::VarType_TensorDesc* VarType_LoDTensorDesc::_internal_mutable_tensor() { - _has_bits_[0] |= 0x00000001u; - if (tensor_ == nullptr) { - auto* p = CreateMaybeMessage<::paddle::framework::proto::VarType_TensorDesc>(GetArena()); - tensor_ = p; - } - return tensor_; -} -inline ::paddle::framework::proto::VarType_TensorDesc* VarType_LoDTensorDesc::mutable_tensor() { - // @@protoc_insertion_point(field_mutable:paddle.framework.proto.VarType.LoDTensorDesc.tensor) - return _internal_mutable_tensor(); -} -inline void VarType_LoDTensorDesc::set_allocated_tensor(::paddle::framework::proto::VarType_TensorDesc* tensor) { - ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArena(); - if (message_arena == nullptr) { - delete tensor_; - } - if (tensor) { - ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = - ::PROTOBUF_NAMESPACE_ID::Arena::GetArena(tensor); - if (message_arena != submessage_arena) { - tensor = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( - message_arena, tensor, submessage_arena); - } - _has_bits_[0] |= 0x00000001u; - } else { - _has_bits_[0] &= ~0x00000001u; - } - tensor_ = tensor; - // @@protoc_insertion_point(field_set_allocated:paddle.framework.proto.VarType.LoDTensorDesc.tensor) -} - -// optional int32 lod_level = 2 [default = 0]; -inline bool VarType_LoDTensorDesc::_internal_has_lod_level() const { - bool value = (_has_bits_[0] & 0x00000002u) != 0; - return value; -} -inline bool VarType_LoDTensorDesc::has_lod_level() const { - return _internal_has_lod_level(); -} -inline void VarType_LoDTensorDesc::clear_lod_level() { - lod_level_ = 0; - _has_bits_[0] &= ~0x00000002u; -} -inline ::PROTOBUF_NAMESPACE_ID::int32 VarType_LoDTensorDesc::_internal_lod_level() const { - return lod_level_; -} -inline ::PROTOBUF_NAMESPACE_ID::int32 VarType_LoDTensorDesc::lod_level() const { - // @@protoc_insertion_point(field_get:paddle.framework.proto.VarType.LoDTensorDesc.lod_level) - return _internal_lod_level(); -} -inline void VarType_LoDTensorDesc::_internal_set_lod_level(::PROTOBUF_NAMESPACE_ID::int32 value) { - _has_bits_[0] |= 0x00000002u; - lod_level_ = value; -} -inline void VarType_LoDTensorDesc::set_lod_level(::PROTOBUF_NAMESPACE_ID::int32 value) { - _internal_set_lod_level(value); - // @@protoc_insertion_point(field_set:paddle.framework.proto.VarType.LoDTensorDesc.lod_level) -} - -// ------------------------------------------------------------------- - -// VarType_LoDTensorArrayDesc - -// required .paddle.framework.proto.VarType.TensorDesc tensor = 1; -inline bool VarType_LoDTensorArrayDesc::_internal_has_tensor() const { - bool value = (_has_bits_[0] & 0x00000001u) != 0; - PROTOBUF_ASSUME(!value || tensor_ != nullptr); - return value; -} -inline bool VarType_LoDTensorArrayDesc::has_tensor() const { - return _internal_has_tensor(); -} -inline void VarType_LoDTensorArrayDesc::clear_tensor() { - if (tensor_ != nullptr) tensor_->Clear(); - _has_bits_[0] &= ~0x00000001u; -} -inline const ::paddle::framework::proto::VarType_TensorDesc& VarType_LoDTensorArrayDesc::_internal_tensor() const { - const ::paddle::framework::proto::VarType_TensorDesc* p = tensor_; - return p != nullptr ? *p : reinterpret_cast( - ::paddle::framework::proto::_VarType_TensorDesc_default_instance_); -} -inline const ::paddle::framework::proto::VarType_TensorDesc& VarType_LoDTensorArrayDesc::tensor() const { - // @@protoc_insertion_point(field_get:paddle.framework.proto.VarType.LoDTensorArrayDesc.tensor) - return _internal_tensor(); -} -inline void VarType_LoDTensorArrayDesc::unsafe_arena_set_allocated_tensor( - ::paddle::framework::proto::VarType_TensorDesc* tensor) { - if (GetArena() == nullptr) { - delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(tensor_); - } - tensor_ = tensor; - if (tensor) { - _has_bits_[0] |= 0x00000001u; - } else { - _has_bits_[0] &= ~0x00000001u; - } - // @@protoc_insertion_point(field_unsafe_arena_set_allocated:paddle.framework.proto.VarType.LoDTensorArrayDesc.tensor) -} -inline ::paddle::framework::proto::VarType_TensorDesc* VarType_LoDTensorArrayDesc::release_tensor() { - _has_bits_[0] &= ~0x00000001u; - ::paddle::framework::proto::VarType_TensorDesc* temp = tensor_; - tensor_ = nullptr; - if (GetArena() != nullptr) { - temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); - } - return temp; -} -inline ::paddle::framework::proto::VarType_TensorDesc* VarType_LoDTensorArrayDesc::unsafe_arena_release_tensor() { - // @@protoc_insertion_point(field_release:paddle.framework.proto.VarType.LoDTensorArrayDesc.tensor) - _has_bits_[0] &= ~0x00000001u; - ::paddle::framework::proto::VarType_TensorDesc* temp = tensor_; - tensor_ = nullptr; - return temp; -} -inline ::paddle::framework::proto::VarType_TensorDesc* VarType_LoDTensorArrayDesc::_internal_mutable_tensor() { - _has_bits_[0] |= 0x00000001u; - if (tensor_ == nullptr) { - auto* p = CreateMaybeMessage<::paddle::framework::proto::VarType_TensorDesc>(GetArena()); - tensor_ = p; - } - return tensor_; -} -inline ::paddle::framework::proto::VarType_TensorDesc* VarType_LoDTensorArrayDesc::mutable_tensor() { - // @@protoc_insertion_point(field_mutable:paddle.framework.proto.VarType.LoDTensorArrayDesc.tensor) - return _internal_mutable_tensor(); -} -inline void VarType_LoDTensorArrayDesc::set_allocated_tensor(::paddle::framework::proto::VarType_TensorDesc* tensor) { - ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArena(); - if (message_arena == nullptr) { - delete tensor_; - } - if (tensor) { - ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = - ::PROTOBUF_NAMESPACE_ID::Arena::GetArena(tensor); - if (message_arena != submessage_arena) { - tensor = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( - message_arena, tensor, submessage_arena); - } - _has_bits_[0] |= 0x00000001u; - } else { - _has_bits_[0] &= ~0x00000001u; - } - tensor_ = tensor; - // @@protoc_insertion_point(field_set_allocated:paddle.framework.proto.VarType.LoDTensorArrayDesc.tensor) -} - -// optional int32 lod_level = 2 [default = 0]; -inline bool VarType_LoDTensorArrayDesc::_internal_has_lod_level() const { - bool value = (_has_bits_[0] & 0x00000002u) != 0; - return value; -} -inline bool VarType_LoDTensorArrayDesc::has_lod_level() const { - return _internal_has_lod_level(); -} -inline void VarType_LoDTensorArrayDesc::clear_lod_level() { - lod_level_ = 0; - _has_bits_[0] &= ~0x00000002u; -} -inline ::PROTOBUF_NAMESPACE_ID::int32 VarType_LoDTensorArrayDesc::_internal_lod_level() const { - return lod_level_; -} -inline ::PROTOBUF_NAMESPACE_ID::int32 VarType_LoDTensorArrayDesc::lod_level() const { - // @@protoc_insertion_point(field_get:paddle.framework.proto.VarType.LoDTensorArrayDesc.lod_level) - return _internal_lod_level(); -} -inline void VarType_LoDTensorArrayDesc::_internal_set_lod_level(::PROTOBUF_NAMESPACE_ID::int32 value) { - _has_bits_[0] |= 0x00000002u; - lod_level_ = value; -} -inline void VarType_LoDTensorArrayDesc::set_lod_level(::PROTOBUF_NAMESPACE_ID::int32 value) { - _internal_set_lod_level(value); - // @@protoc_insertion_point(field_set:paddle.framework.proto.VarType.LoDTensorArrayDesc.lod_level) -} - -// ------------------------------------------------------------------- - -// VarType_ReaderDesc - -// repeated .paddle.framework.proto.VarType.LoDTensorDesc lod_tensor = 1; -inline int VarType_ReaderDesc::_internal_lod_tensor_size() const { - return lod_tensor_.size(); -} -inline int VarType_ReaderDesc::lod_tensor_size() const { - return _internal_lod_tensor_size(); -} -inline void VarType_ReaderDesc::clear_lod_tensor() { - lod_tensor_.Clear(); -} -inline ::paddle::framework::proto::VarType_LoDTensorDesc* VarType_ReaderDesc::mutable_lod_tensor(int index) { - // @@protoc_insertion_point(field_mutable:paddle.framework.proto.VarType.ReaderDesc.lod_tensor) - return lod_tensor_.Mutable(index); -} -inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::VarType_LoDTensorDesc >* -VarType_ReaderDesc::mutable_lod_tensor() { - // @@protoc_insertion_point(field_mutable_list:paddle.framework.proto.VarType.ReaderDesc.lod_tensor) - return &lod_tensor_; -} -inline const ::paddle::framework::proto::VarType_LoDTensorDesc& VarType_ReaderDesc::_internal_lod_tensor(int index) const { - return lod_tensor_.Get(index); -} -inline const ::paddle::framework::proto::VarType_LoDTensorDesc& VarType_ReaderDesc::lod_tensor(int index) const { - // @@protoc_insertion_point(field_get:paddle.framework.proto.VarType.ReaderDesc.lod_tensor) - return _internal_lod_tensor(index); -} -inline ::paddle::framework::proto::VarType_LoDTensorDesc* VarType_ReaderDesc::_internal_add_lod_tensor() { - return lod_tensor_.Add(); -} -inline ::paddle::framework::proto::VarType_LoDTensorDesc* VarType_ReaderDesc::add_lod_tensor() { - // @@protoc_insertion_point(field_add:paddle.framework.proto.VarType.ReaderDesc.lod_tensor) - return _internal_add_lod_tensor(); -} -inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::VarType_LoDTensorDesc >& -VarType_ReaderDesc::lod_tensor() const { - // @@protoc_insertion_point(field_list:paddle.framework.proto.VarType.ReaderDesc.lod_tensor) - return lod_tensor_; -} - -// ------------------------------------------------------------------- - -// VarType_Tuple - -// repeated .paddle.framework.proto.VarType.Type element_type = 1; -inline int VarType_Tuple::_internal_element_type_size() const { - return element_type_.size(); -} -inline int VarType_Tuple::element_type_size() const { - return _internal_element_type_size(); -} -inline void VarType_Tuple::clear_element_type() { - element_type_.Clear(); -} -inline ::paddle::framework::proto::VarType_Type VarType_Tuple::_internal_element_type(int index) const { - return static_cast< ::paddle::framework::proto::VarType_Type >(element_type_.Get(index)); -} -inline ::paddle::framework::proto::VarType_Type VarType_Tuple::element_type(int index) const { - // @@protoc_insertion_point(field_get:paddle.framework.proto.VarType.Tuple.element_type) - return _internal_element_type(index); -} -inline void VarType_Tuple::set_element_type(int index, ::paddle::framework::proto::VarType_Type value) { - assert(::paddle::framework::proto::VarType_Type_IsValid(value)); - element_type_.Set(index, value); - // @@protoc_insertion_point(field_set:paddle.framework.proto.VarType.Tuple.element_type) -} -inline void VarType_Tuple::_internal_add_element_type(::paddle::framework::proto::VarType_Type value) { - assert(::paddle::framework::proto::VarType_Type_IsValid(value)); - element_type_.Add(value); -} -inline void VarType_Tuple::add_element_type(::paddle::framework::proto::VarType_Type value) { - // @@protoc_insertion_point(field_add:paddle.framework.proto.VarType.Tuple.element_type) - _internal_add_element_type(value); -} -inline const ::PROTOBUF_NAMESPACE_ID::RepeatedField& -VarType_Tuple::element_type() const { - // @@protoc_insertion_point(field_list:paddle.framework.proto.VarType.Tuple.element_type) - return element_type_; -} -inline ::PROTOBUF_NAMESPACE_ID::RepeatedField* -VarType_Tuple::_internal_mutable_element_type() { - return &element_type_; -} -inline ::PROTOBUF_NAMESPACE_ID::RepeatedField* -VarType_Tuple::mutable_element_type() { - // @@protoc_insertion_point(field_mutable_list:paddle.framework.proto.VarType.Tuple.element_type) - return _internal_mutable_element_type(); -} - -// ------------------------------------------------------------------- - -// VarType - -// required .paddle.framework.proto.VarType.Type type = 1; -inline bool VarType::_internal_has_type() const { - bool value = (_has_bits_[0] & 0x00000020u) != 0; - return value; -} -inline bool VarType::has_type() const { - return _internal_has_type(); -} -inline void VarType::clear_type() { - type_ = 0; - _has_bits_[0] &= ~0x00000020u; -} -inline ::paddle::framework::proto::VarType_Type VarType::_internal_type() const { - return static_cast< ::paddle::framework::proto::VarType_Type >(type_); -} -inline ::paddle::framework::proto::VarType_Type VarType::type() const { - // @@protoc_insertion_point(field_get:paddle.framework.proto.VarType.type) - return _internal_type(); -} -inline void VarType::_internal_set_type(::paddle::framework::proto::VarType_Type value) { - assert(::paddle::framework::proto::VarType_Type_IsValid(value)); - _has_bits_[0] |= 0x00000020u; - type_ = value; -} -inline void VarType::set_type(::paddle::framework::proto::VarType_Type value) { - _internal_set_type(value); - // @@protoc_insertion_point(field_set:paddle.framework.proto.VarType.type) -} - -// optional .paddle.framework.proto.VarType.TensorDesc selected_rows = 2; -inline bool VarType::_internal_has_selected_rows() const { - bool value = (_has_bits_[0] & 0x00000001u) != 0; - PROTOBUF_ASSUME(!value || selected_rows_ != nullptr); - return value; -} -inline bool VarType::has_selected_rows() const { - return _internal_has_selected_rows(); -} -inline void VarType::clear_selected_rows() { - if (selected_rows_ != nullptr) selected_rows_->Clear(); - _has_bits_[0] &= ~0x00000001u; -} -inline const ::paddle::framework::proto::VarType_TensorDesc& VarType::_internal_selected_rows() const { - const ::paddle::framework::proto::VarType_TensorDesc* p = selected_rows_; - return p != nullptr ? *p : reinterpret_cast( - ::paddle::framework::proto::_VarType_TensorDesc_default_instance_); -} -inline const ::paddle::framework::proto::VarType_TensorDesc& VarType::selected_rows() const { - // @@protoc_insertion_point(field_get:paddle.framework.proto.VarType.selected_rows) - return _internal_selected_rows(); -} -inline void VarType::unsafe_arena_set_allocated_selected_rows( - ::paddle::framework::proto::VarType_TensorDesc* selected_rows) { - if (GetArena() == nullptr) { - delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(selected_rows_); - } - selected_rows_ = selected_rows; - if (selected_rows) { - _has_bits_[0] |= 0x00000001u; - } else { - _has_bits_[0] &= ~0x00000001u; - } - // @@protoc_insertion_point(field_unsafe_arena_set_allocated:paddle.framework.proto.VarType.selected_rows) -} -inline ::paddle::framework::proto::VarType_TensorDesc* VarType::release_selected_rows() { - _has_bits_[0] &= ~0x00000001u; - ::paddle::framework::proto::VarType_TensorDesc* temp = selected_rows_; - selected_rows_ = nullptr; - if (GetArena() != nullptr) { - temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); - } - return temp; -} -inline ::paddle::framework::proto::VarType_TensorDesc* VarType::unsafe_arena_release_selected_rows() { - // @@protoc_insertion_point(field_release:paddle.framework.proto.VarType.selected_rows) - _has_bits_[0] &= ~0x00000001u; - ::paddle::framework::proto::VarType_TensorDesc* temp = selected_rows_; - selected_rows_ = nullptr; - return temp; -} -inline ::paddle::framework::proto::VarType_TensorDesc* VarType::_internal_mutable_selected_rows() { - _has_bits_[0] |= 0x00000001u; - if (selected_rows_ == nullptr) { - auto* p = CreateMaybeMessage<::paddle::framework::proto::VarType_TensorDesc>(GetArena()); - selected_rows_ = p; - } - return selected_rows_; -} -inline ::paddle::framework::proto::VarType_TensorDesc* VarType::mutable_selected_rows() { - // @@protoc_insertion_point(field_mutable:paddle.framework.proto.VarType.selected_rows) - return _internal_mutable_selected_rows(); -} -inline void VarType::set_allocated_selected_rows(::paddle::framework::proto::VarType_TensorDesc* selected_rows) { - ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArena(); - if (message_arena == nullptr) { - delete selected_rows_; - } - if (selected_rows) { - ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = - ::PROTOBUF_NAMESPACE_ID::Arena::GetArena(selected_rows); - if (message_arena != submessage_arena) { - selected_rows = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( - message_arena, selected_rows, submessage_arena); - } - _has_bits_[0] |= 0x00000001u; - } else { - _has_bits_[0] &= ~0x00000001u; - } - selected_rows_ = selected_rows; - // @@protoc_insertion_point(field_set_allocated:paddle.framework.proto.VarType.selected_rows) -} - -// optional .paddle.framework.proto.VarType.LoDTensorDesc lod_tensor = 3; -inline bool VarType::_internal_has_lod_tensor() const { - bool value = (_has_bits_[0] & 0x00000002u) != 0; - PROTOBUF_ASSUME(!value || lod_tensor_ != nullptr); - return value; -} -inline bool VarType::has_lod_tensor() const { - return _internal_has_lod_tensor(); -} -inline void VarType::clear_lod_tensor() { - if (lod_tensor_ != nullptr) lod_tensor_->Clear(); - _has_bits_[0] &= ~0x00000002u; -} -inline const ::paddle::framework::proto::VarType_LoDTensorDesc& VarType::_internal_lod_tensor() const { - const ::paddle::framework::proto::VarType_LoDTensorDesc* p = lod_tensor_; - return p != nullptr ? *p : reinterpret_cast( - ::paddle::framework::proto::_VarType_LoDTensorDesc_default_instance_); -} -inline const ::paddle::framework::proto::VarType_LoDTensorDesc& VarType::lod_tensor() const { - // @@protoc_insertion_point(field_get:paddle.framework.proto.VarType.lod_tensor) - return _internal_lod_tensor(); -} -inline void VarType::unsafe_arena_set_allocated_lod_tensor( - ::paddle::framework::proto::VarType_LoDTensorDesc* lod_tensor) { - if (GetArena() == nullptr) { - delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(lod_tensor_); - } - lod_tensor_ = lod_tensor; - if (lod_tensor) { - _has_bits_[0] |= 0x00000002u; - } else { - _has_bits_[0] &= ~0x00000002u; - } - // @@protoc_insertion_point(field_unsafe_arena_set_allocated:paddle.framework.proto.VarType.lod_tensor) -} -inline ::paddle::framework::proto::VarType_LoDTensorDesc* VarType::release_lod_tensor() { - _has_bits_[0] &= ~0x00000002u; - ::paddle::framework::proto::VarType_LoDTensorDesc* temp = lod_tensor_; - lod_tensor_ = nullptr; - if (GetArena() != nullptr) { - temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); - } - return temp; -} -inline ::paddle::framework::proto::VarType_LoDTensorDesc* VarType::unsafe_arena_release_lod_tensor() { - // @@protoc_insertion_point(field_release:paddle.framework.proto.VarType.lod_tensor) - _has_bits_[0] &= ~0x00000002u; - ::paddle::framework::proto::VarType_LoDTensorDesc* temp = lod_tensor_; - lod_tensor_ = nullptr; - return temp; -} -inline ::paddle::framework::proto::VarType_LoDTensorDesc* VarType::_internal_mutable_lod_tensor() { - _has_bits_[0] |= 0x00000002u; - if (lod_tensor_ == nullptr) { - auto* p = CreateMaybeMessage<::paddle::framework::proto::VarType_LoDTensorDesc>(GetArena()); - lod_tensor_ = p; - } - return lod_tensor_; -} -inline ::paddle::framework::proto::VarType_LoDTensorDesc* VarType::mutable_lod_tensor() { - // @@protoc_insertion_point(field_mutable:paddle.framework.proto.VarType.lod_tensor) - return _internal_mutable_lod_tensor(); -} -inline void VarType::set_allocated_lod_tensor(::paddle::framework::proto::VarType_LoDTensorDesc* lod_tensor) { - ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArena(); - if (message_arena == nullptr) { - delete lod_tensor_; - } - if (lod_tensor) { - ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = - ::PROTOBUF_NAMESPACE_ID::Arena::GetArena(lod_tensor); - if (message_arena != submessage_arena) { - lod_tensor = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( - message_arena, lod_tensor, submessage_arena); - } - _has_bits_[0] |= 0x00000002u; - } else { - _has_bits_[0] &= ~0x00000002u; - } - lod_tensor_ = lod_tensor; - // @@protoc_insertion_point(field_set_allocated:paddle.framework.proto.VarType.lod_tensor) -} - -// optional .paddle.framework.proto.VarType.LoDTensorArrayDesc tensor_array = 4; -inline bool VarType::_internal_has_tensor_array() const { - bool value = (_has_bits_[0] & 0x00000004u) != 0; - PROTOBUF_ASSUME(!value || tensor_array_ != nullptr); - return value; -} -inline bool VarType::has_tensor_array() const { - return _internal_has_tensor_array(); -} -inline void VarType::clear_tensor_array() { - if (tensor_array_ != nullptr) tensor_array_->Clear(); - _has_bits_[0] &= ~0x00000004u; -} -inline const ::paddle::framework::proto::VarType_LoDTensorArrayDesc& VarType::_internal_tensor_array() const { - const ::paddle::framework::proto::VarType_LoDTensorArrayDesc* p = tensor_array_; - return p != nullptr ? *p : reinterpret_cast( - ::paddle::framework::proto::_VarType_LoDTensorArrayDesc_default_instance_); -} -inline const ::paddle::framework::proto::VarType_LoDTensorArrayDesc& VarType::tensor_array() const { - // @@protoc_insertion_point(field_get:paddle.framework.proto.VarType.tensor_array) - return _internal_tensor_array(); -} -inline void VarType::unsafe_arena_set_allocated_tensor_array( - ::paddle::framework::proto::VarType_LoDTensorArrayDesc* tensor_array) { - if (GetArena() == nullptr) { - delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(tensor_array_); - } - tensor_array_ = tensor_array; - if (tensor_array) { - _has_bits_[0] |= 0x00000004u; - } else { - _has_bits_[0] &= ~0x00000004u; - } - // @@protoc_insertion_point(field_unsafe_arena_set_allocated:paddle.framework.proto.VarType.tensor_array) -} -inline ::paddle::framework::proto::VarType_LoDTensorArrayDesc* VarType::release_tensor_array() { - _has_bits_[0] &= ~0x00000004u; - ::paddle::framework::proto::VarType_LoDTensorArrayDesc* temp = tensor_array_; - tensor_array_ = nullptr; - if (GetArena() != nullptr) { - temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); - } - return temp; -} -inline ::paddle::framework::proto::VarType_LoDTensorArrayDesc* VarType::unsafe_arena_release_tensor_array() { - // @@protoc_insertion_point(field_release:paddle.framework.proto.VarType.tensor_array) - _has_bits_[0] &= ~0x00000004u; - ::paddle::framework::proto::VarType_LoDTensorArrayDesc* temp = tensor_array_; - tensor_array_ = nullptr; - return temp; -} -inline ::paddle::framework::proto::VarType_LoDTensorArrayDesc* VarType::_internal_mutable_tensor_array() { - _has_bits_[0] |= 0x00000004u; - if (tensor_array_ == nullptr) { - auto* p = CreateMaybeMessage<::paddle::framework::proto::VarType_LoDTensorArrayDesc>(GetArena()); - tensor_array_ = p; - } - return tensor_array_; -} -inline ::paddle::framework::proto::VarType_LoDTensorArrayDesc* VarType::mutable_tensor_array() { - // @@protoc_insertion_point(field_mutable:paddle.framework.proto.VarType.tensor_array) - return _internal_mutable_tensor_array(); -} -inline void VarType::set_allocated_tensor_array(::paddle::framework::proto::VarType_LoDTensorArrayDesc* tensor_array) { - ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArena(); - if (message_arena == nullptr) { - delete tensor_array_; - } - if (tensor_array) { - ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = - ::PROTOBUF_NAMESPACE_ID::Arena::GetArena(tensor_array); - if (message_arena != submessage_arena) { - tensor_array = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( - message_arena, tensor_array, submessage_arena); - } - _has_bits_[0] |= 0x00000004u; - } else { - _has_bits_[0] &= ~0x00000004u; - } - tensor_array_ = tensor_array; - // @@protoc_insertion_point(field_set_allocated:paddle.framework.proto.VarType.tensor_array) -} - -// optional .paddle.framework.proto.VarType.ReaderDesc reader = 5; -inline bool VarType::_internal_has_reader() const { - bool value = (_has_bits_[0] & 0x00000008u) != 0; - PROTOBUF_ASSUME(!value || reader_ != nullptr); - return value; -} -inline bool VarType::has_reader() const { - return _internal_has_reader(); -} -inline void VarType::clear_reader() { - if (reader_ != nullptr) reader_->Clear(); - _has_bits_[0] &= ~0x00000008u; -} -inline const ::paddle::framework::proto::VarType_ReaderDesc& VarType::_internal_reader() const { - const ::paddle::framework::proto::VarType_ReaderDesc* p = reader_; - return p != nullptr ? *p : reinterpret_cast( - ::paddle::framework::proto::_VarType_ReaderDesc_default_instance_); -} -inline const ::paddle::framework::proto::VarType_ReaderDesc& VarType::reader() const { - // @@protoc_insertion_point(field_get:paddle.framework.proto.VarType.reader) - return _internal_reader(); -} -inline void VarType::unsafe_arena_set_allocated_reader( - ::paddle::framework::proto::VarType_ReaderDesc* reader) { - if (GetArena() == nullptr) { - delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(reader_); - } - reader_ = reader; - if (reader) { - _has_bits_[0] |= 0x00000008u; - } else { - _has_bits_[0] &= ~0x00000008u; - } - // @@protoc_insertion_point(field_unsafe_arena_set_allocated:paddle.framework.proto.VarType.reader) -} -inline ::paddle::framework::proto::VarType_ReaderDesc* VarType::release_reader() { - _has_bits_[0] &= ~0x00000008u; - ::paddle::framework::proto::VarType_ReaderDesc* temp = reader_; - reader_ = nullptr; - if (GetArena() != nullptr) { - temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); - } - return temp; -} -inline ::paddle::framework::proto::VarType_ReaderDesc* VarType::unsafe_arena_release_reader() { - // @@protoc_insertion_point(field_release:paddle.framework.proto.VarType.reader) - _has_bits_[0] &= ~0x00000008u; - ::paddle::framework::proto::VarType_ReaderDesc* temp = reader_; - reader_ = nullptr; - return temp; -} -inline ::paddle::framework::proto::VarType_ReaderDesc* VarType::_internal_mutable_reader() { - _has_bits_[0] |= 0x00000008u; - if (reader_ == nullptr) { - auto* p = CreateMaybeMessage<::paddle::framework::proto::VarType_ReaderDesc>(GetArena()); - reader_ = p; - } - return reader_; -} -inline ::paddle::framework::proto::VarType_ReaderDesc* VarType::mutable_reader() { - // @@protoc_insertion_point(field_mutable:paddle.framework.proto.VarType.reader) - return _internal_mutable_reader(); -} -inline void VarType::set_allocated_reader(::paddle::framework::proto::VarType_ReaderDesc* reader) { - ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArena(); - if (message_arena == nullptr) { - delete reader_; - } - if (reader) { - ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = - ::PROTOBUF_NAMESPACE_ID::Arena::GetArena(reader); - if (message_arena != submessage_arena) { - reader = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( - message_arena, reader, submessage_arena); - } - _has_bits_[0] |= 0x00000008u; - } else { - _has_bits_[0] &= ~0x00000008u; - } - reader_ = reader; - // @@protoc_insertion_point(field_set_allocated:paddle.framework.proto.VarType.reader) -} - -// optional .paddle.framework.proto.VarType.Tuple tuple = 7; -inline bool VarType::_internal_has_tuple() const { - bool value = (_has_bits_[0] & 0x00000010u) != 0; - PROTOBUF_ASSUME(!value || tuple_ != nullptr); - return value; -} -inline bool VarType::has_tuple() const { - return _internal_has_tuple(); -} -inline void VarType::clear_tuple() { - if (tuple_ != nullptr) tuple_->Clear(); - _has_bits_[0] &= ~0x00000010u; -} -inline const ::paddle::framework::proto::VarType_Tuple& VarType::_internal_tuple() const { - const ::paddle::framework::proto::VarType_Tuple* p = tuple_; - return p != nullptr ? *p : reinterpret_cast( - ::paddle::framework::proto::_VarType_Tuple_default_instance_); -} -inline const ::paddle::framework::proto::VarType_Tuple& VarType::tuple() const { - // @@protoc_insertion_point(field_get:paddle.framework.proto.VarType.tuple) - return _internal_tuple(); -} -inline void VarType::unsafe_arena_set_allocated_tuple( - ::paddle::framework::proto::VarType_Tuple* tuple) { - if (GetArena() == nullptr) { - delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(tuple_); - } - tuple_ = tuple; - if (tuple) { - _has_bits_[0] |= 0x00000010u; - } else { - _has_bits_[0] &= ~0x00000010u; - } - // @@protoc_insertion_point(field_unsafe_arena_set_allocated:paddle.framework.proto.VarType.tuple) -} -inline ::paddle::framework::proto::VarType_Tuple* VarType::release_tuple() { - _has_bits_[0] &= ~0x00000010u; - ::paddle::framework::proto::VarType_Tuple* temp = tuple_; - tuple_ = nullptr; - if (GetArena() != nullptr) { - temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); - } - return temp; -} -inline ::paddle::framework::proto::VarType_Tuple* VarType::unsafe_arena_release_tuple() { - // @@protoc_insertion_point(field_release:paddle.framework.proto.VarType.tuple) - _has_bits_[0] &= ~0x00000010u; - ::paddle::framework::proto::VarType_Tuple* temp = tuple_; - tuple_ = nullptr; - return temp; -} -inline ::paddle::framework::proto::VarType_Tuple* VarType::_internal_mutable_tuple() { - _has_bits_[0] |= 0x00000010u; - if (tuple_ == nullptr) { - auto* p = CreateMaybeMessage<::paddle::framework::proto::VarType_Tuple>(GetArena()); - tuple_ = p; - } - return tuple_; -} -inline ::paddle::framework::proto::VarType_Tuple* VarType::mutable_tuple() { - // @@protoc_insertion_point(field_mutable:paddle.framework.proto.VarType.tuple) - return _internal_mutable_tuple(); -} -inline void VarType::set_allocated_tuple(::paddle::framework::proto::VarType_Tuple* tuple) { - ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArena(); - if (message_arena == nullptr) { - delete tuple_; - } - if (tuple) { - ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = - ::PROTOBUF_NAMESPACE_ID::Arena::GetArena(tuple); - if (message_arena != submessage_arena) { - tuple = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( - message_arena, tuple, submessage_arena); - } - _has_bits_[0] |= 0x00000010u; - } else { - _has_bits_[0] &= ~0x00000010u; - } - tuple_ = tuple; - // @@protoc_insertion_point(field_set_allocated:paddle.framework.proto.VarType.tuple) -} - -// ------------------------------------------------------------------- - -// VarDesc - -// required string name = 1; -inline bool VarDesc::_internal_has_name() const { - bool value = (_has_bits_[0] & 0x00000001u) != 0; - return value; -} -inline bool VarDesc::has_name() const { - return _internal_has_name(); -} -inline void VarDesc::clear_name() { - name_.ClearToEmpty(); - _has_bits_[0] &= ~0x00000001u; -} -inline const std::string& VarDesc::name() const { - // @@protoc_insertion_point(field_get:paddle.framework.proto.VarDesc.name) - return _internal_name(); -} -inline void VarDesc::set_name(const std::string& value) { - _internal_set_name(value); - // @@protoc_insertion_point(field_set:paddle.framework.proto.VarDesc.name) -} -inline std::string* VarDesc::mutable_name() { - // @@protoc_insertion_point(field_mutable:paddle.framework.proto.VarDesc.name) - return _internal_mutable_name(); -} -inline const std::string& VarDesc::_internal_name() const { - return name_.Get(); -} -inline void VarDesc::_internal_set_name(const std::string& value) { - _has_bits_[0] |= 0x00000001u; - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); -} -inline void VarDesc::set_name(std::string&& value) { - _has_bits_[0] |= 0x00000001u; - name_.Set( - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena()); - // @@protoc_insertion_point(field_set_rvalue:paddle.framework.proto.VarDesc.name) -} -inline void VarDesc::set_name(const char* value) { - GOOGLE_DCHECK(value != nullptr); - _has_bits_[0] |= 0x00000001u; - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena()); - // @@protoc_insertion_point(field_set_char:paddle.framework.proto.VarDesc.name) -} -inline void VarDesc::set_name(const char* value, - size_t size) { - _has_bits_[0] |= 0x00000001u; - name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string( - reinterpret_cast(value), size), GetArena()); - // @@protoc_insertion_point(field_set_pointer:paddle.framework.proto.VarDesc.name) -} -inline std::string* VarDesc::_internal_mutable_name() { - _has_bits_[0] |= 0x00000001u; - return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); -} -inline std::string* VarDesc::release_name() { - // @@protoc_insertion_point(field_release:paddle.framework.proto.VarDesc.name) - if (!_internal_has_name()) { - return nullptr; - } - _has_bits_[0] &= ~0x00000001u; - return name_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); -} -inline void VarDesc::set_allocated_name(std::string* name) { - if (name != nullptr) { - _has_bits_[0] |= 0x00000001u; - } else { - _has_bits_[0] &= ~0x00000001u; - } - name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name, - GetArena()); - // @@protoc_insertion_point(field_set_allocated:paddle.framework.proto.VarDesc.name) -} - -// required .paddle.framework.proto.VarType type = 2; -inline bool VarDesc::_internal_has_type() const { - bool value = (_has_bits_[0] & 0x00000002u) != 0; - PROTOBUF_ASSUME(!value || type_ != nullptr); - return value; -} -inline bool VarDesc::has_type() const { - return _internal_has_type(); -} -inline void VarDesc::clear_type() { - if (type_ != nullptr) type_->Clear(); - _has_bits_[0] &= ~0x00000002u; -} -inline const ::paddle::framework::proto::VarType& VarDesc::_internal_type() const { - const ::paddle::framework::proto::VarType* p = type_; - return p != nullptr ? *p : reinterpret_cast( - ::paddle::framework::proto::_VarType_default_instance_); -} -inline const ::paddle::framework::proto::VarType& VarDesc::type() const { - // @@protoc_insertion_point(field_get:paddle.framework.proto.VarDesc.type) - return _internal_type(); -} -inline void VarDesc::unsafe_arena_set_allocated_type( - ::paddle::framework::proto::VarType* type) { - if (GetArena() == nullptr) { - delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(type_); - } - type_ = type; - if (type) { - _has_bits_[0] |= 0x00000002u; - } else { - _has_bits_[0] &= ~0x00000002u; - } - // @@protoc_insertion_point(field_unsafe_arena_set_allocated:paddle.framework.proto.VarDesc.type) -} -inline ::paddle::framework::proto::VarType* VarDesc::release_type() { - _has_bits_[0] &= ~0x00000002u; - ::paddle::framework::proto::VarType* temp = type_; - type_ = nullptr; - if (GetArena() != nullptr) { - temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); - } - return temp; -} -inline ::paddle::framework::proto::VarType* VarDesc::unsafe_arena_release_type() { - // @@protoc_insertion_point(field_release:paddle.framework.proto.VarDesc.type) - _has_bits_[0] &= ~0x00000002u; - ::paddle::framework::proto::VarType* temp = type_; - type_ = nullptr; - return temp; -} -inline ::paddle::framework::proto::VarType* VarDesc::_internal_mutable_type() { - _has_bits_[0] |= 0x00000002u; - if (type_ == nullptr) { - auto* p = CreateMaybeMessage<::paddle::framework::proto::VarType>(GetArena()); - type_ = p; - } - return type_; -} -inline ::paddle::framework::proto::VarType* VarDesc::mutable_type() { - // @@protoc_insertion_point(field_mutable:paddle.framework.proto.VarDesc.type) - return _internal_mutable_type(); -} -inline void VarDesc::set_allocated_type(::paddle::framework::proto::VarType* type) { - ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArena(); - if (message_arena == nullptr) { - delete type_; - } - if (type) { - ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = - ::PROTOBUF_NAMESPACE_ID::Arena::GetArena(type); - if (message_arena != submessage_arena) { - type = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( - message_arena, type, submessage_arena); - } - _has_bits_[0] |= 0x00000002u; - } else { - _has_bits_[0] &= ~0x00000002u; - } - type_ = type; - // @@protoc_insertion_point(field_set_allocated:paddle.framework.proto.VarDesc.type) -} - -// optional bool persistable = 3 [default = false]; -inline bool VarDesc::_internal_has_persistable() const { - bool value = (_has_bits_[0] & 0x00000004u) != 0; - return value; -} -inline bool VarDesc::has_persistable() const { - return _internal_has_persistable(); -} -inline void VarDesc::clear_persistable() { - persistable_ = false; - _has_bits_[0] &= ~0x00000004u; -} -inline bool VarDesc::_internal_persistable() const { - return persistable_; -} -inline bool VarDesc::persistable() const { - // @@protoc_insertion_point(field_get:paddle.framework.proto.VarDesc.persistable) - return _internal_persistable(); -} -inline void VarDesc::_internal_set_persistable(bool value) { - _has_bits_[0] |= 0x00000004u; - persistable_ = value; -} -inline void VarDesc::set_persistable(bool value) { - _internal_set_persistable(value); - // @@protoc_insertion_point(field_set:paddle.framework.proto.VarDesc.persistable) -} - -// optional bool need_check_feed = 4 [default = false]; -inline bool VarDesc::_internal_has_need_check_feed() const { - bool value = (_has_bits_[0] & 0x00000008u) != 0; - return value; -} -inline bool VarDesc::has_need_check_feed() const { - return _internal_has_need_check_feed(); -} -inline void VarDesc::clear_need_check_feed() { - need_check_feed_ = false; - _has_bits_[0] &= ~0x00000008u; -} -inline bool VarDesc::_internal_need_check_feed() const { - return need_check_feed_; -} -inline bool VarDesc::need_check_feed() const { - // @@protoc_insertion_point(field_get:paddle.framework.proto.VarDesc.need_check_feed) - return _internal_need_check_feed(); -} -inline void VarDesc::_internal_set_need_check_feed(bool value) { - _has_bits_[0] |= 0x00000008u; - need_check_feed_ = value; -} -inline void VarDesc::set_need_check_feed(bool value) { - _internal_set_need_check_feed(value); - // @@protoc_insertion_point(field_set:paddle.framework.proto.VarDesc.need_check_feed) -} - -// ------------------------------------------------------------------- - -// BlockDesc - -// required int32 idx = 1; -inline bool BlockDesc::_internal_has_idx() const { - bool value = (_has_bits_[0] & 0x00000001u) != 0; - return value; -} -inline bool BlockDesc::has_idx() const { - return _internal_has_idx(); -} -inline void BlockDesc::clear_idx() { - idx_ = 0; - _has_bits_[0] &= ~0x00000001u; -} -inline ::PROTOBUF_NAMESPACE_ID::int32 BlockDesc::_internal_idx() const { - return idx_; -} -inline ::PROTOBUF_NAMESPACE_ID::int32 BlockDesc::idx() const { - // @@protoc_insertion_point(field_get:paddle.framework.proto.BlockDesc.idx) - return _internal_idx(); -} -inline void BlockDesc::_internal_set_idx(::PROTOBUF_NAMESPACE_ID::int32 value) { - _has_bits_[0] |= 0x00000001u; - idx_ = value; -} -inline void BlockDesc::set_idx(::PROTOBUF_NAMESPACE_ID::int32 value) { - _internal_set_idx(value); - // @@protoc_insertion_point(field_set:paddle.framework.proto.BlockDesc.idx) -} - -// required int32 parent_idx = 2; -inline bool BlockDesc::_internal_has_parent_idx() const { - bool value = (_has_bits_[0] & 0x00000002u) != 0; - return value; -} -inline bool BlockDesc::has_parent_idx() const { - return _internal_has_parent_idx(); -} -inline void BlockDesc::clear_parent_idx() { - parent_idx_ = 0; - _has_bits_[0] &= ~0x00000002u; -} -inline ::PROTOBUF_NAMESPACE_ID::int32 BlockDesc::_internal_parent_idx() const { - return parent_idx_; -} -inline ::PROTOBUF_NAMESPACE_ID::int32 BlockDesc::parent_idx() const { - // @@protoc_insertion_point(field_get:paddle.framework.proto.BlockDesc.parent_idx) - return _internal_parent_idx(); -} -inline void BlockDesc::_internal_set_parent_idx(::PROTOBUF_NAMESPACE_ID::int32 value) { - _has_bits_[0] |= 0x00000002u; - parent_idx_ = value; -} -inline void BlockDesc::set_parent_idx(::PROTOBUF_NAMESPACE_ID::int32 value) { - _internal_set_parent_idx(value); - // @@protoc_insertion_point(field_set:paddle.framework.proto.BlockDesc.parent_idx) -} - -// repeated .paddle.framework.proto.VarDesc vars = 3; -inline int BlockDesc::_internal_vars_size() const { - return vars_.size(); -} -inline int BlockDesc::vars_size() const { - return _internal_vars_size(); -} -inline void BlockDesc::clear_vars() { - vars_.Clear(); -} -inline ::paddle::framework::proto::VarDesc* BlockDesc::mutable_vars(int index) { - // @@protoc_insertion_point(field_mutable:paddle.framework.proto.BlockDesc.vars) - return vars_.Mutable(index); -} -inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::VarDesc >* -BlockDesc::mutable_vars() { - // @@protoc_insertion_point(field_mutable_list:paddle.framework.proto.BlockDesc.vars) - return &vars_; -} -inline const ::paddle::framework::proto::VarDesc& BlockDesc::_internal_vars(int index) const { - return vars_.Get(index); -} -inline const ::paddle::framework::proto::VarDesc& BlockDesc::vars(int index) const { - // @@protoc_insertion_point(field_get:paddle.framework.proto.BlockDesc.vars) - return _internal_vars(index); -} -inline ::paddle::framework::proto::VarDesc* BlockDesc::_internal_add_vars() { - return vars_.Add(); -} -inline ::paddle::framework::proto::VarDesc* BlockDesc::add_vars() { - // @@protoc_insertion_point(field_add:paddle.framework.proto.BlockDesc.vars) - return _internal_add_vars(); -} -inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::VarDesc >& -BlockDesc::vars() const { - // @@protoc_insertion_point(field_list:paddle.framework.proto.BlockDesc.vars) - return vars_; -} - -// repeated .paddle.framework.proto.OpDesc ops = 4; -inline int BlockDesc::_internal_ops_size() const { - return ops_.size(); -} -inline int BlockDesc::ops_size() const { - return _internal_ops_size(); -} -inline void BlockDesc::clear_ops() { - ops_.Clear(); -} -inline ::paddle::framework::proto::OpDesc* BlockDesc::mutable_ops(int index) { - // @@protoc_insertion_point(field_mutable:paddle.framework.proto.BlockDesc.ops) - return ops_.Mutable(index); -} -inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::OpDesc >* -BlockDesc::mutable_ops() { - // @@protoc_insertion_point(field_mutable_list:paddle.framework.proto.BlockDesc.ops) - return &ops_; -} -inline const ::paddle::framework::proto::OpDesc& BlockDesc::_internal_ops(int index) const { - return ops_.Get(index); -} -inline const ::paddle::framework::proto::OpDesc& BlockDesc::ops(int index) const { - // @@protoc_insertion_point(field_get:paddle.framework.proto.BlockDesc.ops) - return _internal_ops(index); -} -inline ::paddle::framework::proto::OpDesc* BlockDesc::_internal_add_ops() { - return ops_.Add(); -} -inline ::paddle::framework::proto::OpDesc* BlockDesc::add_ops() { - // @@protoc_insertion_point(field_add:paddle.framework.proto.BlockDesc.ops) - return _internal_add_ops(); -} -inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::OpDesc >& -BlockDesc::ops() const { - // @@protoc_insertion_point(field_list:paddle.framework.proto.BlockDesc.ops) - return ops_; -} - -// optional int32 forward_block_idx = 5 [default = -1]; -inline bool BlockDesc::_internal_has_forward_block_idx() const { - bool value = (_has_bits_[0] & 0x00000004u) != 0; - return value; -} -inline bool BlockDesc::has_forward_block_idx() const { - return _internal_has_forward_block_idx(); -} -inline void BlockDesc::clear_forward_block_idx() { - forward_block_idx_ = -1; - _has_bits_[0] &= ~0x00000004u; -} -inline ::PROTOBUF_NAMESPACE_ID::int32 BlockDesc::_internal_forward_block_idx() const { - return forward_block_idx_; -} -inline ::PROTOBUF_NAMESPACE_ID::int32 BlockDesc::forward_block_idx() const { - // @@protoc_insertion_point(field_get:paddle.framework.proto.BlockDesc.forward_block_idx) - return _internal_forward_block_idx(); -} -inline void BlockDesc::_internal_set_forward_block_idx(::PROTOBUF_NAMESPACE_ID::int32 value) { - _has_bits_[0] |= 0x00000004u; - forward_block_idx_ = value; -} -inline void BlockDesc::set_forward_block_idx(::PROTOBUF_NAMESPACE_ID::int32 value) { - _internal_set_forward_block_idx(value); - // @@protoc_insertion_point(field_set:paddle.framework.proto.BlockDesc.forward_block_idx) -} - -// ------------------------------------------------------------------- - -// OpVersion - -// required int32 version = 1; -inline bool OpVersion::_internal_has_version() const { - bool value = (_has_bits_[0] & 0x00000001u) != 0; - return value; -} -inline bool OpVersion::has_version() const { - return _internal_has_version(); -} -inline void OpVersion::clear_version() { - version_ = 0; - _has_bits_[0] &= ~0x00000001u; -} -inline ::PROTOBUF_NAMESPACE_ID::int32 OpVersion::_internal_version() const { - return version_; -} -inline ::PROTOBUF_NAMESPACE_ID::int32 OpVersion::version() const { - // @@protoc_insertion_point(field_get:paddle.framework.proto.OpVersion.version) - return _internal_version(); -} -inline void OpVersion::_internal_set_version(::PROTOBUF_NAMESPACE_ID::int32 value) { - _has_bits_[0] |= 0x00000001u; - version_ = value; -} -inline void OpVersion::set_version(::PROTOBUF_NAMESPACE_ID::int32 value) { - _internal_set_version(value); - // @@protoc_insertion_point(field_set:paddle.framework.proto.OpVersion.version) -} - -// ------------------------------------------------------------------- - -// OpVersionMap_OpVersionPair - -// required string op_name = 1; -inline bool OpVersionMap_OpVersionPair::_internal_has_op_name() const { - bool value = (_has_bits_[0] & 0x00000001u) != 0; - return value; -} -inline bool OpVersionMap_OpVersionPair::has_op_name() const { - return _internal_has_op_name(); -} -inline void OpVersionMap_OpVersionPair::clear_op_name() { - op_name_.ClearToEmpty(); - _has_bits_[0] &= ~0x00000001u; -} -inline const std::string& OpVersionMap_OpVersionPair::op_name() const { - // @@protoc_insertion_point(field_get:paddle.framework.proto.OpVersionMap.OpVersionPair.op_name) - return _internal_op_name(); -} -inline void OpVersionMap_OpVersionPair::set_op_name(const std::string& value) { - _internal_set_op_name(value); - // @@protoc_insertion_point(field_set:paddle.framework.proto.OpVersionMap.OpVersionPair.op_name) -} -inline std::string* OpVersionMap_OpVersionPair::mutable_op_name() { - // @@protoc_insertion_point(field_mutable:paddle.framework.proto.OpVersionMap.OpVersionPair.op_name) - return _internal_mutable_op_name(); -} -inline const std::string& OpVersionMap_OpVersionPair::_internal_op_name() const { - return op_name_.Get(); -} -inline void OpVersionMap_OpVersionPair::_internal_set_op_name(const std::string& value) { - _has_bits_[0] |= 0x00000001u; - op_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArena()); -} -inline void OpVersionMap_OpVersionPair::set_op_name(std::string&& value) { - _has_bits_[0] |= 0x00000001u; - op_name_.Set( - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::move(value), GetArena()); - // @@protoc_insertion_point(field_set_rvalue:paddle.framework.proto.OpVersionMap.OpVersionPair.op_name) -} -inline void OpVersionMap_OpVersionPair::set_op_name(const char* value) { - GOOGLE_DCHECK(value != nullptr); - _has_bits_[0] |= 0x00000001u; - op_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string(value), GetArena()); - // @@protoc_insertion_point(field_set_char:paddle.framework.proto.OpVersionMap.OpVersionPair.op_name) -} -inline void OpVersionMap_OpVersionPair::set_op_name(const char* value, - size_t size) { - _has_bits_[0] |= 0x00000001u; - op_name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, ::std::string( - reinterpret_cast(value), size), GetArena()); - // @@protoc_insertion_point(field_set_pointer:paddle.framework.proto.OpVersionMap.OpVersionPair.op_name) -} -inline std::string* OpVersionMap_OpVersionPair::_internal_mutable_op_name() { - _has_bits_[0] |= 0x00000001u; - return op_name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArena()); -} -inline std::string* OpVersionMap_OpVersionPair::release_op_name() { - // @@protoc_insertion_point(field_release:paddle.framework.proto.OpVersionMap.OpVersionPair.op_name) - if (!_internal_has_op_name()) { - return nullptr; - } - _has_bits_[0] &= ~0x00000001u; - return op_name_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); -} -inline void OpVersionMap_OpVersionPair::set_allocated_op_name(std::string* op_name) { - if (op_name != nullptr) { - _has_bits_[0] |= 0x00000001u; - } else { - _has_bits_[0] &= ~0x00000001u; - } - op_name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), op_name, - GetArena()); - // @@protoc_insertion_point(field_set_allocated:paddle.framework.proto.OpVersionMap.OpVersionPair.op_name) -} - -// required .paddle.framework.proto.OpVersion op_version = 2; -inline bool OpVersionMap_OpVersionPair::_internal_has_op_version() const { - bool value = (_has_bits_[0] & 0x00000002u) != 0; - PROTOBUF_ASSUME(!value || op_version_ != nullptr); - return value; -} -inline bool OpVersionMap_OpVersionPair::has_op_version() const { - return _internal_has_op_version(); -} -inline void OpVersionMap_OpVersionPair::clear_op_version() { - if (op_version_ != nullptr) op_version_->Clear(); - _has_bits_[0] &= ~0x00000002u; -} -inline const ::paddle::framework::proto::OpVersion& OpVersionMap_OpVersionPair::_internal_op_version() const { - const ::paddle::framework::proto::OpVersion* p = op_version_; - return p != nullptr ? *p : reinterpret_cast( - ::paddle::framework::proto::_OpVersion_default_instance_); -} -inline const ::paddle::framework::proto::OpVersion& OpVersionMap_OpVersionPair::op_version() const { - // @@protoc_insertion_point(field_get:paddle.framework.proto.OpVersionMap.OpVersionPair.op_version) - return _internal_op_version(); -} -inline void OpVersionMap_OpVersionPair::unsafe_arena_set_allocated_op_version( - ::paddle::framework::proto::OpVersion* op_version) { - if (GetArena() == nullptr) { - delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(op_version_); - } - op_version_ = op_version; - if (op_version) { - _has_bits_[0] |= 0x00000002u; - } else { - _has_bits_[0] &= ~0x00000002u; - } - // @@protoc_insertion_point(field_unsafe_arena_set_allocated:paddle.framework.proto.OpVersionMap.OpVersionPair.op_version) -} -inline ::paddle::framework::proto::OpVersion* OpVersionMap_OpVersionPair::release_op_version() { - _has_bits_[0] &= ~0x00000002u; - ::paddle::framework::proto::OpVersion* temp = op_version_; - op_version_ = nullptr; - if (GetArena() != nullptr) { - temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); - } - return temp; -} -inline ::paddle::framework::proto::OpVersion* OpVersionMap_OpVersionPair::unsafe_arena_release_op_version() { - // @@protoc_insertion_point(field_release:paddle.framework.proto.OpVersionMap.OpVersionPair.op_version) - _has_bits_[0] &= ~0x00000002u; - ::paddle::framework::proto::OpVersion* temp = op_version_; - op_version_ = nullptr; - return temp; -} -inline ::paddle::framework::proto::OpVersion* OpVersionMap_OpVersionPair::_internal_mutable_op_version() { - _has_bits_[0] |= 0x00000002u; - if (op_version_ == nullptr) { - auto* p = CreateMaybeMessage<::paddle::framework::proto::OpVersion>(GetArena()); - op_version_ = p; - } - return op_version_; -} -inline ::paddle::framework::proto::OpVersion* OpVersionMap_OpVersionPair::mutable_op_version() { - // @@protoc_insertion_point(field_mutable:paddle.framework.proto.OpVersionMap.OpVersionPair.op_version) - return _internal_mutable_op_version(); -} -inline void OpVersionMap_OpVersionPair::set_allocated_op_version(::paddle::framework::proto::OpVersion* op_version) { - ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArena(); - if (message_arena == nullptr) { - delete op_version_; - } - if (op_version) { - ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = - ::PROTOBUF_NAMESPACE_ID::Arena::GetArena(op_version); - if (message_arena != submessage_arena) { - op_version = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( - message_arena, op_version, submessage_arena); - } - _has_bits_[0] |= 0x00000002u; - } else { - _has_bits_[0] &= ~0x00000002u; - } - op_version_ = op_version; - // @@protoc_insertion_point(field_set_allocated:paddle.framework.proto.OpVersionMap.OpVersionPair.op_version) -} - -// ------------------------------------------------------------------- - -// OpVersionMap - -// repeated .paddle.framework.proto.OpVersionMap.OpVersionPair pair = 1; -inline int OpVersionMap::_internal_pair_size() const { - return pair_.size(); -} -inline int OpVersionMap::pair_size() const { - return _internal_pair_size(); -} -inline void OpVersionMap::clear_pair() { - pair_.Clear(); -} -inline ::paddle::framework::proto::OpVersionMap_OpVersionPair* OpVersionMap::mutable_pair(int index) { - // @@protoc_insertion_point(field_mutable:paddle.framework.proto.OpVersionMap.pair) - return pair_.Mutable(index); -} -inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::OpVersionMap_OpVersionPair >* -OpVersionMap::mutable_pair() { - // @@protoc_insertion_point(field_mutable_list:paddle.framework.proto.OpVersionMap.pair) - return &pair_; -} -inline const ::paddle::framework::proto::OpVersionMap_OpVersionPair& OpVersionMap::_internal_pair(int index) const { - return pair_.Get(index); -} -inline const ::paddle::framework::proto::OpVersionMap_OpVersionPair& OpVersionMap::pair(int index) const { - // @@protoc_insertion_point(field_get:paddle.framework.proto.OpVersionMap.pair) - return _internal_pair(index); -} -inline ::paddle::framework::proto::OpVersionMap_OpVersionPair* OpVersionMap::_internal_add_pair() { - return pair_.Add(); -} -inline ::paddle::framework::proto::OpVersionMap_OpVersionPair* OpVersionMap::add_pair() { - // @@protoc_insertion_point(field_add:paddle.framework.proto.OpVersionMap.pair) - return _internal_add_pair(); -} -inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::OpVersionMap_OpVersionPair >& -OpVersionMap::pair() const { - // @@protoc_insertion_point(field_list:paddle.framework.proto.OpVersionMap.pair) - return pair_; -} - -// ------------------------------------------------------------------- - -// ProgramDesc - -// repeated .paddle.framework.proto.BlockDesc blocks = 1; -inline int ProgramDesc::_internal_blocks_size() const { - return blocks_.size(); -} -inline int ProgramDesc::blocks_size() const { - return _internal_blocks_size(); -} -inline void ProgramDesc::clear_blocks() { - blocks_.Clear(); -} -inline ::paddle::framework::proto::BlockDesc* ProgramDesc::mutable_blocks(int index) { - // @@protoc_insertion_point(field_mutable:paddle.framework.proto.ProgramDesc.blocks) - return blocks_.Mutable(index); -} -inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::BlockDesc >* -ProgramDesc::mutable_blocks() { - // @@protoc_insertion_point(field_mutable_list:paddle.framework.proto.ProgramDesc.blocks) - return &blocks_; -} -inline const ::paddle::framework::proto::BlockDesc& ProgramDesc::_internal_blocks(int index) const { - return blocks_.Get(index); -} -inline const ::paddle::framework::proto::BlockDesc& ProgramDesc::blocks(int index) const { - // @@protoc_insertion_point(field_get:paddle.framework.proto.ProgramDesc.blocks) - return _internal_blocks(index); -} -inline ::paddle::framework::proto::BlockDesc* ProgramDesc::_internal_add_blocks() { - return blocks_.Add(); -} -inline ::paddle::framework::proto::BlockDesc* ProgramDesc::add_blocks() { - // @@protoc_insertion_point(field_add:paddle.framework.proto.ProgramDesc.blocks) - return _internal_add_blocks(); -} -inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::paddle::framework::proto::BlockDesc >& -ProgramDesc::blocks() const { - // @@protoc_insertion_point(field_list:paddle.framework.proto.ProgramDesc.blocks) - return blocks_; -} - -// optional .paddle.framework.proto.Version version = 4; -inline bool ProgramDesc::_internal_has_version() const { - bool value = (_has_bits_[0] & 0x00000001u) != 0; - PROTOBUF_ASSUME(!value || version_ != nullptr); - return value; -} -inline bool ProgramDesc::has_version() const { - return _internal_has_version(); -} -inline void ProgramDesc::clear_version() { - if (version_ != nullptr) version_->Clear(); - _has_bits_[0] &= ~0x00000001u; -} -inline const ::paddle::framework::proto::Version& ProgramDesc::_internal_version() const { - const ::paddle::framework::proto::Version* p = version_; - return p != nullptr ? *p : reinterpret_cast( - ::paddle::framework::proto::_Version_default_instance_); -} -inline const ::paddle::framework::proto::Version& ProgramDesc::version() const { - // @@protoc_insertion_point(field_get:paddle.framework.proto.ProgramDesc.version) - return _internal_version(); -} -inline void ProgramDesc::unsafe_arena_set_allocated_version( - ::paddle::framework::proto::Version* version) { - if (GetArena() == nullptr) { - delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(version_); - } - version_ = version; - if (version) { - _has_bits_[0] |= 0x00000001u; - } else { - _has_bits_[0] &= ~0x00000001u; - } - // @@protoc_insertion_point(field_unsafe_arena_set_allocated:paddle.framework.proto.ProgramDesc.version) -} -inline ::paddle::framework::proto::Version* ProgramDesc::release_version() { - _has_bits_[0] &= ~0x00000001u; - ::paddle::framework::proto::Version* temp = version_; - version_ = nullptr; - if (GetArena() != nullptr) { - temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); - } - return temp; -} -inline ::paddle::framework::proto::Version* ProgramDesc::unsafe_arena_release_version() { - // @@protoc_insertion_point(field_release:paddle.framework.proto.ProgramDesc.version) - _has_bits_[0] &= ~0x00000001u; - ::paddle::framework::proto::Version* temp = version_; - version_ = nullptr; - return temp; -} -inline ::paddle::framework::proto::Version* ProgramDesc::_internal_mutable_version() { - _has_bits_[0] |= 0x00000001u; - if (version_ == nullptr) { - auto* p = CreateMaybeMessage<::paddle::framework::proto::Version>(GetArena()); - version_ = p; - } - return version_; -} -inline ::paddle::framework::proto::Version* ProgramDesc::mutable_version() { - // @@protoc_insertion_point(field_mutable:paddle.framework.proto.ProgramDesc.version) - return _internal_mutable_version(); -} -inline void ProgramDesc::set_allocated_version(::paddle::framework::proto::Version* version) { - ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArena(); - if (message_arena == nullptr) { - delete version_; - } - if (version) { - ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = - ::PROTOBUF_NAMESPACE_ID::Arena::GetArena(version); - if (message_arena != submessage_arena) { - version = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( - message_arena, version, submessage_arena); - } - _has_bits_[0] |= 0x00000001u; - } else { - _has_bits_[0] &= ~0x00000001u; - } - version_ = version; - // @@protoc_insertion_point(field_set_allocated:paddle.framework.proto.ProgramDesc.version) -} - -// optional .paddle.framework.proto.OpVersionMap op_version_map = 5; -inline bool ProgramDesc::_internal_has_op_version_map() const { - bool value = (_has_bits_[0] & 0x00000002u) != 0; - PROTOBUF_ASSUME(!value || op_version_map_ != nullptr); - return value; -} -inline bool ProgramDesc::has_op_version_map() const { - return _internal_has_op_version_map(); -} -inline void ProgramDesc::clear_op_version_map() { - if (op_version_map_ != nullptr) op_version_map_->Clear(); - _has_bits_[0] &= ~0x00000002u; -} -inline const ::paddle::framework::proto::OpVersionMap& ProgramDesc::_internal_op_version_map() const { - const ::paddle::framework::proto::OpVersionMap* p = op_version_map_; - return p != nullptr ? *p : reinterpret_cast( - ::paddle::framework::proto::_OpVersionMap_default_instance_); -} -inline const ::paddle::framework::proto::OpVersionMap& ProgramDesc::op_version_map() const { - // @@protoc_insertion_point(field_get:paddle.framework.proto.ProgramDesc.op_version_map) - return _internal_op_version_map(); -} -inline void ProgramDesc::unsafe_arena_set_allocated_op_version_map( - ::paddle::framework::proto::OpVersionMap* op_version_map) { - if (GetArena() == nullptr) { - delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(op_version_map_); - } - op_version_map_ = op_version_map; - if (op_version_map) { - _has_bits_[0] |= 0x00000002u; - } else { - _has_bits_[0] &= ~0x00000002u; - } - // @@protoc_insertion_point(field_unsafe_arena_set_allocated:paddle.framework.proto.ProgramDesc.op_version_map) -} -inline ::paddle::framework::proto::OpVersionMap* ProgramDesc::release_op_version_map() { - _has_bits_[0] &= ~0x00000002u; - ::paddle::framework::proto::OpVersionMap* temp = op_version_map_; - op_version_map_ = nullptr; - if (GetArena() != nullptr) { - temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); - } - return temp; -} -inline ::paddle::framework::proto::OpVersionMap* ProgramDesc::unsafe_arena_release_op_version_map() { - // @@protoc_insertion_point(field_release:paddle.framework.proto.ProgramDesc.op_version_map) - _has_bits_[0] &= ~0x00000002u; - ::paddle::framework::proto::OpVersionMap* temp = op_version_map_; - op_version_map_ = nullptr; - return temp; -} -inline ::paddle::framework::proto::OpVersionMap* ProgramDesc::_internal_mutable_op_version_map() { - _has_bits_[0] |= 0x00000002u; - if (op_version_map_ == nullptr) { - auto* p = CreateMaybeMessage<::paddle::framework::proto::OpVersionMap>(GetArena()); - op_version_map_ = p; - } - return op_version_map_; -} -inline ::paddle::framework::proto::OpVersionMap* ProgramDesc::mutable_op_version_map() { - // @@protoc_insertion_point(field_mutable:paddle.framework.proto.ProgramDesc.op_version_map) - return _internal_mutable_op_version_map(); -} -inline void ProgramDesc::set_allocated_op_version_map(::paddle::framework::proto::OpVersionMap* op_version_map) { - ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArena(); - if (message_arena == nullptr) { - delete op_version_map_; - } - if (op_version_map) { - ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = - ::PROTOBUF_NAMESPACE_ID::Arena::GetArena(op_version_map); - if (message_arena != submessage_arena) { - op_version_map = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( - message_arena, op_version_map, submessage_arena); - } - _has_bits_[0] |= 0x00000002u; - } else { - _has_bits_[0] &= ~0x00000002u; - } - op_version_map_ = op_version_map; - // @@protoc_insertion_point(field_set_allocated:paddle.framework.proto.ProgramDesc.op_version_map) -} - -#ifdef __GNUC__ - #pragma GCC diagnostic pop -#endif // __GNUC__ -// ------------------------------------------------------------------- - -// ------------------------------------------------------------------- - -// ------------------------------------------------------------------- - -// ------------------------------------------------------------------- - -// ------------------------------------------------------------------- - -// ------------------------------------------------------------------- - -// ------------------------------------------------------------------- - -// ------------------------------------------------------------------- - -// ------------------------------------------------------------------- - -// ------------------------------------------------------------------- - -// ------------------------------------------------------------------- - -// ------------------------------------------------------------------- - -// ------------------------------------------------------------------- - -// ------------------------------------------------------------------- - -// ------------------------------------------------------------------- - -// ------------------------------------------------------------------- - -// ------------------------------------------------------------------- - -// ------------------------------------------------------------------- - - -// @@protoc_insertion_point(namespace_scope) - -} // namespace proto -} // namespace framework -} // namespace paddle - -PROTOBUF_NAMESPACE_OPEN - -template <> struct is_proto_enum< ::paddle::framework::proto::VarType_Type> : ::std::true_type {}; -template <> -inline const EnumDescriptor* GetEnumDescriptor< ::paddle::framework::proto::VarType_Type>() { - return ::paddle::framework::proto::VarType_Type_descriptor(); -} -template <> struct is_proto_enum< ::paddle::framework::proto::AttrType> : ::std::true_type {}; -template <> -inline const EnumDescriptor* GetEnumDescriptor< ::paddle::framework::proto::AttrType>() { - return ::paddle::framework::proto::AttrType_descriptor(); -} - -PROTOBUF_NAMESPACE_CLOSE - -// @@protoc_insertion_point(global_scope) - -#include -#endif // GOOGLE_PROTOBUF_INCLUDED_GOOGLE_PROTOBUF_INCLUDED_framework_2eproto diff --git a/inference-engine/samples/pdpd_poc/framework.proto b/inference-engine/samples/pdpd_poc/framework.proto new file mode 100644 index 00000000000000..baaecb55d06ee3 --- /dev/null +++ b/inference-engine/samples/pdpd_poc/framework.proto @@ -0,0 +1,205 @@ +/* Copyright (c) 2016 PaddlePaddle Authors. 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. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. */ + +syntax = "proto2"; +package paddle.framework.proto; + +// Any incompatible changes to ProgramDesc and its dependencies should +// raise the version defined version.h. +// +// Serailization and Deserialization codes should be modified in a way +// that supports old versions following the version and compatibility policy. +message Version { optional int64 version = 1 [ default = 0 ]; } + +enum AttrType { + INT = 0; + FLOAT = 1; + STRING = 2; + INTS = 3; + FLOATS = 4; + STRINGS = 5; + BOOLEAN = 6; + BOOLEANS = 7; + BLOCK = 8; + LONG = 9; + BLOCKS = 10; + LONGS = 11; +} + +// OpDesc describes an instance of a C++ framework::OperatorBase +// derived class type. +message OpDesc { + + message Attr { + required string name = 1; + required AttrType type = 2; + optional int32 i = 3; + optional float f = 4; + optional string s = 5; + repeated int32 ints = 6; + repeated float floats = 7; + repeated string strings = 8; + optional bool b = 10; + repeated bool bools = 11; + optional int32 block_idx = 12; + optional int64 l = 13; + repeated int32 blocks_idx = 14; + repeated int64 longs = 15; + }; + + message Var { + required string parameter = 1; + repeated string arguments = 2; + }; + + required string type = 3; + repeated Var inputs = 1; + repeated Var outputs = 2; + repeated Attr attrs = 4; + optional bool is_target = 5 [ default = false ]; +}; + +// OpProto describes a C++ framework::OperatorBase derived class. +message OpProto { + + // VarProto describes the C++ type framework::Variable. + message Var { + required string name = 1; + required string comment = 2; + + optional bool duplicable = 3 [ default = false ]; + optional bool intermediate = 4 [ default = false ]; + optional bool dispensable = 5 [ default = false ]; + } + + // AttrProto describes the C++ type Attribute. + message Attr { + required string name = 1; + required AttrType type = 2; + required string comment = 3; + // If that attribute is generated, it means the Paddle third + // language binding has responsibility to fill that + // attribute. End-User should not set that attribute. + optional bool generated = 4 [ default = false ]; + } + + required string type = 1; + repeated Var inputs = 2; + repeated Var outputs = 3; + repeated Attr attrs = 4; + required string comment = 5; +} + +message VarType { + enum Type { + // Pod Types + BOOL = 0; + INT16 = 1; + INT32 = 2; + INT64 = 3; + FP16 = 4; + FP32 = 5; + FP64 = 6; + // Tensor is used in C++. + SIZE_T = 19; + UINT8 = 20; + INT8 = 21; + BF16 = 22; + COMPLEX64 = 23; + COMPLEX128 = 24; + + // Other types that may need additional descriptions + LOD_TENSOR = 7; + SELECTED_ROWS = 8; + FEED_MINIBATCH = 9; + FETCH_LIST = 10; + STEP_SCOPES = 11; + LOD_RANK_TABLE = 12; + LOD_TENSOR_ARRAY = 13; + PLACE_LIST = 14; + READER = 15; + // Any runtime decided variable type is raw + // raw variables should manage their own allocations + // in operators like nccl_op + RAW = 17; + TUPLE = 18; + } + + required Type type = 1; + + message TensorDesc { + // Should only be PODType. Is enforced in C++ + required Type data_type = 1; + repeated int64 dims = 2; // [UNK, 640, 480] is saved as [-1, 640, 480] + } + optional TensorDesc selected_rows = 2; + + message LoDTensorDesc { + required TensorDesc tensor = 1; + optional int32 lod_level = 2 [ default = 0 ]; + } + optional LoDTensorDesc lod_tensor = 3; + + message LoDTensorArrayDesc { + required TensorDesc tensor = 1; + optional int32 lod_level = 2 [ default = 0 ]; + } + optional LoDTensorArrayDesc tensor_array = 4; + + message ReaderDesc { repeated LoDTensorDesc lod_tensor = 1; } + optional ReaderDesc reader = 5; + + message Tuple { repeated Type element_type = 1; } + optional Tuple tuple = 7; +} + +message VarDesc { + required string name = 1; + required VarType type = 2; + optional bool persistable = 3 [ default = false ]; + // True if the variable is an input data and + // have to check the feed data shape and dtype + optional bool need_check_feed = 4 [ default = false ]; +} + +message BlockDesc { + required int32 idx = 1; + required int32 parent_idx = 2; + repeated VarDesc vars = 3; + repeated OpDesc ops = 4; + optional int32 forward_block_idx = 5 [ default = -1 ]; +} + +// In some cases, Paddle may perform operator definition iterations, +// and the operator uses OpVersionMap for compatibility testing. +message OpVersion { required int32 version = 1; } +message OpVersionMap { + message OpVersionPair { + required string op_name = 1; + required OpVersion op_version = 2; + } + repeated OpVersionPair pair = 1; +} + +// Please refer to +// https://github.com/PaddlePaddle/Paddle/blob/develop/doc/design/program.md +// for more details. +// TODO(panyx0718): A model can have multiple programs. Need a +// way to distinguish them. Maybe ID or name? +message ProgramDesc { + reserved 2, 3; // For backward compatibility. + repeated BlockDesc blocks = 1; + optional Version version = 4; + optional OpVersionMap op_version_map = 5; +} diff --git a/inference-engine/samples/pdpd_poc/main.cpp b/inference-engine/samples/pdpd_poc/main.cpp index 6b40ffdeca301f..50dd41d5d140ee 100644 --- a/inference-engine/samples/pdpd_poc/main.cpp +++ b/inference-engine/samples/pdpd_poc/main.cpp @@ -18,7 +18,7 @@ #include #include -#include "framework.pb.h" +#include #include #include @@ -49,81 +49,83 @@ bool endsWith(std::string str, std::string suffix) { } protobuf::RepeatedField get_ints(proto::OpDesc op, std::string name, - protobuf::RepeatedField default = protobuf::RepeatedField()) { + protobuf::RepeatedField def = protobuf::RepeatedField()) { + std::cout << "Running get_ints" << std::endl; std::vector attrs; for (const auto& attr : op.attrs()) { if (attr.name() == name) attrs.push_back(attr); } + std::cout << "Attrs preprocessed" << std::endl; if (attrs.size() == 0) { - return default; + return def; } else if (attrs.size() > 1) { // TODO: raise exception here - return default; + return def; } else { return attrs[0].ints(); } } -int get_int(proto::OpDesc op, std::string name, int default = 0) { +int get_int(proto::OpDesc op, std::string name, int def = 0) { std::vector attrs; for (const auto& attr : op.attrs()) { if (attr.name() == name) attrs.push_back(attr); } if (attrs.size() == 0) { - return default; + return def; } else if (attrs.size() > 1) { // TODO: raise exception here - return default; + return def; } else { return attrs[0].i(); } } -float get_float(proto::OpDesc op, std::string name, float default = 0.) { +float get_float(proto::OpDesc op, std::string name, float def = 0.) { std::vector attrs; for (const auto& attr : op.attrs()) { if (attr.name() == name) attrs.push_back(attr); } if (attrs.size() == 0) { - return default; + return def; } else if (attrs.size() > 1) { // TODO: raise exception here - return default; + return def; } else { return attrs[0].f(); } } -std::string get_str(proto::OpDesc op, std::string name, std::string default = "") { +std::string get_str(proto::OpDesc op, std::string name, std::string def = "") { std::vector attrs; for (const auto& attr : op.attrs()) { if (attr.name() == name) attrs.push_back(attr); } if (attrs.size() == 0) { - return default; + return def; } else if (attrs.size() > 1) { // TODO: raise exception here - return default; + return def; } else { return attrs[0].s(); } } -bool get_bool(proto::OpDesc op, std::string name, bool default = false) { +bool get_bool(proto::OpDesc op, std::string name, bool def = false) { std::vector attrs; for (const auto& attr : op.attrs()) { if (attr.name() == name) attrs.push_back(attr); } if (attrs.size() == 0) { - return default; + return def; } else if (attrs.size() > 1) { // TODO: raise exception here - return default; + return def; } else { return attrs[0].b(); } @@ -134,6 +136,7 @@ typedef std::shared_ptr(*CreatorFunction)(std::map conv2d_creator(std::map>> inputs, proto::OpDesc op, proto::BlockDesc block) { + std::cout << "Running conv2d creator" << std::endl; assert(inputs["Input"].size() == 1); auto data = inputs["Input"][0]; assert(inputs["Filter"].size() == 1); @@ -144,6 +147,7 @@ std::shared_ptr conv2d_creator(std::map(data, filter, ngraph::Strides(strides.begin(), strides.end()), @@ -197,7 +201,7 @@ std::shared_ptr pool2d_creator(std::map(data, axes, true); } else { - throw std::exception("Unsupported pooling type"); + throw std::runtime_error("Unsupported pooling type"); } } @@ -224,7 +228,7 @@ std::shared_ptr mul_creator(std::map(x); int64_t x_num_col_dims = get_int(op, "x_num_col_dims"); auto axis = ngraph::opset6::Constant::create(ngraph::element::i64, {}, { 0 }); - auto split_lengths = ngraph::opset6::Constant::create(ngraph::element::i64, {2}, { x_num_col_dims, x_rank - x_num_col_dims }); + auto split_lengths = ngraph::opset6::Constant::create(ngraph::element::i64, { 2 }, { x_num_col_dims, x_rank - x_num_col_dims }); auto split = std::make_shared(shape, axis, split_lengths); auto f_dim_red_axis = ngraph::opset6::Constant::create(ngraph::element::i64, {}, { 0 }); auto first_dim_reduce = std::make_shared(split->output(0), f_dim_red_axis); @@ -253,6 +257,7 @@ std::shared_ptr make_ng_node(std::map> nodes, paddle::framework::proto::OpDesc op, paddle::framework::proto::BlockDesc block) { + std::cout << "Making node: " << op.type() << std::endl; std::map CREATORS_MAP{ {"conv2d", conv2d_creator}, {"batch_norm", batch_norm_creator}, @@ -275,6 +280,7 @@ std::shared_ptr make_ng_node(std::map read_tensor(paddle::framework::proto::VarDesc var, std::string model_dir) { + std::cout << "Reading tensor " << var.name() << std::endl; assert(var.type().type() == paddle::framework::proto::VarType::LOD_TENSOR); auto tensor = var.type().lod_tensor().tensor(); @@ -283,24 +289,26 @@ std::shared_ptr read_tensor(paddle::framework::proto:: // get length of file: is.seekg(0, std::ios::end); auto length = is.tellg(); - auto tensor_length = std::accumulate(tensor.dims().cbegin(), tensor.dims().cend(), 1, std::multiplies()) * 4; - is.seekg((size_t)length - tensor_length, std::ios::beg); + auto tensor_length = std::accumulate(tensor.dims().cbegin(), tensor.dims().cend(), 1, std::multiplies()); + is.seekg((size_t)length - tensor_length * 4, std::ios::beg); - std::vector tensor_data(tensor_length); - is.read(reinterpret_cast(&tensor_data[0]), tensor_length); + std::vector tensor_data(tensor_length, 0); + is.read(reinterpret_cast(&tensor_data[0]), tensor_length * 4); auto shape = std::vector(tensor.dims().cbegin(), tensor.dims().cend()); return ngraph::opset6::Constant::create(ngraph::element::f32, ngraph::Shape(shape), tensor_data); } -std::shared_ptr convert_model(const std::string & model_dir) { +std::shared_ptr convert_model(const std::string& model_dir) { + std::cout << "Convert Model Start" << std::endl; paddle::framework::proto::ProgramDesc fw_model; - std::ifstream pb_stream(model_dir + "\\model", std::ios::binary); - fw_model.ParseFromIstream(&pb_stream); + std::ifstream pb_stream(model_dir + "/__model__", std::ios::binary); + std::cout << "Model Parsed: " << fw_model.ParseFromIstream(&pb_stream) << std::endl; std::map> nodes_dict; ngraph::ParameterVector parameter_nodes; ngraph::ResultVector result_nodes; + std::cout << "Blocks number: " << fw_model.blocks().size() << std::endl; const auto& global_block = fw_model.blocks()[0]; for (const auto& var : global_block.vars()) { if (endsWith(var.name(), "feed") || endsWith(var.name(), "fetch")) @@ -309,6 +317,7 @@ std::shared_ptr convert_model(const std::string & model_dir) { continue; nodes_dict[var.name()] = read_tensor(var, model_dir); } + std::cout << "Reading consts finished" << std::endl; for (const auto& block : fw_model.blocks()) { std::map vars_dict; @@ -327,14 +336,23 @@ std::shared_ptr convert_model(const std::string & model_dir) { } if (op.type() == "feed") { auto layer_name = outputs_dict["Out"][0]; + std::cout << "Creating parameter: " << layer_name << std::endl; auto var = vars_dict[layer_name]; assert(var.type() == paddle::framework::proto::VarType::LOD_TENSOR); auto tensor_desc = var.lod_tensor().tensor(); auto dtype = tensor_desc.data_type(); - auto shape = std::vector(tensor_desc.dims().cbegin(), tensor_desc.dims().cend()); + std::vector shape; + for (auto dim : tensor_desc.dims()) { + if (dim >= 0) { + shape.push_back(dim); + } else { + shape.push_back(1); + } + } auto param = std::make_shared(TYPE_MAP[dtype], ngraph::Shape(shape)); nodes_dict[layer_name] = param; parameter_nodes.push_back(param); + std::cout << "Parameter created" << std::endl; } else if (op.type() == "fetch") { auto input_node = inputs_dict["X"][0]; assert(nodes_dict.find(input_node) != nodes_dict.end()); @@ -355,7 +373,7 @@ std::shared_ptr convert_model(const std::string & model_dir) { int main(int argc, char* argv[]) { try { - std::string model_path = "C:\\Dev\\resnet_v2_50_imagenet\\model"; + std::string model_path = "/home/mvafin/.paddlehub/modules/resnet_v2_50_imagenet/model"; auto func = convert_model(model_path); } catch (const std::exception& ex) { From a1319aa87dd14c78d442cbdf6c8fd6166d2de045 Mon Sep 17 00:00:00 2001 From: "Vafin, Maxim" Date: Thu, 21 Jan 2021 13:05:06 +0300 Subject: [PATCH 018/116] Update requirements --- tools/pdpd_poc/requirements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/pdpd_poc/requirements.txt b/tools/pdpd_poc/requirements.txt index 229b3c5fe83f00..aa8bc8bd797116 100644 --- a/tools/pdpd_poc/requirements.txt +++ b/tools/pdpd_poc/requirements.txt @@ -1,4 +1,4 @@ numpy protobuf>=3.6.1 -paddlepaddle==1.8.5 -paddlehub==1.8.3 +paddlepaddle==2.0.0rc1 +paddlehub==2.0.0rc0 From 0762f55d4440465c8b9ecd4783548e31172fa8a1 Mon Sep 17 00:00:00 2001 From: "Vafin, Maxim" Date: Mon, 25 Jan 2021 13:19:57 +0300 Subject: [PATCH 019/116] Fix issues and add serialization --- inference-engine/samples/pdpd_poc/main.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/inference-engine/samples/pdpd_poc/main.cpp b/inference-engine/samples/pdpd_poc/main.cpp index 50dd41d5d140ee..9078396d7afb1b 100644 --- a/inference-engine/samples/pdpd_poc/main.cpp +++ b/inference-engine/samples/pdpd_poc/main.cpp @@ -332,7 +332,7 @@ std::shared_ptr convert_model(const std::string& model_dir) { } std::map> inputs_dict; for (const auto& input : op.inputs()) { - outputs_dict[input.parameter()] = input.arguments(); + inputs_dict[input.parameter()] = input.arguments(); } if (op.type() == "feed") { auto layer_name = outputs_dict["Out"][0]; @@ -375,6 +375,9 @@ int main(int argc, char* argv[]) { try { std::string model_path = "/home/mvafin/.paddlehub/modules/resnet_v2_50_imagenet/model"; auto func = convert_model(model_path); + CNNNetwork net(func); + net.reshape({ {"@HUB_resnet_v2_50_imagenet@image"}, {1, 3, 224, 224} }); + net.serialize("PDPD_Resnet50_Function.xml", "PDPD_Resnet50_Function.bin"); } catch (const std::exception& ex) { slog::err << ex.what() << slog::endl; From 11ad0b5b37f688f97ace48520b4e8fea6a4959cc Mon Sep 17 00:00:00 2001 From: "Vafin, Maxim" Date: Tue, 26 Jan 2021 11:10:43 +0300 Subject: [PATCH 020/116] Test IR --- inference-engine/samples/pdpd_poc/main.cpp | 149 ++++++++++++--------- tools/pdpd_poc/pdpd2ir.py | 10 +- 2 files changed, 94 insertions(+), 65 deletions(-) diff --git a/inference-engine/samples/pdpd_poc/main.cpp b/inference-engine/samples/pdpd_poc/main.cpp index 9078396d7afb1b..1874c26c6264af 100644 --- a/inference-engine/samples/pdpd_poc/main.cpp +++ b/inference-engine/samples/pdpd_poc/main.cpp @@ -28,6 +28,10 @@ using namespace InferenceEngine; using namespace google; using namespace paddle::framework; +inline void MY_ASSERT(bool ex, const std::string& msg = "Unspecified error.") { + if (!ex) throw std::runtime_error(msg + std::endl); +} + std::map TYPE_MAP{ {proto::VarType_Type::VarType_Type_BOOL, ngraph::element::boolean}, {proto::VarType_Type::VarType_Type_INT16, ngraph::element::i16}, @@ -41,7 +45,7 @@ std::map TYPE_MAP {proto::VarType_Type::VarType_Type_BF16, ngraph::element::bf16} }; -bool endsWith(std::string str, std::string suffix) { +bool endsWith(const std::string& str, const std::string& suffix) { if (str.length() >= suffix.length()) { return (0 == str.compare(str.length() - suffix.length(), suffix.length(), suffix)); } @@ -59,10 +63,12 @@ protobuf::RepeatedField get_ints(proto::OpDesc op, std::string std::cout << "Attrs preprocessed" << std::endl; if (attrs.size() == 0) { return def; - } else if (attrs.size() > 1) { + } + else if (attrs.size() > 1) { // TODO: raise exception here return def; - } else { + } + else { return attrs[0].ints(); } } @@ -75,10 +81,12 @@ int get_int(proto::OpDesc op, std::string name, int def = 0) { } if (attrs.size() == 0) { return def; - } else if (attrs.size() > 1) { + } + else if (attrs.size() > 1) { // TODO: raise exception here return def; - } else { + } + else { return attrs[0].i(); } } @@ -91,10 +99,12 @@ float get_float(proto::OpDesc op, std::string name, float def = 0.) { } if (attrs.size() == 0) { return def; - } else if (attrs.size() > 1) { + } + else if (attrs.size() > 1) { // TODO: raise exception here return def; - } else { + } + else { return attrs[0].f(); } } @@ -107,10 +117,12 @@ std::string get_str(proto::OpDesc op, std::string name, std::string def = "") { } if (attrs.size() == 0) { return def; - } else if (attrs.size() > 1) { + } + else if (attrs.size() > 1) { // TODO: raise exception here return def; - } else { + } + else { return attrs[0].s(); } } @@ -123,26 +135,26 @@ bool get_bool(proto::OpDesc op, std::string name, bool def = false) { } if (attrs.size() == 0) { return def; - } else if (attrs.size() > 1) { + } + else if (attrs.size() > 1) { // TODO: raise exception here return def; - } else { + } + else { return attrs[0].b(); } } -typedef std::shared_ptr(*CreatorFunction)(std::map>> inputs, - proto::OpDesc op, proto::BlockDesc block); +typedef std::shared_ptr(*CreatorFunction)(const std::map>>& inputs, + const proto::OpDesc& op, const proto::BlockDesc& block); -std::shared_ptr conv2d_creator(std::map>> inputs, - proto::OpDesc op, proto::BlockDesc block) { +std::shared_ptr conv2d_creator(const std::map>>& inputs, + const proto::OpDesc& op, const proto::BlockDesc& block) { std::cout << "Running conv2d creator" << std::endl; - assert(inputs["Input"].size() == 1); + MY_ASSERT(inputs["Input"].size() == 1 && inputs["Filter"].size() == 1, "More then one input for conv2d"); + MY_ASSERT(inputs["Bias"].size() == 0 && inputs["ResidualData"].size() == 0, "Bias and residual have input for conv2d"); auto data = inputs["Input"][0]; - assert(inputs["Filter"].size() == 1); auto filter = inputs["Filter"][0]; - assert(inputs["Bias"].size() == 0); - assert(inputs["ResidualData"].size() == 0); // TODO: resolve padding according to spec auto strides = get_ints(op, "strides"); auto paddings = get_ints(op, "paddings"); @@ -157,13 +169,14 @@ std::shared_ptr conv2d_creator(std::map batch_norm_creator(std::map>> inputs, - proto::OpDesc op, proto::BlockDesc block) { - assert(inputs["X"].size() == 1); - assert(inputs["Scale"].size() == 1); - assert(inputs["Bias"].size() == 1); - assert(inputs["Mean"].size() == 1); - assert(inputs["Variance"].size() == 1); +std::shared_ptr batch_norm_creator(const std::map>>& inputs, + const proto::OpDesc& op, const proto::BlockDesc& block) { + MY_ASSERT(inputs["X"].size() == 1 && + inputs["Scale"].size() == 1 && + inputs["Bias"].size() == 1 && + inputs["Mean"].size() == 1 && + inputs["Variance"].size() == 1, + "More then one input for batch_norm"); auto data = inputs["X"][0]; auto gamma = inputs["Scale"][0]; auto beta = inputs["Bias"][0]; @@ -173,16 +186,16 @@ std::shared_ptr batch_norm_creator(std::map relu_creator(std::map>> inputs, - proto::OpDesc op, proto::BlockDesc block) { - assert(inputs["X"].size() == 1); +std::shared_ptr relu_creator(const std::map>>& inputs, + const proto::OpDesc& op, const proto::BlockDesc& block) { + MY_ASSERT(inputs["X"].size() == 1, "More then one input for relu"); auto data = inputs["X"][0]; return std::make_shared(data); } -std::shared_ptr pool2d_creator(std::map>> inputs, - proto::OpDesc op, proto::BlockDesc block) { - assert(inputs["X"].size() == 1); +std::shared_ptr pool2d_creator(const std::map>>& inputs, + const proto::OpDesc& op, const proto::BlockDesc& block) { + MY_ASSERT(inputs["X"].size() == 1, "More then one input for pool2d"); auto data = inputs["X"][0]; // TODO : resolve padding according to spec auto pooling_type = get_str(op, "pooling_type"); @@ -196,34 +209,34 @@ std::shared_ptr pool2d_creator(std::map(data, axes, true); - } else { + } + else { throw std::runtime_error("Unsupported pooling type"); } } -std::shared_ptr elementwise_add_creator(std::map>> inputs, - proto::OpDesc op, proto::BlockDesc block) { - assert(inputs["X"].size() == 1); - assert(inputs["Y"].size() == 1); +std::shared_ptr elementwise_add_creator(const std::map>>& inputs, + const proto::OpDesc& op, const proto::BlockDesc& block) { + MY_ASSERT(inputs["X"].size() == 1 && inputs["Y"].size() == 1, "More then one input for elementwise_add"); auto x = inputs["X"][0]; auto y = inputs["Y"][0]; // TODO : resolve broadcast return std::make_shared(x, y); } -std::shared_ptr mul_creator(std::map>> inputs, - proto::OpDesc op, proto::BlockDesc block) { - assert(inputs["X"].size() == 1); - assert(inputs["Y"].size() == 1); +std::shared_ptr mul_creator(const std::map>>& inputs, + const proto::OpDesc& op, const proto::BlockDesc& block) { + MY_ASSERT(inputs["X"].size() == 1 && inputs["Y"].size() == 1, "More then one input for mul"); auto x = inputs["X"][0]; auto y = inputs["Y"][0]; - assert(x->output(0).get_partial_shape().rank().is_static()); + MY_ASSERT(x->output(0).get_partial_shape().rank().is_static()); int64_t x_rank = x->output(0).get_partial_shape().rank().get_length(); - assert(y->output(0).get_partial_shape().rank().is_static() && y->output(0).get_partial_shape().rank().get_length() == 2); + MY_ASSERT(y->output(0).get_partial_shape().rank().is_static() && y->output(0).get_partial_shape().rank().get_length() == 2); if (x_rank > 2) { auto shape = std::make_shared(x); int64_t x_num_col_dims = get_int(op, "x_num_col_dims"); @@ -245,18 +258,18 @@ std::shared_ptr mul_creator(std::map(x, y); } -std::shared_ptr scale_creator(std::map>> inputs, - proto::OpDesc op, proto::BlockDesc block) { - assert(inputs["X"].size() == 1); +std::shared_ptr scale_creator(const std::map>>& inputs, + const proto::OpDesc& op, const proto::BlockDesc& block) { + MY_ASSERT(inputs["X"].size() == 1, "More then one input for scale"); auto data = inputs["X"][0]; auto scale = ngraph::opset6::Constant::create(ngraph::element::f32, { 1 }, { get_float(op, "scale") }); return std::make_shared(data, scale); } -std::shared_ptr make_ng_node(std::map> inputs, - std::map> nodes, - paddle::framework::proto::OpDesc op, - paddle::framework::proto::BlockDesc block) { +std::shared_ptr make_ng_node(const std::map>& inputs, + const std::map>& nodes, + const paddle::framework::proto::OpDesc& op, + const paddle::framework::proto::BlockDesc& block) { std::cout << "Making node: " << op.type() << std::endl; std::map CREATORS_MAP{ {"conv2d", conv2d_creator}, @@ -267,7 +280,7 @@ std::shared_ptr make_ng_node(std::map>> inputs_preproc; for (const auto& item : inputs) { inputs_preproc[item.first] = std::vector>(); @@ -279,21 +292,25 @@ std::shared_ptr make_ng_node(std::map read_tensor(paddle::framework::proto::VarDesc var, std::string model_dir) { +std::shared_ptr read_tensor(const paddle::framework::proto::VarDesc& var, const std::string& model_dir) { std::cout << "Reading tensor " << var.name() << std::endl; - assert(var.type().type() == paddle::framework::proto::VarType::LOD_TENSOR); + MY_ASSERT(var.type().type() == paddle::framework::proto::VarType::LOD_TENSOR); auto tensor = var.type().lod_tensor().tensor(); - std::ifstream is; - is.open(model_dir + "\\" + var.name(), std::ios::binary); + std::ifstream is(model_dir + "/" + var.name(), std::ios::in | std::ifstream::binary); + if (!is || !is.is_open()) { + std::cout << "File not opened" << std::endl; + } // get length of file: is.seekg(0, std::ios::end); auto length = is.tellg(); auto tensor_length = std::accumulate(tensor.dims().cbegin(), tensor.dims().cend(), 1, std::multiplies()); + std::cout << "length: " << length << ", ten_len: " << tensor_length << std::endl; is.seekg((size_t)length - tensor_length * 4, std::ios::beg); std::vector tensor_data(tensor_length, 0); is.read(reinterpret_cast(&tensor_data[0]), tensor_length * 4); + is.close(); auto shape = std::vector(tensor.dims().cbegin(), tensor.dims().cend()); return ngraph::opset6::Constant::create(ngraph::element::f32, ngraph::Shape(shape), tensor_data); } @@ -338,29 +355,35 @@ std::shared_ptr convert_model(const std::string& model_dir) { auto layer_name = outputs_dict["Out"][0]; std::cout << "Creating parameter: " << layer_name << std::endl; auto var = vars_dict[layer_name]; - assert(var.type() == paddle::framework::proto::VarType::LOD_TENSOR); + MY_ASSERT(var.type() == paddle::framework::proto::VarType::LOD_TENSOR); auto tensor_desc = var.lod_tensor().tensor(); auto dtype = tensor_desc.data_type(); std::vector shape; + // set all -1 dims to 1 for (auto dim : tensor_desc.dims()) { if (dim >= 0) { shape.push_back(dim); - } else { + } + else { shape.push_back(1); } } auto param = std::make_shared(TYPE_MAP[dtype], ngraph::Shape(shape)); + param->set_friendly_name(layer_name); nodes_dict[layer_name] = param; parameter_nodes.push_back(param); std::cout << "Parameter created" << std::endl; - } else if (op.type() == "fetch") { + } + else if (op.type() == "fetch") { auto input_node = inputs_dict["X"][0]; - assert(nodes_dict.find(input_node) != nodes_dict.end()); + MY_ASSERT(nodes_dict.find(input_node) != nodes_dict.end()); result_nodes.push_back(std::make_shared(nodes_dict[input_node])); - } else { + } + else { auto node = make_ng_node(inputs_dict, nodes_dict, op, block); + node->set_friendly_name(outputs_dict["Out"][0]); for (const auto& item : outputs_dict) { - assert(item.second.size() <= 1); + MY_ASSERT(item.second.size() <= 1); if (item.second.size() == 1) { nodes_dict[item.second[0]] = node; } @@ -376,7 +399,7 @@ int main(int argc, char* argv[]) { std::string model_path = "/home/mvafin/.paddlehub/modules/resnet_v2_50_imagenet/model"; auto func = convert_model(model_path); CNNNetwork net(func); - net.reshape({ {"@HUB_resnet_v2_50_imagenet@image"}, {1, 3, 224, 224} }); + //net.reshape({ {"@HUB_resnet_v2_50_imagenet@image"}, {1, 3, 224, 224} }); net.serialize("PDPD_Resnet50_Function.xml", "PDPD_Resnet50_Function.bin"); } catch (const std::exception& ex) { diff --git a/tools/pdpd_poc/pdpd2ir.py b/tools/pdpd_poc/pdpd2ir.py index 89b4bb8f2337dd..2661e1aa80555b 100644 --- a/tools/pdpd_poc/pdpd2ir.py +++ b/tools/pdpd_poc/pdpd2ir.py @@ -244,10 +244,16 @@ def convert_model(model_dir): from openvino.inference_engine import IECore ie = IECore() - executable_network = ie.load_network(ie_network, 'CPU') + # executable_network = ie.load_network(ie_network, 'CPU') + net = ie.read_network('/media/data/OpenVINO/openvino/build/PDPD_Resnet50_Function.xml', + '/media/data/OpenVINO/openvino/build/PDPD_Resnet50_Function.bin') + executable_network = ie.load_network(net, 'CPU') + + # output = executable_network.infer( + # {'@HUB_resnet_v2_50_imagenet@image': img.astype(np.float32)}) output = executable_network.infer( - {'@HUB_resnet_v2_50_imagenet@image': img.astype(np.float32)}) + {'Parameter_267': img.astype(np.float32)}) print(np.abs(result[0] - list(output.values())[0]).max()) print(np.abs(result[1] - list(output.values())[1]).max()) From 04468143773dce29ee7f35ed7933f53063e02251 Mon Sep 17 00:00:00 2001 From: tomdol Date: Tue, 19 Jan 2021 16:31:49 -0500 Subject: [PATCH 021/116] Subgraph extraction in ONNX models --- .../editor/detail/subgraph_extraction.hpp | 151 +++++++ .../include/onnx_import/editor/editor.hpp | 30 +- .../src/editor/detail/subgraph_extraction.cpp | 405 ++++++++++++++++++ .../onnx_import/src/editor/editor.cpp | 57 +++ ...puts_and_outputs_based_extraction.prototxt | 112 +++++ ..._initializer_to_input_replacement.prototxt | 121 ++++++ ...r_without_matching_input_tail_cut.prototxt | 120 ++++++ ...aph__linear_model_deeper_head_cut.prototxt | 82 ++++ ...aph__linear_model_deeper_tail_cut.prototxt | 121 ++++++ .../subgraph__linear_model_head_cut.prototxt | 88 ++++ .../subgraph__linear_model_tail_cut.prototxt | 127 ++++++ ...r_model_with_initializer_tail_cut.prototxt | 134 ++++++ ...subgraph__multiout_op_output_edge.prototxt | 78 ++++ .../subgraph__inception_head.prototxt | 153 +++++++ ...__inception_head_with_initializer.prototxt | 160 +++++++ ...nitializer_without_matching_input.prototxt | 146 +++++++ .../subgraph_extraction_tests.prototxt | 167 ++++++++ ngraph/test/onnx/onnx_editor.cpp | 248 +++++++++++ ngraph/test/util/CMakeLists.txt | 4 + ngraph/test/util/onnx_test_util.cpp | 311 ++++++++++++++ ngraph/test/util/onnx_test_util.hpp | 33 ++ 21 files changed, 2843 insertions(+), 5 deletions(-) create mode 100644 ngraph/frontend/onnx_import/include/onnx_import/editor/detail/subgraph_extraction.hpp create mode 100644 ngraph/frontend/onnx_import/src/editor/detail/subgraph_extraction.cpp create mode 100644 ngraph/test/models/onnx/model_editor/reference/subgraph__existing_inputs_and_outputs_based_extraction.prototxt create mode 100644 ngraph/test/models/onnx/model_editor/reference/subgraph__initializer_to_input_replacement.prototxt create mode 100644 ngraph/test/models/onnx/model_editor/reference/subgraph__initializer_without_matching_input_tail_cut.prototxt create mode 100644 ngraph/test/models/onnx/model_editor/reference/subgraph__linear_model_deeper_head_cut.prototxt create mode 100644 ngraph/test/models/onnx/model_editor/reference/subgraph__linear_model_deeper_tail_cut.prototxt create mode 100644 ngraph/test/models/onnx/model_editor/reference/subgraph__linear_model_head_cut.prototxt create mode 100644 ngraph/test/models/onnx/model_editor/reference/subgraph__linear_model_tail_cut.prototxt create mode 100644 ngraph/test/models/onnx/model_editor/reference/subgraph__linear_model_with_initializer_tail_cut.prototxt create mode 100644 ngraph/test/models/onnx/model_editor/reference/subgraph__multiout_op_output_edge.prototxt create mode 100644 ngraph/test/models/onnx/model_editor/subgraph__inception_head.prototxt create mode 100644 ngraph/test/models/onnx/model_editor/subgraph__inception_head_with_initializer.prototxt create mode 100644 ngraph/test/models/onnx/model_editor/subgraph__initializer_without_matching_input.prototxt create mode 100644 ngraph/test/models/onnx/model_editor/subgraph_extraction_tests.prototxt create mode 100644 ngraph/test/util/onnx_test_util.cpp create mode 100644 ngraph/test/util/onnx_test_util.hpp diff --git a/ngraph/frontend/onnx_import/include/onnx_import/editor/detail/subgraph_extraction.hpp b/ngraph/frontend/onnx_import/include/onnx_import/editor/detail/subgraph_extraction.hpp new file mode 100644 index 00000000000000..9df92ae91b9aed --- /dev/null +++ b/ngraph/frontend/onnx_import/include/onnx_import/editor/detail/subgraph_extraction.hpp @@ -0,0 +1,151 @@ +//***************************************************************************** +// Copyright 2017-2021 Intel Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//***************************************************************************** + +#pragma once + +#include +#include +#include +#include +#include + +namespace ONNX_NAMESPACE +{ + class GraphProto; + class NodeProto; + class ValueInfoProto; +} // namespace ONNX_NAMESPACE + +namespace ngraph +{ + namespace onnx_import + { + /// \brief Defines an edge connected to an input of any node in the graph. + /// It consists of a node index in the processed ONNX model and the input name. + /// + /// For a node number 5, with 3 inputs: + /// + /// ----(in_A)----> +--------+ + /// ----(in_B)----> | node 5 | ----(out)----> + /// ----(in_C)----> +--------+ + /// + /// there are 3 possible valid instances of this struct: + /// InputEdge(5, "in_A") + /// InputEdge(5, "in_B") + /// InputEdge(5, "in_C") + struct InputEdge + { + InputEdge() = delete; + InputEdge(const int node_idx, std::string tensor_name) + : m_node_idx{node_idx} + , m_tensor_name{std::move(tensor_name)} + { + } + + const int m_node_idx; + const std::string m_tensor_name; + }; + + /// \brief Defines an edge connected to an output of any node in the graph. + /// It consists of a node index in the processed ONNX model and the output name. + /// + /// For a node number 5, with 2 outputs: + /// + /// +--------+ ----(out1)----> + /// ----(in_A)----> | node 5 | + /// +--------+ ----(out2)----> + /// + /// there are 2 possible valid instances of this struct: + /// OutputEdge(5, "out1") + /// OutputEdge(5, "out2") + using OutputEdge = InputEdge; + + /// \brief Subgraph extraction helper structure + struct SubgraphExtractor + { + SubgraphExtractor(ONNX_NAMESPACE::GraphProto& graph); + + /// \brief Adds new inputs to the graph and connects them to the nodes indicated by + /// the provided input edges. + void add_new_inputs(const std::vector& new_inputs); + + /// \brief Adds new outputs to the graph with the same name as the nodes pointed to + /// by the input edges "new_outputs". + void add_new_outputs(const std::vector& new_outputs); + + /// \brief Extracts the final subgraph by traversing the original model bottom-up + /// starting at each of the provided output edges. The extracted subgraph + /// contains all previously added inputs and potentially a subset of original + /// model's inputs that contribute to the value calculated in the output tensors. + /// In the end the underlying GraphProto is modified and obsolete elements + /// are discarded after this method call has finished. + /// + /// \param subgraph_outputs A list of expected outputs of the extracted subgraph. + void extract_subgraph(std::vector subgraph_outputs); + + /// \brief Represents a subgraph of an ONNX model by holding a subset of nodes, inputs, + /// outputs and initializers of the original graph. Objects of this struct can be + /// merged into other instances using the += operator to build a subgraph from + /// smaller clusters. + struct SubgraphComponents + { + SubgraphComponents() = default; + SubgraphComponents(const SubgraphComponents&) = delete; + SubgraphComponents(SubgraphComponents&&) = default; + SubgraphComponents& operator=(const SubgraphComponents&) = delete; + SubgraphComponents& operator=(SubgraphComponents&&) = default; + + std::set nodes; + std::set inputs; + std::set initializers; + std::set outputs; + + SubgraphComponents& operator+=(SubgraphComponents&& other) + { + nodes.insert(other.nodes.begin(), other.nodes.end()); + inputs.insert(other.inputs.begin(), other.inputs.end()); + initializers.insert(other.initializers.begin(), other.initializers.end()); + outputs.insert(other.outputs.begin(), other.outputs.end()); + } + }; + + private: + ONNX_NAMESPACE::GraphProto& m_onnx_graph; + + // Graph traversal helper: node index -> node inputs (one-to-many) + std::unordered_multimap m_node_inputs; + + /// \brief Replaces the old input edge with a new one in the helper struct. + /// This is used by the output contributors discovery. + void replace_input_edge(const InputEdge& old_edge, const InputEdge& new_edge); + + /// \brief Returns a list of edges of each outputs of the graph "m_onnx_graph" + std::vector all_output_edges() const; + + /// \brief Traverses the graph bottom-up and collects all nodes, inputs and initializers + /// that contribute to an output designated by the provided output edge. + /// A sum of such SubgraphComponents objects forms a target extracted subgraph. + SubgraphComponents + discover_output_contributors(const OutputEdge& output_edge, + const SubgraphComponents& already_collected) const; + + /// \brief Modifies the underlying GraphProto object and discards all obsolete elements. + /// + /// \param subgraph An object describing the subgraph to be extracted (elems to be kept) + void extract_subgraph_from_onnx_model(const SubgraphComponents& subgraph); + }; + } // namespace onnx_import +} // namespace ngraph diff --git a/ngraph/frontend/onnx_import/include/onnx_import/editor/editor.hpp b/ngraph/frontend/onnx_import/include/onnx_import/editor/editor.hpp index 39ccd5e6ad901c..b8209c3a9eac30 100644 --- a/ngraph/frontend/onnx_import/include/onnx_import/editor/editor.hpp +++ b/ngraph/frontend/onnx_import/include/onnx_import/editor/editor.hpp @@ -22,6 +22,7 @@ #include "ngraph/partial_shape.hpp" #include "ngraph/type/element_type.hpp" +#include "onnx_import/editor/detail/subgraph_extraction.hpp" #include "onnx_import/utils/onnx_importer_visibility.hpp" namespace ONNX_NAMESPACE @@ -52,7 +53,7 @@ namespace ngraph /// \param model_path Path to the file containing the model. ONNXModelEditor(const std::string& model_path); - /// \brief Modifies the in-memory representation of the model (m_model_proto) by setting + /// \brief Modifies the in-memory representation of the model by setting /// custom input types for all inputs specified in the provided map. /// /// \param input_types A collection of pairs {input_name: new_input_type} that should be @@ -61,7 +62,7 @@ namespace ngraph /// the inputs specified in its parameter. void set_input_types(const std::map& input_types); - /// \brief Modifies the in-memory representation of the model (m_model_proto) by setting + /// \brief Modifies the in-memory representation of the model by setting /// custom input shapes for all inputs specified in the provided map. /// /// \param input_shapes A collection of pairs {input_name: new_input_shape} that should @@ -70,17 +71,36 @@ namespace ngraph /// the inputs specified in its parameter. void set_input_shapes(const std::map& input_shapes); + /// \brief Extracts a subgraph constrained by input edges and output edges. In the end + /// the underlying ModelProto is modified - obsolete inputs, initializers, nodes + /// and outputs are removed from the in-memory model. + /// + /// \node Please look at the declaration of InputEdge and OutputEdge for explanation + /// how those objects can be created. If the outputs parameter is empty + /// this method keeps all of the original outputs of the model. + /// + /// \param inputs A collection of input edges which become new inputs to the graph + /// \param outputs A collection of output edges which become new outputs of the graph + void cut_graph_fragment(const std::vector& inputs, + const std::vector& outputs); + /// \brief Returns a non-const reference to the underlying ModelProto object, possibly /// modified by the editor's API calls /// /// \return A reference to ONNX ModelProto object containing the in-memory model ONNX_NAMESPACE::ModelProto& model() const; + /// \brief Returns a list of all inputs of the in-memory model, including initializers. + /// The returned value might depend on the previous operations executed on an + /// instance of the model editor, in particular the subgraph extraction which + /// can discard some inputs and initializers from the original graph. + std::vector model_inputs() const; + /// \brief Returns the path to the original model file const std::string& model_path() const; - /// \brief Saves the possibly model held by this class to a file. Serializes in binary - /// mode. + /// \brief Saves the possibly modified model held by this class to a file. + /// Serializes in binary mode. /// /// \param out_file_path A path to the file where the modified model should be dumped. void serialize(const std::string& out_file_path) const; @@ -88,7 +108,7 @@ namespace ngraph private: const std::string m_model_path; - class Impl; + struct Impl; std::unique_ptr m_pimpl; }; } // namespace onnx_import diff --git a/ngraph/frontend/onnx_import/src/editor/detail/subgraph_extraction.cpp b/ngraph/frontend/onnx_import/src/editor/detail/subgraph_extraction.cpp new file mode 100644 index 00000000000000..e049caa7555420 --- /dev/null +++ b/ngraph/frontend/onnx_import/src/editor/detail/subgraph_extraction.cpp @@ -0,0 +1,405 @@ +//***************************************************************************** +// Copyright 2017-2021 Intel Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//***************************************************************************** + +#include +#include +#include + +#include "ngraph/check.hpp" +#include "onnx_import/editor/detail/subgraph_extraction.hpp" + +using namespace ngraph::onnx_import; + +namespace +{ + void validate_node_index(const ONNX_NAMESPACE::GraphProto& graph, const int node_idx) + { + NGRAPH_CHECK( + node_idx >= 0 && node_idx < graph.node_size(), + "The specified node index is out of range of nodes in the original model(idx: ", + std::to_string(node_idx), + "; nodes count in the model: ", + std::to_string(graph.node_size()), + ")"); + } + + struct CheckIfHasName + { + }; + + template + std::function name_equals(const std::string& name) + { + return [&name](const T& onnx_object) -> bool { return onnx_object.name() == name; }; + } + + template + std::function name_equals(const std::string& name, CheckIfHasName) + { + return [&name](const T& onnx_object) -> bool { + return onnx_object.has_name() && onnx_object.name() == name; + }; + } + + std::function is_equal_to(const std::string& other) + { + return [&other](const std::string& s) { return s == other; }; + } + + template + bool already_exists(const Container& items, const std::string& name) + { + return std::any_of( + items.begin(), items.end(), name_equals(name)); + } + + bool is_graph_input(const ONNX_NAMESPACE::GraphProto& graph, const std::string& name) + { + return already_exists(graph.input(), name); + } + + bool is_graph_initializer(const ONNX_NAMESPACE::GraphProto& graph, const std::string& name) + { + return already_exists(graph.initializer(), name); + } + + int find_source_node_idx(const ONNX_NAMESPACE::GraphProto& graph, + const int current_node_idx, + const std::string& input_name) + { + for (int i = current_node_idx - 1; i >= 0; --i) + { + const auto& outputs = graph.node(i).output(); + const auto output_found = + std::any_of(outputs.begin(), outputs.end(), is_equal_to(input_name)); + + if (output_found) + { + return i; + } + } + + return -1; + } + + /// \brief Looks up a descriptor for a given tensor name. This descriptor contains inferred + /// shape information which is required to create new inputs and outputs in the graph. + const ONNX_NAMESPACE::ValueInfoProto& + find_tensor_descriptor(const ONNX_NAMESPACE::GraphProto& graph, + const std::string& tensor_name) + { + const auto it = std::find_if( + graph.value_info().begin(), + graph.value_info().end(), + name_equals(tensor_name, CheckIfHasName{})); + + NGRAPH_CHECK(it != graph.value_info().end(), + "Could not find a tensor descriptor for tensor '", + tensor_name, + "'. It's not possible to add a new input to the graph without the type and " + "shape information of the intermediate tensor."); + + return *it; + } + + void replace_initializer_with_new_input(ONNX_NAMESPACE::GraphProto& graph, + const InputEdge& edge, + const std::string& new_input_name) + { + const auto it = std::find_if(graph.initializer().begin(), + graph.initializer().end(), + name_equals(edge.m_tensor_name)); + + NGRAPH_CHECK(it != graph.initializer().end(), + "Could not find an initializer in the graph: '", + edge.m_tensor_name); + + const auto& initializer = *it; + auto& new_input = *(graph.add_input()); + + auto& new_input_tensor_type = *(new_input.mutable_type()->mutable_tensor_type()); + new_input_tensor_type.set_elem_type(initializer.data_type()); + + auto& new_input_shape = *(new_input_tensor_type.mutable_shape()); + for (const auto initializer_dim : initializer.dims()) + { + auto& new_dim = *(new_input_shape.add_dim()); + new_dim.set_dim_value(initializer_dim); + } + + *(new_input.mutable_name()) = new_input_name; + } + + std::pair append_new_graph_input(ONNX_NAMESPACE::GraphProto& graph, + const InputEdge& edge) + { + if (already_exists(graph.input(), edge.m_tensor_name) && + !is_graph_initializer(graph, edge.m_tensor_name)) + { + // no need to append a new input if an edge points to an existing one in the model + return {false, edge}; + } + + auto& target_node = *(graph.mutable_node(edge.m_node_idx)); + auto& node_inputs = *(target_node.mutable_input()); + auto target_input = std::find(node_inputs.begin(), node_inputs.end(), edge.m_tensor_name); + + NGRAPH_CHECK(target_input != node_inputs.end(), + "Input '", + edge.m_tensor_name, + "' not found in the inputs of node ", + edge.m_node_idx, + ". Cannot append a new graph input to this node."); + + const std::string new_input_name = target_node.output(0) + ":" + edge.m_tensor_name; + + if (is_graph_initializer(graph, edge.m_tensor_name)) + { + replace_initializer_with_new_input(graph, edge, new_input_name); + } + else + { + auto& new_input = *(graph.add_input()); + // copy the intermediate tensor properties to the newly created input + new_input.MergeFrom(find_tensor_descriptor(graph, edge.m_tensor_name)); + *(new_input.mutable_name()) = new_input_name; + } + + // attach the new graph input to the target node's input + *target_input = new_input_name; + + return {true, InputEdge{edge.m_node_idx, new_input_name}}; + } + + void append_new_graph_output(ONNX_NAMESPACE::GraphProto& graph, const OutputEdge& edge) + { + if (already_exists(graph.output(), edge.m_tensor_name)) + { + return; + } + + auto& target_node = *(graph.mutable_node(edge.m_node_idx)); + const auto& node_outputs = target_node.output(); + const auto target_output = + std::find(node_outputs.begin(), node_outputs.end(), edge.m_tensor_name); + + NGRAPH_CHECK(target_output != node_outputs.end(), + "Output '", + edge.m_tensor_name, + "' not found in the outputs of node ", + edge.m_node_idx, + ". Cannot append a new graph output to this node."); + + auto& new_output = *(graph.add_output()); + // copy the intermediate tensor's properties to the newly created + new_output.MergeFrom(find_tensor_descriptor(graph, edge.m_tensor_name)); + *(new_output.mutable_name()) = edge.m_tensor_name; + } + + /// \brief Removes all items from a container except the ones whose names are in items_to_keep + /// It's intended to work with ONNX graph inputs and initializers only. + template + void discard_by_name(Container& all_items, const std::set& items_to_keep) + { + static_assert( + std::is_same::value || + std::is_same::value); + + // The tested item can be discarded if its name is not found in the items_to_keep set + const auto can_be_discarded = [&items_to_keep](const typename Container::value_type& item) { + return items_to_keep.count(item.name()) == 0; + }; + + auto items_to_remove = all_items.size() - items_to_keep.size(); + + // move the elements-to-discard to the end of the container + auto new_end = all_items.end(); + while (items_to_remove > 0) + { + new_end = std::remove_if(all_items.begin(), new_end, can_be_discarded); + + --items_to_remove; + } + // erase all of the discarded elements past the new end of the container + all_items.erase(new_end, all_items.end()); + } + + /// \brief Removes all nodes from a container keeping the ones whose index is in nodes_to_keep + template + void discard_nodes(Container& all_nodes, const std::set& nodes_to_keep) + { + static_assert( + std::is_same::value); + + int idx = 0; + const auto keep_node = [&nodes_to_keep, &idx](const typename Container::value_type&) { + return nodes_to_keep.count(idx++) > 0; + }; + + // Stable partition rearranges the nodes keeping the relative order. This way the relative + // ordering is preserved and all of the nodes to discard are moved after the returned iter. + const auto new_end = std::stable_partition(all_nodes.begin(), all_nodes.end(), keep_node); + all_nodes.erase(new_end, all_nodes.end()); + } +} // namespace + +/* -----------------------------------------------------------------------------------------------*/ + +SubgraphExtractor::SubgraphExtractor(ONNX_NAMESPACE::GraphProto& graph) + : m_onnx_graph{graph} +{ + for (int i = 0; i < graph.node_size(); ++i) + { + for (const auto& node_input : graph.node(i).input()) + { + m_node_inputs.insert({i, node_input}); + } + } +} + +void SubgraphExtractor::add_new_inputs(const std::vector& new_inputs) +{ + for (const auto& edge_to_replace : new_inputs) + { + validate_node_index(m_onnx_graph, edge_to_replace.m_node_idx); + + const auto& new_edge = append_new_graph_input(m_onnx_graph, edge_to_replace); + if (new_edge.first) + { + // TODO: all nodes with this input should be updated? additional edges creation uc + replace_input_edge(edge_to_replace, new_edge.second); + } + } +} + +void SubgraphExtractor::add_new_outputs(const std::vector& new_outputs) +{ + for (const auto& new_output : new_outputs) + { + validate_node_index(m_onnx_graph, new_output.m_node_idx); + + append_new_graph_output(m_onnx_graph, new_output); + } +} + +void SubgraphExtractor::replace_input_edge(const InputEdge& old_edge, const InputEdge& new_edge) +{ + const auto node_inputs = m_node_inputs.equal_range(old_edge.m_node_idx); + auto old_input_name = node_inputs.first; + + while (old_input_name->second != old_edge.m_tensor_name && old_input_name != node_inputs.second) + { + ++old_input_name; + } + + m_node_inputs.erase(old_input_name); + m_node_inputs.insert({new_edge.m_node_idx, new_edge.m_tensor_name}); +} + +void SubgraphExtractor::extract_subgraph(std::vector subgraph_outputs) +{ + if (subgraph_outputs.empty()) + { + subgraph_outputs = all_output_edges(); + } + + SubgraphComponents subgraph; + + for (const auto& output_edge : subgraph_outputs) + { + subgraph += discover_output_contributors(output_edge, subgraph); + } + + extract_subgraph_from_onnx_model(subgraph); +} + +SubgraphExtractor::SubgraphComponents SubgraphExtractor::discover_output_contributors( + const OutputEdge& output_edge, const SubgraphComponents& already_collected) const +{ + const auto already_visited = [&already_collected](const int node_index) { + return already_collected.nodes.count(node_index) > 0; + }; + + SubgraphComponents output_contributors; + output_contributors.outputs.insert(output_edge.m_tensor_name); + + // reverse DFS graph traversal + std::stack nodes_to_visit; + nodes_to_visit.push(output_edge.m_node_idx); + + while (!nodes_to_visit.empty()) + { + const auto n = nodes_to_visit.top(); + nodes_to_visit.pop(); + + if (already_visited(n)) + { + continue; + } + + output_contributors.nodes.insert(n); + + // check if the visitor reached any of the graph inputs + // and/or keep looking for more contributors further up in the graph + const auto n_inputs = m_node_inputs.equal_range(n); + for (auto input_name = n_inputs.first; input_name != n_inputs.second; ++input_name) + { + if (is_graph_input(m_onnx_graph, input_name->second)) + { + output_contributors.inputs.insert(input_name->second); + // when an initializer has a matching graph input + if (is_graph_initializer(m_onnx_graph, input_name->second)) + { + output_contributors.initializers.insert(input_name->second); + } + } + else if (is_graph_initializer(m_onnx_graph, input_name->second)) + { + // when an initializer doesn't have a corresponding input + output_contributors.initializers.insert(input_name->second); + } + else + { + nodes_to_visit.push(find_source_node_idx(m_onnx_graph, n, input_name->second)); + } + } + } + + return output_contributors; +} + +void SubgraphExtractor::extract_subgraph_from_onnx_model(const SubgraphComponents& subgraph) +{ + discard_by_name(*(m_onnx_graph.mutable_input()), subgraph.inputs); + discard_by_name(*(m_onnx_graph.mutable_initializer()), subgraph.initializers); + discard_by_name(*(m_onnx_graph.mutable_output()), subgraph.outputs); + discard_nodes(*(m_onnx_graph.mutable_node()), subgraph.nodes); + m_onnx_graph.clear_value_info(); +} + +std::vector SubgraphExtractor::all_output_edges() const +{ + std::vector all_outputs; + + for (const auto& graph_output : m_onnx_graph.output()) + { + all_outputs.emplace_back( + find_source_node_idx(m_onnx_graph, m_onnx_graph.node_size(), graph_output.name()), + graph_output.name()); + } + + return all_outputs; +} diff --git a/ngraph/frontend/onnx_import/src/editor/editor.cpp b/ngraph/frontend/onnx_import/src/editor/editor.cpp index 34a11aadf5fb6b..bbe587c833299b 100644 --- a/ngraph/frontend/onnx_import/src/editor/editor.cpp +++ b/ngraph/frontend/onnx_import/src/editor/editor.cpp @@ -16,6 +16,7 @@ #include #include +#include #include "onnx_import/editor/editor.hpp" #include "utils/parser.hpp" @@ -142,6 +143,12 @@ namespace *(tensor_type->mutable_shape()) = std::move(new_onnx_shape); } } + + template + std::string extract_name(const T& input_or_initializer) + { + return input_or_initializer.name(); + }; } // namespace /// \brief A helper class used to hold the ModelProto object as its field @@ -155,6 +162,18 @@ struct onnx_import::ONNXModelEditor::Impl : m_model_proto{std::move(parse_from_file(model_path))} { } + + void infer_shapes() + { + if (!m_shapes_inferred) + { + ONNX_NAMESPACE::shape_inference::InferShapes(m_model_proto); + m_shapes_inferred = true; + } + } + +private: + bool m_shapes_inferred = false; }; onnx_import::ONNXModelEditor::ONNXModelEditor(const std::string& model_path) @@ -232,3 +251,41 @@ void onnx_import::ONNXModelEditor::set_input_shapes( } } } + +void onnx_import::ONNXModelEditor::cut_graph_fragment(const std::vector& inputs, + const std::vector& outputs) +{ + if (inputs.empty() && outputs.empty()) + { + return; + } + + m_pimpl->infer_shapes(); + + SubgraphExtractor editor{*(m_pimpl->m_model_proto.mutable_graph())}; + + editor.add_new_inputs(inputs); + editor.add_new_outputs(outputs); + + editor.extract_subgraph(outputs); +} + +std::vector onnx_import::ONNXModelEditor::model_inputs() const +{ + const auto& graph = m_pimpl->m_model_proto.graph(); + + std::vector inputs_and_initializers; + inputs_and_initializers.reserve(graph.input_size() + graph.initializer_size()); + + std::transform(graph.input().begin(), + graph.input().end(), + std::back_inserter(inputs_and_initializers), + extract_name); + + std::transform(graph.initializer().begin(), + graph.initializer().end(), + std::back_inserter(inputs_and_initializers), + extract_name); + + return inputs_and_initializers; +} diff --git a/ngraph/test/models/onnx/model_editor/reference/subgraph__existing_inputs_and_outputs_based_extraction.prototxt b/ngraph/test/models/onnx/model_editor/reference/subgraph__existing_inputs_and_outputs_based_extraction.prototxt new file mode 100644 index 00000000000000..6072b62de67a63 --- /dev/null +++ b/ngraph/test/models/onnx/model_editor/reference/subgraph__existing_inputs_and_outputs_based_extraction.prototxt @@ -0,0 +1,112 @@ +ir_version: 7 +producer_name: "tomdol" +graph { + node { + input: "in1" + output: "relu1" + op_type: "Relu" + } + node { + input: "relu1" + input: "in2" + output: "add1" + op_type: "Add" + } + node { + input: "in3" + input: "in4" + output: "conv1" + op_type: "Conv" + } + node { + input: "add1" + input: "conv1" + output: "mul2" + op_type: "Mul" + } + name: "subgraph_extraction_testing" + initializer { + dims: 1 + dims: 1 + data_type: 1 + float_data: 1 + name: "in4" + } + input { + name: "in1" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 2 + } + dim { + dim_value: 2 + } + } + } + } + } + input { + name: "in2" + type { + tensor_type { + elem_type: 1 + shape { + } + } + } + } + input { + name: "in3" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 2 + } + dim { + dim_value: 2 + } + } + } + } + } + input { + name: "in4" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 1 + } + dim { + dim_value: 1 + } + } + } + } + } + output { + name: "mul2" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 2 + } + dim { + dim_value: 2 + } + } + } + } + } +} +opset_import { + version: 13 +} diff --git a/ngraph/test/models/onnx/model_editor/reference/subgraph__initializer_to_input_replacement.prototxt b/ngraph/test/models/onnx/model_editor/reference/subgraph__initializer_to_input_replacement.prototxt new file mode 100644 index 00000000000000..62062044de7e70 --- /dev/null +++ b/ngraph/test/models/onnx/model_editor/reference/subgraph__initializer_to_input_replacement.prototxt @@ -0,0 +1,121 @@ +ir_version: 3 +producer_name: "tomdol" +doc_string: "This model contains the first few nodes of the ONNX Inception V1 model" +graph { + name: "Inception V1 fragment" + node { + input: "data_0" + input: "conv1/7x7_s2_w_0" + input: "conv1/7x7_s2_1:conv1/7x7_s2_b_0" + output: "conv1/7x7_s2_1" + name: "" + op_type: "Conv" + attribute { + name: "strides" + ints: 2 + ints: 2 + type: INTS + } + attribute { + name: "pads" + ints: 3 + ints: 3 + ints: 3 + ints: 3 + type: INTS + } + attribute { + name: "kernel_shape" + ints: 7 + ints: 7 + type: INTS + } + } + + input { + name: "data_0" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 1 + } + dim { + dim_value: 3 + } + dim { + dim_value: 224 + } + dim { + dim_value: 224 + } + } + } + } + } + + input { + name: "conv1/7x7_s2_w_0" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 64 + } + dim { + dim_value: 3 + } + dim { + dim_value: 7 + } + dim { + dim_value: 7 + } + } + } + } + } + + input { + name: "conv1/7x7_s2_1:conv1/7x7_s2_b_0" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 1 + } + } + } + } + } + + output { + name: "conv1/7x7_s2_1" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 1 + } + dim { + dim_value: 64 + } + dim { + dim_value: 112 + } + dim { + dim_value: 112 + } + } + } + } + } +} + +opset_import { + version: 8 +} diff --git a/ngraph/test/models/onnx/model_editor/reference/subgraph__initializer_without_matching_input_tail_cut.prototxt b/ngraph/test/models/onnx/model_editor/reference/subgraph__initializer_without_matching_input_tail_cut.prototxt new file mode 100644 index 00000000000000..5b2a9a0d1e117b --- /dev/null +++ b/ngraph/test/models/onnx/model_editor/reference/subgraph__initializer_without_matching_input_tail_cut.prototxt @@ -0,0 +1,120 @@ +ir_version: 3 +producer_name: "tomdol" +doc_string: "This model contains the first few nodes of the ONNX Inception V1 model" +graph { + name: "Inception V1 fragment" + node { + input: "data_0" + input: "conv1/7x7_s2_w_0" + input: "conv1/7x7_s2_b_0" + output: "conv1/7x7_s2_1" + name: "" + op_type: "Conv" + attribute { + name: "strides" + ints: 2 + ints: 2 + type: INTS + } + attribute { + name: "pads" + ints: 3 + ints: 3 + ints: 3 + ints: 3 + type: INTS + } + attribute { + name: "kernel_shape" + ints: 7 + ints: 7 + type: INTS + } + } + node { + input: "conv1/7x7_s2_1" + output: "conv1/7x7_s2_2" + name: "" + op_type: "Relu" + } + + input { + name: "data_0" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 1 + } + dim { + dim_value: 3 + } + dim { + dim_value: 224 + } + dim { + dim_value: 224 + } + } + } + } + } + + input { + name: "conv1/7x7_s2_w_0" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 64 + } + dim { + dim_value: 3 + } + dim { + dim_value: 7 + } + dim { + dim_value: 7 + } + } + } + } + } + + initializer { + dims: 1 + data_type: 1 + name: "conv1/7x7_s2_b_0" + float_data: 3.141592 + } + + output { + name: "conv1/7x7_s2_2" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 1 + } + dim { + dim_value: 64 + } + dim { + dim_value: 112 + } + dim { + dim_value: 112 + } + } + } + } + } +} + +opset_import { + version: 8 +} diff --git a/ngraph/test/models/onnx/model_editor/reference/subgraph__linear_model_deeper_head_cut.prototxt b/ngraph/test/models/onnx/model_editor/reference/subgraph__linear_model_deeper_head_cut.prototxt new file mode 100644 index 00000000000000..44b3a3f1ce9715 --- /dev/null +++ b/ngraph/test/models/onnx/model_editor/reference/subgraph__linear_model_deeper_head_cut.prototxt @@ -0,0 +1,82 @@ +ir_version: 7 +producer_name: "tomdol" +doc_string: "This model contains the first few nodes of the ONNX Inception V1 model" +graph { + name: "Inception V1 fragment" + node { + input: "pool1/3x3_s2_1:conv1/7x7_s2_2" + output: "pool1/3x3_s2_1" + name: "" + op_type: "MaxPool" + attribute { + name: "strides" + ints: 2 + ints: 2 + type: INTS + } + attribute { + name: "pads" + ints: 0 + ints: 0 + ints: 0 + ints: 0 + type: INTS + } + attribute { + name: "kernel_shape" + ints: 3 + ints: 3 + type: INTS + } + } + + input { + name: "pool1/3x3_s2_1:conv1/7x7_s2_2" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 1 + } + dim { + dim_value: 64 + } + dim { + dim_value: 112 + } + dim { + dim_value: 112 + } + } + } + } + } + + output { + name: "pool1/3x3_s2_1" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 1 + } + dim { + dim_value: 64 + } + dim { + dim_value: 55 + } + dim { + dim_value: 55 + } + } + } + } + } +} + +opset_import { + version: 13 +} diff --git a/ngraph/test/models/onnx/model_editor/reference/subgraph__linear_model_deeper_tail_cut.prototxt b/ngraph/test/models/onnx/model_editor/reference/subgraph__linear_model_deeper_tail_cut.prototxt new file mode 100644 index 00000000000000..c2b948b1c7c90b --- /dev/null +++ b/ngraph/test/models/onnx/model_editor/reference/subgraph__linear_model_deeper_tail_cut.prototxt @@ -0,0 +1,121 @@ +ir_version: 7 +producer_name: "tomdol" +doc_string: "This model contains the first few nodes of the ONNX Inception V1 model" +graph { + name: "Inception V1 fragment" + node { + input: "data_0" + input: "conv1/7x7_s2_w_0" + input: "conv1/7x7_s2_b_0" + output: "conv1/7x7_s2_1" + name: "" + op_type: "Conv" + attribute { + name: "strides" + ints: 2 + ints: 2 + type: INTS + } + attribute { + name: "pads" + ints: 3 + ints: 3 + ints: 3 + ints: 3 + type: INTS + } + attribute { + name: "kernel_shape" + ints: 7 + ints: 7 + type: INTS + } + } + + input { + name: "data_0" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 1 + } + dim { + dim_value: 3 + } + dim { + dim_value: 224 + } + dim { + dim_value: 224 + } + } + } + } + } + + input { + name: "conv1/7x7_s2_w_0" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 64 + } + dim { + dim_value: 3 + } + dim { + dim_value: 7 + } + dim { + dim_value: 7 + } + } + } + } + } + + input { + name: "conv1/7x7_s2_b_0" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 64 + } + } + } + } + } + + output { + name: "conv1/7x7_s2_1" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 1 + } + dim { + dim_value: 64 + } + dim { + dim_value: 112 + } + dim { + dim_value: 112 + } + } + } + } + } +} + +opset_import { + version: 13 +} diff --git a/ngraph/test/models/onnx/model_editor/reference/subgraph__linear_model_head_cut.prototxt b/ngraph/test/models/onnx/model_editor/reference/subgraph__linear_model_head_cut.prototxt new file mode 100644 index 00000000000000..f43cfcc2904711 --- /dev/null +++ b/ngraph/test/models/onnx/model_editor/reference/subgraph__linear_model_head_cut.prototxt @@ -0,0 +1,88 @@ +ir_version: 7 +producer_name: "tomdol" +doc_string: "This model contains the first few nodes of the ONNX Inception V1 model" +graph { + name: "Inception V1 fragment" + node { + input: "conv1/7x7_s2_2:conv1/7x7_s2_1" + output: "conv1/7x7_s2_2" + name: "" + op_type: "Relu" + } + node { + input: "conv1/7x7_s2_2" + output: "pool1/3x3_s2_1" + name: "" + op_type: "MaxPool" + attribute { + name: "strides" + ints: 2 + ints: 2 + type: INTS + } + attribute { + name: "pads" + ints: 0 + ints: 0 + ints: 0 + ints: 0 + type: INTS + } + attribute { + name: "kernel_shape" + ints: 3 + ints: 3 + type: INTS + } + } + + input { + name: "conv1/7x7_s2_2:conv1/7x7_s2_1" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 1 + } + dim { + dim_value: 64 + } + dim { + dim_value: 112 + } + dim { + dim_value: 112 + } + } + } + } + } + + output { + name: "pool1/3x3_s2_1" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 1 + } + dim { + dim_value: 64 + } + dim { + dim_value: 55 + } + dim { + dim_value: 55 + } + } + } + } + } +} + +opset_import { + version: 13 +} diff --git a/ngraph/test/models/onnx/model_editor/reference/subgraph__linear_model_tail_cut.prototxt b/ngraph/test/models/onnx/model_editor/reference/subgraph__linear_model_tail_cut.prototxt new file mode 100644 index 00000000000000..65518599cabbab --- /dev/null +++ b/ngraph/test/models/onnx/model_editor/reference/subgraph__linear_model_tail_cut.prototxt @@ -0,0 +1,127 @@ +ir_version: 7 +producer_name: "tomdol" +doc_string: "This model contains the first few nodes of the ONNX Inception V1 model" +graph { + name: "Inception V1 fragment" + node { + input: "data_0" + input: "conv1/7x7_s2_w_0" + input: "conv1/7x7_s2_b_0" + output: "conv1/7x7_s2_1" + name: "" + op_type: "Conv" + attribute { + name: "strides" + ints: 2 + ints: 2 + type: INTS + } + attribute { + name: "pads" + ints: 3 + ints: 3 + ints: 3 + ints: 3 + type: INTS + } + attribute { + name: "kernel_shape" + ints: 7 + ints: 7 + type: INTS + } + } + node { + input: "conv1/7x7_s2_1" + output: "conv1/7x7_s2_2" + name: "" + op_type: "Relu" + } + + input { + name: "data_0" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 1 + } + dim { + dim_value: 3 + } + dim { + dim_value: 224 + } + dim { + dim_value: 224 + } + } + } + } + } + + input { + name: "conv1/7x7_s2_w_0" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 64 + } + dim { + dim_value: 3 + } + dim { + dim_value: 7 + } + dim { + dim_value: 7 + } + } + } + } + } + + input { + name: "conv1/7x7_s2_b_0" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 64 + } + } + } + } + } + + output { + name: "conv1/7x7_s2_2" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 1 + } + dim { + dim_value: 64 + } + dim { + dim_value: 112 + } + dim { + dim_value: 112 + } + } + } + } + } +} + +opset_import { + version: 13 +} diff --git a/ngraph/test/models/onnx/model_editor/reference/subgraph__linear_model_with_initializer_tail_cut.prototxt b/ngraph/test/models/onnx/model_editor/reference/subgraph__linear_model_with_initializer_tail_cut.prototxt new file mode 100644 index 00000000000000..af08b388c2d936 --- /dev/null +++ b/ngraph/test/models/onnx/model_editor/reference/subgraph__linear_model_with_initializer_tail_cut.prototxt @@ -0,0 +1,134 @@ +ir_version: 3 +producer_name: "tomdol" +doc_string: "This model contains the first few nodes of the ONNX Inception V1 model" +graph { + name: "Inception V1 fragment" + node { + input: "data_0" + input: "conv1/7x7_s2_w_0" + input: "conv1/7x7_s2_b_0" + output: "conv1/7x7_s2_1" + name: "" + op_type: "Conv" + attribute { + name: "strides" + ints: 2 + ints: 2 + type: INTS + } + attribute { + name: "pads" + ints: 3 + ints: 3 + ints: 3 + ints: 3 + type: INTS + } + attribute { + name: "kernel_shape" + ints: 7 + ints: 7 + type: INTS + } + } + node { + input: "conv1/7x7_s2_1" + output: "conv1/7x7_s2_2" + name: "" + op_type: "Relu" + } + + input { + name: "data_0" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 1 + } + dim { + dim_value: 3 + } + dim { + dim_value: 224 + } + dim { + dim_value: 224 + } + } + } + } + } + + input { + name: "conv1/7x7_s2_w_0" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 64 + } + dim { + dim_value: 3 + } + dim { + dim_value: 7 + } + dim { + dim_value: 7 + } + } + } + } + } + + input { + name: "conv1/7x7_s2_b_0" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 1 + } + } + } + } + } + + initializer { + dims: 1 + data_type: 1 + name: "conv1/7x7_s2_b_0" + float_data: 3.141592 + } + + output { + name: "conv1/7x7_s2_2" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 1 + } + dim { + dim_value: 64 + } + dim { + dim_value: 112 + } + dim { + dim_value: 112 + } + } + } + } + } +} + +opset_import { + version: 8 +} diff --git a/ngraph/test/models/onnx/model_editor/reference/subgraph__multiout_op_output_edge.prototxt b/ngraph/test/models/onnx/model_editor/reference/subgraph__multiout_op_output_edge.prototxt new file mode 100644 index 00000000000000..0d99c4e70c0b9e --- /dev/null +++ b/ngraph/test/models/onnx/model_editor/reference/subgraph__multiout_op_output_edge.prototxt @@ -0,0 +1,78 @@ +ir_version: 7 +producer_name: "tomdol" +graph { + node { + input: "in1" + output: "relu1" + op_type: "Relu" + } + node { + input: "relu1" + input: "in2" + output: "add1" + op_type: "Add" + } + node { + input: "relu1" + input: "add1" + output: "add2" + op_type: "Add" + } + node { + input: "add2" + output: "split1" + output: "split2" + op_type: "Split" + attribute { + name: "axis" + i: 1 + type: INT + } + } + name: "subgraph_extraction_testing" + input { + name: "in1" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 2 + } + dim { + dim_value: 2 + } + } + } + } + } + input { + name: "in2" + type { + tensor_type { + elem_type: 1 + shape { + } + } + } + } + output { + name: "split2" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 2 + } + dim { + dim_value: 1 + } + } + } + } + } +} +opset_import { + version: 13 +} diff --git a/ngraph/test/models/onnx/model_editor/subgraph__inception_head.prototxt b/ngraph/test/models/onnx/model_editor/subgraph__inception_head.prototxt new file mode 100644 index 00000000000000..250c8c75444c59 --- /dev/null +++ b/ngraph/test/models/onnx/model_editor/subgraph__inception_head.prototxt @@ -0,0 +1,153 @@ +ir_version: 7 +producer_name: "tomdol" +doc_string: "This model contains the first few nodes of the ONNX Inception V1 model" +graph { + name: "Inception V1 fragment" + node { + input: "data_0" + input: "conv1/7x7_s2_w_0" + input: "conv1/7x7_s2_b_0" + output: "conv1/7x7_s2_1" + name: "" + op_type: "Conv" + attribute { + name: "strides" + ints: 2 + ints: 2 + type: INTS + } + attribute { + name: "pads" + ints: 3 + ints: 3 + ints: 3 + ints: 3 + type: INTS + } + attribute { + name: "kernel_shape" + ints: 7 + ints: 7 + type: INTS + } + } + node { + input: "conv1/7x7_s2_1" + output: "conv1/7x7_s2_2" + name: "" + op_type: "Relu" + } + node { + input: "conv1/7x7_s2_2" + output: "pool1/3x3_s2_1" + name: "" + op_type: "MaxPool" + attribute { + name: "strides" + ints: 2 + ints: 2 + type: INTS + } + attribute { + name: "pads" + ints: 0 + ints: 0 + ints: 0 + ints: 0 + type: INTS + } + attribute { + name: "kernel_shape" + ints: 3 + ints: 3 + type: INTS + } + } + + input { + name: "data_0" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 1 + } + dim { + dim_value: 3 + } + dim { + dim_value: 224 + } + dim { + dim_value: 224 + } + } + } + } + } + + input { + name: "conv1/7x7_s2_w_0" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 64 + } + dim { + dim_value: 3 + } + dim { + dim_value: 7 + } + dim { + dim_value: 7 + } + } + } + } + } + + input { + name: "conv1/7x7_s2_b_0" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 64 + } + } + } + } + } + + output { + name: "pool1/3x3_s2_1" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 1 + } + dim { + dim_value: 64 + } + dim { + dim_value: 55 + } + dim { + dim_value: 55 + } + } + } + } + } +} + +opset_import { + version: 13 +} diff --git a/ngraph/test/models/onnx/model_editor/subgraph__inception_head_with_initializer.prototxt b/ngraph/test/models/onnx/model_editor/subgraph__inception_head_with_initializer.prototxt new file mode 100644 index 00000000000000..933290aed2e54f --- /dev/null +++ b/ngraph/test/models/onnx/model_editor/subgraph__inception_head_with_initializer.prototxt @@ -0,0 +1,160 @@ +ir_version: 3 +producer_name: "tomdol" +doc_string: "This model contains the first few nodes of the ONNX Inception V1 model" +graph { + name: "Inception V1 fragment" + node { + input: "data_0" + input: "conv1/7x7_s2_w_0" + input: "conv1/7x7_s2_b_0" + output: "conv1/7x7_s2_1" + name: "" + op_type: "Conv" + attribute { + name: "strides" + ints: 2 + ints: 2 + type: INTS + } + attribute { + name: "pads" + ints: 3 + ints: 3 + ints: 3 + ints: 3 + type: INTS + } + attribute { + name: "kernel_shape" + ints: 7 + ints: 7 + type: INTS + } + } + node { + input: "conv1/7x7_s2_1" + output: "conv1/7x7_s2_2" + name: "" + op_type: "Relu" + } + node { + input: "conv1/7x7_s2_2" + output: "pool1/3x3_s2_1" + name: "" + op_type: "MaxPool" + attribute { + name: "strides" + ints: 2 + ints: 2 + type: INTS + } + attribute { + name: "pads" + ints: 0 + ints: 0 + ints: 0 + ints: 0 + type: INTS + } + attribute { + name: "kernel_shape" + ints: 3 + ints: 3 + type: INTS + } + } + + input { + name: "data_0" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 1 + } + dim { + dim_value: 3 + } + dim { + dim_value: 224 + } + dim { + dim_value: 224 + } + } + } + } + } + + input { + name: "conv1/7x7_s2_w_0" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 64 + } + dim { + dim_value: 3 + } + dim { + dim_value: 7 + } + dim { + dim_value: 7 + } + } + } + } + } + + input { + name: "conv1/7x7_s2_b_0" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 1 + } + } + } + } + } + + initializer { + dims: 1 + data_type: 1 + name: "conv1/7x7_s2_b_0" + float_data: 3.141592 + } + + output { + name: "pool1/3x3_s2_1" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 1 + } + dim { + dim_value: 64 + } + dim { + dim_value: 55 + } + dim { + dim_value: 55 + } + } + } + } + } +} + +opset_import { + version: 8 +} diff --git a/ngraph/test/models/onnx/model_editor/subgraph__initializer_without_matching_input.prototxt b/ngraph/test/models/onnx/model_editor/subgraph__initializer_without_matching_input.prototxt new file mode 100644 index 00000000000000..040273881a4f26 --- /dev/null +++ b/ngraph/test/models/onnx/model_editor/subgraph__initializer_without_matching_input.prototxt @@ -0,0 +1,146 @@ +ir_version: 3 +producer_name: "tomdol" +doc_string: "This model contains the first few nodes of the ONNX Inception V1 model" +graph { + name: "Inception V1 fragment" + node { + input: "data_0" + input: "conv1/7x7_s2_w_0" + input: "conv1/7x7_s2_b_0" + output: "conv1/7x7_s2_1" + name: "" + op_type: "Conv" + attribute { + name: "strides" + ints: 2 + ints: 2 + type: INTS + } + attribute { + name: "pads" + ints: 3 + ints: 3 + ints: 3 + ints: 3 + type: INTS + } + attribute { + name: "kernel_shape" + ints: 7 + ints: 7 + type: INTS + } + } + node { + input: "conv1/7x7_s2_1" + output: "conv1/7x7_s2_2" + name: "" + op_type: "Relu" + } + node { + input: "conv1/7x7_s2_2" + output: "pool1/3x3_s2_1" + name: "" + op_type: "MaxPool" + attribute { + name: "strides" + ints: 2 + ints: 2 + type: INTS + } + attribute { + name: "pads" + ints: 0 + ints: 0 + ints: 0 + ints: 0 + type: INTS + } + attribute { + name: "kernel_shape" + ints: 3 + ints: 3 + type: INTS + } + } + + input { + name: "data_0" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 1 + } + dim { + dim_value: 3 + } + dim { + dim_value: 224 + } + dim { + dim_value: 224 + } + } + } + } + } + + input { + name: "conv1/7x7_s2_w_0" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 64 + } + dim { + dim_value: 3 + } + dim { + dim_value: 7 + } + dim { + dim_value: 7 + } + } + } + } + } + + initializer { + dims: 1 + data_type: 1 + name: "conv1/7x7_s2_b_0" + float_data: 3.141592 + } + + output { + name: "pool1/3x3_s2_1" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 1 + } + dim { + dim_value: 64 + } + dim { + dim_value: 55 + } + dim { + dim_value: 55 + } + } + } + } + } +} + +opset_import { + version: 8 +} diff --git a/ngraph/test/models/onnx/model_editor/subgraph_extraction_tests.prototxt b/ngraph/test/models/onnx/model_editor/subgraph_extraction_tests.prototxt new file mode 100644 index 00000000000000..9e9a165123e156 --- /dev/null +++ b/ngraph/test/models/onnx/model_editor/subgraph_extraction_tests.prototxt @@ -0,0 +1,167 @@ +ir_version: 7 +producer_name: "tomdol" +graph { + node { + input: "in1" + output: "relu1" + op_type: "Relu" + } + node { + input: "relu1" + input: "in2" + output: "add1" + op_type: "Add" + } + node { + input: "in3" + input: "in4" + output: "conv1" + op_type: "Conv" + } + node { + input: "relu1" + input: "add1" + output: "add2" + op_type: "Add" + } + node { + input: "add1" + input: "conv1" + output: "mul2" + op_type: "Mul" + } + node { + input: "add2" + output: "split1" + output: "split2" + op_type: "Split" + attribute { + name: "axis" + i: 1 + type: INT + } + } + node { + input: "relu1" + input: "split1" + output: "mul1" + op_type: "Mul" + } + name: "subgraph_extraction_testing" + initializer { + dims: 1 + dims: 1 + data_type: 1 + float_data: 1 + name: "in4" + } + input { + name: "in1" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 2 + } + dim { + dim_value: 2 + } + } + } + } + } + input { + name: "in2" + type { + tensor_type { + elem_type: 1 + shape { + } + } + } + } + input { + name: "in3" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 2 + } + dim { + dim_value: 2 + } + } + } + } + } + input { + name: "in4" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 1 + } + dim { + dim_value: 1 + } + } + } + } + } + output { + name: "mul1" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 2 + } + dim { + dim_value: 2 + } + } + } + } + } + output { + name: "split2" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 2 + } + dim { + dim_value: 1 + } + } + } + } + } + output { + name: "mul2" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 2 + } + dim { + dim_value: 2 + } + } + } + } + } +} +opset_import { + version: 13 +} diff --git a/ngraph/test/onnx/onnx_editor.cpp b/ngraph/test/onnx/onnx_editor.cpp index 2d1c2b72532b2d..f574b6972f04f8 100644 --- a/ngraph/test/onnx/onnx_editor.cpp +++ b/ngraph/test/onnx/onnx_editor.cpp @@ -15,18 +15,24 @@ //***************************************************************************** #include +#include +#include + #include "gtest/gtest.h" #include "default_opset.hpp" #include "ngraph/file_util.hpp" #include "ngraph/op/util/op_types.hpp" +#include "ngraph/opsets/opset1.hpp" #include "onnx_import/editor/editor.hpp" #include "onnx_import/onnx.hpp" +#include "util/onnx_test_util.hpp" #include "util/test_control.hpp" NGRAPH_SUPPRESS_DEPRECATED_START using namespace ngraph; +using namespace ngraph::onnx_import; static std::string s_manifest = "${MANIFEST}"; @@ -284,3 +290,245 @@ NGRAPH_TEST(onnx_editor, shapes__static_to_dynamic_rank_substitution) EXPECT_TRUE(input->get_partial_shape().same_scheme(new_shape)); } } + +NGRAPH_TEST(onnx_editor, subgraph__linear_model_head_cut) +{ + onnx_import::ONNXModelEditor editor{file_util::path_join( + SERIALIZED_ZOO, "onnx/model_editor/subgraph__inception_head.prototxt")}; + + editor.cut_graph_fragment({{InputEdge(1, "conv1/7x7_s2_1")}}, {}); + + const auto ref_model = file_util::path_join( + SERIALIZED_ZOO, "onnx/model_editor/reference/subgraph__linear_model_head_cut.prototxt"); + + const auto res = test::compare_onnx_graphs(editor.model().graph(), ref_model); + + EXPECT_TRUE(res.first) << res.second; +} + +NGRAPH_TEST(onnx_editor, subgraph__linear_model_head_cut_ins_and_outs) +{ + onnx_import::ONNXModelEditor editor{file_util::path_join( + SERIALIZED_ZOO, "onnx/model_editor/subgraph__inception_head.prototxt")}; + + editor.cut_graph_fragment({{InputEdge(1, "conv1/7x7_s2_1")}}, + {{OutputEdge(2, "pool1/3x3_s2_1")}}); + + // expected to behave the same way as subgraph__linear_model_head_cut + const auto ref_model = file_util::path_join( + SERIALIZED_ZOO, "onnx/model_editor/reference/subgraph__linear_model_head_cut.prototxt"); + + const auto res = test::compare_onnx_graphs(editor.model().graph(), ref_model); + + EXPECT_TRUE(res.first) << res.second; +} + +NGRAPH_TEST(onnx_editor, subgraph__linear_model_deeper_head_cut) +{ + onnx_import::ONNXModelEditor editor{file_util::path_join( + SERIALIZED_ZOO, "onnx/model_editor/subgraph__inception_head.prototxt")}; + + editor.cut_graph_fragment({{InputEdge(2, "conv1/7x7_s2_2")}}, {}); + + const auto ref_model = file_util::path_join( + SERIALIZED_ZOO, + "onnx/model_editor/reference/subgraph__linear_model_deeper_head_cut.prototxt"); + + const auto res = test::compare_onnx_graphs(editor.model().graph(), ref_model); + + EXPECT_TRUE(res.first) << res.second; +} + +NGRAPH_TEST(onnx_editor, subgraph__linear_model_tail_cut) +{ + onnx_import::ONNXModelEditor editor{file_util::path_join( + SERIALIZED_ZOO, "onnx/model_editor/subgraph__inception_head.prototxt")}; + + editor.cut_graph_fragment({}, {{OutputEdge{1, "conv1/7x7_s2_2"}}}); + + const auto ref_model = file_util::path_join( + SERIALIZED_ZOO, "onnx/model_editor/reference/subgraph__linear_model_tail_cut.prototxt"); + + const auto res = test::compare_onnx_graphs(editor.model().graph(), ref_model); + + EXPECT_TRUE(res.first) << res.second; +} + +NGRAPH_TEST(onnx_editor, subgraph__linear_model_tail_cut_ins_and_outs) +{ + onnx_import::ONNXModelEditor editor{file_util::path_join( + SERIALIZED_ZOO, "onnx/model_editor/subgraph__inception_head.prototxt")}; + + editor.cut_graph_fragment({{InputEdge{0, "data_0"}}}, {{OutputEdge{1, "conv1/7x7_s2_2"}}}); + + // expected to behave the same way as subgraph__linear_model_tail_cut + const auto ref_model = file_util::path_join( + SERIALIZED_ZOO, "onnx/model_editor/reference/subgraph__linear_model_tail_cut.prototxt"); + + const auto res = test::compare_onnx_graphs(editor.model().graph(), ref_model); + + EXPECT_TRUE(res.first) << res.second; +} + +NGRAPH_TEST(onnx_editor, subgraph__linear_model_with_initializer_tail_cut) +{ + onnx_import::ONNXModelEditor editor{file_util::path_join( + SERIALIZED_ZOO, "onnx/model_editor/subgraph__inception_head_with_initializer.prototxt")}; + + editor.cut_graph_fragment({}, {{OutputEdge{1, "conv1/7x7_s2_2"}}}); + + const auto ref_model = file_util::path_join( + SERIALIZED_ZOO, + "onnx/model_editor/reference/subgraph__linear_model_with_initializer_tail_cut.prototxt"); + + const auto res = test::compare_onnx_graphs(editor.model().graph(), ref_model); + + EXPECT_TRUE(res.first) << res.second; +} + +NGRAPH_TEST(onnx_editor, subgraph__initializer_without_matching_input_tail_cut) +{ + onnx_import::ONNXModelEditor editor{file_util::path_join( + SERIALIZED_ZOO, "onnx/model_editor/subgraph__initializer_without_matching_input.prototxt")}; + + editor.cut_graph_fragment({}, {{OutputEdge{1, "conv1/7x7_s2_2"}}}); + + const auto ref_model = + file_util::path_join(SERIALIZED_ZOO, + "onnx/model_editor/reference/" + "subgraph__initializer_without_matching_input_tail_cut.prototxt"); + + const auto res = test::compare_onnx_graphs(editor.model().graph(), ref_model); + + EXPECT_TRUE(res.first) << res.second; +} + +NGRAPH_TEST(onnx_editor, subgraph__linear_model_deeper_tail_cut) +{ + onnx_import::ONNXModelEditor editor{file_util::path_join( + SERIALIZED_ZOO, "onnx/model_editor/subgraph__inception_head.prototxt")}; + + editor.cut_graph_fragment({}, {{OutputEdge{0, "conv1/7x7_s2_1"}}}); + + const auto ref_model = file_util::path_join( + SERIALIZED_ZOO, + "onnx/model_editor/reference/subgraph__linear_model_deeper_tail_cut.prototxt"); + + const auto res = test::compare_onnx_graphs(editor.model().graph(), ref_model); + + EXPECT_TRUE(res.first) << res.second; +} + +NGRAPH_TEST(onnx_editor, subgraph__no_input_params) +{ + const auto model_path = + file_util::path_join(SERIALIZED_ZOO, "onnx/model_editor/subgraph__inception_head.prototxt"); + + onnx_import::ONNXModelEditor editor{model_path}; + + editor.cut_graph_fragment({}, {}); + + const auto res = test::compare_onnx_graphs(editor.model().graph(), model_path); + + EXPECT_TRUE(res.first) << res.second; +} + +NGRAPH_TEST(onnx_editor, subgraph__initializer_to_input_replacement) +{ + onnx_import::ONNXModelEditor editor{file_util::path_join( + SERIALIZED_ZOO, "onnx/model_editor/subgraph__inception_head_with_initializer.prototxt")}; + + editor.cut_graph_fragment({{InputEdge{0, "conv1/7x7_s2_b_0"}}}, + {{OutputEdge{0, "conv1/7x7_s2_1"}}}); + + const auto ref_model = file_util::path_join( + SERIALIZED_ZOO, + "onnx/model_editor/reference/subgraph__initializer_to_input_replacement.prototxt"); + + const auto res = test::compare_onnx_graphs(editor.model().graph(), ref_model); + + EXPECT_TRUE(res.first) << res.second; +} + +NGRAPH_TEST(onnx_editor, subgraph__initializer_to_input_replacement_2) +{ + onnx_import::ONNXModelEditor editor{file_util::path_join( + SERIALIZED_ZOO, "onnx/model_editor/subgraph__initializer_without_matching_input.prototxt")}; + + editor.cut_graph_fragment({{InputEdge{0, "conv1/7x7_s2_b_0"}}}, + {{OutputEdge{0, "conv1/7x7_s2_1"}}}); + + const auto ref_model = file_util::path_join( + SERIALIZED_ZOO, + "onnx/model_editor/reference/subgraph__initializer_to_input_replacement.prototxt"); + + const auto res = test::compare_onnx_graphs(editor.model().graph(), ref_model); + + EXPECT_TRUE(res.first) << res.second; +} + +NGRAPH_TEST(onnx_editor, subgraph__multiout_op_output_edge) +{ + onnx_import::ONNXModelEditor editor{file_util::path_join( + SERIALIZED_ZOO, "onnx/model_editor/subgraph_extraction_tests.prototxt")}; + + editor.cut_graph_fragment({}, {{OutputEdge{5, "split2"}}}); + + const auto ref_model = file_util::path_join( + SERIALIZED_ZOO, "onnx/model_editor/reference/subgraph__multiout_op_output_edge.prototxt"); + + const auto res = test::compare_onnx_graphs(editor.model().graph(), ref_model); + + EXPECT_TRUE(res.first) << res.second; +} + +NGRAPH_TEST(onnx_editor, subgraph__existing_inputs_and_outputs_based_extraction) +{ + onnx_import::ONNXModelEditor editor{file_util::path_join( + SERIALIZED_ZOO, "onnx/model_editor/subgraph_extraction_tests.prototxt")}; + + editor.cut_graph_fragment({{InputEdge{1, "in2"}, InputEdge{2, "in3"}}}, + {{OutputEdge{4, "mul2"}}}); + + const auto ref_model = + file_util::path_join(SERIALIZED_ZOO, + "onnx/model_editor/reference/" + "subgraph__existing_inputs_and_outputs_based_extraction.prototxt"); + + const auto res = test::compare_onnx_graphs(editor.model().graph(), ref_model); + + EXPECT_TRUE(res.first) << res.second; +} + +NGRAPH_TEST(onnx_editor, subgraph__invalid_edge_idx) +{ + const auto model_path = + file_util::path_join(SERIALIZED_ZOO, "onnx/model_editor/subgraph__inception_head.prototxt"); + + onnx_import::ONNXModelEditor editor{model_path}; + + EXPECT_THROW(editor.cut_graph_fragment({{InputEdge{15, "x"}}}, {}), ngraph::ngraph_error); +} + +NGRAPH_TEST(onnx_editor, subgraph__invalid_edge_name) +{ + const auto model_path = + file_util::path_join(SERIALIZED_ZOO, "onnx/model_editor/subgraph__inception_head.prototxt"); + + onnx_import::ONNXModelEditor editor{model_path}; + + EXPECT_THROW(editor.cut_graph_fragment({{InputEdge{0, "x"}}}, {}), ngraph::ngraph_error); +} + +NGRAPH_TEST(onnx_editor, subgraph__inputs_getter) +{ + onnx_import::ONNXModelEditor editor{file_util::path_join( + SERIALIZED_ZOO, "onnx/model_editor/subgraph__inception_head.prototxt")}; + + EXPECT_EQ(editor.model_inputs(), + (std::vector{"data_0", "conv1/7x7_s2_w_0", "conv1/7x7_s2_b_0"})); + + editor.cut_graph_fragment({{InputEdge(1, "conv1/7x7_s2_1")}}, {}); + + EXPECT_EQ(editor.model_inputs(), (std::vector{"conv1/7x7_s2_2:conv1/7x7_s2_1"})); +} diff --git a/ngraph/test/util/CMakeLists.txt b/ngraph/test/util/CMakeLists.txt index 548326c6c85a33..f5e837ebf8089d 100644 --- a/ngraph/test/util/CMakeLists.txt +++ b/ngraph/test/util/CMakeLists.txt @@ -23,6 +23,7 @@ set (SRC engine/ie_engines.cpp engine/interpreter_engine.cpp float_util.cpp + onnx_test_util.cpp test_tools.cpp test_control.cpp visitor.hpp @@ -43,3 +44,6 @@ if(NGRAPH_LIB_VERSIONING_ENABLE) endif() target_include_directories(ngraph_test_util PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/.. ${IE_MAIN_SOURCE_DIR}/include) target_link_libraries(ngraph_test_util PRIVATE ngraph ngraph_backend libgtest) + +target_include_directories(ngraph_test_util SYSTEM PRIVATE ${ONNX_INCLUDE_DIR} ${ONNX_PROTO_INCLUDE_DIR}) +target_link_libraries(ngraph_test_util PRIVATE ${ONNX_LIBRARIES}) diff --git a/ngraph/test/util/onnx_test_util.cpp b/ngraph/test/util/onnx_test_util.cpp new file mode 100644 index 00000000000000..78cfd93c5cabb0 --- /dev/null +++ b/ngraph/test/util/onnx_test_util.cpp @@ -0,0 +1,311 @@ +//***************************************************************************** +// Copyright 2017-2021 Intel Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//***************************************************************************** + +#include +#include +#include +#include +#include + +#include "util/onnx_test_util.hpp" + +namespace +{ + ONNX_NAMESPACE::ModelProto parse_from_file(const std::string& file_path) + { + std::ifstream file_stream{file_path, std::ios::in | std::ios::binary}; + + if (!file_stream.is_open()) + { + throw std::runtime_error("Could not open the file: " + file_path); + }; + + if (!file_stream.good()) + { + file_stream.clear(); + file_stream.seekg(0); + if (!file_stream.good()) + { + throw std::runtime_error("Invalid state of model's input stream."); + } + } + + ONNX_NAMESPACE::ModelProto model_proto; + if (!model_proto.ParseFromIstream(&file_stream)) + { +#ifdef NGRAPH_USE_PROTOBUF_LITE + throw ngraph_error("Could not import the model"); +#else + // Rewind to the beginning and clear stream state. + file_stream.clear(); + file_stream.seekg(0); + google::protobuf::io::IstreamInputStream iistream(&file_stream); + // Try parsing input as a prototxt message + if (!google::protobuf::TextFormat::Parse(&iistream, &model_proto)) + { + throw std::runtime_error("Could not import the prototxt model"); + } +#endif + } + + return model_proto; + } + + const std::pair COMPARISON_OK{true, {}}; + + std::pair compare_nodes(const ONNX_NAMESPACE::GraphProto& graph, + const ONNX_NAMESPACE::GraphProto& ref_graph) + { + if (graph.node_size() != ref_graph.node_size()) + { + return {false, "The number of nodes in compared models doesn't match"}; + } + else + { + for (int i = 0; i < graph.node_size(); ++i) + { + const auto& lhs = graph.node(i); + const auto& rhs = ref_graph.node(i); + + if (lhs.op_type() != rhs.op_type()) + { + return {false, + "Operation types are different at index " + std::to_string(i) + ": " + + lhs.op_type() + " vs " + rhs.op_type()}; + } + + for (int j = 0; j < lhs.input_size(); ++j) + { + if (lhs.input(j) != rhs.input(j)) + { + return {false, + "Input names don't match for nodes at index " + std::to_string(i) + + ": " + lhs.input(j) + " vs " + rhs.input(j)}; + } + } + + for (int j = 0; j < lhs.output_size(); ++j) + { + if (lhs.output(j) != rhs.output(j)) + { + return {false, + "Output names don't match for nodes at index " + std::to_string(i) + + ": " + lhs.output(j) + " vs " + rhs.output(j)}; + } + } + } + } + + return COMPARISON_OK; + } + + std::pair compare_value_info(const ONNX_NAMESPACE::ValueInfoProto& lhs, + const ONNX_NAMESPACE::ValueInfoProto& rhs, + const std::string& item_type) + { + if (lhs.name() != rhs.name()) + { + return {false, + item_type + " names in the graph don't match: " + lhs.name() + " vs " + + rhs.name()}; + } + + const auto& lhs_tensor = lhs.type().tensor_type(); + const auto& rhs_tensor = rhs.type().tensor_type(); + if (lhs_tensor.elem_type() != rhs_tensor.elem_type()) + { + return {false, + "Element types don't match for " + item_type + " " + lhs.name() + ": " + + std::to_string(lhs_tensor.elem_type()) + " vs " + + std::to_string(rhs_tensor.elem_type())}; + } + + const auto& lhs_shape = lhs_tensor.shape(); + const auto& rhs_shape = rhs_tensor.shape(); + if (lhs_shape.dim_size() != rhs_shape.dim_size()) + { + return {false, + "Tensor ranks don't match for " + item_type + " " + lhs.name() + ": " + + std::to_string(lhs_shape.dim_size()) + " vs " + + std::to_string(rhs_shape.dim_size())}; + } + else + { + for (int j = 0; j < lhs_shape.dim_size(); ++j) + { + const auto& lhs_dim = lhs_shape.dim(j); + const auto& rhs_dim = rhs_shape.dim(j); + if (lhs_dim.has_dim_value() && rhs_dim.has_dim_param() || + rhs_dim.has_dim_value() && lhs_dim.has_dim_param()) + { + return {false, + "Dynamic vs static dimension mismatch for " + item_type + " " + + lhs.name() + " at index: " + std::to_string(j)}; + } + else if (lhs_dim.has_dim_value() && lhs_dim.dim_value() != rhs_dim.dim_value()) + { + return {false, + "Shape dimensions don't match for " + item_type + " " + lhs.name() + + " at index: " + std::to_string(j) + ". " + + std::to_string(lhs_dim.dim_value()) + " vs " + + std::to_string(rhs_dim.dim_value())}; + } + } + } + + return COMPARISON_OK; + } + + std::pair compare_inputs(const ONNX_NAMESPACE::GraphProto& graph, + const ONNX_NAMESPACE::GraphProto& ref_graph) + { + if (graph.input_size() != ref_graph.input_size()) + { + return {false, "The number of inputs in compared models doesn't match"}; + } + else + { + for (int i = 0; i < graph.input_size(); ++i) + { + const auto& lhs = graph.input(i); + const auto& rhs = ref_graph.input(i); + + const auto res = compare_value_info(lhs, rhs, "input"); + if (!res.first) + { + return res; + } + } + + return COMPARISON_OK; + } + } + + std::pair compare_outputs(const ONNX_NAMESPACE::GraphProto& graph, + const ONNX_NAMESPACE::GraphProto& ref_graph) + { + if (graph.output_size() != ref_graph.output_size()) + { + return {false, "The number of outputs in compared models doesn't match"}; + } + else + { + for (int i = 0; i < graph.output_size(); ++i) + { + const auto& lhs = graph.output(i); + const auto& rhs = ref_graph.output(i); + + const auto res = compare_value_info(lhs, rhs, "output"); + if (!res.first) + { + return res; + } + } + + return COMPARISON_OK; + } + } + + std::pair compare_initializers(const ONNX_NAMESPACE::GraphProto& graph, + const ONNX_NAMESPACE::GraphProto& ref_graph) + { + if (graph.initializer_size() != ref_graph.initializer_size()) + { + return {false, "The number of initializers in compared models doesn't match"}; + } + else + { + for (int i = 0; i < graph.initializer_size(); ++i) + { + const auto& lhs = graph.initializer(i); + const auto& rhs = ref_graph.initializer(i); + + if (lhs.name() != rhs.name()) + { + return {false, + "Initializer names in the graph don't match: " + lhs.name() + " vs " + + rhs.name()}; + } + else if (lhs.data_type() != rhs.data_type()) + { + return {false, + "Initializer data types in the graph don't match: " + + std::to_string(lhs.data_type()) + " vs " + + std::to_string(rhs.data_type())}; + } + else if (lhs.dims_size() != rhs.dims_size()) + { + return {false, + "Initializer ranks in the graph don't match: " + + std::to_string(lhs.dims_size()) + " vs " + + std::to_string(rhs.dims_size())}; + } + else + { + for (int j = 0; j < lhs.dims_size(); ++j) + { + if (lhs.dims(j) != rhs.dims(j)) + { + return {false, + "Shape dimensions don't match for initializer " + lhs.name() + + " at index: " + std::to_string(j) + ". " + + std::to_string(lhs.dims(j)) + " vs " + + std::to_string(rhs.dims(j))}; + } + } + } + } + + return COMPARISON_OK; + } + } +} // namespace +namespace ngraph +{ + namespace test + { + std::pair compare_onnx_graphs(const ONNX_NAMESPACE::GraphProto& graph, + const std::string& reference_model_path) + { + std::pair res = COMPARISON_OK; + + const auto ref_model = parse_from_file(reference_model_path); + const auto& ref_graph = ref_model.graph(); + + res = compare_inputs(graph, ref_graph); + if (!res.first) + { + return res; + } + + res = compare_outputs(graph, ref_graph); + if (!res.first) + { + return res; + } + + res = compare_initializers(graph, ref_graph); + if (!res.first) + { + return res; + } + + res = compare_nodes(graph, ref_graph); + + return res; + } + } // namespace test +} // namespace ngraph diff --git a/ngraph/test/util/onnx_test_util.hpp b/ngraph/test/util/onnx_test_util.hpp new file mode 100644 index 00000000000000..4ee8b0a01930e4 --- /dev/null +++ b/ngraph/test/util/onnx_test_util.hpp @@ -0,0 +1,33 @@ +//***************************************************************************** +// Copyright 2017-2021 Intel Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//***************************************************************************** + +#pragma once + +#include + +namespace ONNX_NAMESPACE +{ + class GraphProto; +} + +namespace ngraph +{ + namespace test + { + std::pair compare_onnx_graphs(const ONNX_NAMESPACE::GraphProto& graph, + const std::string& reference_model_path); + } +} // namespace ngraph From 0c8a4f78f3edc790c5e381e35eede2475b8278de Mon Sep 17 00:00:00 2001 From: tomdol Date: Mon, 1 Feb 2021 08:43:27 -0500 Subject: [PATCH 022/116] Windows compilation error fix + docs update --- .../src/editor/detail/subgraph_extraction.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/ngraph/frontend/onnx_import/src/editor/detail/subgraph_extraction.cpp b/ngraph/frontend/onnx_import/src/editor/detail/subgraph_extraction.cpp index e049caa7555420..4b4f946c01249e 100644 --- a/ngraph/frontend/onnx_import/src/editor/detail/subgraph_extraction.cpp +++ b/ngraph/frontend/onnx_import/src/editor/detail/subgraph_extraction.cpp @@ -92,7 +92,9 @@ namespace } } - return -1; + throw ngraph::ngraph_error{"Source node not found in the graph for node: " + + std::to_string(current_node_idx) + " and input name: " + + input_name}; } /// \brief Looks up a descriptor for a given tensor name. This descriptor contains inferred @@ -210,13 +212,14 @@ namespace } /// \brief Removes all items from a container except the ones whose names are in items_to_keep - /// It's intended to work with ONNX graph inputs and initializers only. + /// It's intended to work with ONNX graph inputs, outputs and initializers only. template void discard_by_name(Container& all_items, const std::set& items_to_keep) { static_assert( std::is_same::value || - std::is_same::value); + std::is_same::value, + "Unsupported value type of the container"); // The tested item can be discarded if its name is not found in the items_to_keep set const auto can_be_discarded = [&items_to_keep](const typename Container::value_type& item) { @@ -242,15 +245,17 @@ namespace void discard_nodes(Container& all_nodes, const std::set& nodes_to_keep) { static_assert( - std::is_same::value); + std::is_same::value, + "Unsupported value type of the container"); int idx = 0; const auto keep_node = [&nodes_to_keep, &idx](const typename Container::value_type&) { return nodes_to_keep.count(idx++) > 0; }; - // Stable partition rearranges the nodes keeping the relative order. This way the relative - // ordering is preserved and all of the nodes to discard are moved after the returned iter. + // Stable partition rearranges the nodes keeping the relative order in both partitions. + // This way the topological sort is preserved and all of the nodes to discard are moved + // after the returned iterator. const auto new_end = std::stable_partition(all_nodes.begin(), all_nodes.end(), keep_node); all_nodes.erase(new_end, all_nodes.end()); } From 4a512fc489fa82cfb462f76c6f10d9f2cc2a9993 Mon Sep 17 00:00:00 2001 From: tomdol Date: Mon, 1 Feb 2021 11:53:54 -0500 Subject: [PATCH 023/116] Code cleanup after the first round of reviews --- .../src/editor/detail/subgraph_extraction.cpp | 66 +++----- ngraph/test/onnx/onnx_editor.cpp | 52 +++--- ngraph/test/util/onnx_test_util.cpp | 158 +++++++++--------- ngraph/test/util/onnx_test_util.hpp | 28 +++- 4 files changed, 151 insertions(+), 153 deletions(-) diff --git a/ngraph/frontend/onnx_import/src/editor/detail/subgraph_extraction.cpp b/ngraph/frontend/onnx_import/src/editor/detail/subgraph_extraction.cpp index 4b4f946c01249e..240829f290379d 100644 --- a/ngraph/frontend/onnx_import/src/editor/detail/subgraph_extraction.cpp +++ b/ngraph/frontend/onnx_import/src/editor/detail/subgraph_extraction.cpp @@ -36,24 +36,12 @@ namespace ")"); } - struct CheckIfHasName - { - }; - template std::function name_equals(const std::string& name) { return [&name](const T& onnx_object) -> bool { return onnx_object.name() == name; }; } - template - std::function name_equals(const std::string& name, CheckIfHasName) - { - return [&name](const T& onnx_object) -> bool { - return onnx_object.has_name() && onnx_object.name() == name; - }; - } - std::function is_equal_to(const std::string& other) { return [&other](const std::string& s) { return s == other; }; @@ -62,8 +50,10 @@ namespace template bool already_exists(const Container& items, const std::string& name) { + using std::begin; + using std::end; return std::any_of( - items.begin(), items.end(), name_equals(name)); + begin(items), end(items), name_equals(name)); } bool is_graph_input(const ONNX_NAMESPACE::GraphProto& graph, const std::string& name) @@ -84,7 +74,7 @@ namespace { const auto& outputs = graph.node(i).output(); const auto output_found = - std::any_of(outputs.begin(), outputs.end(), is_equal_to(input_name)); + std::any_of(std::begin(outputs), std::end(outputs), is_equal_to(input_name)); if (output_found) { @@ -92,9 +82,9 @@ namespace } } - throw ngraph::ngraph_error{"Source node not found in the graph for node: " + - std::to_string(current_node_idx) + " and input name: " + - input_name}; + throw ngraph::ngraph_error{ + "Source node not found in the graph for node: " + std::to_string(current_node_idx) + + " and input name: " + input_name}; } /// \brief Looks up a descriptor for a given tensor name. This descriptor contains inferred @@ -103,12 +93,11 @@ namespace find_tensor_descriptor(const ONNX_NAMESPACE::GraphProto& graph, const std::string& tensor_name) { - const auto it = std::find_if( - graph.value_info().begin(), - graph.value_info().end(), - name_equals(tensor_name, CheckIfHasName{})); + const auto it = std::find_if(std::begin(graph.value_info()), + std::end(graph.value_info()), + name_equals(tensor_name)); - NGRAPH_CHECK(it != graph.value_info().end(), + NGRAPH_CHECK(it != std::end(graph.value_info()), "Could not find a tensor descriptor for tensor '", tensor_name, "'. It's not possible to add a new input to the graph without the type and " @@ -121,11 +110,11 @@ namespace const InputEdge& edge, const std::string& new_input_name) { - const auto it = std::find_if(graph.initializer().begin(), - graph.initializer().end(), + const auto it = std::find_if(std::begin(graph.initializer()), + std::end(graph.initializer()), name_equals(edge.m_tensor_name)); - NGRAPH_CHECK(it != graph.initializer().end(), + NGRAPH_CHECK(it != std::end(graph.initializer()), "Could not find an initializer in the graph: '", edge.m_tensor_name); @@ -157,9 +146,10 @@ namespace auto& target_node = *(graph.mutable_node(edge.m_node_idx)); auto& node_inputs = *(target_node.mutable_input()); - auto target_input = std::find(node_inputs.begin(), node_inputs.end(), edge.m_tensor_name); + auto target_input = + std::find(std::begin(node_inputs), std::end(node_inputs), edge.m_tensor_name); - NGRAPH_CHECK(target_input != node_inputs.end(), + NGRAPH_CHECK(target_input != std::end(node_inputs), "Input '", edge.m_tensor_name, "' not found in the inputs of node ", @@ -196,9 +186,9 @@ namespace auto& target_node = *(graph.mutable_node(edge.m_node_idx)); const auto& node_outputs = target_node.output(); const auto target_output = - std::find(node_outputs.begin(), node_outputs.end(), edge.m_tensor_name); + std::find(std::begin(node_outputs), std::end(node_outputs), edge.m_tensor_name); - NGRAPH_CHECK(target_output != node_outputs.end(), + NGRAPH_CHECK(target_output != std::end(node_outputs), "Output '", edge.m_tensor_name, "' not found in the outputs of node ", @@ -226,18 +216,11 @@ namespace return items_to_keep.count(item.name()) == 0; }; - auto items_to_remove = all_items.size() - items_to_keep.size(); - // move the elements-to-discard to the end of the container - auto new_end = all_items.end(); - while (items_to_remove > 0) - { - new_end = std::remove_if(all_items.begin(), new_end, can_be_discarded); - - --items_to_remove; - } + const auto new_end = + std::remove_if(std::begin(all_items), std::end(all_items), can_be_discarded); // erase all of the discarded elements past the new end of the container - all_items.erase(new_end, all_items.end()); + all_items.erase(new_end, std::end(all_items)); } /// \brief Removes all nodes from a container keeping the ones whose index is in nodes_to_keep @@ -256,8 +239,9 @@ namespace // Stable partition rearranges the nodes keeping the relative order in both partitions. // This way the topological sort is preserved and all of the nodes to discard are moved // after the returned iterator. - const auto new_end = std::stable_partition(all_nodes.begin(), all_nodes.end(), keep_node); - all_nodes.erase(new_end, all_nodes.end()); + const auto new_end = + std::stable_partition(std::begin(all_nodes), std::end(all_nodes), keep_node); + all_nodes.erase(new_end, std::end(all_nodes)); } } // namespace diff --git a/ngraph/test/onnx/onnx_editor.cpp b/ngraph/test/onnx/onnx_editor.cpp index f574b6972f04f8..62f0fc89458a30 100644 --- a/ngraph/test/onnx/onnx_editor.cpp +++ b/ngraph/test/onnx/onnx_editor.cpp @@ -301,9 +301,9 @@ NGRAPH_TEST(onnx_editor, subgraph__linear_model_head_cut) const auto ref_model = file_util::path_join( SERIALIZED_ZOO, "onnx/model_editor/reference/subgraph__linear_model_head_cut.prototxt"); - const auto res = test::compare_onnx_graphs(editor.model().graph(), ref_model); + const auto result = test::compare_onnx_graphs(editor.model().graph(), ref_model); - EXPECT_TRUE(res.first) << res.second; + EXPECT_TRUE(result.is_ok) << result.error_message; } NGRAPH_TEST(onnx_editor, subgraph__linear_model_head_cut_ins_and_outs) @@ -318,9 +318,9 @@ NGRAPH_TEST(onnx_editor, subgraph__linear_model_head_cut_ins_and_outs) const auto ref_model = file_util::path_join( SERIALIZED_ZOO, "onnx/model_editor/reference/subgraph__linear_model_head_cut.prototxt"); - const auto res = test::compare_onnx_graphs(editor.model().graph(), ref_model); + const auto result = test::compare_onnx_graphs(editor.model().graph(), ref_model); - EXPECT_TRUE(res.first) << res.second; + EXPECT_TRUE(result.is_ok) << result.error_message; } NGRAPH_TEST(onnx_editor, subgraph__linear_model_deeper_head_cut) @@ -334,9 +334,9 @@ NGRAPH_TEST(onnx_editor, subgraph__linear_model_deeper_head_cut) SERIALIZED_ZOO, "onnx/model_editor/reference/subgraph__linear_model_deeper_head_cut.prototxt"); - const auto res = test::compare_onnx_graphs(editor.model().graph(), ref_model); + const auto result = test::compare_onnx_graphs(editor.model().graph(), ref_model); - EXPECT_TRUE(res.first) << res.second; + EXPECT_TRUE(result.is_ok) << result.error_message; } NGRAPH_TEST(onnx_editor, subgraph__linear_model_tail_cut) @@ -349,9 +349,9 @@ NGRAPH_TEST(onnx_editor, subgraph__linear_model_tail_cut) const auto ref_model = file_util::path_join( SERIALIZED_ZOO, "onnx/model_editor/reference/subgraph__linear_model_tail_cut.prototxt"); - const auto res = test::compare_onnx_graphs(editor.model().graph(), ref_model); + const auto result = test::compare_onnx_graphs(editor.model().graph(), ref_model); - EXPECT_TRUE(res.first) << res.second; + EXPECT_TRUE(result.is_ok) << result.error_message; } NGRAPH_TEST(onnx_editor, subgraph__linear_model_tail_cut_ins_and_outs) @@ -365,9 +365,9 @@ NGRAPH_TEST(onnx_editor, subgraph__linear_model_tail_cut_ins_and_outs) const auto ref_model = file_util::path_join( SERIALIZED_ZOO, "onnx/model_editor/reference/subgraph__linear_model_tail_cut.prototxt"); - const auto res = test::compare_onnx_graphs(editor.model().graph(), ref_model); + const auto result = test::compare_onnx_graphs(editor.model().graph(), ref_model); - EXPECT_TRUE(res.first) << res.second; + EXPECT_TRUE(result.is_ok) << result.error_message; } NGRAPH_TEST(onnx_editor, subgraph__linear_model_with_initializer_tail_cut) @@ -381,9 +381,9 @@ NGRAPH_TEST(onnx_editor, subgraph__linear_model_with_initializer_tail_cut) SERIALIZED_ZOO, "onnx/model_editor/reference/subgraph__linear_model_with_initializer_tail_cut.prototxt"); - const auto res = test::compare_onnx_graphs(editor.model().graph(), ref_model); + const auto result = test::compare_onnx_graphs(editor.model().graph(), ref_model); - EXPECT_TRUE(res.first) << res.second; + EXPECT_TRUE(result.is_ok) << result.error_message; } NGRAPH_TEST(onnx_editor, subgraph__initializer_without_matching_input_tail_cut) @@ -398,9 +398,9 @@ NGRAPH_TEST(onnx_editor, subgraph__initializer_without_matching_input_tail_cut) "onnx/model_editor/reference/" "subgraph__initializer_without_matching_input_tail_cut.prototxt"); - const auto res = test::compare_onnx_graphs(editor.model().graph(), ref_model); + const auto result = test::compare_onnx_graphs(editor.model().graph(), ref_model); - EXPECT_TRUE(res.first) << res.second; + EXPECT_TRUE(result.is_ok) << result.error_message; } NGRAPH_TEST(onnx_editor, subgraph__linear_model_deeper_tail_cut) @@ -414,9 +414,9 @@ NGRAPH_TEST(onnx_editor, subgraph__linear_model_deeper_tail_cut) SERIALIZED_ZOO, "onnx/model_editor/reference/subgraph__linear_model_deeper_tail_cut.prototxt"); - const auto res = test::compare_onnx_graphs(editor.model().graph(), ref_model); + const auto result = test::compare_onnx_graphs(editor.model().graph(), ref_model); - EXPECT_TRUE(res.first) << res.second; + EXPECT_TRUE(result.is_ok) << result.error_message; } NGRAPH_TEST(onnx_editor, subgraph__no_input_params) @@ -428,9 +428,9 @@ NGRAPH_TEST(onnx_editor, subgraph__no_input_params) editor.cut_graph_fragment({}, {}); - const auto res = test::compare_onnx_graphs(editor.model().graph(), model_path); + const auto result = test::compare_onnx_graphs(editor.model().graph(), model_path); - EXPECT_TRUE(res.first) << res.second; + EXPECT_TRUE(result.is_ok) << result.error_message; } NGRAPH_TEST(onnx_editor, subgraph__initializer_to_input_replacement) @@ -445,9 +445,9 @@ NGRAPH_TEST(onnx_editor, subgraph__initializer_to_input_replacement) SERIALIZED_ZOO, "onnx/model_editor/reference/subgraph__initializer_to_input_replacement.prototxt"); - const auto res = test::compare_onnx_graphs(editor.model().graph(), ref_model); + const auto result = test::compare_onnx_graphs(editor.model().graph(), ref_model); - EXPECT_TRUE(res.first) << res.second; + EXPECT_TRUE(result.is_ok) << result.error_message; } NGRAPH_TEST(onnx_editor, subgraph__initializer_to_input_replacement_2) @@ -462,9 +462,9 @@ NGRAPH_TEST(onnx_editor, subgraph__initializer_to_input_replacement_2) SERIALIZED_ZOO, "onnx/model_editor/reference/subgraph__initializer_to_input_replacement.prototxt"); - const auto res = test::compare_onnx_graphs(editor.model().graph(), ref_model); + const auto result = test::compare_onnx_graphs(editor.model().graph(), ref_model); - EXPECT_TRUE(res.first) << res.second; + EXPECT_TRUE(result.is_ok) << result.error_message; } NGRAPH_TEST(onnx_editor, subgraph__multiout_op_output_edge) @@ -477,9 +477,9 @@ NGRAPH_TEST(onnx_editor, subgraph__multiout_op_output_edge) const auto ref_model = file_util::path_join( SERIALIZED_ZOO, "onnx/model_editor/reference/subgraph__multiout_op_output_edge.prototxt"); - const auto res = test::compare_onnx_graphs(editor.model().graph(), ref_model); + const auto result = test::compare_onnx_graphs(editor.model().graph(), ref_model); - EXPECT_TRUE(res.first) << res.second; + EXPECT_TRUE(result.is_ok) << result.error_message; } NGRAPH_TEST(onnx_editor, subgraph__existing_inputs_and_outputs_based_extraction) @@ -495,9 +495,9 @@ NGRAPH_TEST(onnx_editor, subgraph__existing_inputs_and_outputs_based_extraction) "onnx/model_editor/reference/" "subgraph__existing_inputs_and_outputs_based_extraction.prototxt"); - const auto res = test::compare_onnx_graphs(editor.model().graph(), ref_model); + const auto result = test::compare_onnx_graphs(editor.model().graph(), ref_model); - EXPECT_TRUE(res.first) << res.second; + EXPECT_TRUE(result.is_ok) << result.error_message; } NGRAPH_TEST(onnx_editor, subgraph__invalid_edge_idx) diff --git a/ngraph/test/util/onnx_test_util.cpp b/ngraph/test/util/onnx_test_util.cpp index 78cfd93c5cabb0..463e43aa8cae6c 100644 --- a/ngraph/test/util/onnx_test_util.cpp +++ b/ngraph/test/util/onnx_test_util.cpp @@ -22,6 +22,7 @@ #include "util/onnx_test_util.hpp" +using namespace ngraph::test; namespace { ONNX_NAMESPACE::ModelProto parse_from_file(const std::string& file_path) @@ -64,14 +65,12 @@ namespace return model_proto; } - const std::pair COMPARISON_OK{true, {}}; - - std::pair compare_nodes(const ONNX_NAMESPACE::GraphProto& graph, - const ONNX_NAMESPACE::GraphProto& ref_graph) + ComparisonResult compare_nodes(const ONNX_NAMESPACE::GraphProto& graph, + const ONNX_NAMESPACE::GraphProto& ref_graph) { if (graph.node_size() != ref_graph.node_size()) { - return {false, "The number of nodes in compared models doesn't match"}; + return ComparisonResult::fail("The number of nodes in compared models doesn't match"); } else { @@ -82,18 +81,18 @@ namespace if (lhs.op_type() != rhs.op_type()) { - return {false, - "Operation types are different at index " + std::to_string(i) + ": " + - lhs.op_type() + " vs " + rhs.op_type()}; + return ComparisonResult::fail("Operation types are different at index " + + std::to_string(i) + ": " + lhs.op_type() + + " vs " + rhs.op_type()); } for (int j = 0; j < lhs.input_size(); ++j) { if (lhs.input(j) != rhs.input(j)) { - return {false, - "Input names don't match for nodes at index " + std::to_string(i) + - ": " + lhs.input(j) + " vs " + rhs.input(j)}; + return ComparisonResult::fail( + "Input names don't match for nodes at index " + std::to_string(i) + + ": " + lhs.input(j) + " vs " + rhs.input(j)); } } @@ -101,46 +100,44 @@ namespace { if (lhs.output(j) != rhs.output(j)) { - return {false, - "Output names don't match for nodes at index " + std::to_string(i) + - ": " + lhs.output(j) + " vs " + rhs.output(j)}; + return ComparisonResult::fail( + "Output names don't match for nodes at index " + std::to_string(i) + + ": " + lhs.output(j) + " vs " + rhs.output(j)); } } } } - return COMPARISON_OK; + return ComparisonResult::pass(); } - std::pair compare_value_info(const ONNX_NAMESPACE::ValueInfoProto& lhs, - const ONNX_NAMESPACE::ValueInfoProto& rhs, - const std::string& item_type) + ComparisonResult compare_value_info(const ONNX_NAMESPACE::ValueInfoProto& lhs, + const ONNX_NAMESPACE::ValueInfoProto& rhs, + const std::string& item_type) { if (lhs.name() != rhs.name()) { - return {false, - item_type + " names in the graph don't match: " + lhs.name() + " vs " + - rhs.name()}; + return ComparisonResult::fail( + item_type + " names in the graph don't match: " + lhs.name() + " vs " + rhs.name()); } const auto& lhs_tensor = lhs.type().tensor_type(); const auto& rhs_tensor = rhs.type().tensor_type(); if (lhs_tensor.elem_type() != rhs_tensor.elem_type()) { - return {false, - "Element types don't match for " + item_type + " " + lhs.name() + ": " + - std::to_string(lhs_tensor.elem_type()) + " vs " + - std::to_string(rhs_tensor.elem_type())}; + return ComparisonResult::fail("Element types don't match for " + item_type + " " + + lhs.name() + ": " + + std::to_string(lhs_tensor.elem_type()) + " vs " + + std::to_string(rhs_tensor.elem_type())); } const auto& lhs_shape = lhs_tensor.shape(); const auto& rhs_shape = rhs_tensor.shape(); if (lhs_shape.dim_size() != rhs_shape.dim_size()) { - return {false, - "Tensor ranks don't match for " + item_type + " " + lhs.name() + ": " + - std::to_string(lhs_shape.dim_size()) + " vs " + - std::to_string(rhs_shape.dim_size())}; + return ComparisonResult::fail("Tensor ranks don't match for " + item_type + " " + + lhs.name() + ": " + std::to_string(lhs_shape.dim_size()) + + " vs " + std::to_string(rhs_shape.dim_size())); } else { @@ -151,30 +148,30 @@ namespace if (lhs_dim.has_dim_value() && rhs_dim.has_dim_param() || rhs_dim.has_dim_value() && lhs_dim.has_dim_param()) { - return {false, - "Dynamic vs static dimension mismatch for " + item_type + " " + - lhs.name() + " at index: " + std::to_string(j)}; + return ComparisonResult::fail("Dynamic vs static dimension mismatch for " + + item_type + " " + lhs.name() + + " at index: " + std::to_string(j)); } else if (lhs_dim.has_dim_value() && lhs_dim.dim_value() != rhs_dim.dim_value()) { - return {false, - "Shape dimensions don't match for " + item_type + " " + lhs.name() + - " at index: " + std::to_string(j) + ". " + - std::to_string(lhs_dim.dim_value()) + " vs " + - std::to_string(rhs_dim.dim_value())}; + return ComparisonResult::fail("Shape dimensions don't match for " + item_type + + " " + lhs.name() + + " at index: " + std::to_string(j) + ". " + + std::to_string(lhs_dim.dim_value()) + " vs " + + std::to_string(rhs_dim.dim_value())); } } } - return COMPARISON_OK; + return ComparisonResult::pass(); } - std::pair compare_inputs(const ONNX_NAMESPACE::GraphProto& graph, - const ONNX_NAMESPACE::GraphProto& ref_graph) + ComparisonResult compare_inputs(const ONNX_NAMESPACE::GraphProto& graph, + const ONNX_NAMESPACE::GraphProto& ref_graph) { if (graph.input_size() != ref_graph.input_size()) { - return {false, "The number of inputs in compared models doesn't match"}; + return ComparisonResult::fail("The number of inputs in compared models doesn't match"); } else { @@ -184,22 +181,22 @@ namespace const auto& rhs = ref_graph.input(i); const auto res = compare_value_info(lhs, rhs, "input"); - if (!res.first) + if (!res.is_ok) { return res; } } - return COMPARISON_OK; + return ComparisonResult::pass(); } } - std::pair compare_outputs(const ONNX_NAMESPACE::GraphProto& graph, - const ONNX_NAMESPACE::GraphProto& ref_graph) + ComparisonResult compare_outputs(const ONNX_NAMESPACE::GraphProto& graph, + const ONNX_NAMESPACE::GraphProto& ref_graph) { if (graph.output_size() != ref_graph.output_size()) { - return {false, "The number of outputs in compared models doesn't match"}; + return ComparisonResult::fail("The number of outputs in compared models doesn't match"); } else { @@ -209,22 +206,23 @@ namespace const auto& rhs = ref_graph.output(i); const auto res = compare_value_info(lhs, rhs, "output"); - if (!res.first) + if (!res.is_ok) { return res; } } - return COMPARISON_OK; + return ComparisonResult::pass(); } } - std::pair compare_initializers(const ONNX_NAMESPACE::GraphProto& graph, - const ONNX_NAMESPACE::GraphProto& ref_graph) + ComparisonResult compare_initializers(const ONNX_NAMESPACE::GraphProto& graph, + const ONNX_NAMESPACE::GraphProto& ref_graph) { if (graph.initializer_size() != ref_graph.initializer_size()) { - return {false, "The number of initializers in compared models doesn't match"}; + return ComparisonResult::fail( + "The number of initializers in compared models doesn't match"); } else { @@ -235,23 +233,20 @@ namespace if (lhs.name() != rhs.name()) { - return {false, - "Initializer names in the graph don't match: " + lhs.name() + " vs " + - rhs.name()}; + return ComparisonResult::fail("Initializer names in the graph don't match: " + + lhs.name() + " vs " + rhs.name()); } else if (lhs.data_type() != rhs.data_type()) { - return {false, - "Initializer data types in the graph don't match: " + - std::to_string(lhs.data_type()) + " vs " + - std::to_string(rhs.data_type())}; + return ComparisonResult::fail( + "Initializer data types in the graph don't match: " + + std::to_string(lhs.data_type()) + " vs " + std::to_string(rhs.data_type())); } else if (lhs.dims_size() != rhs.dims_size()) { - return {false, - "Initializer ranks in the graph don't match: " + - std::to_string(lhs.dims_size()) + " vs " + - std::to_string(rhs.dims_size())}; + return ComparisonResult::fail("Initializer ranks in the graph don't match: " + + std::to_string(lhs.dims_size()) + " vs " + + std::to_string(rhs.dims_size())); } else { @@ -259,17 +254,16 @@ namespace { if (lhs.dims(j) != rhs.dims(j)) { - return {false, - "Shape dimensions don't match for initializer " + lhs.name() + - " at index: " + std::to_string(j) + ". " + - std::to_string(lhs.dims(j)) + " vs " + - std::to_string(rhs.dims(j))}; + return ComparisonResult::fail( + "Shape dimensions don't match for initializer " + lhs.name() + + " at index: " + std::to_string(j) + ". " + + std::to_string(lhs.dims(j)) + " vs " + std::to_string(rhs.dims(j))); } } } } - return COMPARISON_OK; + return ComparisonResult::pass(); } } } // namespace @@ -277,35 +271,33 @@ namespace ngraph { namespace test { - std::pair compare_onnx_graphs(const ONNX_NAMESPACE::GraphProto& graph, - const std::string& reference_model_path) + ComparisonResult compare_onnx_graphs(const ONNX_NAMESPACE::GraphProto& graph, + const std::string& reference_model_path) { - std::pair res = COMPARISON_OK; + ComparisonResult comparison; const auto ref_model = parse_from_file(reference_model_path); const auto& ref_graph = ref_model.graph(); - res = compare_inputs(graph, ref_graph); - if (!res.first) + comparison = compare_inputs(graph, ref_graph); + if (!comparison.is_ok) { - return res; + return comparison; } - res = compare_outputs(graph, ref_graph); - if (!res.first) + comparison = compare_outputs(graph, ref_graph); + if (!comparison.is_ok) { - return res; + return comparison; } - res = compare_initializers(graph, ref_graph); - if (!res.first) + comparison = compare_initializers(graph, ref_graph); + if (!comparison.is_ok) { - return res; + return comparison; } - res = compare_nodes(graph, ref_graph); - - return res; + return compare_nodes(graph, ref_graph); } } // namespace test } // namespace ngraph diff --git a/ngraph/test/util/onnx_test_util.hpp b/ngraph/test/util/onnx_test_util.hpp index 4ee8b0a01930e4..182cd1f3d6835f 100644 --- a/ngraph/test/util/onnx_test_util.hpp +++ b/ngraph/test/util/onnx_test_util.hpp @@ -27,7 +27,29 @@ namespace ngraph { namespace test { - std::pair compare_onnx_graphs(const ONNX_NAMESPACE::GraphProto& graph, - const std::string& reference_model_path); - } + struct ComparisonResult + { + ComparisonResult() = default; + ComparisonResult(std::string error) + : error_message{std::move(error)} + { + } + ComparisonResult(ComparisonResult&&) = default; + ComparisonResult(const ComparisonResult&) = default; + ComparisonResult& operator=(ComparisonResult&&) = default; + ComparisonResult& operator=(const ComparisonResult&) = default; + + bool is_ok = true; + std::string error_message; + + static ComparisonResult pass() { return {}; } + static ComparisonResult fail(std::string error) + { + return ComparisonResult{std::move(error)}; + } + }; + + ComparisonResult compare_onnx_graphs(const ONNX_NAMESPACE::GraphProto& graph, + const std::string& reference_model_path); + } // namespace test } // namespace ngraph From 15bcb0281d54c4896b5ec3d2449845fa53487595 Mon Sep 17 00:00:00 2001 From: tomdol Date: Mon, 1 Feb 2021 13:57:23 -0500 Subject: [PATCH 024/116] CI compilation error fix --- .../editor/detail/subgraph_extraction.hpp | 1 + .../src/editor/detail/subgraph_extraction.cpp | 6 +++--- ngraph/test/util/CMakeLists.txt | 4 ++-- ngraph/test/util/onnx_test_util.cpp | 12 ++++++------ 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/ngraph/frontend/onnx_import/include/onnx_import/editor/detail/subgraph_extraction.hpp b/ngraph/frontend/onnx_import/include/onnx_import/editor/detail/subgraph_extraction.hpp index 9df92ae91b9aed..ce59cc52bb0f98 100644 --- a/ngraph/frontend/onnx_import/include/onnx_import/editor/detail/subgraph_extraction.hpp +++ b/ngraph/frontend/onnx_import/include/onnx_import/editor/detail/subgraph_extraction.hpp @@ -119,6 +119,7 @@ namespace ngraph inputs.insert(other.inputs.begin(), other.inputs.end()); initializers.insert(other.initializers.begin(), other.initializers.end()); outputs.insert(other.outputs.begin(), other.outputs.end()); + return *this; } }; diff --git a/ngraph/frontend/onnx_import/src/editor/detail/subgraph_extraction.cpp b/ngraph/frontend/onnx_import/src/editor/detail/subgraph_extraction.cpp index 240829f290379d..a934130f06c50f 100644 --- a/ngraph/frontend/onnx_import/src/editor/detail/subgraph_extraction.cpp +++ b/ngraph/frontend/onnx_import/src/editor/detail/subgraph_extraction.cpp @@ -82,9 +82,9 @@ namespace } } - throw ngraph::ngraph_error{ - "Source node not found in the graph for node: " + std::to_string(current_node_idx) + - " and input name: " + input_name}; + throw ngraph::ngraph_error{"Source node not found in the graph for node: " + + std::to_string(current_node_idx) + " and input name: " + + input_name}; } /// \brief Looks up a descriptor for a given tensor name. This descriptor contains inferred diff --git a/ngraph/test/util/CMakeLists.txt b/ngraph/test/util/CMakeLists.txt index f5e837ebf8089d..722d67821c39e6 100644 --- a/ngraph/test/util/CMakeLists.txt +++ b/ngraph/test/util/CMakeLists.txt @@ -45,5 +45,5 @@ endif() target_include_directories(ngraph_test_util PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/.. ${IE_MAIN_SOURCE_DIR}/include) target_link_libraries(ngraph_test_util PRIVATE ngraph ngraph_backend libgtest) -target_include_directories(ngraph_test_util SYSTEM PRIVATE ${ONNX_INCLUDE_DIR} ${ONNX_PROTO_INCLUDE_DIR}) -target_link_libraries(ngraph_test_util PRIVATE ${ONNX_LIBRARIES}) +target_include_directories(ngraph_test_util SYSTEM PRIVATE ${ONNX_INCLUDE_DIR} ${ONNX_PROTO_INCLUDE_DIR} ${Protobuf_INCLUDE_DIRS}) +target_link_libraries(ngraph_test_util PRIVATE ${ONNX_LIBRARIES} ${Protobuf_LIBRARIES}) diff --git a/ngraph/test/util/onnx_test_util.cpp b/ngraph/test/util/onnx_test_util.cpp index 463e43aa8cae6c..578e5ff4d750c9 100644 --- a/ngraph/test/util/onnx_test_util.cpp +++ b/ngraph/test/util/onnx_test_util.cpp @@ -117,8 +117,8 @@ namespace { if (lhs.name() != rhs.name()) { - return ComparisonResult::fail( - item_type + " names in the graph don't match: " + lhs.name() + " vs " + rhs.name()); + return ComparisonResult::fail(item_type + " names in the graph don't match: " + + lhs.name() + " vs " + rhs.name()); } const auto& lhs_tensor = lhs.type().tensor_type(); @@ -149,14 +149,14 @@ namespace rhs_dim.has_dim_value() && lhs_dim.has_dim_param()) { return ComparisonResult::fail("Dynamic vs static dimension mismatch for " + - item_type + " " + lhs.name() + - " at index: " + std::to_string(j)); + item_type + " " + lhs.name() + " at index: " + + std::to_string(j)); } else if (lhs_dim.has_dim_value() && lhs_dim.dim_value() != rhs_dim.dim_value()) { return ComparisonResult::fail("Shape dimensions don't match for " + item_type + - " " + lhs.name() + - " at index: " + std::to_string(j) + ". " + + " " + lhs.name() + " at index: " + + std::to_string(j) + ". " + std::to_string(lhs_dim.dim_value()) + " vs " + std::to_string(rhs_dim.dim_value())); } From fe7b3b1dfd4d2c0f9e99245d1cc5ab628b0faa61 Mon Sep 17 00:00:00 2001 From: tomdol Date: Mon, 1 Feb 2021 15:22:15 -0500 Subject: [PATCH 025/116] Even more CI compilation error fixes --- .../onnx_import/src/editor/detail/subgraph_extraction.cpp | 2 +- ngraph/test/util/onnx_test_util.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ngraph/frontend/onnx_import/src/editor/detail/subgraph_extraction.cpp b/ngraph/frontend/onnx_import/src/editor/detail/subgraph_extraction.cpp index a934130f06c50f..04e9ad25c12d86 100644 --- a/ngraph/frontend/onnx_import/src/editor/detail/subgraph_extraction.cpp +++ b/ngraph/frontend/onnx_import/src/editor/detail/subgraph_extraction.cpp @@ -248,7 +248,7 @@ namespace /* -----------------------------------------------------------------------------------------------*/ SubgraphExtractor::SubgraphExtractor(ONNX_NAMESPACE::GraphProto& graph) - : m_onnx_graph{graph} + : m_onnx_graph(graph) { for (int i = 0; i < graph.node_size(); ++i) { diff --git a/ngraph/test/util/onnx_test_util.cpp b/ngraph/test/util/onnx_test_util.cpp index 578e5ff4d750c9..272756efd436c1 100644 --- a/ngraph/test/util/onnx_test_util.cpp +++ b/ngraph/test/util/onnx_test_util.cpp @@ -145,8 +145,8 @@ namespace { const auto& lhs_dim = lhs_shape.dim(j); const auto& rhs_dim = rhs_shape.dim(j); - if (lhs_dim.has_dim_value() && rhs_dim.has_dim_param() || - rhs_dim.has_dim_value() && lhs_dim.has_dim_param()) + if ((lhs_dim.has_dim_value() && rhs_dim.has_dim_param()) || + (rhs_dim.has_dim_value() && lhs_dim.has_dim_param())) { return ComparisonResult::fail("Dynamic vs static dimension mismatch for " + item_type + " " + lhs.name() + " at index: " + From 7e70fdaed386d1a4495ce7d9d2150d04d30fc8ae Mon Sep 17 00:00:00 2001 From: tomdol Date: Tue, 2 Feb 2021 03:14:23 -0500 Subject: [PATCH 026/116] Proper usage of ADL in generic code --- .../src/editor/detail/subgraph_extraction.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/ngraph/frontend/onnx_import/src/editor/detail/subgraph_extraction.cpp b/ngraph/frontend/onnx_import/src/editor/detail/subgraph_extraction.cpp index 04e9ad25c12d86..4b353e5184e56d 100644 --- a/ngraph/frontend/onnx_import/src/editor/detail/subgraph_extraction.cpp +++ b/ngraph/frontend/onnx_import/src/editor/detail/subgraph_extraction.cpp @@ -216,11 +216,13 @@ namespace return items_to_keep.count(item.name()) == 0; }; + using std::begin; + using std::end; + // move the elements-to-discard to the end of the container - const auto new_end = - std::remove_if(std::begin(all_items), std::end(all_items), can_be_discarded); + const auto new_end = std::remove_if(begin(all_items), end(all_items), can_be_discarded); // erase all of the discarded elements past the new end of the container - all_items.erase(new_end, std::end(all_items)); + all_items.erase(new_end, end(all_items)); } /// \brief Removes all nodes from a container keeping the ones whose index is in nodes_to_keep @@ -236,12 +238,14 @@ namespace return nodes_to_keep.count(idx++) > 0; }; + using std::begin; + using std::end; + // Stable partition rearranges the nodes keeping the relative order in both partitions. // This way the topological sort is preserved and all of the nodes to discard are moved // after the returned iterator. - const auto new_end = - std::stable_partition(std::begin(all_nodes), std::end(all_nodes), keep_node); - all_nodes.erase(new_end, std::end(all_nodes)); + const auto new_end = std::stable_partition(begin(all_nodes), end(all_nodes), keep_node); + all_nodes.erase(new_end, end(all_nodes)); } } // namespace From 53667fa79c587568d0cbb7be89fff1ad98f4bfa5 Mon Sep 17 00:00:00 2001 From: tomdol Date: Tue, 2 Feb 2021 07:58:40 -0500 Subject: [PATCH 027/116] ONNX shape inference related code cleanup --- .../src/editor/detail/subgraph_extraction.cpp | 1 - .../frontend/onnx_import/src/editor/editor.cpp | 17 ++++------------- ngraph/frontend/onnx_import/src/onnx.cpp | 4 ---- 3 files changed, 4 insertions(+), 18 deletions(-) diff --git a/ngraph/frontend/onnx_import/src/editor/detail/subgraph_extraction.cpp b/ngraph/frontend/onnx_import/src/editor/detail/subgraph_extraction.cpp index 4b353e5184e56d..c111700a285656 100644 --- a/ngraph/frontend/onnx_import/src/editor/detail/subgraph_extraction.cpp +++ b/ngraph/frontend/onnx_import/src/editor/detail/subgraph_extraction.cpp @@ -380,7 +380,6 @@ void SubgraphExtractor::extract_subgraph_from_onnx_model(const SubgraphComponent discard_by_name(*(m_onnx_graph.mutable_initializer()), subgraph.initializers); discard_by_name(*(m_onnx_graph.mutable_output()), subgraph.outputs); discard_nodes(*(m_onnx_graph.mutable_node()), subgraph.nodes); - m_onnx_graph.clear_value_info(); } std::vector SubgraphExtractor::all_output_edges() const diff --git a/ngraph/frontend/onnx_import/src/editor/editor.cpp b/ngraph/frontend/onnx_import/src/editor/editor.cpp index bbe587c833299b..4e06c9b886e7ba 100644 --- a/ngraph/frontend/onnx_import/src/editor/editor.cpp +++ b/ngraph/frontend/onnx_import/src/editor/editor.cpp @@ -163,17 +163,8 @@ struct onnx_import::ONNXModelEditor::Impl { } - void infer_shapes() - { - if (!m_shapes_inferred) - { - ONNX_NAMESPACE::shape_inference::InferShapes(m_model_proto); - m_shapes_inferred = true; - } - } - -private: - bool m_shapes_inferred = false; + void infer_shapes() { ONNX_NAMESPACE::shape_inference::InferShapes(m_model_proto); } + void remove_shape_inference_info() { m_model_proto.mutable_graph()->clear_value_info(); } }; onnx_import::ONNXModelEditor::ONNXModelEditor(const std::string& model_path) @@ -263,11 +254,11 @@ void onnx_import::ONNXModelEditor::cut_graph_fragment(const std::vectorinfer_shapes(); SubgraphExtractor editor{*(m_pimpl->m_model_proto.mutable_graph())}; - editor.add_new_inputs(inputs); editor.add_new_outputs(outputs); - editor.extract_subgraph(outputs); + + m_pimpl->remove_shape_inference_info(); } std::vector onnx_import::ONNXModelEditor::model_inputs() const diff --git a/ngraph/frontend/onnx_import/src/onnx.cpp b/ngraph/frontend/onnx_import/src/onnx.cpp index 1af5bcf7a67fcc..be6c35a6301c0f 100644 --- a/ngraph/frontend/onnx_import/src/onnx.cpp +++ b/ngraph/frontend/onnx_import/src/onnx.cpp @@ -15,8 +15,6 @@ //***************************************************************************** #include -#include -#include #include #include "core/graph.hpp" @@ -82,8 +80,6 @@ namespace ngraph std::shared_ptr import_onnx_model(const ONNXModelEditor& model_editor) { - // this overload of the import_onnx_model is friended with the ONNXModelEditor - // and thus can access its private members return detail::import_onnx_model(model_editor.model(), model_editor.model_path()); } From ddcffa30d0f4845d10e9ca7ca408f791e58a48f4 Mon Sep 17 00:00:00 2001 From: tomdol Date: Tue, 2 Feb 2021 08:17:03 -0500 Subject: [PATCH 028/116] Disable the onnx test utils when pb-lite is used --- ngraph/test/util/CMakeLists.txt | 12 +++++++++--- ngraph/test/util/onnx_test_util.cpp | 26 ++++++++++---------------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/ngraph/test/util/CMakeLists.txt b/ngraph/test/util/CMakeLists.txt index 722d67821c39e6..d53b520fce10a7 100644 --- a/ngraph/test/util/CMakeLists.txt +++ b/ngraph/test/util/CMakeLists.txt @@ -23,13 +23,16 @@ set (SRC engine/ie_engines.cpp engine/interpreter_engine.cpp float_util.cpp - onnx_test_util.cpp test_tools.cpp test_control.cpp visitor.hpp provenance_enabler.hpp ) +if (NGRAPH_ONNX_IMPORT_ENABLE AND NOT NGRAPH_USE_PROTOBUF_LITE) + list(APPEND SRC onnx_test_util.cpp) +endif() + add_library(ngraph_test_util STATIC ${SRC}) if(COMMAND ie_faster_build) @@ -45,5 +48,8 @@ endif() target_include_directories(ngraph_test_util PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/.. ${IE_MAIN_SOURCE_DIR}/include) target_link_libraries(ngraph_test_util PRIVATE ngraph ngraph_backend libgtest) -target_include_directories(ngraph_test_util SYSTEM PRIVATE ${ONNX_INCLUDE_DIR} ${ONNX_PROTO_INCLUDE_DIR} ${Protobuf_INCLUDE_DIRS}) -target_link_libraries(ngraph_test_util PRIVATE ${ONNX_LIBRARIES} ${Protobuf_LIBRARIES}) +if (NGRAPH_ONNX_IMPORT_ENABLE AND NOT NGRAPH_USE_PROTOBUF_LITE) + target_include_directories(ngraph_test_util SYSTEM PRIVATE ${ONNX_INCLUDE_DIR} + ${ONNX_PROTO_INCLUDE_DIR} ${Protobuf_INCLUDE_DIRS}) + target_link_libraries(ngraph_test_util PRIVATE ${ONNX_LIBRARIES} ${Protobuf_LIBRARIES}) +endif() diff --git a/ngraph/test/util/onnx_test_util.cpp b/ngraph/test/util/onnx_test_util.cpp index 272756efd436c1..e6b079d419a1f1 100644 --- a/ngraph/test/util/onnx_test_util.cpp +++ b/ngraph/test/util/onnx_test_util.cpp @@ -45,21 +45,15 @@ namespace } ONNX_NAMESPACE::ModelProto model_proto; - if (!model_proto.ParseFromIstream(&file_stream)) + google::protobuf::io::IstreamInputStream iistream(&file_stream); + if (!google::protobuf::TextFormat::Parse(&iistream, &model_proto)) { -#ifdef NGRAPH_USE_PROTOBUF_LITE - throw ngraph_error("Could not import the model"); -#else - // Rewind to the beginning and clear stream state. file_stream.clear(); file_stream.seekg(0); - google::protobuf::io::IstreamInputStream iistream(&file_stream); - // Try parsing input as a prototxt message - if (!google::protobuf::TextFormat::Parse(&iistream, &model_proto)) + if (!model_proto.ParseFromIstream(&file_stream)) { - throw std::runtime_error("Could not import the prototxt model"); + throw std::runtime_error("Could not import the test model: " + file_path); } -#endif } return model_proto; @@ -117,8 +111,8 @@ namespace { if (lhs.name() != rhs.name()) { - return ComparisonResult::fail(item_type + " names in the graph don't match: " + - lhs.name() + " vs " + rhs.name()); + return ComparisonResult::fail( + item_type + " names in the graph don't match: " + lhs.name() + " vs " + rhs.name()); } const auto& lhs_tensor = lhs.type().tensor_type(); @@ -149,14 +143,14 @@ namespace (rhs_dim.has_dim_value() && lhs_dim.has_dim_param())) { return ComparisonResult::fail("Dynamic vs static dimension mismatch for " + - item_type + " " + lhs.name() + " at index: " + - std::to_string(j)); + item_type + " " + lhs.name() + + " at index: " + std::to_string(j)); } else if (lhs_dim.has_dim_value() && lhs_dim.dim_value() != rhs_dim.dim_value()) { return ComparisonResult::fail("Shape dimensions don't match for " + item_type + - " " + lhs.name() + " at index: " + - std::to_string(j) + ". " + + " " + lhs.name() + + " at index: " + std::to_string(j) + ". " + std::to_string(lhs_dim.dim_value()) + " vs " + std::to_string(rhs_dim.dim_value())); } From 0078926bfa64aa811352430c8074d20cfe3d7612 Mon Sep 17 00:00:00 2001 From: tomdol Date: Thu, 4 Feb 2021 05:10:08 -0500 Subject: [PATCH 029/116] PB dependency removal from UT, strong types for input and output edges, more verbose errors in tests --- .../editor/detail/subgraph_extraction.hpp | 38 ++++++++++++------- .../onnx_import/src/editor/editor.cpp | 2 +- ngraph/test/CMakeLists.txt | 2 +- ngraph/test/onnx/onnx_import.in.cpp | 1 - ngraph/test/util/onnx_test_util.cpp | 25 +++++++----- ngraph/test/util/onnx_test_util.hpp | 3 +- 6 files changed, 44 insertions(+), 27 deletions(-) diff --git a/ngraph/frontend/onnx_import/include/onnx_import/editor/detail/subgraph_extraction.hpp b/ngraph/frontend/onnx_import/include/onnx_import/editor/detail/subgraph_extraction.hpp index ce59cc52bb0f98..27b7a801d33847 100644 --- a/ngraph/frontend/onnx_import/include/onnx_import/editor/detail/subgraph_extraction.hpp +++ b/ngraph/frontend/onnx_import/include/onnx_import/editor/detail/subgraph_extraction.hpp @@ -31,10 +31,31 @@ namespace ONNX_NAMESPACE namespace ngraph { + enum class EdgeType + { + INPUT, + OUTPUT + }; + + template + struct Edge + { + Edge() = delete; + Edge(const int node_idx, std::string tensor_name) + : m_node_idx{node_idx} + , m_tensor_name{std::move(tensor_name)} + { + } + + const int m_node_idx; + const std::string m_tensor_name; + }; namespace onnx_import { /// \brief Defines an edge connected to an input of any node in the graph. /// It consists of a node index in the processed ONNX model and the input name. + /// The index should point to a node in the topological sort of the underlying graph + /// which means it has to be in range: 0 <= node_idx < graph.node_size() /// /// For a node number 5, with 3 inputs: /// @@ -46,18 +67,7 @@ namespace ngraph /// InputEdge(5, "in_A") /// InputEdge(5, "in_B") /// InputEdge(5, "in_C") - struct InputEdge - { - InputEdge() = delete; - InputEdge(const int node_idx, std::string tensor_name) - : m_node_idx{node_idx} - , m_tensor_name{std::move(tensor_name)} - { - } - - const int m_node_idx; - const std::string m_tensor_name; - }; + using InputEdge = Edge; /// \brief Defines an edge connected to an output of any node in the graph. /// It consists of a node index in the processed ONNX model and the output name. @@ -71,7 +81,7 @@ namespace ngraph /// there are 2 possible valid instances of this struct: /// OutputEdge(5, "out1") /// OutputEdge(5, "out2") - using OutputEdge = InputEdge; + using OutputEdge = Edge; /// \brief Subgraph extraction helper structure struct SubgraphExtractor @@ -94,7 +104,7 @@ namespace ngraph /// are discarded after this method call has finished. /// /// \param subgraph_outputs A list of expected outputs of the extracted subgraph. - void extract_subgraph(std::vector subgraph_outputs); + void extract_subgraph(std::vector subgraph_outputs); /// \brief Represents a subgraph of an ONNX model by holding a subset of nodes, inputs, /// outputs and initializers of the original graph. Objects of this struct can be diff --git a/ngraph/frontend/onnx_import/src/editor/editor.cpp b/ngraph/frontend/onnx_import/src/editor/editor.cpp index 4e06c9b886e7ba..b538edc9f2ce04 100644 --- a/ngraph/frontend/onnx_import/src/editor/editor.cpp +++ b/ngraph/frontend/onnx_import/src/editor/editor.cpp @@ -244,7 +244,7 @@ void onnx_import::ONNXModelEditor::set_input_shapes( } void onnx_import::ONNXModelEditor::cut_graph_fragment(const std::vector& inputs, - const std::vector& outputs) + const std::vector& outputs) { if (inputs.empty() && outputs.empty()) { diff --git a/ngraph/test/CMakeLists.txt b/ngraph/test/CMakeLists.txt index 8465d01bc90c5c..a548a9caee2af6 100644 --- a/ngraph/test/CMakeLists.txt +++ b/ngraph/test/CMakeLists.txt @@ -420,7 +420,7 @@ target_link_libraries(unit-test PRIVATE ngraph_test_util if (NGRAPH_ONNX_IMPORT_ENABLE AND NOT NGRAPH_USE_PROTOBUF_LITE) target_include_directories(unit-test SYSTEM PRIVATE ${ONNX_INCLUDE_DIR} ${ONNX_PROTO_INCLUDE_DIR} ${Protobuf_INCLUDE_DIRS}) - target_link_libraries(unit-test PRIVATE ${Protobuf_LIBRARIES} ${ONNX_LIBRARIES}) + target_link_libraries(unit-test PRIVATE ${ONNX_LIBRARIES}) get_target_property(ONNX_IMPORTER_SRC_DIR onnx_importer SOURCE_DIR) target_include_directories(unit-test PRIVATE ${ONNX_IMPORTER_SRC_DIR}/src) diff --git a/ngraph/test/onnx/onnx_import.in.cpp b/ngraph/test/onnx/onnx_import.in.cpp index ec0a046fdc1dc3..a9effa69a32d00 100644 --- a/ngraph/test/onnx/onnx_import.in.cpp +++ b/ngraph/test/onnx/onnx_import.in.cpp @@ -39,7 +39,6 @@ #include "onnx_import/onnx.hpp" #include "onnx_import/onnx_utils.hpp" #include "default_opset.hpp" -#include "exceptions.hpp" #include "ngraph/ngraph.hpp" #include "ngraph/pass/manager.hpp" #include "ngraph/pass/constant_folding.hpp" diff --git a/ngraph/test/util/onnx_test_util.cpp b/ngraph/test/util/onnx_test_util.cpp index e6b079d419a1f1..ddb24c9a2bc5e5 100644 --- a/ngraph/test/util/onnx_test_util.cpp +++ b/ngraph/test/util/onnx_test_util.cpp @@ -111,8 +111,8 @@ namespace { if (lhs.name() != rhs.name()) { - return ComparisonResult::fail( - item_type + " names in the graph don't match: " + lhs.name() + " vs " + rhs.name()); + return ComparisonResult::fail(item_type + " names in the graph don't match: " + + lhs.name() + " vs " + rhs.name()); } const auto& lhs_tensor = lhs.type().tensor_type(); @@ -143,14 +143,14 @@ namespace (rhs_dim.has_dim_value() && lhs_dim.has_dim_param())) { return ComparisonResult::fail("Dynamic vs static dimension mismatch for " + - item_type + " " + lhs.name() + - " at index: " + std::to_string(j)); + item_type + " " + lhs.name() + " at index: " + + std::to_string(j)); } else if (lhs_dim.has_dim_value() && lhs_dim.dim_value() != rhs_dim.dim_value()) { return ComparisonResult::fail("Shape dimensions don't match for " + item_type + - " " + lhs.name() + - " at index: " + std::to_string(j) + ". " + + " " + lhs.name() + " at index: " + + std::to_string(j) + ". " + std::to_string(lhs_dim.dim_value()) + " vs " + std::to_string(rhs_dim.dim_value())); } @@ -165,7 +165,10 @@ namespace { if (graph.input_size() != ref_graph.input_size()) { - return ComparisonResult::fail("The number of inputs in compared models doesn't match"); + return ComparisonResult::fail( + "The number of inputs in compared models doesn't match: " + + std::to_string(graph.input_size()) + " vs " + + std::to_string(ref_graph.input_size())); } else { @@ -190,7 +193,9 @@ namespace { if (graph.output_size() != ref_graph.output_size()) { - return ComparisonResult::fail("The number of outputs in compared models doesn't match"); + return ComparisonResult::fail("The number of outputs in compared models doesn't match" + + std::to_string(graph.output_size()) + " vs " + + std::to_string(ref_graph.output_size())); } else { @@ -216,7 +221,9 @@ namespace if (graph.initializer_size() != ref_graph.initializer_size()) { return ComparisonResult::fail( - "The number of initializers in compared models doesn't match"); + "The number of initializers in compared models doesn't match" + + std::to_string(graph.initializer_size()) + " vs " + + std::to_string(ref_graph.initializer_size())); } else { diff --git a/ngraph/test/util/onnx_test_util.hpp b/ngraph/test/util/onnx_test_util.hpp index 182cd1f3d6835f..66cbf0787b57a8 100644 --- a/ngraph/test/util/onnx_test_util.hpp +++ b/ngraph/test/util/onnx_test_util.hpp @@ -31,7 +31,8 @@ namespace ngraph { ComparisonResult() = default; ComparisonResult(std::string error) - : error_message{std::move(error)} + : is_ok{false} + , error_message{std::move(error)} { } ComparisonResult(ComparisonResult&&) = default; From b8fb3bd8779c4bce9612ce2480f6abd9df1c35b7 Mon Sep 17 00:00:00 2001 From: tomdol Date: Mon, 8 Feb 2021 03:27:41 -0500 Subject: [PATCH 030/116] Fix for the protobuf descriptor database corruption --- ngraph/frontend/onnx_import/CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ngraph/frontend/onnx_import/CMakeLists.txt b/ngraph/frontend/onnx_import/CMakeLists.txt index ed7726de263d9f..dfaebe27455df9 100644 --- a/ngraph/frontend/onnx_import/CMakeLists.txt +++ b/ngraph/frontend/onnx_import/CMakeLists.txt @@ -59,6 +59,11 @@ if(COMMAND ie_faster_build) ) endif() +set_target_properties(onnx_importer PROPERTIES + CXX_VISIBILITY_PRESET default + C_VISIBILITY_PRESET default + VISIBILITY_INLINES_HIDDEN OFF) + target_link_libraries(onnx_importer PRIVATE onnx onnx_proto ${Protobuf_LIBRARIES} ngraph::builder PUBLIC ngraph) From 45d11e1c7b921f897e4ab128bc36d1f4be2141ce Mon Sep 17 00:00:00 2001 From: tomdol Date: Mon, 8 Feb 2021 05:04:04 -0500 Subject: [PATCH 031/116] testing visibility changes --- cmake/developer_package/compile_flags/os_flags.cmake | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmake/developer_package/compile_flags/os_flags.cmake b/cmake/developer_package/compile_flags/os_flags.cmake index 87359245b541e9..b7ef233b428dbe 100644 --- a/cmake/developer_package/compile_flags/os_flags.cmake +++ b/cmake/developer_package/compile_flags/os_flags.cmake @@ -207,9 +207,9 @@ endif() # Honor visibility properties for all target types set(CMAKE_POLICY_DEFAULT_CMP0063 NEW) -set(CMAKE_CXX_VISIBILITY_PRESET hidden) -set(CMAKE_C_VISIBILITY_PRESET hidden) -set(CMAKE_VISIBILITY_INLINES_HIDDEN ON) +set(CMAKE_CXX_VISIBILITY_PRESET default) +set(CMAKE_C_VISIBILITY_PRESET default) +set(CMAKE_VISIBILITY_INLINES_HIDDEN OFF) if(WIN32) ie_add_compiler_flags(-D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS) From 2d3e29839ad6766dfa71e9c6ee7e7f8fd4ead2d0 Mon Sep 17 00:00:00 2001 From: tomdol Date: Mon, 8 Feb 2021 05:41:28 -0500 Subject: [PATCH 032/116] Revert the changes that didn't work --- cmake/developer_package/compile_flags/os_flags.cmake | 6 +++--- ngraph/frontend/onnx_import/CMakeLists.txt | 5 ----- ngraph/test/CMakeLists.txt | 2 +- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/cmake/developer_package/compile_flags/os_flags.cmake b/cmake/developer_package/compile_flags/os_flags.cmake index b7ef233b428dbe..87359245b541e9 100644 --- a/cmake/developer_package/compile_flags/os_flags.cmake +++ b/cmake/developer_package/compile_flags/os_flags.cmake @@ -207,9 +207,9 @@ endif() # Honor visibility properties for all target types set(CMAKE_POLICY_DEFAULT_CMP0063 NEW) -set(CMAKE_CXX_VISIBILITY_PRESET default) -set(CMAKE_C_VISIBILITY_PRESET default) -set(CMAKE_VISIBILITY_INLINES_HIDDEN OFF) +set(CMAKE_CXX_VISIBILITY_PRESET hidden) +set(CMAKE_C_VISIBILITY_PRESET hidden) +set(CMAKE_VISIBILITY_INLINES_HIDDEN ON) if(WIN32) ie_add_compiler_flags(-D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS) diff --git a/ngraph/frontend/onnx_import/CMakeLists.txt b/ngraph/frontend/onnx_import/CMakeLists.txt index dfaebe27455df9..ed7726de263d9f 100644 --- a/ngraph/frontend/onnx_import/CMakeLists.txt +++ b/ngraph/frontend/onnx_import/CMakeLists.txt @@ -59,11 +59,6 @@ if(COMMAND ie_faster_build) ) endif() -set_target_properties(onnx_importer PROPERTIES - CXX_VISIBILITY_PRESET default - C_VISIBILITY_PRESET default - VISIBILITY_INLINES_HIDDEN OFF) - target_link_libraries(onnx_importer PRIVATE onnx onnx_proto ${Protobuf_LIBRARIES} ngraph::builder PUBLIC ngraph) diff --git a/ngraph/test/CMakeLists.txt b/ngraph/test/CMakeLists.txt index 2e6a3a90d2cfe3..fc7f38e31deccd 100644 --- a/ngraph/test/CMakeLists.txt +++ b/ngraph/test/CMakeLists.txt @@ -421,7 +421,7 @@ target_link_libraries(unit-test PRIVATE ngraph_test_util if (NGRAPH_ONNX_IMPORT_ENABLE AND NOT NGRAPH_USE_PROTOBUF_LITE) target_include_directories(unit-test SYSTEM PRIVATE ${ONNX_INCLUDE_DIR} ${ONNX_PROTO_INCLUDE_DIR} ${Protobuf_INCLUDE_DIRS}) - target_link_libraries(unit-test PRIVATE ${ONNX_LIBRARIES}) + target_link_libraries(unit-test PRIVATE ${Protobuf_LIBRARIES} ${ONNX_LIBRARIES}) get_target_property(ONNX_IMPORTER_SRC_DIR onnx_importer SOURCE_DIR) target_include_directories(unit-test PRIVATE ${ONNX_IMPORTER_SRC_DIR}/src) From f2fdf5eb7d6ecf8aa095ea9dead97d72cbebe29c Mon Sep 17 00:00:00 2001 From: tomdol Date: Tue, 9 Feb 2021 07:51:08 -0500 Subject: [PATCH 033/116] Make tests green again? --- .../src/editor/detail/subgraph_extraction.cpp | 6 +- .../onnx_import/src/utils}/onnx_test_util.cpp | 111 +++++++----------- .../onnx_import/src/utils}/onnx_test_util.hpp | 16 ++- ...puts_and_outputs_based_extraction.prototxt | 20 ++++ .../subgraph_extraction_tests.prototxt | 20 ++++ ngraph/test/onnx/onnx_editor.cpp | 28 ++--- ngraph/test/util/CMakeLists.txt | 10 -- 7 files changed, 103 insertions(+), 108 deletions(-) rename ngraph/{test/util => frontend/onnx_import/src/utils}/onnx_test_util.cpp (80%) rename ngraph/{test/util => frontend/onnx_import/src/utils}/onnx_test_util.hpp (83%) diff --git a/ngraph/frontend/onnx_import/src/editor/detail/subgraph_extraction.cpp b/ngraph/frontend/onnx_import/src/editor/detail/subgraph_extraction.cpp index c111700a285656..cb46637faa83f5 100644 --- a/ngraph/frontend/onnx_import/src/editor/detail/subgraph_extraction.cpp +++ b/ngraph/frontend/onnx_import/src/editor/detail/subgraph_extraction.cpp @@ -42,10 +42,8 @@ namespace return [&name](const T& onnx_object) -> bool { return onnx_object.name() == name; }; } - std::function is_equal_to(const std::string& other) - { - return [&other](const std::string& s) { return s == other; }; - } + const auto is_equal_to = + +[](const std::string& other) { return [&](const std::string& s) { return s == other; }; }; template bool already_exists(const Container& items, const std::string& name) diff --git a/ngraph/test/util/onnx_test_util.cpp b/ngraph/frontend/onnx_import/src/utils/onnx_test_util.cpp similarity index 80% rename from ngraph/test/util/onnx_test_util.cpp rename to ngraph/frontend/onnx_import/src/utils/onnx_test_util.cpp index ddb24c9a2bc5e5..14a204aacfea3b 100644 --- a/ngraph/test/util/onnx_test_util.cpp +++ b/ngraph/frontend/onnx_import/src/utils/onnx_test_util.cpp @@ -16,49 +16,16 @@ #include #include -#include -#include #include +#include -#include "util/onnx_test_util.hpp" +#include "onnx_test_util.hpp" +#include "parser.hpp" + +using namespace ngraph::onnx_import; -using namespace ngraph::test; namespace { - ONNX_NAMESPACE::ModelProto parse_from_file(const std::string& file_path) - { - std::ifstream file_stream{file_path, std::ios::in | std::ios::binary}; - - if (!file_stream.is_open()) - { - throw std::runtime_error("Could not open the file: " + file_path); - }; - - if (!file_stream.good()) - { - file_stream.clear(); - file_stream.seekg(0); - if (!file_stream.good()) - { - throw std::runtime_error("Invalid state of model's input stream."); - } - } - - ONNX_NAMESPACE::ModelProto model_proto; - google::protobuf::io::IstreamInputStream iistream(&file_stream); - if (!google::protobuf::TextFormat::Parse(&iistream, &model_proto)) - { - file_stream.clear(); - file_stream.seekg(0); - if (!model_proto.ParseFromIstream(&file_stream)) - { - throw std::runtime_error("Could not import the test model: " + file_path); - } - } - - return model_proto; - } - ComparisonResult compare_nodes(const ONNX_NAMESPACE::GraphProto& graph, const ONNX_NAMESPACE::GraphProto& ref_graph) { @@ -111,8 +78,8 @@ namespace { if (lhs.name() != rhs.name()) { - return ComparisonResult::fail(item_type + " names in the graph don't match: " + - lhs.name() + " vs " + rhs.name()); + return ComparisonResult::fail( + item_type + " names in the graph don't match: " + lhs.name() + " vs " + rhs.name()); } const auto& lhs_tensor = lhs.type().tensor_type(); @@ -143,14 +110,14 @@ namespace (rhs_dim.has_dim_value() && lhs_dim.has_dim_param())) { return ComparisonResult::fail("Dynamic vs static dimension mismatch for " + - item_type + " " + lhs.name() + " at index: " + - std::to_string(j)); + item_type + " " + lhs.name() + + " at index: " + std::to_string(j)); } else if (lhs_dim.has_dim_value() && lhs_dim.dim_value() != rhs_dim.dim_value()) { return ComparisonResult::fail("Shape dimensions don't match for " + item_type + - " " + lhs.name() + " at index: " + - std::to_string(j) + ". " + + " " + lhs.name() + + " at index: " + std::to_string(j) + ". " + std::to_string(lhs_dim.dim_value()) + " vs " + std::to_string(rhs_dim.dim_value())); } @@ -267,38 +234,40 @@ namespace return ComparisonResult::pass(); } } + + ComparisonResult compare_onnx_graphs(const ONNX_NAMESPACE::GraphProto& graph, + const ONNX_NAMESPACE::GraphProto& ref_graph) + { + ComparisonResult comparison = compare_inputs(graph, ref_graph); + if (!comparison.is_ok) + { + return comparison; + } + + comparison = compare_outputs(graph, ref_graph); + if (!comparison.is_ok) + { + return comparison; + } + + comparison = compare_initializers(graph, ref_graph); + if (!comparison.is_ok) + { + return comparison; + } + + return compare_nodes(graph, ref_graph); + } } // namespace namespace ngraph { - namespace test + namespace onnx_import { - ComparisonResult compare_onnx_graphs(const ONNX_NAMESPACE::GraphProto& graph, + ComparisonResult compare_onnx_models(const ONNX_NAMESPACE::GraphProto& graph, const std::string& reference_model_path) { - ComparisonResult comparison; - - const auto ref_model = parse_from_file(reference_model_path); - const auto& ref_graph = ref_model.graph(); - - comparison = compare_inputs(graph, ref_graph); - if (!comparison.is_ok) - { - return comparison; - } - - comparison = compare_outputs(graph, ref_graph); - if (!comparison.is_ok) - { - return comparison; - } - - comparison = compare_initializers(graph, ref_graph); - if (!comparison.is_ok) - { - return comparison; - } - - return compare_nodes(graph, ref_graph); + const auto ref_model = onnx_import::parse_from_file(reference_model_path); + return compare_onnx_graphs(graph, ref_model.graph()); } - } // namespace test + } // namespace onnx_import } // namespace ngraph diff --git a/ngraph/test/util/onnx_test_util.hpp b/ngraph/frontend/onnx_import/src/utils/onnx_test_util.hpp similarity index 83% rename from ngraph/test/util/onnx_test_util.hpp rename to ngraph/frontend/onnx_import/src/utils/onnx_test_util.hpp index 66cbf0787b57a8..05707c6e9b3fff 100644 --- a/ngraph/test/util/onnx_test_util.hpp +++ b/ngraph/frontend/onnx_import/src/utils/onnx_test_util.hpp @@ -18,16 +18,13 @@ #include -namespace ONNX_NAMESPACE -{ - class GraphProto; -} +#include "onnx_import/utils/onnx_importer_visibility.hpp" namespace ngraph { - namespace test + namespace onnx_import { - struct ComparisonResult + struct ONNX_IMPORTER_API ComparisonResult { ComparisonResult() = default; ComparisonResult(std::string error) @@ -50,7 +47,8 @@ namespace ngraph } }; - ComparisonResult compare_onnx_graphs(const ONNX_NAMESPACE::GraphProto& graph, - const std::string& reference_model_path); - } // namespace test + ONNX_IMPORTER_API ComparisonResult compare_onnx_models( + const ONNX_NAMESPACE::GraphProto& graph, const std::string& reference_model_path); + + } // namespace onnx_import } // namespace ngraph diff --git a/ngraph/test/models/onnx/model_editor/reference/subgraph__existing_inputs_and_outputs_based_extraction.prototxt b/ngraph/test/models/onnx/model_editor/reference/subgraph__existing_inputs_and_outputs_based_extraction.prototxt index 6072b62de67a63..f47378b8af2583 100644 --- a/ngraph/test/models/onnx/model_editor/reference/subgraph__existing_inputs_and_outputs_based_extraction.prototxt +++ b/ngraph/test/models/onnx/model_editor/reference/subgraph__existing_inputs_and_outputs_based_extraction.prototxt @@ -26,6 +26,8 @@ graph { } name: "subgraph_extraction_testing" initializer { + dims: 1 + dims: 1 dims: 1 dims: 1 data_type: 1 @@ -64,6 +66,12 @@ graph { tensor_type { elem_type: 1 shape { + dim { + dim_value: 1 + } + dim { + dim_value: 1 + } dim { dim_value: 2 } @@ -86,6 +94,12 @@ graph { dim { dim_value: 1 } + dim { + dim_value: 1 + } + dim { + dim_value: 1 + } } } } @@ -96,6 +110,12 @@ graph { tensor_type { elem_type: 1 shape { + dim { + dim_value: 1 + } + dim { + dim_value: 1 + } dim { dim_value: 2 } diff --git a/ngraph/test/models/onnx/model_editor/subgraph_extraction_tests.prototxt b/ngraph/test/models/onnx/model_editor/subgraph_extraction_tests.prototxt index 9e9a165123e156..2b60155688eb34 100644 --- a/ngraph/test/models/onnx/model_editor/subgraph_extraction_tests.prototxt +++ b/ngraph/test/models/onnx/model_editor/subgraph_extraction_tests.prototxt @@ -49,6 +49,8 @@ graph { } name: "subgraph_extraction_testing" initializer { + dims: 1 + dims: 1 dims: 1 dims: 1 data_type: 1 @@ -87,6 +89,12 @@ graph { tensor_type { elem_type: 1 shape { + dim { + dim_value: 1 + } + dim { + dim_value: 1 + } dim { dim_value: 2 } @@ -109,6 +117,12 @@ graph { dim { dim_value: 1 } + dim { + dim_value: 1 + } + dim { + dim_value: 1 + } } } } @@ -151,6 +165,12 @@ graph { tensor_type { elem_type: 1 shape { + dim { + dim_value: 1 + } + dim { + dim_value: 1 + } dim { dim_value: 2 } diff --git a/ngraph/test/onnx/onnx_editor.cpp b/ngraph/test/onnx/onnx_editor.cpp index 62f0fc89458a30..eb3e6dd4d6270c 100644 --- a/ngraph/test/onnx/onnx_editor.cpp +++ b/ngraph/test/onnx/onnx_editor.cpp @@ -26,8 +26,8 @@ #include "ngraph/opsets/opset1.hpp" #include "onnx_import/editor/editor.hpp" #include "onnx_import/onnx.hpp" -#include "util/onnx_test_util.hpp" #include "util/test_control.hpp" +#include "utils/onnx_test_util.hpp" NGRAPH_SUPPRESS_DEPRECATED_START @@ -301,7 +301,7 @@ NGRAPH_TEST(onnx_editor, subgraph__linear_model_head_cut) const auto ref_model = file_util::path_join( SERIALIZED_ZOO, "onnx/model_editor/reference/subgraph__linear_model_head_cut.prototxt"); - const auto result = test::compare_onnx_graphs(editor.model().graph(), ref_model); + const auto result = compare_onnx_models(editor.model().graph(), ref_model); EXPECT_TRUE(result.is_ok) << result.error_message; } @@ -318,7 +318,7 @@ NGRAPH_TEST(onnx_editor, subgraph__linear_model_head_cut_ins_and_outs) const auto ref_model = file_util::path_join( SERIALIZED_ZOO, "onnx/model_editor/reference/subgraph__linear_model_head_cut.prototxt"); - const auto result = test::compare_onnx_graphs(editor.model().graph(), ref_model); + const auto result = compare_onnx_models(editor.model().graph(), ref_model); EXPECT_TRUE(result.is_ok) << result.error_message; } @@ -334,7 +334,7 @@ NGRAPH_TEST(onnx_editor, subgraph__linear_model_deeper_head_cut) SERIALIZED_ZOO, "onnx/model_editor/reference/subgraph__linear_model_deeper_head_cut.prototxt"); - const auto result = test::compare_onnx_graphs(editor.model().graph(), ref_model); + const auto result = compare_onnx_models(editor.model().graph(), ref_model); EXPECT_TRUE(result.is_ok) << result.error_message; } @@ -349,7 +349,7 @@ NGRAPH_TEST(onnx_editor, subgraph__linear_model_tail_cut) const auto ref_model = file_util::path_join( SERIALIZED_ZOO, "onnx/model_editor/reference/subgraph__linear_model_tail_cut.prototxt"); - const auto result = test::compare_onnx_graphs(editor.model().graph(), ref_model); + const auto result = compare_onnx_models(editor.model().graph(), ref_model); EXPECT_TRUE(result.is_ok) << result.error_message; } @@ -365,7 +365,7 @@ NGRAPH_TEST(onnx_editor, subgraph__linear_model_tail_cut_ins_and_outs) const auto ref_model = file_util::path_join( SERIALIZED_ZOO, "onnx/model_editor/reference/subgraph__linear_model_tail_cut.prototxt"); - const auto result = test::compare_onnx_graphs(editor.model().graph(), ref_model); + const auto result = compare_onnx_models(editor.model().graph(), ref_model); EXPECT_TRUE(result.is_ok) << result.error_message; } @@ -381,7 +381,7 @@ NGRAPH_TEST(onnx_editor, subgraph__linear_model_with_initializer_tail_cut) SERIALIZED_ZOO, "onnx/model_editor/reference/subgraph__linear_model_with_initializer_tail_cut.prototxt"); - const auto result = test::compare_onnx_graphs(editor.model().graph(), ref_model); + const auto result = compare_onnx_models(editor.model().graph(), ref_model); EXPECT_TRUE(result.is_ok) << result.error_message; } @@ -398,7 +398,7 @@ NGRAPH_TEST(onnx_editor, subgraph__initializer_without_matching_input_tail_cut) "onnx/model_editor/reference/" "subgraph__initializer_without_matching_input_tail_cut.prototxt"); - const auto result = test::compare_onnx_graphs(editor.model().graph(), ref_model); + const auto result = compare_onnx_models(editor.model().graph(), ref_model); EXPECT_TRUE(result.is_ok) << result.error_message; } @@ -414,7 +414,7 @@ NGRAPH_TEST(onnx_editor, subgraph__linear_model_deeper_tail_cut) SERIALIZED_ZOO, "onnx/model_editor/reference/subgraph__linear_model_deeper_tail_cut.prototxt"); - const auto result = test::compare_onnx_graphs(editor.model().graph(), ref_model); + const auto result = compare_onnx_models(editor.model().graph(), ref_model); EXPECT_TRUE(result.is_ok) << result.error_message; } @@ -428,7 +428,7 @@ NGRAPH_TEST(onnx_editor, subgraph__no_input_params) editor.cut_graph_fragment({}, {}); - const auto result = test::compare_onnx_graphs(editor.model().graph(), model_path); + const auto result = compare_onnx_models(editor.model().graph(), model_path); EXPECT_TRUE(result.is_ok) << result.error_message; } @@ -445,7 +445,7 @@ NGRAPH_TEST(onnx_editor, subgraph__initializer_to_input_replacement) SERIALIZED_ZOO, "onnx/model_editor/reference/subgraph__initializer_to_input_replacement.prototxt"); - const auto result = test::compare_onnx_graphs(editor.model().graph(), ref_model); + const auto result = compare_onnx_models(editor.model().graph(), ref_model); EXPECT_TRUE(result.is_ok) << result.error_message; } @@ -462,7 +462,7 @@ NGRAPH_TEST(onnx_editor, subgraph__initializer_to_input_replacement_2) SERIALIZED_ZOO, "onnx/model_editor/reference/subgraph__initializer_to_input_replacement.prototxt"); - const auto result = test::compare_onnx_graphs(editor.model().graph(), ref_model); + const auto result = compare_onnx_models(editor.model().graph(), ref_model); EXPECT_TRUE(result.is_ok) << result.error_message; } @@ -477,7 +477,7 @@ NGRAPH_TEST(onnx_editor, subgraph__multiout_op_output_edge) const auto ref_model = file_util::path_join( SERIALIZED_ZOO, "onnx/model_editor/reference/subgraph__multiout_op_output_edge.prototxt"); - const auto result = test::compare_onnx_graphs(editor.model().graph(), ref_model); + const auto result = compare_onnx_models(editor.model().graph(), ref_model); EXPECT_TRUE(result.is_ok) << result.error_message; } @@ -495,7 +495,7 @@ NGRAPH_TEST(onnx_editor, subgraph__existing_inputs_and_outputs_based_extraction) "onnx/model_editor/reference/" "subgraph__existing_inputs_and_outputs_based_extraction.prototxt"); - const auto result = test::compare_onnx_graphs(editor.model().graph(), ref_model); + const auto result = compare_onnx_models(editor.model().graph(), ref_model); EXPECT_TRUE(result.is_ok) << result.error_message; } diff --git a/ngraph/test/util/CMakeLists.txt b/ngraph/test/util/CMakeLists.txt index d53b520fce10a7..548326c6c85a33 100644 --- a/ngraph/test/util/CMakeLists.txt +++ b/ngraph/test/util/CMakeLists.txt @@ -29,10 +29,6 @@ set (SRC provenance_enabler.hpp ) -if (NGRAPH_ONNX_IMPORT_ENABLE AND NOT NGRAPH_USE_PROTOBUF_LITE) - list(APPEND SRC onnx_test_util.cpp) -endif() - add_library(ngraph_test_util STATIC ${SRC}) if(COMMAND ie_faster_build) @@ -47,9 +43,3 @@ if(NGRAPH_LIB_VERSIONING_ENABLE) endif() target_include_directories(ngraph_test_util PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/.. ${IE_MAIN_SOURCE_DIR}/include) target_link_libraries(ngraph_test_util PRIVATE ngraph ngraph_backend libgtest) - -if (NGRAPH_ONNX_IMPORT_ENABLE AND NOT NGRAPH_USE_PROTOBUF_LITE) - target_include_directories(ngraph_test_util SYSTEM PRIVATE ${ONNX_INCLUDE_DIR} - ${ONNX_PROTO_INCLUDE_DIR} ${Protobuf_INCLUDE_DIRS}) - target_link_libraries(ngraph_test_util PRIVATE ${ONNX_LIBRARIES} ${Protobuf_LIBRARIES}) -endif() From 92addf29355289c8790ef4299951fe8d5c251f32 Mon Sep 17 00:00:00 2001 From: tomdol Date: Tue, 9 Feb 2021 10:03:02 -0500 Subject: [PATCH 034/116] Make the current tests pass --- .../onnx_import/src/utils/onnx_test_util.cpp | 12 +- ...om_tensor_with_multiple_consumers.prototxt | 203 ++++++++++++++++++ ..._tensor_with_multiple_consumers_2.prototxt | 203 ++++++++++++++++++ ngraph/test/onnx/onnx_editor.cpp | 36 ++++ 4 files changed, 448 insertions(+), 6 deletions(-) create mode 100644 ngraph/test/models/onnx/model_editor/reference/subgraph__input_edge_from_tensor_with_multiple_consumers.prototxt create mode 100644 ngraph/test/models/onnx/model_editor/reference/subgraph__input_edge_from_tensor_with_multiple_consumers_2.prototxt diff --git a/ngraph/frontend/onnx_import/src/utils/onnx_test_util.cpp b/ngraph/frontend/onnx_import/src/utils/onnx_test_util.cpp index 14a204aacfea3b..468509f06fcd95 100644 --- a/ngraph/frontend/onnx_import/src/utils/onnx_test_util.cpp +++ b/ngraph/frontend/onnx_import/src/utils/onnx_test_util.cpp @@ -78,8 +78,8 @@ namespace { if (lhs.name() != rhs.name()) { - return ComparisonResult::fail( - item_type + " names in the graph don't match: " + lhs.name() + " vs " + rhs.name()); + return ComparisonResult::fail(item_type + " names in the graph don't match: " + + lhs.name() + " vs " + rhs.name()); } const auto& lhs_tensor = lhs.type().tensor_type(); @@ -110,14 +110,14 @@ namespace (rhs_dim.has_dim_value() && lhs_dim.has_dim_param())) { return ComparisonResult::fail("Dynamic vs static dimension mismatch for " + - item_type + " " + lhs.name() + - " at index: " + std::to_string(j)); + item_type + " " + lhs.name() + " at index: " + + std::to_string(j)); } else if (lhs_dim.has_dim_value() && lhs_dim.dim_value() != rhs_dim.dim_value()) { return ComparisonResult::fail("Shape dimensions don't match for " + item_type + - " " + lhs.name() + - " at index: " + std::to_string(j) + ". " + + " " + lhs.name() + " at index: " + + std::to_string(j) + ". " + std::to_string(lhs_dim.dim_value()) + " vs " + std::to_string(rhs_dim.dim_value())); } diff --git a/ngraph/test/models/onnx/model_editor/reference/subgraph__input_edge_from_tensor_with_multiple_consumers.prototxt b/ngraph/test/models/onnx/model_editor/reference/subgraph__input_edge_from_tensor_with_multiple_consumers.prototxt new file mode 100644 index 00000000000000..9ad9a9c9331906 --- /dev/null +++ b/ngraph/test/models/onnx/model_editor/reference/subgraph__input_edge_from_tensor_with_multiple_consumers.prototxt @@ -0,0 +1,203 @@ +ir_version: 7 +producer_name: "tomdol" +graph { + node { + input: "in1" + output: "relu1" + op_type: "Relu" + } + node { + input: "add1:relu1" + input: "in2" + output: "add1" + op_type: "Add" + } + node { + input: "in3" + input: "in4" + output: "conv1" + op_type: "Conv" + } + node { + input: "relu1" + input: "add1" + output: "add2" + op_type: "Add" + } + node { + input: "add1" + input: "conv1" + output: "mul2" + op_type: "Mul" + } + node { + input: "add2" + output: "split1" + output: "split2" + op_type: "Split" + attribute { + name: "axis" + i: 1 + type: INT + } + } + node { + input: "mul1:relu1" + input: "split1" + output: "mul1" + op_type: "Mul" + } + name: "subgraph_extraction_testing" + initializer { + dims: 1 + dims: 1 + dims: 1 + dims: 1 + data_type: 1 + float_data: 1 + name: "in4" + } + input { + name: "in1" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 2 + } + dim { + dim_value: 2 + } + } + } + } + } + input { + name: "in2" + type { + tensor_type { + elem_type: 1 + shape { + } + } + } + } + input { + name: "in3" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 1 + } + dim { + dim_value: 1 + } + dim { + dim_value: 2 + } + dim { + dim_value: 2 + } + } + } + } + } + input { + name: "in4" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 1 + } + dim { + dim_value: 1 + } + dim { + dim_value: 1 + } + dim { + dim_value: 1 + } + } + } + } + } + input { + name: "add1:relu1" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 2 + } + dim { + dim_value: 2 + } + } + } + } + } + input { + name: "mul1:relu1" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 2 + } + dim { + dim_value: 2 + } + } + } + } + } + output { + name: "mul1" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 2 + } + dim { + dim_value: 2 + } + } + } + } + } + output { + name: "mul2" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 1 + } + dim { + dim_value: 1 + } + dim { + dim_value: 2 + } + dim { + dim_value: 2 + } + } + } + } + } +} +opset_import { + version: 13 +} diff --git a/ngraph/test/models/onnx/model_editor/reference/subgraph__input_edge_from_tensor_with_multiple_consumers_2.prototxt b/ngraph/test/models/onnx/model_editor/reference/subgraph__input_edge_from_tensor_with_multiple_consumers_2.prototxt new file mode 100644 index 00000000000000..9ad9a9c9331906 --- /dev/null +++ b/ngraph/test/models/onnx/model_editor/reference/subgraph__input_edge_from_tensor_with_multiple_consumers_2.prototxt @@ -0,0 +1,203 @@ +ir_version: 7 +producer_name: "tomdol" +graph { + node { + input: "in1" + output: "relu1" + op_type: "Relu" + } + node { + input: "add1:relu1" + input: "in2" + output: "add1" + op_type: "Add" + } + node { + input: "in3" + input: "in4" + output: "conv1" + op_type: "Conv" + } + node { + input: "relu1" + input: "add1" + output: "add2" + op_type: "Add" + } + node { + input: "add1" + input: "conv1" + output: "mul2" + op_type: "Mul" + } + node { + input: "add2" + output: "split1" + output: "split2" + op_type: "Split" + attribute { + name: "axis" + i: 1 + type: INT + } + } + node { + input: "mul1:relu1" + input: "split1" + output: "mul1" + op_type: "Mul" + } + name: "subgraph_extraction_testing" + initializer { + dims: 1 + dims: 1 + dims: 1 + dims: 1 + data_type: 1 + float_data: 1 + name: "in4" + } + input { + name: "in1" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 2 + } + dim { + dim_value: 2 + } + } + } + } + } + input { + name: "in2" + type { + tensor_type { + elem_type: 1 + shape { + } + } + } + } + input { + name: "in3" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 1 + } + dim { + dim_value: 1 + } + dim { + dim_value: 2 + } + dim { + dim_value: 2 + } + } + } + } + } + input { + name: "in4" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 1 + } + dim { + dim_value: 1 + } + dim { + dim_value: 1 + } + dim { + dim_value: 1 + } + } + } + } + } + input { + name: "add1:relu1" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 2 + } + dim { + dim_value: 2 + } + } + } + } + } + input { + name: "mul1:relu1" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 2 + } + dim { + dim_value: 2 + } + } + } + } + } + output { + name: "mul1" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 2 + } + dim { + dim_value: 2 + } + } + } + } + } + output { + name: "mul2" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 1 + } + dim { + dim_value: 1 + } + dim { + dim_value: 2 + } + dim { + dim_value: 2 + } + } + } + } + } +} +opset_import { + version: 13 +} diff --git a/ngraph/test/onnx/onnx_editor.cpp b/ngraph/test/onnx/onnx_editor.cpp index eb3e6dd4d6270c..e6098b962f8901 100644 --- a/ngraph/test/onnx/onnx_editor.cpp +++ b/ngraph/test/onnx/onnx_editor.cpp @@ -500,6 +500,42 @@ NGRAPH_TEST(onnx_editor, subgraph__existing_inputs_and_outputs_based_extraction) EXPECT_TRUE(result.is_ok) << result.error_message; } +NGRAPH_TEST(onnx_editor, subgraph__input_edge_from_tensor_with_multiple_consumers) +{ + onnx_import::ONNXModelEditor editor{file_util::path_join( + SERIALIZED_ZOO, "onnx/model_editor/subgraph_extraction_tests.prototxt")}; + + editor.cut_graph_fragment({{InputEdge{1, "relu1"}, InputEdge{6, "relu1"}}}, + {{OutputEdge{6, "mul1"}, OutputEdge{4, "mul2"}}}); + + const auto ref_model = + file_util::path_join(SERIALIZED_ZOO, + "onnx/model_editor/reference/" + "subgraph__input_edge_from_tensor_with_multiple_consumers.prototxt"); + + const auto result = compare_onnx_models(editor.model().graph(), ref_model); + + EXPECT_TRUE(result.is_ok) << result.error_message; +} + +NGRAPH_TEST(onnx_editor, subgraph__input_edge_from_tensor_with_multiple_consumers_2) +{ + onnx_import::ONNXModelEditor editor{file_util::path_join( + SERIALIZED_ZOO, "onnx/model_editor/subgraph_extraction_tests.prototxt")}; + + editor.cut_graph_fragment({{InputEdge{1, "relu1"}, InputEdge{6, "relu1"}}}, + {{OutputEdge{6, "mul1"}, OutputEdge{4, "mul2"}}}); + + const auto ref_model = + file_util::path_join(SERIALIZED_ZOO, + "onnx/model_editor/reference/" + "subgraph__input_edge_from_tensor_with_multiple_consumers_2.prototxt"); + + const auto result = compare_onnx_models(editor.model().graph(), ref_model); + + EXPECT_TRUE(result.is_ok) << result.error_message; +} + NGRAPH_TEST(onnx_editor, subgraph__invalid_edge_idx) { const auto model_path = From 59d7ef4e3d5e32b30a648b77cb045362d41c5e8d Mon Sep 17 00:00:00 2001 From: tomdol Date: Tue, 9 Feb 2021 10:09:48 -0500 Subject: [PATCH 035/116] Remove the ONNX header from editor's tests --- .../include/onnx_import/editor/editor.hpp | 2 ++ .../onnx_import/src/editor/editor.cpp | 5 +++ .../onnx_import/src/utils/onnx_test_util.cpp | 6 ++-- .../onnx_import/src/utils/onnx_test_util.hpp | 4 +-- ngraph/test/onnx/onnx_editor.cpp | 31 +++++++++---------- 5 files changed, 28 insertions(+), 20 deletions(-) diff --git a/ngraph/frontend/onnx_import/include/onnx_import/editor/editor.hpp b/ngraph/frontend/onnx_import/include/onnx_import/editor/editor.hpp index b8209c3a9eac30..5cf5b94abb69fa 100644 --- a/ngraph/frontend/onnx_import/include/onnx_import/editor/editor.hpp +++ b/ngraph/frontend/onnx_import/include/onnx_import/editor/editor.hpp @@ -90,6 +90,8 @@ namespace ngraph /// \return A reference to ONNX ModelProto object containing the in-memory model ONNX_NAMESPACE::ModelProto& model() const; + std::string model_string() const; + /// \brief Returns a list of all inputs of the in-memory model, including initializers. /// The returned value might depend on the previous operations executed on an /// instance of the model editor, in particular the subgraph extraction which diff --git a/ngraph/frontend/onnx_import/src/editor/editor.cpp b/ngraph/frontend/onnx_import/src/editor/editor.cpp index b538edc9f2ce04..d36b0818e8b683 100644 --- a/ngraph/frontend/onnx_import/src/editor/editor.cpp +++ b/ngraph/frontend/onnx_import/src/editor/editor.cpp @@ -280,3 +280,8 @@ std::vector onnx_import::ONNXModelEditor::model_inputs() const return inputs_and_initializers; } + +std::string onnx_import::ONNXModelEditor::model_string() const +{ + return m_pimpl->m_model_proto.SerializeAsString(); +} diff --git a/ngraph/frontend/onnx_import/src/utils/onnx_test_util.cpp b/ngraph/frontend/onnx_import/src/utils/onnx_test_util.cpp index 468509f06fcd95..b396c27b80cb28 100644 --- a/ngraph/frontend/onnx_import/src/utils/onnx_test_util.cpp +++ b/ngraph/frontend/onnx_import/src/utils/onnx_test_util.cpp @@ -263,11 +263,13 @@ namespace ngraph { namespace onnx_import { - ComparisonResult compare_onnx_models(const ONNX_NAMESPACE::GraphProto& graph, + ComparisonResult compare_onnx_models(const std::string& model, const std::string& reference_model_path) { + std::stringstream model_stream{model}; + const auto model_proto = onnx_import::parse_from_istream(model_stream); const auto ref_model = onnx_import::parse_from_file(reference_model_path); - return compare_onnx_graphs(graph, ref_model.graph()); + return compare_onnx_graphs(model_proto.graph(), ref_model.graph()); } } // namespace onnx_import } // namespace ngraph diff --git a/ngraph/frontend/onnx_import/src/utils/onnx_test_util.hpp b/ngraph/frontend/onnx_import/src/utils/onnx_test_util.hpp index 05707c6e9b3fff..6c97bd1c1fee5b 100644 --- a/ngraph/frontend/onnx_import/src/utils/onnx_test_util.hpp +++ b/ngraph/frontend/onnx_import/src/utils/onnx_test_util.hpp @@ -47,8 +47,8 @@ namespace ngraph } }; - ONNX_IMPORTER_API ComparisonResult compare_onnx_models( - const ONNX_NAMESPACE::GraphProto& graph, const std::string& reference_model_path); + ONNX_IMPORTER_API ComparisonResult + compare_onnx_models(const std::string& model, const std::string& reference_model_path); } // namespace onnx_import } // namespace ngraph diff --git a/ngraph/test/onnx/onnx_editor.cpp b/ngraph/test/onnx/onnx_editor.cpp index e6098b962f8901..b330fbe67a59bd 100644 --- a/ngraph/test/onnx/onnx_editor.cpp +++ b/ngraph/test/onnx/onnx_editor.cpp @@ -15,7 +15,6 @@ //***************************************************************************** #include -#include #include #include "gtest/gtest.h" @@ -301,7 +300,7 @@ NGRAPH_TEST(onnx_editor, subgraph__linear_model_head_cut) const auto ref_model = file_util::path_join( SERIALIZED_ZOO, "onnx/model_editor/reference/subgraph__linear_model_head_cut.prototxt"); - const auto result = compare_onnx_models(editor.model().graph(), ref_model); + const auto result = compare_onnx_models(editor.model_string(), ref_model); EXPECT_TRUE(result.is_ok) << result.error_message; } @@ -318,7 +317,7 @@ NGRAPH_TEST(onnx_editor, subgraph__linear_model_head_cut_ins_and_outs) const auto ref_model = file_util::path_join( SERIALIZED_ZOO, "onnx/model_editor/reference/subgraph__linear_model_head_cut.prototxt"); - const auto result = compare_onnx_models(editor.model().graph(), ref_model); + const auto result = compare_onnx_models(editor.model_string(), ref_model); EXPECT_TRUE(result.is_ok) << result.error_message; } @@ -334,7 +333,7 @@ NGRAPH_TEST(onnx_editor, subgraph__linear_model_deeper_head_cut) SERIALIZED_ZOO, "onnx/model_editor/reference/subgraph__linear_model_deeper_head_cut.prototxt"); - const auto result = compare_onnx_models(editor.model().graph(), ref_model); + const auto result = compare_onnx_models(editor.model_string(), ref_model); EXPECT_TRUE(result.is_ok) << result.error_message; } @@ -349,7 +348,7 @@ NGRAPH_TEST(onnx_editor, subgraph__linear_model_tail_cut) const auto ref_model = file_util::path_join( SERIALIZED_ZOO, "onnx/model_editor/reference/subgraph__linear_model_tail_cut.prototxt"); - const auto result = compare_onnx_models(editor.model().graph(), ref_model); + const auto result = compare_onnx_models(editor.model_string(), ref_model); EXPECT_TRUE(result.is_ok) << result.error_message; } @@ -365,7 +364,7 @@ NGRAPH_TEST(onnx_editor, subgraph__linear_model_tail_cut_ins_and_outs) const auto ref_model = file_util::path_join( SERIALIZED_ZOO, "onnx/model_editor/reference/subgraph__linear_model_tail_cut.prototxt"); - const auto result = compare_onnx_models(editor.model().graph(), ref_model); + const auto result = compare_onnx_models(editor.model_string(), ref_model); EXPECT_TRUE(result.is_ok) << result.error_message; } @@ -381,7 +380,7 @@ NGRAPH_TEST(onnx_editor, subgraph__linear_model_with_initializer_tail_cut) SERIALIZED_ZOO, "onnx/model_editor/reference/subgraph__linear_model_with_initializer_tail_cut.prototxt"); - const auto result = compare_onnx_models(editor.model().graph(), ref_model); + const auto result = compare_onnx_models(editor.model_string(), ref_model); EXPECT_TRUE(result.is_ok) << result.error_message; } @@ -398,7 +397,7 @@ NGRAPH_TEST(onnx_editor, subgraph__initializer_without_matching_input_tail_cut) "onnx/model_editor/reference/" "subgraph__initializer_without_matching_input_tail_cut.prototxt"); - const auto result = compare_onnx_models(editor.model().graph(), ref_model); + const auto result = compare_onnx_models(editor.model_string(), ref_model); EXPECT_TRUE(result.is_ok) << result.error_message; } @@ -414,7 +413,7 @@ NGRAPH_TEST(onnx_editor, subgraph__linear_model_deeper_tail_cut) SERIALIZED_ZOO, "onnx/model_editor/reference/subgraph__linear_model_deeper_tail_cut.prototxt"); - const auto result = compare_onnx_models(editor.model().graph(), ref_model); + const auto result = compare_onnx_models(editor.model_string(), ref_model); EXPECT_TRUE(result.is_ok) << result.error_message; } @@ -428,7 +427,7 @@ NGRAPH_TEST(onnx_editor, subgraph__no_input_params) editor.cut_graph_fragment({}, {}); - const auto result = compare_onnx_models(editor.model().graph(), model_path); + const auto result = compare_onnx_models(editor.model_string(), model_path); EXPECT_TRUE(result.is_ok) << result.error_message; } @@ -445,7 +444,7 @@ NGRAPH_TEST(onnx_editor, subgraph__initializer_to_input_replacement) SERIALIZED_ZOO, "onnx/model_editor/reference/subgraph__initializer_to_input_replacement.prototxt"); - const auto result = compare_onnx_models(editor.model().graph(), ref_model); + const auto result = compare_onnx_models(editor.model_string(), ref_model); EXPECT_TRUE(result.is_ok) << result.error_message; } @@ -462,7 +461,7 @@ NGRAPH_TEST(onnx_editor, subgraph__initializer_to_input_replacement_2) SERIALIZED_ZOO, "onnx/model_editor/reference/subgraph__initializer_to_input_replacement.prototxt"); - const auto result = compare_onnx_models(editor.model().graph(), ref_model); + const auto result = compare_onnx_models(editor.model_string(), ref_model); EXPECT_TRUE(result.is_ok) << result.error_message; } @@ -477,7 +476,7 @@ NGRAPH_TEST(onnx_editor, subgraph__multiout_op_output_edge) const auto ref_model = file_util::path_join( SERIALIZED_ZOO, "onnx/model_editor/reference/subgraph__multiout_op_output_edge.prototxt"); - const auto result = compare_onnx_models(editor.model().graph(), ref_model); + const auto result = compare_onnx_models(editor.model_string(), ref_model); EXPECT_TRUE(result.is_ok) << result.error_message; } @@ -495,7 +494,7 @@ NGRAPH_TEST(onnx_editor, subgraph__existing_inputs_and_outputs_based_extraction) "onnx/model_editor/reference/" "subgraph__existing_inputs_and_outputs_based_extraction.prototxt"); - const auto result = compare_onnx_models(editor.model().graph(), ref_model); + const auto result = compare_onnx_models(editor.model_string(), ref_model); EXPECT_TRUE(result.is_ok) << result.error_message; } @@ -513,7 +512,7 @@ NGRAPH_TEST(onnx_editor, subgraph__input_edge_from_tensor_with_multiple_consumer "onnx/model_editor/reference/" "subgraph__input_edge_from_tensor_with_multiple_consumers.prototxt"); - const auto result = compare_onnx_models(editor.model().graph(), ref_model); + const auto result = compare_onnx_models(editor.model_string(), ref_model); EXPECT_TRUE(result.is_ok) << result.error_message; } @@ -531,7 +530,7 @@ NGRAPH_TEST(onnx_editor, subgraph__input_edge_from_tensor_with_multiple_consumer "onnx/model_editor/reference/" "subgraph__input_edge_from_tensor_with_multiple_consumers_2.prototxt"); - const auto result = compare_onnx_models(editor.model().graph(), ref_model); + const auto result = compare_onnx_models(editor.model_string(), ref_model); EXPECT_TRUE(result.is_ok) << result.error_message; } From 6eaee4287ae62721728e43b17c007ddd2c3808ed Mon Sep 17 00:00:00 2001 From: tomdol Date: Wed, 10 Feb 2021 04:07:52 -0500 Subject: [PATCH 036/116] Switch from stable_partition to remove_if because of compiler bugs --- .../src/editor/detail/subgraph_extraction.cpp | 9 +++------ ngraph/test/onnx/onnx_editor.cpp | 1 - 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/ngraph/frontend/onnx_import/src/editor/detail/subgraph_extraction.cpp b/ngraph/frontend/onnx_import/src/editor/detail/subgraph_extraction.cpp index cb46637faa83f5..839b960cbe314f 100644 --- a/ngraph/frontend/onnx_import/src/editor/detail/subgraph_extraction.cpp +++ b/ngraph/frontend/onnx_import/src/editor/detail/subgraph_extraction.cpp @@ -232,17 +232,14 @@ namespace "Unsupported value type of the container"); int idx = 0; - const auto keep_node = [&nodes_to_keep, &idx](const typename Container::value_type&) { - return nodes_to_keep.count(idx++) > 0; + const auto discard_node = [&idx, &nodes_to_keep](const typename Container::value_type&) { + return nodes_to_keep.count(idx++) == 0; }; using std::begin; using std::end; - // Stable partition rearranges the nodes keeping the relative order in both partitions. - // This way the topological sort is preserved and all of the nodes to discard are moved - // after the returned iterator. - const auto new_end = std::stable_partition(begin(all_nodes), end(all_nodes), keep_node); + const auto new_end = std::remove_if(begin(all_nodes), end(all_nodes), discard_node); all_nodes.erase(new_end, end(all_nodes)); } } // namespace diff --git a/ngraph/test/onnx/onnx_editor.cpp b/ngraph/test/onnx/onnx_editor.cpp index b330fbe67a59bd..1e2c1ea23bef96 100644 --- a/ngraph/test/onnx/onnx_editor.cpp +++ b/ngraph/test/onnx/onnx_editor.cpp @@ -15,7 +15,6 @@ //***************************************************************************** #include -#include #include "gtest/gtest.h" From 0e7822f905c2ba3feaa6e8f5da47a793d4568b99 Mon Sep 17 00:00:00 2001 From: tomdol Date: Thu, 11 Feb 2021 06:53:51 -0500 Subject: [PATCH 037/116] Obsolete test removal and cmakelists cleanup in tests --- .../include/onnx_import/editor/editor.hpp | 1 + ngraph/test/CMakeLists.txt | 7 ++----- ngraph/test/onnx/onnx_import_library.cpp | 12 ------------ 3 files changed, 3 insertions(+), 17 deletions(-) diff --git a/ngraph/frontend/onnx_import/include/onnx_import/editor/editor.hpp b/ngraph/frontend/onnx_import/include/onnx_import/editor/editor.hpp index 5cf5b94abb69fa..101bcf520e35de 100644 --- a/ngraph/frontend/onnx_import/include/onnx_import/editor/editor.hpp +++ b/ngraph/frontend/onnx_import/include/onnx_import/editor/editor.hpp @@ -90,6 +90,7 @@ namespace ngraph /// \return A reference to ONNX ModelProto object containing the in-memory model ONNX_NAMESPACE::ModelProto& model() const; + /// \brief Returns a serialized ONNX model, possiblie modified by an instance of editor. std::string model_string() const; /// \brief Returns a list of all inputs of the in-memory model, including initializers. diff --git a/ngraph/test/CMakeLists.txt b/ngraph/test/CMakeLists.txt index aacc74257fecd1..55baa0bad1b8d7 100644 --- a/ngraph/test/CMakeLists.txt +++ b/ngraph/test/CMakeLists.txt @@ -17,8 +17,6 @@ add_definitions("-DSERIALIZED_ZOO=\"${CMAKE_CURRENT_SOURCE_DIR}/models\"") set(NGRAPH_ONNX_NAMESPACE ngraph_onnx) -set(ONNX_LIBRARIES onnx onnx_proto) - add_subdirectory(runtime) if(NOT NGRAPH_UNIT_TEST_ENABLE) @@ -422,9 +420,8 @@ target_link_libraries(unit-test PRIVATE ngraph_test_util # Protobuf-lite does not support parsing files from prototxt format # Since most of the onnx models are stored in this format it have to be disabled if (NGRAPH_ONNX_IMPORT_ENABLE AND NOT NGRAPH_USE_PROTOBUF_LITE) - target_include_directories(unit-test - SYSTEM PRIVATE ${ONNX_INCLUDE_DIR} ${ONNX_PROTO_INCLUDE_DIR} ${Protobuf_INCLUDE_DIRS}) - target_link_libraries(unit-test PRIVATE ${Protobuf_LIBRARIES} ${ONNX_LIBRARIES}) + target_include_directories(unit-test SYSTEM PRIVATE ${ONNX_INCLUDE_DIR}) + target_link_libraries(unit-test PRIVATE onnx_proto) get_target_property(ONNX_IMPORTER_SRC_DIR onnx_importer SOURCE_DIR) target_include_directories(unit-test PRIVATE ${ONNX_IMPORTER_SRC_DIR}/src) diff --git a/ngraph/test/onnx/onnx_import_library.cpp b/ngraph/test/onnx/onnx_import_library.cpp index 593b4bf13ae666..643a584ce68c74 100644 --- a/ngraph/test/onnx/onnx_import_library.cpp +++ b/ngraph/test/onnx/onnx_import_library.cpp @@ -15,8 +15,6 @@ //***************************************************************************** #include -#include "onnx/defs/function.h" -#include "onnx/defs/schema.h" #include "gtest/gtest.h" #include "util/test_control.hpp" @@ -25,16 +23,6 @@ using namespace ngraph; static std::string s_manifest = "${MANIFEST}"; -NGRAPH_TEST(onnx, get_function_op_with_version) -{ - const auto* schema = - ONNX_NAMESPACE::OpSchemaRegistry::Schema("MeanVarianceNormalization", 9, ""); - EXPECT_TRUE(schema); - EXPECT_TRUE(schema->HasFunction()); - auto func = schema->GetFunction(); - EXPECT_EQ(func->name(), "MeanVarianceNormalization"); -} - NGRAPH_TEST(onnx, check_ir_version_support) { // It appears you've changed the ONNX library version used by nGraph. Please update the value From 985ef97382c6cbcdb27f6ae925d8231da38ae778 Mon Sep 17 00:00:00 2001 From: tomdol Date: Thu, 11 Feb 2021 10:25:34 -0500 Subject: [PATCH 038/116] Macos failed, reverting some changes --- ngraph/test/CMakeLists.txt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ngraph/test/CMakeLists.txt b/ngraph/test/CMakeLists.txt index 55baa0bad1b8d7..aacc74257fecd1 100644 --- a/ngraph/test/CMakeLists.txt +++ b/ngraph/test/CMakeLists.txt @@ -17,6 +17,8 @@ add_definitions("-DSERIALIZED_ZOO=\"${CMAKE_CURRENT_SOURCE_DIR}/models\"") set(NGRAPH_ONNX_NAMESPACE ngraph_onnx) +set(ONNX_LIBRARIES onnx onnx_proto) + add_subdirectory(runtime) if(NOT NGRAPH_UNIT_TEST_ENABLE) @@ -420,8 +422,9 @@ target_link_libraries(unit-test PRIVATE ngraph_test_util # Protobuf-lite does not support parsing files from prototxt format # Since most of the onnx models are stored in this format it have to be disabled if (NGRAPH_ONNX_IMPORT_ENABLE AND NOT NGRAPH_USE_PROTOBUF_LITE) - target_include_directories(unit-test SYSTEM PRIVATE ${ONNX_INCLUDE_DIR}) - target_link_libraries(unit-test PRIVATE onnx_proto) + target_include_directories(unit-test + SYSTEM PRIVATE ${ONNX_INCLUDE_DIR} ${ONNX_PROTO_INCLUDE_DIR} ${Protobuf_INCLUDE_DIRS}) + target_link_libraries(unit-test PRIVATE ${Protobuf_LIBRARIES} ${ONNX_LIBRARIES}) get_target_property(ONNX_IMPORTER_SRC_DIR onnx_importer SOURCE_DIR) target_include_directories(unit-test PRIVATE ${ONNX_IMPORTER_SRC_DIR}/src) From 263cd4b21f5cce44be73ee6439f69020898f7caa Mon Sep 17 00:00:00 2001 From: tomdol Date: Thu, 11 Feb 2021 13:51:26 -0500 Subject: [PATCH 039/116] Handle the multiple output consumers UC --- .../editor/detail/subgraph_extraction.hpp | 2 + .../src/editor/detail/subgraph_extraction.cpp | 92 +++++++++++++++--- ...om_tensor_with_multiple_consumers.prototxt | 43 +-------- ..._tensor_with_multiple_consumers_2.prototxt | 74 ++------------- ..._tensor_with_multiple_consumers_3.prototxt | 95 +++++++++++++++++++ ngraph/test/onnx/onnx_editor.cpp | 41 +++++++- 6 files changed, 227 insertions(+), 120 deletions(-) create mode 100644 ngraph/test/models/onnx/model_editor/reference/subgraph__input_edge_from_tensor_with_multiple_consumers_3.prototxt diff --git a/ngraph/frontend/onnx_import/include/onnx_import/editor/detail/subgraph_extraction.hpp b/ngraph/frontend/onnx_import/include/onnx_import/editor/detail/subgraph_extraction.hpp index 27b7a801d33847..a005bb3d1c43d6 100644 --- a/ngraph/frontend/onnx_import/include/onnx_import/editor/detail/subgraph_extraction.hpp +++ b/ngraph/frontend/onnx_import/include/onnx_import/editor/detail/subgraph_extraction.hpp @@ -138,6 +138,8 @@ namespace ngraph // Graph traversal helper: node index -> node inputs (one-to-many) std::unordered_multimap m_node_inputs; + // Number of consumers of all tensors in the graph + std::map m_tensor_consumers; /// \brief Replaces the old input edge with a new one in the helper struct. /// This is used by the output contributors discovery. diff --git a/ngraph/frontend/onnx_import/src/editor/detail/subgraph_extraction.cpp b/ngraph/frontend/onnx_import/src/editor/detail/subgraph_extraction.cpp index 839b960cbe314f..d85a8aecb5f2a0 100644 --- a/ngraph/frontend/onnx_import/src/editor/detail/subgraph_extraction.cpp +++ b/ngraph/frontend/onnx_import/src/editor/detail/subgraph_extraction.cpp @@ -116,20 +116,25 @@ namespace "Could not find an initializer in the graph: '", edge.m_tensor_name); - const auto& initializer = *it; - auto& new_input = *(graph.add_input()); + if (!already_exists(graph.input(), new_input_name)) + { + const auto& initializer = *it; + auto& new_input = *(graph.add_input()); - auto& new_input_tensor_type = *(new_input.mutable_type()->mutable_tensor_type()); - new_input_tensor_type.set_elem_type(initializer.data_type()); + auto& new_input_tensor_type = *(new_input.mutable_type()->mutable_tensor_type()); + new_input_tensor_type.set_elem_type(initializer.data_type()); - auto& new_input_shape = *(new_input_tensor_type.mutable_shape()); - for (const auto initializer_dim : initializer.dims()) - { - auto& new_dim = *(new_input_shape.add_dim()); - new_dim.set_dim_value(initializer_dim); + auto& new_input_shape = *(new_input_tensor_type.mutable_shape()); + for (const auto initializer_dim : initializer.dims()) + { + auto& new_dim = *(new_input_shape.add_dim()); + new_dim.set_dim_value(initializer_dim); + } + + *(new_input.mutable_name()) = new_input_name; } - *(new_input.mutable_name()) = new_input_name; + graph.mutable_initializer()->erase(it); } std::pair append_new_graph_input(ONNX_NAMESPACE::GraphProto& graph, @@ -158,6 +163,7 @@ namespace if (is_graph_initializer(graph, edge.m_tensor_name)) { + // TODO remove the last param? replace_initializer_with_new_input(graph, edge, new_input_name); } else @@ -174,6 +180,51 @@ namespace return {true, InputEdge{edge.m_node_idx, new_input_name}}; } + /// \brief Replaces a node or initializer (consumed by multiple nodes) with a new input + int replace_source_with_new_input(ONNX_NAMESPACE::GraphProto& graph, const InputEdge& edge) + { + if (already_exists(graph.input(), edge.m_tensor_name) && + !is_graph_initializer(graph, edge.m_tensor_name)) + { + // happens when a user specifies multiple input edges pointing to the same tensor name + return -1; + } + + if (is_graph_initializer(graph, edge.m_tensor_name)) + { + // replace an initializer with a new input but maintain the original name + // TODO remove the last param? + replace_initializer_with_new_input(graph, edge, edge.m_tensor_name); + } + else + { + auto& new_input = *(graph.add_input()); + // copy the intermediate tensor properties to the newly created input + new_input.MergeFrom(find_tensor_descriptor(graph, edge.m_tensor_name)); + + const auto source_node_idx = + find_source_node_idx(graph, edge.m_node_idx, edge.m_tensor_name); + auto& source_node = *(graph.mutable_node(source_node_idx)); + auto& node_outputs = *source_node.mutable_output(); + auto target_output = + std::find(std::begin(node_outputs), std::end(node_outputs), edge.m_tensor_name); + + NGRAPH_CHECK(target_output != std::end(node_outputs), + "Output '", + edge.m_tensor_name, + "' not found in the outputs of node ", + source_node_idx, + ". Cannot remove the output from this node."); + + // stop produsing tensor "edge.m_tensor_name" by the source node of the processed edge + *target_output = ""; + + return source_node_idx; + } + + return -1; + } + void append_new_graph_output(ONNX_NAMESPACE::GraphProto& graph, const OutputEdge& edge) { if (already_exists(graph.output(), edge.m_tensor_name)) @@ -254,6 +305,7 @@ SubgraphExtractor::SubgraphExtractor(ONNX_NAMESPACE::GraphProto& graph) for (const auto& node_input : graph.node(i).input()) { m_node_inputs.insert({i, node_input}); + m_tensor_consumers[node_input] += 1; } } } @@ -264,11 +316,23 @@ void SubgraphExtractor::add_new_inputs(const std::vector& new_inputs) { validate_node_index(m_onnx_graph, edge_to_replace.m_node_idx); - const auto& new_edge = append_new_graph_input(m_onnx_graph, edge_to_replace); - if (new_edge.first) + if (m_tensor_consumers[edge_to_replace.m_tensor_name] > 1) { - // TODO: all nodes with this input should be updated? additional edges creation uc - replace_input_edge(edge_to_replace, new_edge.second); + int idx = replace_source_with_new_input(m_onnx_graph, edge_to_replace); + if (idx != -1) + { + // if a node was replaced with an input, remove input edges from a helper multimap + // for this node because it won't end up in the target subgraph + m_node_inputs.erase(idx); + } + } + else + { + const auto& new_edge = append_new_graph_input(m_onnx_graph, edge_to_replace); + if (new_edge.first) + { + replace_input_edge(edge_to_replace, new_edge.second); + } } } } diff --git a/ngraph/test/models/onnx/model_editor/reference/subgraph__input_edge_from_tensor_with_multiple_consumers.prototxt b/ngraph/test/models/onnx/model_editor/reference/subgraph__input_edge_from_tensor_with_multiple_consumers.prototxt index 9ad9a9c9331906..e68c95d134bf03 100644 --- a/ngraph/test/models/onnx/model_editor/reference/subgraph__input_edge_from_tensor_with_multiple_consumers.prototxt +++ b/ngraph/test/models/onnx/model_editor/reference/subgraph__input_edge_from_tensor_with_multiple_consumers.prototxt @@ -2,12 +2,7 @@ ir_version: 7 producer_name: "tomdol" graph { node { - input: "in1" - output: "relu1" - op_type: "Relu" - } - node { - input: "add1:relu1" + input: "relu1" input: "in2" output: "add1" op_type: "Add" @@ -42,7 +37,7 @@ graph { } } node { - input: "mul1:relu1" + input: "relu1" input: "split1" output: "mul1" op_type: "Mul" @@ -57,22 +52,6 @@ graph { float_data: 1 name: "in4" } - input { - name: "in1" - type { - tensor_type { - elem_type: 1 - shape { - dim { - dim_value: 2 - } - dim { - dim_value: 2 - } - } - } - } - } input { name: "in2" type { @@ -128,23 +107,7 @@ graph { } } input { - name: "add1:relu1" - type { - tensor_type { - elem_type: 1 - shape { - dim { - dim_value: 2 - } - dim { - dim_value: 2 - } - } - } - } - } - input { - name: "mul1:relu1" + name: "relu1" type { tensor_type { elem_type: 1 diff --git a/ngraph/test/models/onnx/model_editor/reference/subgraph__input_edge_from_tensor_with_multiple_consumers_2.prototxt b/ngraph/test/models/onnx/model_editor/reference/subgraph__input_edge_from_tensor_with_multiple_consumers_2.prototxt index 9ad9a9c9331906..405c9fdd0d848d 100644 --- a/ngraph/test/models/onnx/model_editor/reference/subgraph__input_edge_from_tensor_with_multiple_consumers_2.prototxt +++ b/ngraph/test/models/onnx/model_editor/reference/subgraph__input_edge_from_tensor_with_multiple_consumers_2.prototxt @@ -1,17 +1,6 @@ ir_version: 7 producer_name: "tomdol" graph { - node { - input: "in1" - output: "relu1" - op_type: "Relu" - } - node { - input: "add1:relu1" - input: "in2" - output: "add1" - op_type: "Add" - } node { input: "in3" input: "in4" @@ -30,23 +19,6 @@ graph { output: "mul2" op_type: "Mul" } - node { - input: "add2" - output: "split1" - output: "split2" - op_type: "Split" - attribute { - name: "axis" - i: 1 - type: INT - } - } - node { - input: "mul1:relu1" - input: "split1" - output: "mul1" - op_type: "Mul" - } name: "subgraph_extraction_testing" initializer { dims: 1 @@ -57,32 +29,6 @@ graph { float_data: 1 name: "in4" } - input { - name: "in1" - type { - tensor_type { - elem_type: 1 - shape { - dim { - dim_value: 2 - } - dim { - dim_value: 2 - } - } - } - } - } - input { - name: "in2" - type { - tensor_type { - elem_type: 1 - shape { - } - } - } - } input { name: "in3" type { @@ -128,7 +74,7 @@ graph { } } input { - name: "add1:relu1" + name: "relu1" type { tensor_type { elem_type: 1 @@ -144,7 +90,7 @@ graph { } } input { - name: "mul1:relu1" + name: "add1" type { tensor_type { elem_type: 1 @@ -160,11 +106,17 @@ graph { } } output { - name: "mul1" + name: "mul2" type { tensor_type { elem_type: 1 shape { + dim { + dim_value: 1 + } + dim { + dim_value: 1 + } dim { dim_value: 2 } @@ -176,17 +128,11 @@ graph { } } output { - name: "mul2" + name: "add2" type { tensor_type { elem_type: 1 shape { - dim { - dim_value: 1 - } - dim { - dim_value: 1 - } dim { dim_value: 2 } diff --git a/ngraph/test/models/onnx/model_editor/reference/subgraph__input_edge_from_tensor_with_multiple_consumers_3.prototxt b/ngraph/test/models/onnx/model_editor/reference/subgraph__input_edge_from_tensor_with_multiple_consumers_3.prototxt new file mode 100644 index 00000000000000..209b4bd32ece8e --- /dev/null +++ b/ngraph/test/models/onnx/model_editor/reference/subgraph__input_edge_from_tensor_with_multiple_consumers_3.prototxt @@ -0,0 +1,95 @@ +ir_version: 7 +producer_name: "tomdol" +graph { + node { + input: "relu1" + input: "in2" + output: "add1" + op_type: "Add" + } + node { + input: "relu1" + input: "add1" + output: "add2" + op_type: "Add" + } + node { + input: "add2" + output: "split1" + output: "split2" + op_type: "Split" + attribute { + name: "axis" + i: 1 + type: INT + } + } + node { + input: "relu1" + input: "split1" + output: "mul1" + op_type: "Mul" + } + name: "subgraph_extraction_testing" + input { + name: "in2" + type { + tensor_type { + elem_type: 1 + shape { + } + } + } + } + input { + name: "relu1" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 2 + } + dim { + dim_value: 2 + } + } + } + } + } + output { + name: "mul1" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 2 + } + dim { + dim_value: 2 + } + } + } + } + } + output { + name: "split2" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 2 + } + dim { + dim_value: 1 + } + } + } + } + } +} +opset_import { + version: 13 +} diff --git a/ngraph/test/onnx/onnx_editor.cpp b/ngraph/test/onnx/onnx_editor.cpp index 1e2c1ea23bef96..43173cedad9287 100644 --- a/ngraph/test/onnx/onnx_editor.cpp +++ b/ngraph/test/onnx/onnx_editor.cpp @@ -521,8 +521,8 @@ NGRAPH_TEST(onnx_editor, subgraph__input_edge_from_tensor_with_multiple_consumer onnx_import::ONNXModelEditor editor{file_util::path_join( SERIALIZED_ZOO, "onnx/model_editor/subgraph_extraction_tests.prototxt")}; - editor.cut_graph_fragment({{InputEdge{1, "relu1"}, InputEdge{6, "relu1"}}}, - {{OutputEdge{6, "mul1"}, OutputEdge{4, "mul2"}}}); + editor.cut_graph_fragment({{InputEdge{3, "relu1"}, InputEdge{3, "add1"}}}, + {{OutputEdge{3, "add2"}, OutputEdge{4, "mul2"}}}); const auto ref_model = file_util::path_join(SERIALIZED_ZOO, @@ -534,6 +534,43 @@ NGRAPH_TEST(onnx_editor, subgraph__input_edge_from_tensor_with_multiple_consumer EXPECT_TRUE(result.is_ok) << result.error_message; } +NGRAPH_TEST(onnx_editor, subgraph__input_edge_from_tensor_with_multiple_consumers_3) +{ + onnx_import::ONNXModelEditor editor{file_util::path_join( + SERIALIZED_ZOO, "onnx/model_editor/subgraph_extraction_tests.prototxt")}; + + editor.cut_graph_fragment({{InputEdge{3, "relu1"}, InputEdge{6, "relu1"}}}, + {{OutputEdge{6, "mul1"}, OutputEdge{5, "split2"}}}); + + const auto ref_model = + file_util::path_join(SERIALIZED_ZOO, + "onnx/model_editor/reference/" + "subgraph__input_edge_from_tensor_with_multiple_consumers_3.prototxt"); + + const auto result = compare_onnx_models(editor.model_string(), ref_model); + + EXPECT_TRUE(result.is_ok) << result.error_message; +} + +NGRAPH_TEST(onnx_editor, subgraph__input_edge_from_tensor_with_multiple_consumers_4) +{ + onnx_import::ONNXModelEditor editor{file_util::path_join( + SERIALIZED_ZOO, "onnx/model_editor/subgraph_extraction_tests.prototxt")}; + + editor.cut_graph_fragment({{InputEdge{3, "relu1"}}}, + {{OutputEdge{6, "mul1"}, OutputEdge{5, "split2"}}}); + + // expected to behave the same way as the test above + const auto ref_model = + file_util::path_join(SERIALIZED_ZOO, + "onnx/model_editor/reference/" + "subgraph__input_edge_from_tensor_with_multiple_consumers_3.prototxt"); + + const auto result = compare_onnx_models(editor.model_string(), ref_model); + + EXPECT_TRUE(result.is_ok) << result.error_message; +} + NGRAPH_TEST(onnx_editor, subgraph__invalid_edge_idx) { const auto model_path = From 1f18183f0614e02860c6bd18a5989b247e1d1bf8 Mon Sep 17 00:00:00 2001 From: tomdol Date: Thu, 11 Feb 2021 14:04:47 -0500 Subject: [PATCH 040/116] Keep the tensor name when replacing an initializer --- .../src/editor/detail/subgraph_extraction.cpp | 23 ++++++++----------- ..._initializer_to_input_replacement.prototxt | 4 ++-- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/ngraph/frontend/onnx_import/src/editor/detail/subgraph_extraction.cpp b/ngraph/frontend/onnx_import/src/editor/detail/subgraph_extraction.cpp index d85a8aecb5f2a0..f81f92e9e9ab29 100644 --- a/ngraph/frontend/onnx_import/src/editor/detail/subgraph_extraction.cpp +++ b/ngraph/frontend/onnx_import/src/editor/detail/subgraph_extraction.cpp @@ -105,8 +105,7 @@ namespace } void replace_initializer_with_new_input(ONNX_NAMESPACE::GraphProto& graph, - const InputEdge& edge, - const std::string& new_input_name) + const InputEdge& edge) { const auto it = std::find_if(std::begin(graph.initializer()), std::end(graph.initializer()), @@ -116,7 +115,7 @@ namespace "Could not find an initializer in the graph: '", edge.m_tensor_name); - if (!already_exists(graph.input(), new_input_name)) + if (!already_exists(graph.input(), edge.m_tensor_name)) { const auto& initializer = *it; auto& new_input = *(graph.add_input()); @@ -131,7 +130,7 @@ namespace new_dim.set_dim_value(initializer_dim); } - *(new_input.mutable_name()) = new_input_name; + *(new_input.mutable_name()) = edge.m_tensor_name; } graph.mutable_initializer()->erase(it); @@ -163,8 +162,8 @@ namespace if (is_graph_initializer(graph, edge.m_tensor_name)) { - // TODO remove the last param? - replace_initializer_with_new_input(graph, edge, new_input_name); + replace_initializer_with_new_input(graph, edge); + return {false, edge}; } else { @@ -172,12 +171,10 @@ namespace // copy the intermediate tensor properties to the newly created input new_input.MergeFrom(find_tensor_descriptor(graph, edge.m_tensor_name)); *(new_input.mutable_name()) = new_input_name; + // attach the new graph input to the target node's input + *target_input = new_input_name; + return {true, InputEdge{edge.m_node_idx, new_input_name}}; } - - // attach the new graph input to the target node's input - *target_input = new_input_name; - - return {true, InputEdge{edge.m_node_idx, new_input_name}}; } /// \brief Replaces a node or initializer (consumed by multiple nodes) with a new input @@ -192,9 +189,7 @@ namespace if (is_graph_initializer(graph, edge.m_tensor_name)) { - // replace an initializer with a new input but maintain the original name - // TODO remove the last param? - replace_initializer_with_new_input(graph, edge, edge.m_tensor_name); + replace_initializer_with_new_input(graph, edge); } else { diff --git a/ngraph/test/models/onnx/model_editor/reference/subgraph__initializer_to_input_replacement.prototxt b/ngraph/test/models/onnx/model_editor/reference/subgraph__initializer_to_input_replacement.prototxt index 62062044de7e70..145580668c1d77 100644 --- a/ngraph/test/models/onnx/model_editor/reference/subgraph__initializer_to_input_replacement.prototxt +++ b/ngraph/test/models/onnx/model_editor/reference/subgraph__initializer_to_input_replacement.prototxt @@ -6,7 +6,7 @@ graph { node { input: "data_0" input: "conv1/7x7_s2_w_0" - input: "conv1/7x7_s2_1:conv1/7x7_s2_b_0" + input: "conv1/7x7_s2_b_0" output: "conv1/7x7_s2_1" name: "" op_type: "Conv" @@ -79,7 +79,7 @@ graph { } input { - name: "conv1/7x7_s2_1:conv1/7x7_s2_b_0" + name: "conv1/7x7_s2_b_0" type { tensor_type { elem_type: 1 From 9972ac08409cf593876c576c5b6f38395070e80b Mon Sep 17 00:00:00 2001 From: tomdol Date: Thu, 11 Feb 2021 14:16:26 -0500 Subject: [PATCH 041/116] Cutting a graph with multiple consumers of inputs and initializers --- ...le_consumers_of_graph_input_relu2.prototxt | 100 ++++++++++++++++++ .../subgraph_extraction_tests_2.prototxt | 95 +++++++++++++++++ ngraph/test/onnx/onnx_editor.cpp | 17 +++ 3 files changed, 212 insertions(+) create mode 100644 ngraph/test/models/onnx/model_editor/reference/subgraph__multiple_consumers_of_graph_input_relu2.prototxt create mode 100644 ngraph/test/models/onnx/model_editor/subgraph_extraction_tests_2.prototxt diff --git a/ngraph/test/models/onnx/model_editor/reference/subgraph__multiple_consumers_of_graph_input_relu2.prototxt b/ngraph/test/models/onnx/model_editor/reference/subgraph__multiple_consumers_of_graph_input_relu2.prototxt new file mode 100644 index 00000000000000..962bac303b0779 --- /dev/null +++ b/ngraph/test/models/onnx/model_editor/reference/subgraph__multiple_consumers_of_graph_input_relu2.prototxt @@ -0,0 +1,100 @@ +ir_version: 7 +producer_name: "tomdol" +graph { + node { + input: "in1" + output: "relu1" + op_type: "Relu" + } + node { + input: "in2" + output: "relu3" + op_type: "Relu" + } + node { + input: "in2" + output: "relu4" + op_type: "Relu" + } + node { + input: "relu1" + input: "relu2" + output: "add1" + op_type: "Add" + } + node { + input: "relu2" + input: "relu3" + output: "add2" + op_type: "Add" + } + name: "subgraph_extraction_testing" + initializer { + data_type: 1 + float_data: 1 + name: "in2" + } + input { + name: "in1" + type { + tensor_type { + elem_type: 1 + shape { + } + } + } + } + input { + name: "in2" + type { + tensor_type { + elem_type: 1 + shape { + } + } + } + } + input { + name: "relu2" + type { + tensor_type { + elem_type: 1 + shape { + } + } + } + } + output { + name: "add1" + type { + tensor_type { + elem_type: 1 + shape { + } + } + } + } + output { + name: "add2" + type { + tensor_type { + elem_type: 1 + shape { + } + } + } + } + output { + name: "relu4" + type { + tensor_type { + elem_type: 1 + shape { + } + } + } + } +} +opset_import { + version: 13 +} diff --git a/ngraph/test/models/onnx/model_editor/subgraph_extraction_tests_2.prototxt b/ngraph/test/models/onnx/model_editor/subgraph_extraction_tests_2.prototxt new file mode 100644 index 00000000000000..9d721dd8324f50 --- /dev/null +++ b/ngraph/test/models/onnx/model_editor/subgraph_extraction_tests_2.prototxt @@ -0,0 +1,95 @@ +ir_version: 7 +producer_name: "tomdol" +graph { + node { + input: "in1" + output: "relu1" + op_type: "Relu" + } + node { + input: "in1" + output: "relu2" + op_type: "Relu" + } + node { + input: "in2" + output: "relu3" + op_type: "Relu" + } + node { + input: "in2" + output: "relu4" + op_type: "Relu" + } + node { + input: "relu1" + input: "relu2" + output: "add1" + op_type: "Add" + } + node { + input: "relu2" + input: "relu3" + output: "add2" + op_type: "Add" + } + name: "subgraph_extraction_testing" + initializer { + data_type: 1 + float_data: 1 + name: "in2" + } + input { + name: "in1" + type { + tensor_type { + elem_type: 1 + shape { + } + } + } + } + input { + name: "in2" + type { + tensor_type { + elem_type: 1 + shape { + } + } + } + } + output { + name: "add1" + type { + tensor_type { + elem_type: 1 + shape { + } + } + } + } + output { + name: "add2" + type { + tensor_type { + elem_type: 1 + shape { + } + } + } + } + output { + name: "relu4" + type { + tensor_type { + elem_type: 1 + shape { + } + } + } + } +} +opset_import { + version: 13 +} diff --git a/ngraph/test/onnx/onnx_editor.cpp b/ngraph/test/onnx/onnx_editor.cpp index 43173cedad9287..44d9235478ad36 100644 --- a/ngraph/test/onnx/onnx_editor.cpp +++ b/ngraph/test/onnx/onnx_editor.cpp @@ -571,6 +571,23 @@ NGRAPH_TEST(onnx_editor, subgraph__input_edge_from_tensor_with_multiple_consumer EXPECT_TRUE(result.is_ok) << result.error_message; } +NGRAPH_TEST(onnx_editor, subgraph__multiple_consumers_of_graph_input_relu2) +{ + onnx_import::ONNXModelEditor editor{file_util::path_join( + SERIALIZED_ZOO, "onnx/model_editor/subgraph_extraction_tests_2.prototxt")}; + + editor.cut_graph_fragment({{InputEdge{4, "relu2"}}}, {}); + + const auto ref_model = + file_util::path_join(SERIALIZED_ZOO, + "onnx/model_editor/reference/" + "subgraph__multiple_consumers_of_graph_input_relu2.prototxt"); + + const auto result = compare_onnx_models(editor.model_string(), ref_model); + + EXPECT_TRUE(result.is_ok) << result.error_message; +} + NGRAPH_TEST(onnx_editor, subgraph__invalid_edge_idx) { const auto model_path = From a39cbd0fdfb21c1d50f9220c84070e43041307f1 Mon Sep 17 00:00:00 2001 From: tomdol Date: Thu, 11 Feb 2021 14:26:15 -0500 Subject: [PATCH 042/116] Subgraph extraction with multiple initializer consumers --- ...le_consumers_of_graph_initializer.prototxt | 90 ++++++++++++++++++ ..._graph_initializer_relu2_and_init.prototxt | 95 +++++++++++++++++++ ngraph/test/onnx/onnx_editor.cpp | 52 ++++++++++ 3 files changed, 237 insertions(+) create mode 100644 ngraph/test/models/onnx/model_editor/reference/subgraph__multiple_consumers_of_graph_initializer.prototxt create mode 100644 ngraph/test/models/onnx/model_editor/reference/subgraph__multiple_consumers_of_graph_initializer_relu2_and_init.prototxt diff --git a/ngraph/test/models/onnx/model_editor/reference/subgraph__multiple_consumers_of_graph_initializer.prototxt b/ngraph/test/models/onnx/model_editor/reference/subgraph__multiple_consumers_of_graph_initializer.prototxt new file mode 100644 index 00000000000000..b237e23b63e2aa --- /dev/null +++ b/ngraph/test/models/onnx/model_editor/reference/subgraph__multiple_consumers_of_graph_initializer.prototxt @@ -0,0 +1,90 @@ +ir_version: 7 +producer_name: "tomdol" +graph { + node { + input: "in1" + output: "relu1" + op_type: "Relu" + } + node { + input: "in1" + output: "relu2" + op_type: "Relu" + } + node { + input: "in2" + output: "relu3" + op_type: "Relu" + } + node { + input: "in2" + output: "relu4" + op_type: "Relu" + } + node { + input: "relu1" + input: "relu2" + output: "add1" + op_type: "Add" + } + node { + input: "relu2" + input: "relu3" + output: "add2" + op_type: "Add" + } + name: "subgraph_extraction_testing" + input { + name: "in1" + type { + tensor_type { + elem_type: 1 + shape { + } + } + } + } + input { + name: "in2" + type { + tensor_type { + elem_type: 1 + shape { + } + } + } + } + output { + name: "add1" + type { + tensor_type { + elem_type: 1 + shape { + } + } + } + } + output { + name: "add2" + type { + tensor_type { + elem_type: 1 + shape { + } + } + } + } + output { + name: "relu4" + type { + tensor_type { + elem_type: 1 + shape { + } + } + } + } +} +opset_import { + version: 13 +} diff --git a/ngraph/test/models/onnx/model_editor/reference/subgraph__multiple_consumers_of_graph_initializer_relu2_and_init.prototxt b/ngraph/test/models/onnx/model_editor/reference/subgraph__multiple_consumers_of_graph_initializer_relu2_and_init.prototxt new file mode 100644 index 00000000000000..ca4d93f203d382 --- /dev/null +++ b/ngraph/test/models/onnx/model_editor/reference/subgraph__multiple_consumers_of_graph_initializer_relu2_and_init.prototxt @@ -0,0 +1,95 @@ +ir_version: 7 +producer_name: "tomdol" +graph { + node { + input: "in1" + output: "relu1" + op_type: "Relu" + } + node { + input: "in2" + output: "relu3" + op_type: "Relu" + } + node { + input: "in2" + output: "relu4" + op_type: "Relu" + } + node { + input: "relu1" + input: "relu2" + output: "add1" + op_type: "Add" + } + node { + input: "relu2" + input: "relu3" + output: "add2" + op_type: "Add" + } + name: "subgraph_extraction_testing" + input { + name: "in1" + type { + tensor_type { + elem_type: 1 + shape { + } + } + } + } + input { + name: "in2" + type { + tensor_type { + elem_type: 1 + shape { + } + } + } + } + input { + name: "relu2" + type { + tensor_type { + elem_type: 1 + shape { + } + } + } + } + output { + name: "add1" + type { + tensor_type { + elem_type: 1 + shape { + } + } + } + } + output { + name: "add2" + type { + tensor_type { + elem_type: 1 + shape { + } + } + } + } + output { + name: "relu4" + type { + tensor_type { + elem_type: 1 + shape { + } + } + } + } +} +opset_import { + version: 13 +} diff --git a/ngraph/test/onnx/onnx_editor.cpp b/ngraph/test/onnx/onnx_editor.cpp index 44d9235478ad36..9fd56c03ac3450 100644 --- a/ngraph/test/onnx/onnx_editor.cpp +++ b/ngraph/test/onnx/onnx_editor.cpp @@ -588,6 +588,58 @@ NGRAPH_TEST(onnx_editor, subgraph__multiple_consumers_of_graph_input_relu2) EXPECT_TRUE(result.is_ok) << result.error_message; } +NGRAPH_TEST(onnx_editor, subgraph__multiple_consumers_of_graph_initializer) +{ + onnx_import::ONNXModelEditor editor{file_util::path_join( + SERIALIZED_ZOO, "onnx/model_editor/subgraph_extraction_tests_2.prototxt")}; + + editor.cut_graph_fragment({{InputEdge{2, "in2"}}}, {}); + + const auto ref_model = + file_util::path_join(SERIALIZED_ZOO, + "onnx/model_editor/reference/" + "subgraph__multiple_consumers_of_graph_initializer.prototxt"); + + const auto result = compare_onnx_models(editor.model_string(), ref_model); + + EXPECT_TRUE(result.is_ok) << result.error_message; +} + +NGRAPH_TEST(onnx_editor, subgraph__multiple_consumers_of_graph_initializer_2) +{ + onnx_import::ONNXModelEditor editor{file_util::path_join( + SERIALIZED_ZOO, "onnx/model_editor/subgraph_extraction_tests_2.prototxt")}; + + editor.cut_graph_fragment({{InputEdge{2, "in2"}, InputEdge{3, "in2"}}}, {}); + + // same as above + const auto ref_model = + file_util::path_join(SERIALIZED_ZOO, + "onnx/model_editor/reference/" + "subgraph__multiple_consumers_of_graph_initializer.prototxt"); + + const auto result = compare_onnx_models(editor.model_string(), ref_model); + + EXPECT_TRUE(result.is_ok) << result.error_message; +} + +NGRAPH_TEST(onnx_editor, subgraph__multiple_consumers_of_graph_initializer_relu2_and_init) +{ + onnx_import::ONNXModelEditor editor{file_util::path_join( + SERIALIZED_ZOO, "onnx/model_editor/subgraph_extraction_tests_2.prototxt")}; + + editor.cut_graph_fragment({{InputEdge{5, "relu2"}, InputEdge{3, "in2"}}}, {}); + + const auto ref_model = file_util::path_join( + SERIALIZED_ZOO, + "onnx/model_editor/reference/" + "subgraph__multiple_consumers_of_graph_initializer_relu2_and_init.prototxt"); + + const auto result = compare_onnx_models(editor.model_string(), ref_model); + + EXPECT_TRUE(result.is_ok) << result.error_message; +} + NGRAPH_TEST(onnx_editor, subgraph__invalid_edge_idx) { const auto model_path = From 326354808861d48c2079acedd6abd4f5fc58af5f Mon Sep 17 00:00:00 2001 From: "Lyalin, Sergey" Date: Wed, 17 Feb 2021 09:36:51 +0300 Subject: [PATCH 043/116] Now calling onnx_import through FE API placehodler. Keep pipeline functional w/o major code migration to the new API --- model-optimizer/mo/pipeline/unified.py | 14 +++- ngraph/frontend/CMakeLists.txt | 1 + ngraph/frontend/generic/CMakeLists.txt | 77 +++++++++++++++++++ .../frontend_manager/frontend_manager.hpp | 63 +++++++++++++++ .../frontend/generic/src/frontend_manager.cpp | 77 +++++++++++++++++++ ngraph/python/CMakeLists.txt | 3 +- ngraph/python/src/ngraph/__init__.py | 3 + ngraph/python/src/ngraph/impl/__init__.py | 3 + .../python/src/pyngraph/frontend_manager.cpp | 52 +++++++++++++ .../python/src/pyngraph/frontend_manager.hpp | 25 ++++++ ngraph/python/src/pyngraph/pyngraph.cpp | 4 + ngraph/test/CMakeLists.txt | 2 + 12 files changed, 321 insertions(+), 3 deletions(-) create mode 100644 ngraph/frontend/generic/CMakeLists.txt create mode 100644 ngraph/frontend/generic/include/frontend_manager/frontend_manager.hpp create mode 100644 ngraph/frontend/generic/src/frontend_manager.cpp create mode 100644 ngraph/python/src/pyngraph/frontend_manager.cpp create mode 100644 ngraph/python/src/pyngraph/frontend_manager.hpp diff --git a/model-optimizer/mo/pipeline/unified.py b/model-optimizer/mo/pipeline/unified.py index da233912eefd0d..b9a5dcd50d7214 100644 --- a/model-optimizer/mo/pipeline/unified.py +++ b/model-optimizer/mo/pipeline/unified.py @@ -37,9 +37,19 @@ def unified_pipeline(argv: argparse.Namespace): def moc_pipeline(argv: argparse.Namespace): from openvino.inference_engine import IECore - import openvino + from openvino.inference_engine import IENetwork + import ngraph as ng + print('ngrph.dir = ' + str(dir(ng))) + from ngraph import FrontEndManager ie = IECore() - network = ie.read_network(model=argv.input_model) + fem = FrontEndManager() + print('fem.availableFrontEnds: ' + str(fem.availableFrontEnds())) + fe = fem.loadByFramework('onnx') + print(fe) + inputModel = fe.load(argv.input_model) + nGraphModel = fe.convert(inputModel) + network = ng.function_to_cnn(nGraphModel) + #network = ie.read_network(model=argv.input_model) # Wrap nGraph network to Graph for smoothly pass through the legacy code in MO. # This trick doesn't mean that we will hold Graph forever as a wrapper, it is derived from diff --git a/ngraph/frontend/CMakeLists.txt b/ngraph/frontend/CMakeLists.txt index 598019c77075d3..6479a7f0fd7d51 100644 --- a/ngraph/frontend/CMakeLists.txt +++ b/ngraph/frontend/CMakeLists.txt @@ -16,4 +16,5 @@ if (NGRAPH_ONNX_IMPORT_ENABLE) add_subdirectory(onnx_import) + add_subdirectory(generic) endif() diff --git a/ngraph/frontend/generic/CMakeLists.txt b/ngraph/frontend/generic/CMakeLists.txt new file mode 100644 index 00000000000000..f775b43925db0f --- /dev/null +++ b/ngraph/frontend/generic/CMakeLists.txt @@ -0,0 +1,77 @@ +# ****************************************************************************** +# Copyright 2017-2021 Intel Corporation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ****************************************************************************** + +file(GLOB_RECURSE LIBRARY_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp) +file(GLOB_RECURSE LIBRARY_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/src/*.hpp) +file(GLOB_RECURSE LIBRARY_PUBLIC_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/include/*.hpp) + +set(FRONTEND_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include) + +# Create named folders for the sources within the .vcproj +# Empty name lists them directly under the .vcproj + +source_group("src" FILES ${LIBRARY_SRC}) +source_group("include" FILES ${LIBRARY_HEADERS}) +source_group("public include" FILES ${LIBRARY_PUBLIC_HEADERS}) + +# Create shared library +add_library(frontend_manager SHARED ${LIBRARY_SRC} ${LIBRARY_HEADERS} ${LIBRARY_PUBLIC_HEADERS}) +add_library(ngraph::frontend_manager ALIAS frontend_manager) + +target_include_directories(frontend_manager PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../onnx_import/include) +MESSAGE("HERE4: " ${CMAKE_CURRENT_SOURCE_DIR}) + +if(COMMAND ie_add_vs_version_file) + ie_add_vs_version_file(NAME frontend_manager + FILEDESCRIPTION "Manager of OpenVINO nGraph Front Ends") +endif() + +# TODO: Add other frontends to the list of dependencies temporary; in the produce version they should be discovered +# TODO: in runtime. +target_link_libraries(frontend_manager PRIVATE onnx_importer PUBLIC ngraph) + +set(FRONTEND_INSTALL_INCLUDE "${NGRAPH_INSTALL_INCLUDE}/ngraph/frontend/generic") +target_include_directories(frontend_manager SYSTEM PUBLIC $ + $ ${ONNX_IMPORT_INCLUDE_DIR}) +target_include_directories(frontend_manager SYSTEM PRIVATE ${NGRAPH_INCLUDE_PATH} ${ONNX_IMPORT_INCLUDE_PATH} ${ONNX_IMPORT_INCLUDE_DIR} + ${FRONTEND_INCLUDE_DIR} ) + +target_include_directories(frontend_manager PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src ${ONNX_IMPORT_INCLUDE_DIR}) + +# TODO: Consider to remove the following block (inherited from onnx_import just in case). +if (CMAKE_CXX_COMPILER_ID MATCHES "^(Apple)?Clang$") + target_compile_options(frontend_manager PRIVATE -Wno-undef -Wno-reserved-id-macro -Wno-switch-enum + -Wno-invalid-offsetof -Wno-shorten-64-to-32 -Wno-unused-macros -Wno-missing-variable-declarations + -Wno-unused-private-field -Wno-shadow -Wno-deprecated PUBLIC -Wno-undefined-func-template) +endif() + +install(TARGETS frontend_manager EXPORT ngraphTargets + RUNTIME DESTINATION ${NGRAPH_INSTALL_LIB} COMPONENT ngraph + ARCHIVE DESTINATION ${NGRAPH_INSTALL_LIB} COMPONENT ngraph + LIBRARY DESTINATION ${NGRAPH_INSTALL_LIB} COMPONENT ngraph) + +install(DIRECTORY ${FRONTEND_IMPORT_INCLUDE_DIR}/frontend_manager + DESTINATION ${FRONTEND_INSTALL_INCLUDE} + COMPONENT ngraph + FILES_MATCHING + PATTERN "*.hpp" + PATTERN "*.h" +) + + +if (NGRAPH_EXPORT_TARGETS_ENABLE) + export(TARGETS frontend_manager NAMESPACE ngraph:: APPEND FILE "${NGRAPH_TARGETS_FILE}") +endif() diff --git a/ngraph/frontend/generic/include/frontend_manager/frontend_manager.hpp b/ngraph/frontend/generic/include/frontend_manager/frontend_manager.hpp new file mode 100644 index 00000000000000..eae42826463964 --- /dev/null +++ b/ngraph/frontend/generic/include/frontend_manager/frontend_manager.hpp @@ -0,0 +1,63 @@ +//***************************************************************************** +// Copyright 2017-2021 Intel Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//***************************************************************************** + +#include +#include +#include "ngraph/function.hpp" +#include "ngraph/visibility.hpp" + +namespace ngraph +{ + namespace frontend + { + class NGRAPH_API Place + { + public: + + typedef std::shared_ptr Ptr; + + }; + + class NGRAPH_API InputModel + { + public: + + typedef std::shared_ptr Ptr; + + virtual std::vector getInputs () const = 0; + virtual std::vector getOutputs () const = 0; + }; + + class NGRAPH_API FrontEnd + { + public: + typedef std::shared_ptr Ptr; + + virtual InputModel::Ptr load (const std::string& path) const = 0; + virtual std::shared_ptr convert (InputModel::Ptr model) const = 0; + }; + + class NGRAPH_API FrontEndManager + { + public: + FrontEndManager () {} + FrontEnd::Ptr loadByFramework (const std::string& framework); + FrontEnd::Ptr loadByModel (const std::string& path); + std::vector availableFrontEnds () const; + }; + } // namespace frontend + +} // namespace ngraph diff --git a/ngraph/frontend/generic/src/frontend_manager.cpp b/ngraph/frontend/generic/src/frontend_manager.cpp new file mode 100644 index 00000000000000..311cfd80f4dc92 --- /dev/null +++ b/ngraph/frontend/generic/src/frontend_manager.cpp @@ -0,0 +1,77 @@ +//***************************************************************************** +// Copyright 2017-2021 Intel Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//***************************************************************************** + +#include +#include "onnx_import/onnx.hpp" +#include "onnx_import/editor/editor.hpp" +#include "frontend_manager/frontend_manager.hpp" + +namespace ngraph +{ + namespace frontend + { + class InputModelONNX : public InputModel + { + public: + onnx_import::ONNXModelEditor editor; + + InputModelONNX (const std::string& model_path) : editor(model_path) {} + + virtual std::vector getInputs () const { + throw ngraph::ngraph_error("getInputs is not supported for InputModelONNX"); + } + + virtual std::vector getOutputs () const { + throw ngraph::ngraph_error("getOutputs is not supported for InputModelONNX"); + } + }; + + class FrontEndONNX : public FrontEnd + { + public: + + FrontEndONNX () + { + } + + virtual InputModel::Ptr load (const std::string& path) const { + return std::make_shared(path); + } + + virtual std::shared_ptr convert (InputModel::Ptr model) const { + return import_onnx_model(std::dynamic_pointer_cast(model)->editor); + } + }; + + + FrontEnd::Ptr FrontEndManager::loadByFramework (const std::string& framework) + { + NGRAPH_CHECK(framework == "onnx"); + return std::make_shared(); + } + + FrontEnd::Ptr FrontEndManager::loadByModel (const std::string& path) + { + return loadByFramework("onnx"); + } + + std::vector FrontEndManager::availableFrontEnds () const + { + return std::vector(1, "onnx"); + } + } // namespace frontend + +} // namespace ngraph diff --git a/ngraph/python/CMakeLists.txt b/ngraph/python/CMakeLists.txt index 5840f71214fee2..d8641da0ac680d 100644 --- a/ngraph/python/CMakeLists.txt +++ b/ngraph/python/CMakeLists.txt @@ -72,7 +72,8 @@ file(GLOB_RECURSE SOURCES src/pyngraph/*.cpp) pybind11_add_module(_${PROJECT_NAME} MODULE ${SOURCES}) target_include_directories(_${PROJECT_NAME} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src") -target_link_libraries(_${PROJECT_NAME} PRIVATE ngraph::ngraph ngraph::onnx_importer) +target_include_directories(_${PROJECT_NAME} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../frontend/generic/include") +target_link_libraries(_${PROJECT_NAME} PRIVATE ngraph::ngraph ngraph::onnx_importer ngraph::frontend_manager) if(OpenVINO_MAIN_SOURCE_DIR OR InferenceEngineDeveloperPackage_FOUND) ie_cpack_add_component(pyngraph_${PYTHON_VERSION}) diff --git a/ngraph/python/src/ngraph/__init__.py b/ngraph/python/src/ngraph/__init__.py index bc41e932e54eb4..a41b9c2f62a392 100644 --- a/ngraph/python/src/ngraph/__init__.py +++ b/ngraph/python/src/ngraph/__init__.py @@ -25,6 +25,9 @@ from ngraph.impl import Node from ngraph.impl import Function +from ngraph.impl import FrontEndManager +from ngraph.impl import FrontEnd +from ngraph.impl import InputModel from ngraph.helpers import function_from_cnn from ngraph.helpers import function_to_cnn diff --git a/ngraph/python/src/ngraph/impl/__init__.py b/ngraph/python/src/ngraph/impl/__init__.py index 224b02334eac5d..430e8481b63464 100644 --- a/ngraph/python/src/ngraph/impl/__init__.py +++ b/ngraph/python/src/ngraph/impl/__init__.py @@ -39,6 +39,9 @@ from _pyngraph import Dimension from _pyngraph import Function +from _pyngraph import FrontEndManager +from _pyngraph import FrontEnd +from _pyngraph import InputModel from _pyngraph import Input from _pyngraph import Output from _pyngraph import Node diff --git a/ngraph/python/src/pyngraph/frontend_manager.cpp b/ngraph/python/src/pyngraph/frontend_manager.cpp new file mode 100644 index 00000000000000..49d69097b80d69 --- /dev/null +++ b/ngraph/python/src/pyngraph/frontend_manager.cpp @@ -0,0 +1,52 @@ +//***************************************************************************** +// Copyright 2017-2021 Intel Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//***************************************************************************** + +#include +#include +#include + +#include "frontend_manager/frontend_manager.hpp" +#include "pyngraph/function.hpp" + +namespace py = pybind11; + + +void regclass_pyngraph_FrontEndManager(py::module m) +{ + py::class_> fem(m, "FrontEndManager", py::dynamic_attr()); + fem.doc() = "ngraph.impl.FrontEndManager wraps ngraph::frontend::FrontEndManager"; + + fem.def(py::init<>()); + + fem.def("availableFrontEnds", &ngraph::frontend::FrontEndManager::availableFrontEnds); + fem.def("loadByFramework", &ngraph::frontend::FrontEndManager::loadByFramework); +} + +void regclass_pyngraph_FrontEnd(py::module m) +{ + py::class_> fem(m, "FrontEnd", py::dynamic_attr()); + fem.doc() = "ngraph.impl.FrontEnd wraps ngraph::frontend::FrontEnd"; + + fem.def("load", &ngraph::frontend::FrontEnd::load); + fem.def("convert", &ngraph::frontend::FrontEnd::convert); +} + +void regclass_pyngraph_InputModel(py::module m) +{ + py::class_> fem(m, "InputModel", py::dynamic_attr()); + fem.doc() = "ngraph.impl.InputModel wraps ngraph::frontend::InputModel"; + +} \ No newline at end of file diff --git a/ngraph/python/src/pyngraph/frontend_manager.hpp b/ngraph/python/src/pyngraph/frontend_manager.hpp new file mode 100644 index 00000000000000..730bd13de20542 --- /dev/null +++ b/ngraph/python/src/pyngraph/frontend_manager.hpp @@ -0,0 +1,25 @@ +//***************************************************************************** +// Copyright 2017-2021 Intel Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//***************************************************************************** + +#pragma once + +#include + +namespace py = pybind11; + +void regclass_pyngraph_FrontEndManager(py::module m); +void regclass_pyngraph_FrontEnd(py::module m); +void regclass_pyngraph_InputModel(py::module m); \ No newline at end of file diff --git a/ngraph/python/src/pyngraph/pyngraph.cpp b/ngraph/python/src/pyngraph/pyngraph.cpp index 09ab2e933c180e..d84e49ab7b42cd 100644 --- a/ngraph/python/src/pyngraph/pyngraph.cpp +++ b/ngraph/python/src/pyngraph/pyngraph.cpp @@ -27,6 +27,7 @@ #if defined(NGRAPH_ONNX_IMPORT_ENABLE) #include "pyngraph/onnx_import/onnx_import.hpp" #endif +#include "pyngraph/frontend_manager.hpp" #include "pyngraph/dimension.hpp" #include "pyngraph/ops/constant.hpp" #include "pyngraph/ops/parameter.hpp" @@ -48,6 +49,9 @@ PYBIND11_MODULE(_pyngraph, m) m.doc() = "Package ngraph.impl that wraps nGraph's namespace ngraph"; regclass_pyngraph_PyRTMap(m); regclass_pyngraph_Node(m); + regclass_pyngraph_FrontEndManager(m); + regclass_pyngraph_FrontEnd(m); + regclass_pyngraph_InputModel(m); regclass_pyngraph_Input(m); regclass_pyngraph_Output(m); regclass_pyngraph_NodeFactory(m); diff --git a/ngraph/test/CMakeLists.txt b/ngraph/test/CMakeLists.txt index aacc74257fecd1..2d07ba99c96c29 100644 --- a/ngraph/test/CMakeLists.txt +++ b/ngraph/test/CMakeLists.txt @@ -460,3 +460,5 @@ if (NGRAPH_INTERPRETER_ENABLE) target_compile_definitions(unit-test PRIVATE NGRAPH_INTERPRETER_ENABLE) target_link_libraries(unit-test PRIVATE interpreter_backend) endif() + +MESSAGE("HERE2" ${ONNX_IMPORT_INCLUDE_DIR}) \ No newline at end of file From f6ed37b15443bae8b458d88c6cfe170f67ef9932 Mon Sep 17 00:00:00 2001 From: "Lyalin, Sergey" Date: Mon, 22 Feb 2021 12:30:47 +0300 Subject: [PATCH 044/116] Rebased on new advances in ONNX editor class --- .../frontend_manager/frontend_manager.hpp | 79 ++++- .../frontend/generic/src/frontend_manager.cpp | 330 +++++++++++++++++- .../editor/detail/subgraph_extraction.hpp | 9 + .../include/onnx_import/editor/editor.hpp | 9 +- .../src/editor/detail/subgraph_extraction.cpp | 3 + .../onnx_import/src/editor/editor.cpp | 25 ++ ngraph/python/src/ngraph/__init__.py | 1 + ngraph/python/src/ngraph/impl/__init__.py | 1 + .../python/src/pyngraph/frontend_manager.cpp | 21 +- .../python/src/pyngraph/frontend_manager.hpp | 4 +- ngraph/python/src/pyngraph/pyngraph.cpp | 1 + 11 files changed, 460 insertions(+), 23 deletions(-) diff --git a/ngraph/frontend/generic/include/frontend_manager/frontend_manager.hpp b/ngraph/frontend/generic/include/frontend_manager/frontend_manager.hpp index eae42826463964..b47e036d7c8dd3 100644 --- a/ngraph/frontend/generic/include/frontend_manager/frontend_manager.hpp +++ b/ngraph/frontend/generic/include/frontend_manager/frontend_manager.hpp @@ -29,6 +29,17 @@ namespace ngraph typedef std::shared_ptr Ptr; + // All associated names that uniquely identify this place in the graph + // from the FW perspective + virtual std::vector getNames () const; + // -1 means port 0 is selected if it is exists and exception otherwise + virtual Ptr getConsumingOperation (int outputPortIndex = -1) const; + virtual Ptr getConsumingTensor (int outputPortIndex = -1) const; + virtual Ptr getProducingOperation (int inputPortIndex = -1) const; + virtual Ptr getProducingPort () const; + virtual Ptr getInputPort (int inputPortIndex) const; + virtual Ptr getOutputPort (int outputPortIndex) const; + virtual std::vector getConsumingPorts () const; }; class NGRAPH_API InputModel @@ -37,8 +48,49 @@ namespace ngraph typedef std::shared_ptr Ptr; - virtual std::vector getInputs () const = 0; - virtual std::vector getOutputs () const = 0; + virtual std::vector getInputs () const; + virtual std::vector getOutputs () const; + + virtual Place::Ptr getPlaceByTensorName (const std::string& tensorName); + virtual Place::Ptr getPlaceByOperationName (const std::string& operationName); + virtual Place::Ptr getPlaceByOperationAndInputPort (const std::string& operationName, int inputPortIndex); + virtual Place::Ptr getPlaceByOperationAndOutputPort (const std::string& operationName, int outputPortIndex); + + // Naming and annotation + virtual void setNameForTensor (Place::Ptr tensor, const std::string& newName); + virtual void addNameForTensor (Place::Ptr tensor, const std::string& newName); + virtual void setNameForOperation (Place::Ptr operation, const std::string& newName); + virtual void freeNameForTensor (const std::string& name); + virtual void freeNameForOperation (const std::string& name); + virtual void setNameForDimension (Place::Ptr place, const std::string& dimName); + + // Topology Editing + virtual void cutAndAddNewInput (Place::Ptr place, const std::string& newNameOptional = ""); + virtual void cutAndAddNewOutput (Place::Ptr place, const std::string& newNameOptional = ""); + virtual void addOutput (Place::Ptr place); + virtual void removeOutput (Place::Ptr place); + virtual void removeInput (Place::Ptr place); // is it really needed? that means that input is not available and all dataflow below should be removed + virtual void overrideAllOutputs (const std::vector& outputs); + virtual void overrideAllInputs (const std::vector& inputs); + virtual void extractSubgraph (const std::vector& inputs, const std::vector& outputs); + + // Setting tensor properties + virtual void setDefaultShape (Place::Ptr place, const ngraph::Shape&); + virtual void setPartialShape (Place::Ptr place, const ngraph::PartialShape&); + virtual void setElementType (Place::Ptr place, const ngraph::element::Type&); + virtual void setTensorValue (Place::Ptr place, const void* value); + virtual void setTensorPartialValue (Place::Ptr place, const void* minValue, const void* maxValue); + + // Standard specializations: "N", "C", "H", "W", "D", "L" + // Issues: name collisions; too bulky to select simple layouts "NCHW" + virtual void setSourceTensorDimSpecialization (Place::Ptr place, unsigned int dimIndex, const std::string& specialization); + virtual void setTargetTensorDimSpecialization (Place::Ptr place, unsigned int dimIndex, const std::string& specialization); + + // Traversing + // TODO + + // Support querying + // TODO }; class NGRAPH_API FrontEnd @@ -46,16 +98,33 @@ namespace ngraph public: typedef std::shared_ptr Ptr; + // TODO: rename to loadFromPath virtual InputModel::Ptr load (const std::string& path) const = 0; - virtual std::shared_ptr convert (InputModel::Ptr model) const = 0; + virtual InputModel::Ptr loadFromPaths (const std::vector& paths) const; + virtual InputModel::Ptr loadFromMemory (const void* model); + virtual InputModel::Ptr loadFromMemoryFragments (const std::vector modelParts); + virtual std::shared_ptr convert (InputModel::Ptr model) const = 0; + + // Convert only those parts of the model that + virtual std::shared_ptr convertPartially (InputModel::Ptr model) const; + virtual void normalize (std::shared_ptr function) const; + }; + + enum FrontEndCapabilities { + FEC_DEFAULT = 0, // Just reading and conversion, w/o any modifications; intended to be used in Reader + FEC_CUT = 1, + FEC_NAMES = 2, + FEC_REPLACE = 4, + FEC_TRAVERSE = 8, + FEC_WILDCARDS = 16, }; class NGRAPH_API FrontEndManager { public: FrontEndManager () {} - FrontEnd::Ptr loadByFramework (const std::string& framework); - FrontEnd::Ptr loadByModel (const std::string& path); + FrontEnd::Ptr loadByFramework (const std::string& framework, FrontEndCapabilities fec = FEC_DEFAULT); + FrontEnd::Ptr loadByModel (const std::string& path, FrontEndCapabilities fec = FEC_DEFAULT); std::vector availableFrontEnds () const; }; } // namespace frontend diff --git a/ngraph/frontend/generic/src/frontend_manager.cpp b/ngraph/frontend/generic/src/frontend_manager.cpp index 311cfd80f4dc92..9635c622a0e316 100644 --- a/ngraph/frontend/generic/src/frontend_manager.cpp +++ b/ngraph/frontend/generic/src/frontend_manager.cpp @@ -19,26 +19,314 @@ #include "onnx_import/editor/editor.hpp" #include "frontend_manager/frontend_manager.hpp" + namespace ngraph { namespace frontend { + + #define FRONT_END_NOT_IMPLEMENTED(NAME) throw #NAME " is not implemented for this FrontEnd class"; + + std::vector InputModel::InputModel::getInputs () const + { + FRONT_END_NOT_IMPLEMENTED(getInputs); + } + + std::vector InputModel::getOutputs () const + { + FRONT_END_NOT_IMPLEMENTED(getOutputs); + } + + Place::Ptr InputModel::getPlaceByTensorName (const std::string& tensorName) + { + FRONT_END_NOT_IMPLEMENTED(getPlaceByTensorName); + } + + Place::Ptr InputModel::getPlaceByOperationName (const std::string& operationName) + { + FRONT_END_NOT_IMPLEMENTED(getPlaceByOperationName); + } + + Place::Ptr InputModel::getPlaceByOperationAndInputPort (const std::string& operationName, int inputPortIndex) + { + FRONT_END_NOT_IMPLEMENTED(getPlaceByOperationAndInputPort); + } + + Place::Ptr InputModel::getPlaceByOperationAndOutputPort (const std::string& operationName, int outputPortIndex) + { + FRONT_END_NOT_IMPLEMENTED(getPlaceByOperationAndOutputPort); + } + + void InputModel::setNameForTensor (Place::Ptr tensor, const std::string& newName) + { + FRONT_END_NOT_IMPLEMENTED(setNameForTensor); + } + + void InputModel::addNameForTensor (Place::Ptr tensor, const std::string& newName) + { + FRONT_END_NOT_IMPLEMENTED(addNameForTensor); + } + + void InputModel::setNameForOperation (Place::Ptr operation, const std::string& newName) + { + FRONT_END_NOT_IMPLEMENTED(setNameForOperation); + } + + void InputModel::freeNameForTensor (const std::string& name) + { + FRONT_END_NOT_IMPLEMENTED(freeNameForTensor); + } + + void InputModel::freeNameForOperation (const std::string& name) + { + FRONT_END_NOT_IMPLEMENTED(freeNameForOperation); + } + + void InputModel::setNameForDimension (Place::Ptr place, const std::string& dimName) + { + FRONT_END_NOT_IMPLEMENTED(setNameForDimension); + } + + void InputModel::cutAndAddNewInput (Place::Ptr place, const std::string& newNameOptional) + { + FRONT_END_NOT_IMPLEMENTED(cutAndAddNewInput); + } + + void InputModel::cutAndAddNewOutput (Place::Ptr place, const std::string& newNameOptional) + { + FRONT_END_NOT_IMPLEMENTED(cutAndAddNewOutput); + } + + void InputModel::addOutput (Place::Ptr place) + { + FRONT_END_NOT_IMPLEMENTED(addOutput); + } + + void InputModel::removeOutput (Place::Ptr place) + { + FRONT_END_NOT_IMPLEMENTED(removeOutput); + } + + void InputModel::removeInput (Place::Ptr place) + { + FRONT_END_NOT_IMPLEMENTED(removeInput); + } + + void InputModel::overrideAllOutputs (const std::vector& outputs) + { + FRONT_END_NOT_IMPLEMENTED(overrideAllOutputs); + } + + void InputModel::overrideAllInputs (const std::vector& inputs) + { + FRONT_END_NOT_IMPLEMENTED(overrideAllInputs); + } + + void InputModel::extractSubgraph (const std::vector& inputs, const std::vector& outputs) + { + FRONT_END_NOT_IMPLEMENTED(extractSubgraph); + } + + // Setting tensor properties + void InputModel::setDefaultShape (Place::Ptr place, const ngraph::Shape&) + { + FRONT_END_NOT_IMPLEMENTED(setDefaultShape); + } + + void InputModel::setPartialShape (Place::Ptr place, const ngraph::PartialShape&) + { + FRONT_END_NOT_IMPLEMENTED(setPartialShape); + } + + void InputModel::setElementType (Place::Ptr place, const ngraph::element::Type&) + { + FRONT_END_NOT_IMPLEMENTED(setElementType); + } + + void InputModel::setTensorValue (Place::Ptr place, const void*) + { + FRONT_END_NOT_IMPLEMENTED(setTensorValue); + } + + void InputModel::setTensorPartialValue (Place::Ptr place, const void* minValue, const void* maxValue) + { + FRONT_END_NOT_IMPLEMENTED(setTensorPartialValue); + } + + void InputModel::setSourceTensorDimSpecialization (Place::Ptr place, unsigned int dimIndex, const std::string& specialization) + { + FRONT_END_NOT_IMPLEMENTED(setSourceTensorDimSpecialization); + } + + void InputModel::setTargetTensorDimSpecialization (Place::Ptr place, unsigned int dimIndex, const std::string& specialization) + { + FRONT_END_NOT_IMPLEMENTED(setTargetTensorDimSpecialization); + } + + // All associated names that uniquely identify this place in the graph + // from the FW perspective + std::vector Place::getNames () const + { + FRONT_END_NOT_IMPLEMENTED(getNames); + } + + // -1 means port 0 is selected if it is exists and exception otherwise + Place::Ptr Place::getConsumingOperation (int outputPortIndex) const + { + FRONT_END_NOT_IMPLEMENTED(getConsumingOperation); + } + + Place::Ptr Place::getConsumingTensor (int outputPortIndex) const + { + FRONT_END_NOT_IMPLEMENTED(getConsumingTensor); + } + + Place::Ptr Place::getProducingOperation (int inputPortIndex) const + { + FRONT_END_NOT_IMPLEMENTED(getProducingOperation); + } + + Place::Ptr Place::getProducingPort () const + { + FRONT_END_NOT_IMPLEMENTED(getProducingPort); + } + + Place::Ptr Place::getInputPort (int inputPortIndex) const + { + FRONT_END_NOT_IMPLEMENTED(getInputPort); + } + + Place::Ptr Place::getOutputPort (int outputPortIndex) const + { + FRONT_END_NOT_IMPLEMENTED(getOutputPort); + } + + std::vector Place::getConsumingPorts () const + { + FRONT_END_NOT_IMPLEMENTED(getConsumingPorts); + } + + class PlaceInputEdgeONNX : public Place + { + public: + + onnx_import::InputEdge edge; + + PlaceInputEdgeONNX (int _operationNodeIndex, const std::string& _targetTensorName) : + edge(_operationNodeIndex, _targetTensorName) + {} + }; + + class PlaceOutputEdgeONNX : public Place + { + public: + + onnx_import::OutputEdge edge; + + PlaceOutputEdgeONNX (const std::string& _sourceTensorName, int _operationNodeIndex) : + edge(_operationNodeIndex, _sourceTensorName) + {} + + + }; + + class InputModelONNX; + + class PlaceTensorONNX : public Place + { + std::string tensorName; + const InputModelONNX* model; + + public: + + PlaceTensorONNX (const std::string& _tensorName, const InputModelONNX* _model) : tensorName(_tensorName), model(_model){} + + virtual std::vector getNames () const override + { + return std::vector(1, tensorName); + } + + //virtual std::vector Place::getConsumingPorts () const override; + virtual Place::Ptr getProducingPort () const override; + }; + class InputModelONNX : public InputModel { + public: + // TODO: Move to private onnx_import::ONNXModelEditor editor; InputModelONNX (const std::string& model_path) : editor(model_path) {} - virtual std::vector getInputs () const { - throw ngraph::ngraph_error("getInputs is not supported for InputModelONNX"); + Place::Ptr getPlaceByTensorName (const std::string& tensorName) override + { + + editor.model(); // TODO: by using this `model` check if name really exists in the model + return std::make_shared(tensorName, this); } - virtual std::vector getOutputs () const { - throw ngraph::ngraph_error("getOutputs is not supported for InputModelONNX"); + std::vector getInputs () const override { + auto inputs = editor.model_inputs(); + std::vector outputs; + outputs.reserve(inputs.size()); + for(auto const& input: inputs) + { + outputs.push_back(std::make_shared(input, this)); + } + return outputs; + } + + void setPartialShape (Place::Ptr place, const ngraph::PartialShape& shape) override + { + std::map m; + m[place->getNames()[0]] = shape; + editor.set_input_shapes(m); + } + + void extractSubgraph (const std::vector& inputs, const std::vector& outputs) + { + // Current implementation is limited by tensor places only, each input tensor should be consumed by a single op only + // TODO Extend to non tensor inputs/outputs and remove other limitations + std::vector onnx_inputs; + onnx_inputs.reserve(inputs.size()); + for(const auto& input: inputs) + { + // TODO check if input is a tensor + auto inputPorts = input->getConsumingPorts(); + NGRAPH_CHECK(inputPorts.size() == 1); + auto inputPort = inputPorts.front(); + auto onnxInputEdge = std::dynamic_pointer_cast(inputPort); + NGRAPH_CHECK(onnxInputEdge); + onnx_inputs.push_back(onnxInputEdge->edge); + } + + std::vector onnx_outputs; + onnx_outputs.reserve(outputs.size()); + for(const auto& output: outputs) + { + // TODO check if output is a tensor + auto outputPort = output->getProducingPort(); + auto onnxOutputEdge = std::dynamic_pointer_cast(outputPort); + NGRAPH_CHECK(onnxOutputEdge); + onnx_outputs.push_back(onnxOutputEdge->edge); + } + + editor.cut_graph_fragment(onnx_inputs, onnx_outputs); } }; + /*std::vector PlaceTensorONNX::getConsumingPorts () const + { + // ONNX specific code to find a node indices for all operations that consume a given tensor name + + }*/ + + Place::Ptr PlaceTensorONNX::getProducingPort () const + { + return std::make_shared(tensorName, model->editor.find_producing_node_idx(tensorName)); + } + class FrontEndONNX : public FrontEnd { public: @@ -47,23 +335,49 @@ namespace ngraph { } - virtual InputModel::Ptr load (const std::string& path) const { + virtual InputModel::Ptr load (const std::string& path) const + { return std::make_shared(path); } - virtual std::shared_ptr convert (InputModel::Ptr model) const { + virtual std::shared_ptr convert (InputModel::Ptr model) const + { return import_onnx_model(std::dynamic_pointer_cast(model)->editor); } }; + InputModel::Ptr FrontEnd::loadFromPaths (const std::vector& paths) const + { + FRONT_END_NOT_IMPLEMENTED(loadFromPaths); + } + + InputModel::Ptr FrontEnd::loadFromMemory (const void* model) + { + FRONT_END_NOT_IMPLEMENTED(loadFromMemory); + } + + InputModel::Ptr FrontEnd::loadFromMemoryFragments (const std::vector modelParts) + { + FRONT_END_NOT_IMPLEMENTED(loadFromMemoryFragments); + } + + std::shared_ptr FrontEnd::convertPartially (InputModel::Ptr model) const + { + FRONT_END_NOT_IMPLEMENTED(convertPartially); + } + + void FrontEnd::normalize (std::shared_ptr function) const + { + FRONT_END_NOT_IMPLEMENTED(normalize); + } - FrontEnd::Ptr FrontEndManager::loadByFramework (const std::string& framework) + FrontEnd::Ptr FrontEndManager::loadByFramework (const std::string& framework, FrontEndCapabilities fec) { NGRAPH_CHECK(framework == "onnx"); return std::make_shared(); } - FrontEnd::Ptr FrontEndManager::loadByModel (const std::string& path) + FrontEnd::Ptr FrontEndManager::loadByModel (const std::string& path, FrontEndCapabilities fec) { return loadByFramework("onnx"); } diff --git a/ngraph/frontend/onnx_import/include/onnx_import/editor/detail/subgraph_extraction.hpp b/ngraph/frontend/onnx_import/include/onnx_import/editor/detail/subgraph_extraction.hpp index a005bb3d1c43d6..c0ffae1dfe42c2 100644 --- a/ngraph/frontend/onnx_import/include/onnx_import/editor/detail/subgraph_extraction.hpp +++ b/ngraph/frontend/onnx_import/include/onnx_import/editor/detail/subgraph_extraction.hpp @@ -21,12 +21,16 @@ #include #include #include +#include "../../utils/onnx_importer_visibility.hpp" namespace ONNX_NAMESPACE { + // forward declaration to avoid the necessity of include paths setting in components + // that don't directly depend on the ONNX library class GraphProto; class NodeProto; class ValueInfoProto; + class ModelProto; } // namespace ONNX_NAMESPACE namespace ngraph @@ -52,6 +56,11 @@ namespace ngraph }; namespace onnx_import { + + ONNX_IMPORTER_API + int find_producing_node_idx(const ONNX_NAMESPACE::ModelProto& model, + const std::string& tensorName); + /// \brief Defines an edge connected to an input of any node in the graph. /// It consists of a node index in the processed ONNX model and the input name. /// The index should point to a node in the topological sort of the underlying graph diff --git a/ngraph/frontend/onnx_import/include/onnx_import/editor/editor.hpp b/ngraph/frontend/onnx_import/include/onnx_import/editor/editor.hpp index 5e2fa4c778e1d6..082ea3db3d60b6 100644 --- a/ngraph/frontend/onnx_import/include/onnx_import/editor/editor.hpp +++ b/ngraph/frontend/onnx_import/include/onnx_import/editor/editor.hpp @@ -26,13 +26,6 @@ #include "onnx_import/editor/detail/subgraph_extraction.hpp" #include "onnx_import/utils/onnx_importer_visibility.hpp" -namespace ONNX_NAMESPACE -{ - // forward declaration to avoid the necessity of include paths setting in components - // that don't directly depend on the ONNX library - class ModelProto; -} // namespace ONNX_NAMESPACE - namespace ngraph { namespace onnx_import @@ -123,6 +116,8 @@ namespace ngraph /// \param out_file_path A path to the file where the modified model should be dumped. void serialize(const std::string& out_file_path) const; + int find_producing_node_idx(const std::string& tensorName) const; + private: const std::string m_model_path; diff --git a/ngraph/frontend/onnx_import/src/editor/detail/subgraph_extraction.cpp b/ngraph/frontend/onnx_import/src/editor/detail/subgraph_extraction.cpp index f81f92e9e9ab29..66df579486e5eb 100644 --- a/ngraph/frontend/onnx_import/src/editor/detail/subgraph_extraction.cpp +++ b/ngraph/frontend/onnx_import/src/editor/detail/subgraph_extraction.cpp @@ -292,6 +292,9 @@ namespace /* -----------------------------------------------------------------------------------------------*/ + + + SubgraphExtractor::SubgraphExtractor(ONNX_NAMESPACE::GraphProto& graph) : m_onnx_graph(graph) { diff --git a/ngraph/frontend/onnx_import/src/editor/editor.cpp b/ngraph/frontend/onnx_import/src/editor/editor.cpp index 94bb7e775a9c96..c635ad6d760c42 100644 --- a/ngraph/frontend/onnx_import/src/editor/editor.cpp +++ b/ngraph/frontend/onnx_import/src/editor/editor.cpp @@ -369,3 +369,28 @@ std::string onnx_import::ONNXModelEditor::model_string() const { return m_pimpl->m_model_proto.SerializeAsString(); } + +namespace { + const auto is_equal_to = + +[](const std::string& other) { return [&](const std::string& s) { return s == other; }; }; +} + +int onnx_import::ONNXModelEditor::find_producing_node_idx(const std::string& tensorName) const +{ + + const auto& graph = m_pimpl->m_model_proto.graph(); + for (int i = 0; i <= graph.node_size(); ++i) + { + const auto& outputs = graph.node(i).output(); + const auto output_found = + std::any_of(std::begin(outputs), std::end(outputs), is_equal_to(tensorName)); + + if (output_found) + { + return i; + } + } + + throw ngraph::ngraph_error{"Source node not found in the graph for tensor name: " + + tensorName}; +} diff --git a/ngraph/python/src/ngraph/__init__.py b/ngraph/python/src/ngraph/__init__.py index a41b9c2f62a392..bfeedbc81fc21a 100644 --- a/ngraph/python/src/ngraph/__init__.py +++ b/ngraph/python/src/ngraph/__init__.py @@ -26,6 +26,7 @@ from ngraph.impl import Node from ngraph.impl import Function from ngraph.impl import FrontEndManager +from ngraph.impl import FrontEndCapabilities from ngraph.impl import FrontEnd from ngraph.impl import InputModel from ngraph.helpers import function_from_cnn diff --git a/ngraph/python/src/ngraph/impl/__init__.py b/ngraph/python/src/ngraph/impl/__init__.py index 430e8481b63464..9be3eef4fda81a 100644 --- a/ngraph/python/src/ngraph/impl/__init__.py +++ b/ngraph/python/src/ngraph/impl/__init__.py @@ -41,6 +41,7 @@ from _pyngraph import Function from _pyngraph import FrontEndManager from _pyngraph import FrontEnd +from _pyngraph import FrontEndCapabilities from _pyngraph import InputModel from _pyngraph import Input from _pyngraph import Output diff --git a/ngraph/python/src/pyngraph/frontend_manager.cpp b/ngraph/python/src/pyngraph/frontend_manager.cpp index 49d69097b80d69..6d139654ed1194 100644 --- a/ngraph/python/src/pyngraph/frontend_manager.cpp +++ b/ngraph/python/src/pyngraph/frontend_manager.cpp @@ -32,7 +32,7 @@ void regclass_pyngraph_FrontEndManager(py::module m) fem.def(py::init<>()); fem.def("availableFrontEnds", &ngraph::frontend::FrontEndManager::availableFrontEnds); - fem.def("loadByFramework", &ngraph::frontend::FrontEndManager::loadByFramework); + fem.def("loadByFramework", &ngraph::frontend::FrontEndManager::loadByFramework, py::arg("framework"), py::arg("capabilities") = ngraph::frontend::FEC_DEFAULT); } void regclass_pyngraph_FrontEnd(py::module m) @@ -49,4 +49,21 @@ void regclass_pyngraph_InputModel(py::module m) py::class_> fem(m, "InputModel", py::dynamic_attr()); fem.doc() = "ngraph.impl.InputModel wraps ngraph::frontend::InputModel"; -} \ No newline at end of file +} + +void regclass_pyngraph_FEC(py::module m) +{ + py::class_> type(m, "FrontEndCapabilities"); + //type.doc() = "FrontEndCapabilities"; + type.attr("DEFAULT") = ngraph::frontend::FEC_DEFAULT; + type.attr("CUT") = ngraph::frontend::FEC_CUT; + type.attr("NAMES") = ngraph::frontend::FEC_NAMES; + type.attr("REPLACE") = ngraph::frontend::FEC_REPLACE; + type.attr("TRAVERSE") = ngraph::frontend::FEC_TRAVERSE; + type.attr("WILDCARDS") = ngraph::frontend::FEC_WILDCARDS; + + type.def("__eq__", + [](const ngraph::frontend::FrontEndCapabilities& a, const ngraph::frontend::FrontEndCapabilities& b) { return a == b; }, + py::is_operator()); + +} diff --git a/ngraph/python/src/pyngraph/frontend_manager.hpp b/ngraph/python/src/pyngraph/frontend_manager.hpp index 730bd13de20542..5608d3ce1c8108 100644 --- a/ngraph/python/src/pyngraph/frontend_manager.hpp +++ b/ngraph/python/src/pyngraph/frontend_manager.hpp @@ -22,4 +22,6 @@ namespace py = pybind11; void regclass_pyngraph_FrontEndManager(py::module m); void regclass_pyngraph_FrontEnd(py::module m); -void regclass_pyngraph_InputModel(py::module m); \ No newline at end of file +void regclass_pyngraph_InputModel(py::module m); +void regclass_pyngraph_FEC(py::module m); +//void regclass_pyngraph_Place(py::module m); diff --git a/ngraph/python/src/pyngraph/pyngraph.cpp b/ngraph/python/src/pyngraph/pyngraph.cpp index d84e49ab7b42cd..31cdbb87cee0fe 100644 --- a/ngraph/python/src/pyngraph/pyngraph.cpp +++ b/ngraph/python/src/pyngraph/pyngraph.cpp @@ -49,6 +49,7 @@ PYBIND11_MODULE(_pyngraph, m) m.doc() = "Package ngraph.impl that wraps nGraph's namespace ngraph"; regclass_pyngraph_PyRTMap(m); regclass_pyngraph_Node(m); + regclass_pyngraph_FEC(m); regclass_pyngraph_FrontEndManager(m); regclass_pyngraph_FrontEnd(m); regclass_pyngraph_InputModel(m); From aac48a794b33c0058e939b7cf71498dc9c138533 Mon Sep 17 00:00:00 2001 From: "Lyalin, Sergey" Date: Tue, 23 Feb 2021 13:51:58 +0300 Subject: [PATCH 045/116] Restored input cuting machinery with ONNX editor --- .../extensions/front/user_data_repack.py | 7 +++ model-optimizer/mo/front/extractor.py | 48 +++++++++++++++++++ model-optimizer/mo/graph/graph.py | 2 +- model-optimizer/mo/pipeline/unified.py | 14 ++++-- .../frontend_manager/frontend_manager.hpp | 2 +- .../frontend/generic/src/frontend_manager.cpp | 36 +++++++++----- .../include/onnx_import/editor/editor.hpp | 8 ++++ .../onnx_import/src/editor/editor.cpp | 40 +++++++++++++++- .../python/src/pyngraph/frontend_manager.cpp | 16 +++++-- .../python/src/pyngraph/frontend_manager.hpp | 2 +- ngraph/python/src/pyngraph/pyngraph.cpp | 1 + 11 files changed, 154 insertions(+), 22 deletions(-) diff --git a/model-optimizer/extensions/front/user_data_repack.py b/model-optimizer/extensions/front/user_data_repack.py index 6affc1bd27c559..a2f6a72f856ebc 100644 --- a/model-optimizer/extensions/front/user_data_repack.py +++ b/model-optimizer/extensions/front/user_data_repack.py @@ -42,3 +42,10 @@ def find_and_replace_pattern(self, graph: Graph): inputs = list(packed_user_shapes.keys()) \ if packed_user_shapes is not None and isinstance(packed_user_shapes, dict) else None graph.graph['inputs'] = inputs # save user defined inputs for other extensions + + print('---------- Inputs/outpus -----------') + print(packed_user_shapes) + print(packed_outputs) + print(freeze_placeholder) + print(inputs) + print('------------------------------------') diff --git a/model-optimizer/mo/front/extractor.py b/model-optimizer/mo/front/extractor.py index 32b43fa8358331..af62ce591a4d1e 100644 --- a/model-optimizer/mo/front/extractor.py +++ b/model-optimizer/mo/front/extractor.py @@ -455,6 +455,34 @@ def extract_node_attrs(graph: Graph, extractor: callable): return graph +def decodeNameWithPort (graph: Graph, node_name: str): + """ + Decode name with optional port specification w/o traversing all the nodes in the graph + :param graph: + :param node_name: + :return: decoded place in the graph + """ + # Check exact match with one of the names in the graph first + inputModel = graph.graph['input_model'] + #TODO: search for any name, not only a tensor + node = inputModel.getPlaceByTensorName(node_name) + if node: + return node + regexpPost = r'(.*)(:(\d+))' + matchPost = re.search(regexpPost, node_name) + nodePost = inputModel.findTensor(matchPost.group(1)) if matchPost else None + regexpPre = r'((\d+):)(.*)' + matchPre = re.search(regexpPre, node_name) + nodePre = inputModel.findTensor(matchPre.group(3)) if matchPost else None + if nodePost and nodePre: + raise Error('Name collision for {}'.format(node_name)) + if nodePost: + return node.getOutputPort(int(matchPost.group(3))) + if nodePre: + return node.getInputPort(int(matchPre.group(1))) + raise Error('There is no node with name {}'.format(node_name)) + + def get_node_id_with_ports(graph: Graph, node_name: str, skip_if_no_port=True): """ Extracts port and node ID out of user provided name @@ -556,6 +584,26 @@ def input_user_data_repack(graph: Graph, input_user_shapes: [None, list, dict, n 'phase_train' : False } """ + _input_shapes = [] + if 'frontend' in graph.graph: + # New version of FrontEnd is activated + print("I'm HERE") + inputModel = graph.graph['input_model'] + if isinstance(input_user_shapes, list) or isinstance(input_user_shapes, dict): + for input_name in input_user_shapes: + node = decodeNameWithPort(graph, input_name) + if node is None: + raise Error('Cannot find location {} in the graph'.format(input_name)) + shape = None if isinstance(input_user_shapes, list) else input_user_shapes[input_name] + if input_name in input_user_data_types and input_user_data_types[input_name] is not None: + data_type = input_user_data_types[input_name] + _input_shapes.append({'node': node, 'shape': shape, 'data_type': data_type}) + else: + _input_shapes.append({'node': node, 'shape': shape}) + # TODO: Implement the remaining cases + return _input_shapes, dict() + + _input_shapes = defaultdict(list) _freeze_placeholder = dict() _freeze_new_placeholder = defaultdict(list) diff --git a/model-optimizer/mo/graph/graph.py b/model-optimizer/mo/graph/graph.py index d8fc60b91c62b6..8bc1fd8f689545 100644 --- a/model-optimizer/mo/graph/graph.py +++ b/model-optimizer/mo/graph/graph.py @@ -746,7 +746,7 @@ def unique_id(self, prefix: str = ""): return prefix + str(self.unique_id_count) def check_empty_graph(self, description: str): - if len(self.nodes()) <= 1 and self.graph['network'] is None: + if len(self.nodes()) <= 1 and self.graph['frontend'] is None: raise Error( "Graph contains {} node after executing {}. It considered as error because resulting IR will be " "empty which is not usual".format(len(self.nodes()), description)) diff --git a/model-optimizer/mo/pipeline/unified.py b/model-optimizer/mo/pipeline/unified.py index b9a5dcd50d7214..4bacadf6861590 100644 --- a/model-optimizer/mo/pipeline/unified.py +++ b/model-optimizer/mo/pipeline/unified.py @@ -48,7 +48,7 @@ def moc_pipeline(argv: argparse.Namespace): print(fe) inputModel = fe.load(argv.input_model) nGraphModel = fe.convert(inputModel) - network = ng.function_to_cnn(nGraphModel) + #network = ng.function_to_cnn(nGraphModel) #network = ie.read_network(model=argv.input_model) # Wrap nGraph network to Graph for smoothly pass through the legacy code in MO. @@ -56,14 +56,20 @@ def moc_pipeline(argv: argparse.Namespace): # NX graph and this is not required. But Graph has several methods that can be implemented for nGraph # and probably they should be kept at least for transition period where some existing transformations # that manipulate Graph object really translate those modifications directly to nGraph representation. - graph = Graph(network=network, cmd_params=argv, name=argv.model_name, ir_version=get_ir_version(argv)) + graph = Graph(frontend=fe, input_model=inputModel, cmd_params=argv, name=argv.model_name, ir_version=get_ir_version(argv)) transforms = [ UserDataRepack, - InputCut, + #InputCut, #OutputCut ] apply_replacements_list(graph, transforms) - + user_shapes = graph.graph['user_shapes'] + print(user_shapes) + if user_shapes: + inputModel.extractSubgraph([us['node'] for us in user_shapes], []) + nGraphModel = fe.convert(inputModel) + network = ng.function_to_cnn(nGraphModel) + graph.graph['network'] = network return graph \ No newline at end of file diff --git a/ngraph/frontend/generic/include/frontend_manager/frontend_manager.hpp b/ngraph/frontend/generic/include/frontend_manager/frontend_manager.hpp index b47e036d7c8dd3..a58d4a8f075f81 100644 --- a/ngraph/frontend/generic/include/frontend_manager/frontend_manager.hpp +++ b/ngraph/frontend/generic/include/frontend_manager/frontend_manager.hpp @@ -39,7 +39,7 @@ namespace ngraph virtual Ptr getProducingPort () const; virtual Ptr getInputPort (int inputPortIndex) const; virtual Ptr getOutputPort (int outputPortIndex) const; - virtual std::vector getConsumingPorts () const; + virtual std::vector getConsumingPorts () const; }; class NGRAPH_API InputModel diff --git a/ngraph/frontend/generic/src/frontend_manager.cpp b/ngraph/frontend/generic/src/frontend_manager.cpp index 9635c622a0e316..781165c53eace7 100644 --- a/ngraph/frontend/generic/src/frontend_manager.cpp +++ b/ngraph/frontend/generic/src/frontend_manager.cpp @@ -212,8 +212,8 @@ namespace ngraph onnx_import::InputEdge edge; - PlaceInputEdgeONNX (int _operationNodeIndex, const std::string& _targetTensorName) : - edge(_operationNodeIndex, _targetTensorName) + PlaceInputEdgeONNX (const std::string& _sourceTensorName, int _operationNodeIndex) : + edge(_operationNodeIndex, _sourceTensorName) {} }; @@ -223,8 +223,8 @@ namespace ngraph onnx_import::OutputEdge edge; - PlaceOutputEdgeONNX (const std::string& _sourceTensorName, int _operationNodeIndex) : - edge(_operationNodeIndex, _sourceTensorName) + PlaceOutputEdgeONNX (int _operationNodeIndex, const std::string& _targetTensorName) : + edge(_operationNodeIndex, _targetTensorName) {} @@ -246,7 +246,7 @@ namespace ngraph return std::vector(1, tensorName); } - //virtual std::vector Place::getConsumingPorts () const override; + virtual std::vector getConsumingPorts () const override; virtual Place::Ptr getProducingPort () const override; }; @@ -261,8 +261,10 @@ namespace ngraph Place::Ptr getPlaceByTensorName (const std::string& tensorName) override { - - editor.model(); // TODO: by using this `model` check if name really exists in the model + if(!editor.validate_tensor_name(tensorName)) { + std::cerr << " [ ERROR ] Node with name " << tensorName << " is not valid for a given model\n"; + return nullptr; + } return std::make_shared(tensorName, this); } @@ -286,20 +288,27 @@ namespace ngraph void extractSubgraph (const std::vector& inputs, const std::vector& outputs) { + std::cerr << "\nTTTTTTTTTTTTT\n"; + std::cerr << "inputs.size() = " << inputs.size() << "\n"; // Current implementation is limited by tensor places only, each input tensor should be consumed by a single op only // TODO Extend to non tensor inputs/outputs and remove other limitations std::vector onnx_inputs; onnx_inputs.reserve(inputs.size()); for(const auto& input: inputs) { + std::cerr << "[] = " << input.get() << "\n"; // TODO check if input is a tensor auto inputPorts = input->getConsumingPorts(); + std::cerr << "{1}\n"; NGRAPH_CHECK(inputPorts.size() == 1); + std::cerr << "{2}\n"; auto inputPort = inputPorts.front(); + std::cerr << "{3}\n"; auto onnxInputEdge = std::dynamic_pointer_cast(inputPort); NGRAPH_CHECK(onnxInputEdge); onnx_inputs.push_back(onnxInputEdge->edge); } + std::cerr << "{4}\n"; std::vector onnx_outputs; onnx_outputs.reserve(outputs.size()); @@ -316,15 +325,20 @@ namespace ngraph } }; - /*std::vector PlaceTensorONNX::getConsumingPorts () const + std::vector PlaceTensorONNX::getConsumingPorts () const { // ONNX specific code to find a node indices for all operations that consume a given tensor name - - }*/ + std::vector result; + for(int i: model->editor.find_consumeing_node_idxs(tensorName)) + { + result.push_back(std::make_shared(tensorName, i)); + } + return result; + } Place::Ptr PlaceTensorONNX::getProducingPort () const { - return std::make_shared(tensorName, model->editor.find_producing_node_idx(tensorName)); + return std::make_shared(model->editor.find_producing_node_idx(tensorName), tensorName); } class FrontEndONNX : public FrontEnd diff --git a/ngraph/frontend/onnx_import/include/onnx_import/editor/editor.hpp b/ngraph/frontend/onnx_import/include/onnx_import/editor/editor.hpp index 082ea3db3d60b6..a0110376608164 100644 --- a/ngraph/frontend/onnx_import/include/onnx_import/editor/editor.hpp +++ b/ngraph/frontend/onnx_import/include/onnx_import/editor/editor.hpp @@ -116,8 +116,16 @@ namespace ngraph /// \param out_file_path A path to the file where the modified model should be dumped. void serialize(const std::string& out_file_path) const; + // Finds an ONNX node index that writes to a given tensorName int find_producing_node_idx(const std::string& tensorName) const; + // Finds all ONNX nodes indices that consume a value of a given tensorName + std::vector find_consumeing_node_idxs(const std::string& tensorName) const; + + // Find out whether there is a tensor with a given name + bool validate_tensor_name(const std::string& tensorName) const; + + private: const std::string m_model_path; diff --git a/ngraph/frontend/onnx_import/src/editor/editor.cpp b/ngraph/frontend/onnx_import/src/editor/editor.cpp index c635ad6d760c42..48341bead75184 100644 --- a/ngraph/frontend/onnx_import/src/editor/editor.cpp +++ b/ngraph/frontend/onnx_import/src/editor/editor.cpp @@ -379,7 +379,7 @@ int onnx_import::ONNXModelEditor::find_producing_node_idx(const std::string& ten { const auto& graph = m_pimpl->m_model_proto.graph(); - for (int i = 0; i <= graph.node_size(); ++i) + for (int i = 0; i < graph.node_size(); ++i) { const auto& outputs = graph.node(i).output(); const auto output_found = @@ -394,3 +394,41 @@ int onnx_import::ONNXModelEditor::find_producing_node_idx(const std::string& ten throw ngraph::ngraph_error{"Source node not found in the graph for tensor name: " + tensorName}; } + + +std::vector onnx_import::ONNXModelEditor::find_consumeing_node_idxs(const std::string& tensorName) const { + const auto &graph = m_pimpl->m_model_proto.graph(); + std::vector result; + for (int i = 0; i < graph.node_size(); ++i) { + const auto &inputs = graph.node(i).input(); + const auto input_found = + std::any_of(std::begin(inputs), std::end(inputs), is_equal_to(tensorName)); + + if (input_found) { + result.push_back(i); + } + } + return result; +} + +bool onnx_import::ONNXModelEditor::validate_tensor_name(const std::string& tensorName) const { + const auto &graph = m_pimpl->m_model_proto.graph(); + for (int i = 0; i < graph.node_size(); ++i) { + const auto &outputs = graph.node(i).output(); + const auto output_found = + std::any_of(std::begin(outputs), std::end(outputs), is_equal_to(tensorName)); + + if (output_found) { + return true; + } + + const auto &inputs = graph.node(i).input(); + const auto input_found = + std::any_of(std::begin(inputs), std::end(inputs), is_equal_to(tensorName)); + + if (input_found) { + return true; + } + } + return false; +} \ No newline at end of file diff --git a/ngraph/python/src/pyngraph/frontend_manager.cpp b/ngraph/python/src/pyngraph/frontend_manager.cpp index 6d139654ed1194..ee7c2b8fa986e6 100644 --- a/ngraph/python/src/pyngraph/frontend_manager.cpp +++ b/ngraph/python/src/pyngraph/frontend_manager.cpp @@ -44,11 +44,21 @@ void regclass_pyngraph_FrontEnd(py::module m) fem.def("convert", &ngraph::frontend::FrontEnd::convert); } -void regclass_pyngraph_InputModel(py::module m) +void regclass_pyngraph_Place(py::module m) { - py::class_> fem(m, "InputModel", py::dynamic_attr()); - fem.doc() = "ngraph.impl.InputModel wraps ngraph::frontend::InputModel"; + py::class_> fem(m, "Place", py::dynamic_attr()); + fem.doc() = "ngraph.impl.Place wraps ngraph::frontend::Place"; + + //fem.def("load", &ngraph::frontend::FrontEnd::load); + //fem.def("convert", &ngraph::frontend::FrontEnd::convert); +} +void regclass_pyngraph_InputModel(py::module m) +{ + py::class_> im(m, "InputModel", py::dynamic_attr()); + im.doc() = "ngraph.impl.InputModel wraps ngraph::frontend::InputModel"; + im.def("extractSubgraph", &ngraph::frontend::InputModel::extractSubgraph); + im.def("getPlaceByTensorName", &ngraph::frontend::InputModel::getPlaceByTensorName); } void regclass_pyngraph_FEC(py::module m) diff --git a/ngraph/python/src/pyngraph/frontend_manager.hpp b/ngraph/python/src/pyngraph/frontend_manager.hpp index 5608d3ce1c8108..4446fb45f40d56 100644 --- a/ngraph/python/src/pyngraph/frontend_manager.hpp +++ b/ngraph/python/src/pyngraph/frontend_manager.hpp @@ -24,4 +24,4 @@ void regclass_pyngraph_FrontEndManager(py::module m); void regclass_pyngraph_FrontEnd(py::module m); void regclass_pyngraph_InputModel(py::module m); void regclass_pyngraph_FEC(py::module m); -//void regclass_pyngraph_Place(py::module m); +void regclass_pyngraph_Place(py::module m); diff --git a/ngraph/python/src/pyngraph/pyngraph.cpp b/ngraph/python/src/pyngraph/pyngraph.cpp index 31cdbb87cee0fe..7a635df285dbdb 100644 --- a/ngraph/python/src/pyngraph/pyngraph.cpp +++ b/ngraph/python/src/pyngraph/pyngraph.cpp @@ -49,6 +49,7 @@ PYBIND11_MODULE(_pyngraph, m) m.doc() = "Package ngraph.impl that wraps nGraph's namespace ngraph"; regclass_pyngraph_PyRTMap(m); regclass_pyngraph_Node(m); + regclass_pyngraph_Place(m); regclass_pyngraph_FEC(m); regclass_pyngraph_FrontEndManager(m); regclass_pyngraph_FrontEnd(m); From 31079bc8bc6d87f1c34aa81303ee6d393aacd086 Mon Sep 17 00:00:00 2001 From: "Lyalin, Sergey" Date: Thu, 25 Feb 2021 13:37:35 +0300 Subject: [PATCH 046/116] Better names and more comments --- model-optimizer/mo/front/extractor.py | 4 +- model-optimizer/mo/pipeline/unified.py | 6 +- .../frontend_manager/frontend_manager.hpp | 39 ++++++++---- .../frontend/generic/src/frontend_manager.cpp | 62 +++++++++++++------ ngraph/python/src/ngraph/__init__.py | 2 + ngraph/python/src/ngraph/impl/__init__.py | 1 + .../python/src/pyngraph/frontend_manager.cpp | 3 +- 7 files changed, 81 insertions(+), 36 deletions(-) diff --git a/model-optimizer/mo/front/extractor.py b/model-optimizer/mo/front/extractor.py index af62ce591a4d1e..56c33947583d8d 100644 --- a/model-optimizer/mo/front/extractor.py +++ b/model-optimizer/mo/front/extractor.py @@ -470,10 +470,10 @@ def decodeNameWithPort (graph: Graph, node_name: str): return node regexpPost = r'(.*)(:(\d+))' matchPost = re.search(regexpPost, node_name) - nodePost = inputModel.findTensor(matchPost.group(1)) if matchPost else None + nodePost = inputModel.getPlaceByTensorName(matchPost.group(1)) if matchPost else None regexpPre = r'((\d+):)(.*)' matchPre = re.search(regexpPre, node_name) - nodePre = inputModel.findTensor(matchPre.group(3)) if matchPost else None + nodePre = inputModel.getPlaceByTensorName(matchPre.group(3)) if matchPost else None if nodePost and nodePre: raise Error('Name collision for {}'.format(node_name)) if nodePost: diff --git a/model-optimizer/mo/pipeline/unified.py b/model-optimizer/mo/pipeline/unified.py index 4bacadf6861590..3493840be06747 100644 --- a/model-optimizer/mo/pipeline/unified.py +++ b/model-optimizer/mo/pipeline/unified.py @@ -46,8 +46,8 @@ def moc_pipeline(argv: argparse.Namespace): print('fem.availableFrontEnds: ' + str(fem.availableFrontEnds())) fe = fem.loadByFramework('onnx') print(fe) - inputModel = fe.load(argv.input_model) - nGraphModel = fe.convert(inputModel) + inputModel = fe.loadFromFile(argv.input_model) + #nGraphModel = fe.convert(inputModel) #network = ng.function_to_cnn(nGraphModel) #network = ie.read_network(model=argv.input_model) @@ -69,6 +69,8 @@ def moc_pipeline(argv: argparse.Namespace): print(user_shapes) if user_shapes: inputModel.extractSubgraph([us['node'] for us in user_shapes], []) +# for shape in user_shapes: +# inputModel.setPartialShape(shape['node'], ng.PartialShape([ng.Dimension(5,5), ng.Dimension(3), ng.Dimension(-1), ng.Dimension(-1)])) nGraphModel = fe.convert(inputModel) network = ng.function_to_cnn(nGraphModel) graph.graph['network'] = network diff --git a/ngraph/frontend/generic/include/frontend_manager/frontend_manager.hpp b/ngraph/frontend/generic/include/frontend_manager/frontend_manager.hpp index a58d4a8f075f81..1b0e7632994e0d 100644 --- a/ngraph/frontend/generic/include/frontend_manager/frontend_manager.hpp +++ b/ngraph/frontend/generic/include/frontend_manager/frontend_manager.hpp @@ -33,8 +33,8 @@ namespace ngraph // from the FW perspective virtual std::vector getNames () const; // -1 means port 0 is selected if it is exists and exception otherwise - virtual Ptr getConsumingOperation (int outputPortIndex = -1) const; - virtual Ptr getConsumingTensor (int outputPortIndex = -1) const; + virtual std::vector getConsumingOperations (int outputPortIndex = -1) const; + virtual Ptr getTargetTensor (int outputPortIndex = -1) const; virtual Ptr getProducingOperation (int inputPortIndex = -1) const; virtual Ptr getProducingPort () const; virtual Ptr getInputPort (int inputPortIndex) const; @@ -83,8 +83,7 @@ namespace ngraph // Standard specializations: "N", "C", "H", "W", "D", "L" // Issues: name collisions; too bulky to select simple layouts "NCHW" - virtual void setSourceTensorDimSpecialization (Place::Ptr place, unsigned int dimIndex, const std::string& specialization); - virtual void setTargetTensorDimSpecialization (Place::Ptr place, unsigned int dimIndex, const std::string& specialization); + virtual void setTensorDimSpecialization (Place::Ptr place, unsigned int dimIndex, const std::string& specialization); // Traversing // TODO @@ -98,15 +97,33 @@ namespace ngraph public: typedef std::shared_ptr Ptr; - // TODO: rename to loadFromPath - virtual InputModel::Ptr load (const std::string& path) const = 0; - virtual InputModel::Ptr loadFromPaths (const std::vector& paths) const; - virtual InputModel::Ptr loadFromMemory (const void* model); - virtual InputModel::Ptr loadFromMemoryFragments (const std::vector modelParts); - virtual std::shared_ptr convert (InputModel::Ptr model) const = 0; + virtual InputModel::Ptr loadFromFile (const std::string& path) const; + virtual InputModel::Ptr loadFromFiles (const std::vector& paths) const; + virtual InputModel::Ptr loadFromMemory (const void* model) const; + virtual InputModel::Ptr loadFromMemoryFragments (const std::vector& modelParts) const; + virtual InputModel::Ptr loadFromStream (std::istream& path) const; + virtual InputModel::Ptr loadFromStreams (const std::vector& paths) const; - // Convert only those parts of the model that + // Extra ctors may be provided by FW-specialized data structure for graph representaion + + // Completely convert and normalize entire function, throws if it is not possible + virtual std::shared_ptr convert (InputModel::Ptr model) const; + + // Convert only those parts of the model that can be converted, leaving others as-is + // Converted parts are not normalized by additional transformations; normalize function + // should be called to finalize the conversion process. virtual std::shared_ptr convertPartially (InputModel::Ptr model) const; + + // Convert operations 1:1 representing each FW operation as a single nGraph node with all attributes + // represented in FW-independent way + virtual std::shared_ptr convertDecodingOnly (InputModel::Ptr model) const; + + // Convert operations 1:1 with deconding only basic attributes that are required for node + // identificatoin (like name of nodes and tensors), leaving other attributes undecoded and keeping + // original FW descriptor for the node + virtual std::shared_ptr convertNoDecoding (InputModel::Ptr model) const; + + // Runs normalization passes on function that was loaded with partial conversion virtual void normalize (std::shared_ptr function) const; }; diff --git a/ngraph/frontend/generic/src/frontend_manager.cpp b/ngraph/frontend/generic/src/frontend_manager.cpp index 781165c53eace7..aa7c61e6749a90 100644 --- a/ngraph/frontend/generic/src/frontend_manager.cpp +++ b/ngraph/frontend/generic/src/frontend_manager.cpp @@ -153,32 +153,24 @@ namespace ngraph FRONT_END_NOT_IMPLEMENTED(setTensorPartialValue); } - void InputModel::setSourceTensorDimSpecialization (Place::Ptr place, unsigned int dimIndex, const std::string& specialization) + void InputModel::setTensorDimSpecialization (Place::Ptr place, unsigned int dimIndex, const std::string& specialization) { - FRONT_END_NOT_IMPLEMENTED(setSourceTensorDimSpecialization); + FRONT_END_NOT_IMPLEMENTED(setTensorDimSpecialization); } - void InputModel::setTargetTensorDimSpecialization (Place::Ptr place, unsigned int dimIndex, const std::string& specialization) - { - FRONT_END_NOT_IMPLEMENTED(setTargetTensorDimSpecialization); - } - - // All associated names that uniquely identify this place in the graph - // from the FW perspective std::vector Place::getNames () const { FRONT_END_NOT_IMPLEMENTED(getNames); } - // -1 means port 0 is selected if it is exists and exception otherwise - Place::Ptr Place::getConsumingOperation (int outputPortIndex) const + std::vector Place::getConsumingOperations (int outputPortIndex) const { - FRONT_END_NOT_IMPLEMENTED(getConsumingOperation); + FRONT_END_NOT_IMPLEMENTED(getConsumingOperations); } - Place::Ptr Place::getConsumingTensor (int outputPortIndex) const + Place::Ptr Place::getTargetTensor (int outputPortIndex) const { - FRONT_END_NOT_IMPLEMENTED(getConsumingTensor); + FRONT_END_NOT_IMPLEMENTED(getTargetTensor); } Place::Ptr Place::getProducingOperation (int inputPortIndex) const @@ -349,37 +341,67 @@ namespace ngraph { } - virtual InputModel::Ptr load (const std::string& path) const + virtual InputModel::Ptr loadFromFile (const std::string& path) const override { return std::make_shared(path); } - virtual std::shared_ptr convert (InputModel::Ptr model) const + virtual std::shared_ptr convert (InputModel::Ptr model) const override { return import_onnx_model(std::dynamic_pointer_cast(model)->editor); } }; - InputModel::Ptr FrontEnd::loadFromPaths (const std::vector& paths) const + InputModel::Ptr FrontEnd::loadFromFile (const std::string& paths) const + { + FRONT_END_NOT_IMPLEMENTED(loadFromFile); + } + + InputModel::Ptr FrontEnd::loadFromFiles (const std::vector& paths) const { - FRONT_END_NOT_IMPLEMENTED(loadFromPaths); + FRONT_END_NOT_IMPLEMENTED(loadFromFiles); } - InputModel::Ptr FrontEnd::loadFromMemory (const void* model) + InputModel::Ptr FrontEnd::loadFromMemory (const void* model) const { FRONT_END_NOT_IMPLEMENTED(loadFromMemory); } - InputModel::Ptr FrontEnd::loadFromMemoryFragments (const std::vector modelParts) + InputModel::Ptr FrontEnd::loadFromMemoryFragments (const std::vector& modelParts) const { FRONT_END_NOT_IMPLEMENTED(loadFromMemoryFragments); } + InputModel::Ptr FrontEnd::loadFromStream (std::istream& path) const + { + FRONT_END_NOT_IMPLEMENTED(loadFromStream); + } + + InputModel::Ptr FrontEnd::loadFromStreams (const std::vector& paths) const + { + FRONT_END_NOT_IMPLEMENTED(loadFromStreams); + } + + std::shared_ptr FrontEnd::convert (InputModel::Ptr model) const + { + FRONT_END_NOT_IMPLEMENTED(convert); + } + std::shared_ptr FrontEnd::convertPartially (InputModel::Ptr model) const { FRONT_END_NOT_IMPLEMENTED(convertPartially); } + std::shared_ptr FrontEnd::convertDecodingOnly (InputModel::Ptr model) const + { + FRONT_END_NOT_IMPLEMENTED(convertDecodingOnly); + } + + std::shared_ptr FrontEnd::convertNoDecoding (InputModel::Ptr model) const + { + FRONT_END_NOT_IMPLEMENTED(convertNoDecoding); + } + void FrontEnd::normalize (std::shared_ptr function) const { FRONT_END_NOT_IMPLEMENTED(normalize); diff --git a/ngraph/python/src/ngraph/__init__.py b/ngraph/python/src/ngraph/__init__.py index bfeedbc81fc21a..860919b42931a0 100644 --- a/ngraph/python/src/ngraph/__init__.py +++ b/ngraph/python/src/ngraph/__init__.py @@ -24,6 +24,8 @@ __version__ = "0.0.0.dev0" from ngraph.impl import Node +from ngraph.impl import PartialShape +from ngraph.impl import Dimension from ngraph.impl import Function from ngraph.impl import FrontEndManager from ngraph.impl import FrontEndCapabilities diff --git a/ngraph/python/src/ngraph/impl/__init__.py b/ngraph/python/src/ngraph/impl/__init__.py index 9be3eef4fda81a..048d67b2953592 100644 --- a/ngraph/python/src/ngraph/impl/__init__.py +++ b/ngraph/python/src/ngraph/impl/__init__.py @@ -48,6 +48,7 @@ from _pyngraph import Node from _pyngraph import Type from _pyngraph import PartialShape +from _pyngraph import Dimension from _pyngraph import Shape from _pyngraph import Strides from _pyngraph import CoordinateDiff diff --git a/ngraph/python/src/pyngraph/frontend_manager.cpp b/ngraph/python/src/pyngraph/frontend_manager.cpp index ee7c2b8fa986e6..c71a208d91cb17 100644 --- a/ngraph/python/src/pyngraph/frontend_manager.cpp +++ b/ngraph/python/src/pyngraph/frontend_manager.cpp @@ -40,7 +40,7 @@ void regclass_pyngraph_FrontEnd(py::module m) py::class_> fem(m, "FrontEnd", py::dynamic_attr()); fem.doc() = "ngraph.impl.FrontEnd wraps ngraph::frontend::FrontEnd"; - fem.def("load", &ngraph::frontend::FrontEnd::load); + fem.def("loadFromFile", &ngraph::frontend::FrontEnd::loadFromFile); fem.def("convert", &ngraph::frontend::FrontEnd::convert); } @@ -59,6 +59,7 @@ void regclass_pyngraph_InputModel(py::module m) im.doc() = "ngraph.impl.InputModel wraps ngraph::frontend::InputModel"; im.def("extractSubgraph", &ngraph::frontend::InputModel::extractSubgraph); im.def("getPlaceByTensorName", &ngraph::frontend::InputModel::getPlaceByTensorName); + im.def("setPartialShape", &ngraph::frontend::InputModel::setPartialShape); } void regclass_pyngraph_FEC(py::module m) From cfaf57dea69c5160d3c67d38483fba18d86a2dc1 Mon Sep 17 00:00:00 2001 From: "Lyalin, Sergey" Date: Fri, 26 Feb 2021 13:17:49 +0300 Subject: [PATCH 047/116] Fixed PDPD C++ prototype functionality --- inference-engine/samples/pdpd_poc/main.cpp | 49 +++++++++++++++------- tools/pdpd_poc/download_model.py | 7 ++++ 2 files changed, 41 insertions(+), 15 deletions(-) create mode 100644 tools/pdpd_poc/download_model.py diff --git a/inference-engine/samples/pdpd_poc/main.cpp b/inference-engine/samples/pdpd_poc/main.cpp index 1874c26c6264af..a1ac13d048a7a3 100644 --- a/inference-engine/samples/pdpd_poc/main.cpp +++ b/inference-engine/samples/pdpd_poc/main.cpp @@ -18,7 +18,7 @@ #include #include -#include +#include "framework.pb.h" #include #include @@ -29,7 +29,7 @@ using namespace google; using namespace paddle::framework; inline void MY_ASSERT(bool ex, const std::string& msg = "Unspecified error.") { - if (!ex) throw std::runtime_error(msg + std::endl); + if (!ex) throw std::runtime_error(msg); } std::map TYPE_MAP{ @@ -145,10 +145,21 @@ bool get_bool(proto::OpDesc op, std::string name, bool def = false) { } } -typedef std::shared_ptr(*CreatorFunction)(const std::map>>& inputs, +typedef std::shared_ptr(*CreatorFunction)(std::map>>& inputs, const proto::OpDesc& op, const proto::BlockDesc& block); -std::shared_ptr conv2d_creator(const std::map>>& inputs, +template +void print (const T& a) +{ + std::cerr << "["; + for(const auto& e: a) + { + std::cerr << e << ", "; + } + std::cerr << "]\n"; +} + +std::shared_ptr conv2d_creator(std::map>>& inputs, const proto::OpDesc& op, const proto::BlockDesc& block) { std::cout << "Running conv2d creator" << std::endl; MY_ASSERT(inputs["Input"].size() == 1 && inputs["Filter"].size() == 1, "More then one input for conv2d"); @@ -160,6 +171,9 @@ std::shared_ptr conv2d_creator(const std::map(data, filter, ngraph::Strides(strides.begin(), strides.end()), @@ -169,7 +183,7 @@ std::shared_ptr conv2d_creator(const std::map batch_norm_creator(const std::map>>& inputs, +std::shared_ptr batch_norm_creator(std::map>>& inputs, const proto::OpDesc& op, const proto::BlockDesc& block) { MY_ASSERT(inputs["X"].size() == 1 && inputs["Scale"].size() == 1 && @@ -186,14 +200,14 @@ std::shared_ptr batch_norm_creator(const std::map relu_creator(const std::map>>& inputs, +std::shared_ptr relu_creator(std::map>>& inputs, const proto::OpDesc& op, const proto::BlockDesc& block) { MY_ASSERT(inputs["X"].size() == 1, "More then one input for relu"); auto data = inputs["X"][0]; return std::make_shared(data); } -std::shared_ptr pool2d_creator(const std::map>>& inputs, +std::shared_ptr pool2d_creator(std::map>>& inputs, const proto::OpDesc& op, const proto::BlockDesc& block) { MY_ASSERT(inputs["X"].size() == 1, "More then one input for pool2d"); auto data = inputs["X"][0]; @@ -220,7 +234,7 @@ std::shared_ptr pool2d_creator(const std::map elementwise_add_creator(const std::map>>& inputs, +std::shared_ptr elementwise_add_creator(std::map>>& inputs, const proto::OpDesc& op, const proto::BlockDesc& block) { MY_ASSERT(inputs["X"].size() == 1 && inputs["Y"].size() == 1, "More then one input for elementwise_add"); auto x = inputs["X"][0]; @@ -229,7 +243,7 @@ std::shared_ptr elementwise_add_creator(const std::map(x, y); } -std::shared_ptr mul_creator(const std::map>>& inputs, +std::shared_ptr mul_creator(std::map>>& inputs, const proto::OpDesc& op, const proto::BlockDesc& block) { MY_ASSERT(inputs["X"].size() == 1 && inputs["Y"].size() == 1, "More then one input for mul"); auto x = inputs["X"][0]; @@ -258,7 +272,7 @@ std::shared_ptr mul_creator(const std::map(x, y); } -std::shared_ptr scale_creator(const std::map>>& inputs, +std::shared_ptr scale_creator(std::map>>& inputs, const proto::OpDesc& op, const proto::BlockDesc& block) { MY_ASSERT(inputs["X"].size() == 1, "More then one input for scale"); auto data = inputs["X"][0]; @@ -266,12 +280,12 @@ std::shared_ptr scale_creator(const std::map(data, scale); } -std::shared_ptr make_ng_node(const std::map>& inputs, - const std::map>& nodes, +std::shared_ptr make_ng_node(std::map>& inputs, + std::map>& nodes, const paddle::framework::proto::OpDesc& op, const paddle::framework::proto::BlockDesc& block) { std::cout << "Making node: " << op.type() << std::endl; - std::map CREATORS_MAP{ + std::map CREATORS_MAP = { {"conv2d", conv2d_creator}, {"batch_norm", batch_norm_creator}, {"relu", relu_creator}, @@ -342,10 +356,13 @@ std::shared_ptr convert_model(const std::string& model_dir) { vars_dict[var.name()] = var.type(); } for (int i = 0; i < block.ops_size(); i++) { + std::cerr << "Observing index i = " << i << "\n"; const auto& op = block.ops()[i]; + std::cerr << "Observing " << op.type() << "\n"; std::map> outputs_dict; for (const auto& output : op.outputs()) { outputs_dict[output.parameter()] = output.arguments(); + std::cerr << output.parameter() << "\n"; } std::map> inputs_dict; for (const auto& input : op.inputs()) { @@ -381,7 +398,9 @@ std::shared_ptr convert_model(const std::string& model_dir) { } else { auto node = make_ng_node(inputs_dict, nodes_dict, op, block); - node->set_friendly_name(outputs_dict["Out"][0]); + std::cerr << "Node created: " << node << "\n"; + node->set_friendly_name(op.outputs()[0].parameter()); + std::cerr << "Named with " << node->get_friendly_name() << "\n"; for (const auto& item : outputs_dict) { MY_ASSERT(item.second.size() <= 1); if (item.second.size() == 1) { @@ -396,7 +415,7 @@ std::shared_ptr convert_model(const std::string& model_dir) { int main(int argc, char* argv[]) { try { - std::string model_path = "/home/mvafin/.paddlehub/modules/resnet_v2_50_imagenet/model"; + std::string model_path = "/home/slyalin/.paddlehub/modules/resnet_v2_50_imagenet/model"; auto func = convert_model(model_path); CNNNetwork net(func); //net.reshape({ {"@HUB_resnet_v2_50_imagenet@image"}, {1, 3, 224, 224} }); diff --git a/tools/pdpd_poc/download_model.py b/tools/pdpd_poc/download_model.py new file mode 100644 index 00000000000000..8e60fa00cedd42 --- /dev/null +++ b/tools/pdpd_poc/download_model.py @@ -0,0 +1,7 @@ +def download_pdpd_resnet50(): + import paddlehub as hub + module = hub.Module(name="resnet_v2_50_imagenet") + return module.directory + +print(download_pdpd_resnet50()) + From 1fdd30adb04e9faaf8bfc5b8b981de1b3c4d82c8 Mon Sep 17 00:00:00 2001 From: "Lyalin, Sergey" Date: Sat, 27 Feb 2021 14:03:20 +0300 Subject: [PATCH 048/116] Cleanier code to call new FE API depending on framework --- model-optimizer/mo/main.py | 19 +++++++++++---- model-optimizer/mo/pipeline/unified.py | 23 ++++++++----------- model-optimizer/mo/utils/cli_parser.py | 8 ++++++- model-optimizer/mo/utils/versions_checker.py | 9 +++++--- .../frontend/generic/src/frontend_manager.cpp | 2 +- 5 files changed, 39 insertions(+), 22 deletions(-) diff --git a/model-optimizer/mo/main.py b/model-optimizer/mo/main.py index a69723fa0754fc..3e24231bc91928 100644 --- a/model-optimizer/mo/main.py +++ b/model-optimizer/mo/main.py @@ -43,6 +43,8 @@ from mo.utils.version import get_version from mo.utils.versions_checker import check_requirements +from ngraph import FrontEndManager + def replace_ext(name: str, old: str, new: str): base, ext = os.path.splitext(name) @@ -97,9 +99,18 @@ def print_argv(argv: argparse.Namespace, is_caffe: bool, is_tf: bool, is_mxnet: def prepare_ir(argv: argparse.Namespace): is_tf, is_caffe, is_mxnet, is_kaldi, is_onnx = deduce_framework_by_namespace(argv) + new_front_ends = [] + if not argv.use_legacy_frontend: + fem = FrontEndManager() + new_front_ends = fem.availableFrontEnds() + argv.feManager = fem + if not any([is_tf, is_caffe, is_mxnet, is_kaldi, is_onnx]): - raise Error('Framework {} is not a valid target. Please use --framework with one from the list: caffe, tf, ' - 'mxnet, kaldi, onnx. ' + refer_to_faq_msg(15), argv.framework) + frameworks = ['tf', 'caffe', 'mxnet', 'kaldi', 'onnx'] + frameworks = list(set(frameworks + new_front_ends)) + if argv.framework not in frameworks: + raise Error('Framework {} is not a valid target. Please use --framework with one from the list: {}. ' + + refer_to_faq_msg(15), argv.framework, frameworks) if is_tf and not argv.input_model and not argv.saved_model_dir and not argv.input_meta_graph: raise Error('Path to input model or saved model dir is required: use --input_model, --saved_model_dir or ' @@ -231,12 +242,12 @@ def prepare_ir(argv: argparse.Namespace): t.send_event('mo', 'framework', 'kaldi') from mo.front.kaldi.register_custom_ops import get_front_classes import_extensions.load_dirs(argv.framework, extensions, get_front_classes) - elif is_onnx and argv.use_legacy_frontend: + elif is_onnx and ('onnx' not in new_front_ends or argv.use_legacy_frontend): t.send_event('mo', 'framework', 'onnx') from mo.front.onnx.register_custom_ops import get_front_classes import_extensions.load_dirs(argv.framework, extensions, get_front_classes) - if not(is_onnx and not argv.use_legacy_frontend): + if argv.framework not in new_front_ends or argv.use_legacy_frontend: graph = unified_pipeline(argv) else: graph = moc_pipeline(argv) diff --git a/model-optimizer/mo/pipeline/unified.py b/model-optimizer/mo/pipeline/unified.py index 3493840be06747..e7817b8c4693f9 100644 --- a/model-optimizer/mo/pipeline/unified.py +++ b/model-optimizer/mo/pipeline/unified.py @@ -23,9 +23,13 @@ from extensions.front.input_cut import InputCut from extensions.front.output_cut import OutputCut from mo.utils.class_registration import apply_replacements_list +from ngraph import FrontEndManager +from ngraph import function_to_cnn +import logging as log def unified_pipeline(argv: argparse.Namespace): + log.info('Legacy unified pipeline') graph = Graph(cmd_params=argv, name=argv.model_name, ir_version=get_ir_version(argv)) class_registration.apply_replacements(graph, [ class_registration.ClassType.LOADER, @@ -36,20 +40,13 @@ def unified_pipeline(argv: argparse.Namespace): return graph def moc_pipeline(argv: argparse.Namespace): - from openvino.inference_engine import IECore - from openvino.inference_engine import IENetwork - import ngraph as ng - print('ngrph.dir = ' + str(dir(ng))) - from ngraph import FrontEndManager - ie = IECore() - fem = FrontEndManager() - print('fem.availableFrontEnds: ' + str(fem.availableFrontEnds())) - fe = fem.loadByFramework('onnx') + log.info('New MOC pipeline') + fem = argv.feManager if 'feManager' in argv else FrontEndManager() + log.info('fem.availableFrontEnds: ' + str(fem.availableFrontEnds())) + fe = fem.loadByFramework(argv.framework) print(fe) inputModel = fe.loadFromFile(argv.input_model) - #nGraphModel = fe.convert(inputModel) - #network = ng.function_to_cnn(nGraphModel) - #network = ie.read_network(model=argv.input_model) + # Wrap nGraph network to Graph for smoothly pass through the legacy code in MO. # This trick doesn't mean that we will hold Graph forever as a wrapper, it is derived from @@ -72,6 +69,6 @@ def moc_pipeline(argv: argparse.Namespace): # for shape in user_shapes: # inputModel.setPartialShape(shape['node'], ng.PartialShape([ng.Dimension(5,5), ng.Dimension(3), ng.Dimension(-1), ng.Dimension(-1)])) nGraphModel = fe.convert(inputModel) - network = ng.function_to_cnn(nGraphModel) + network = function_to_cnn(nGraphModel) graph.graph['network'] = network return graph \ No newline at end of file diff --git a/model-optimizer/mo/utils/cli_parser.py b/model-optimizer/mo/utils/cli_parser.py index 030fd169b0135d..b2bd098a48f0f5 100644 --- a/model-optimizer/mo/utils/cli_parser.py +++ b/model-optimizer/mo/utils/cli_parser.py @@ -31,6 +31,8 @@ from mo.utils.utils import refer_to_faq_msg from mo.utils.version import get_version +from ngraph import FrontEndManager + class DeprecatedStoreTrue(argparse.Action): def __init__(self, nargs=0, **kw): @@ -635,10 +637,14 @@ def get_all_cli_parser(): """ parser = argparse.ArgumentParser(usage='%(prog)s [options]') + # TODO: Move FE API load to a single place (except this place there is another one when it is loaded). + fem = FrontEndManager() + frameworks = list(set(['tf', 'caffe', 'mxnet', 'kaldi', 'onnx'] + fem.availableFrontEnds())) + parser.add_argument('--framework', help='Name of the framework used to train the input model.', type=str, - choices=['tf', 'caffe', 'mxnet', 'kaldi', 'onnx']) + choices=frameworks) get_common_cli_parser(parser=parser) diff --git a/model-optimizer/mo/utils/versions_checker.py b/model-optimizer/mo/utils/versions_checker.py index 627be8fe4ad010..03388e4c423c03 100644 --- a/model-optimizer/mo/utils/versions_checker.py +++ b/model-optimizer/mo/utils/versions_checker.py @@ -139,9 +139,12 @@ def get_module_version_list_from_file(file_name, env_setup): [('tensorflow', '>=', '1.2.0'), ('networkx', '==', '2.1'), ('numpy', None, None)] """ req_dict = list() - with open(file_name) as f: - for line in f: - req_dict = parse_and_filter_versions_list(line, req_dict, env_setup) + try: + with open(file_name) as f: + for line in f: + req_dict = parse_and_filter_versions_list(line, req_dict, env_setup) + except FileNotFoundError: + log.warning("No file with name {} that contains requirements for selected framework was found".format(file_name)) return req_dict diff --git a/ngraph/frontend/generic/src/frontend_manager.cpp b/ngraph/frontend/generic/src/frontend_manager.cpp index aa7c61e6749a90..074dd434467e00 100644 --- a/ngraph/frontend/generic/src/frontend_manager.cpp +++ b/ngraph/frontend/generic/src/frontend_manager.cpp @@ -420,7 +420,7 @@ namespace ngraph std::vector FrontEndManager::availableFrontEnds () const { - return std::vector(1, "onnx"); + return {"onnx"}; } } // namespace frontend From d16ed3dae6b50bb2335770653665709599230ce6 Mon Sep 17 00:00:00 2001 From: "Lyalin, Sergey" Date: Sat, 27 Feb 2021 18:42:28 +0300 Subject: [PATCH 049/116] Integrated PDPD PoC C++ code under FE API with immediate activation inside MO; use --framework pdpd. --- .../samples/pdpd_poc/CMakeLists.txt | 17 ------ model-optimizer/mo/pipeline/unified.py | 1 + model-optimizer/mo/utils/cli_parser.py | 4 +- ngraph/frontend/generic/CMakeLists.txt | 9 ++-- .../frontend_manager/frontend_manager.hpp | 2 + .../frontend/generic/src/frontend_manager.cpp | 13 +++-- .../generic/src/pdpd}/framework.proto | 0 .../frontend/generic/src/pdpd/pdpd.cpp | 24 +++++---- ngraph/frontend/generic/src/pdpd/pdpd.hpp | 53 +++++++++++++++++++ 9 files changed, 87 insertions(+), 36 deletions(-) delete mode 100644 inference-engine/samples/pdpd_poc/CMakeLists.txt rename {inference-engine/samples/pdpd_poc => ngraph/frontend/generic/src/pdpd}/framework.proto (100%) rename inference-engine/samples/pdpd_poc/main.cpp => ngraph/frontend/generic/src/pdpd/pdpd.cpp (97%) create mode 100644 ngraph/frontend/generic/src/pdpd/pdpd.hpp diff --git a/inference-engine/samples/pdpd_poc/CMakeLists.txt b/inference-engine/samples/pdpd_poc/CMakeLists.txt deleted file mode 100644 index f899a85e390a99..00000000000000 --- a/inference-engine/samples/pdpd_poc/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -# Copyright (C) 2018-2020 Intel Corporation -# SPDX-License-Identifier: Apache-2.0 -# - -file (GLOB SRC ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) -file (GLOB HDR ${CMAKE_CURRENT_SOURCE_DIR}/*.hpp) - -find_package(Protobuf REQUIRED IMPORTED) -include_directories(${Protobuf_INCLUDE_DIRS}) -protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS framework.proto) - -ie_add_sample(NAME pdpd_poc - SOURCES ${SRC} ${PROTO_SRCS} - HEADERS ${HDR} ${PROTO_HDRS} - DEPENDENCIES format_reader ngraph libprotobuf libprotoc - OPENCV_DEPENDENCIES imgcodecs - EXCLUDE_CPPLINT) diff --git a/model-optimizer/mo/pipeline/unified.py b/model-optimizer/mo/pipeline/unified.py index e7817b8c4693f9..30ebc2fb32246f 100644 --- a/model-optimizer/mo/pipeline/unified.py +++ b/model-optimizer/mo/pipeline/unified.py @@ -43,6 +43,7 @@ def moc_pipeline(argv: argparse.Namespace): log.info('New MOC pipeline') fem = argv.feManager if 'feManager' in argv else FrontEndManager() log.info('fem.availableFrontEnds: ' + str(fem.availableFrontEnds())) + log.info('Initializing new FE for framework {}'.format(argv.framework)) fe = fem.loadByFramework(argv.framework) print(fe) inputModel = fe.loadFromFile(argv.input_model) diff --git a/model-optimizer/mo/utils/cli_parser.py b/model-optimizer/mo/utils/cli_parser.py index b2bd098a48f0f5..5732cf4ad88f77 100644 --- a/model-optimizer/mo/utils/cli_parser.py +++ b/model-optimizer/mo/utils/cli_parser.py @@ -106,8 +106,8 @@ def readable_file(path: str): :param path: path to check :return: path if the file is readable """ - if not os.path.isfile(path): - raise Error('The "{}" is not existing file'.format(path)) + if not os.path.exists(path): + raise Error('The "{}" doesn\'t exist'.format(path)) elif not os.access(path, os.R_OK): raise Error('The "{}" is not readable'.format(path)) else: diff --git a/ngraph/frontend/generic/CMakeLists.txt b/ngraph/frontend/generic/CMakeLists.txt index f775b43925db0f..703dbe38828246 100644 --- a/ngraph/frontend/generic/CMakeLists.txt +++ b/ngraph/frontend/generic/CMakeLists.txt @@ -14,10 +14,13 @@ # limitations under the License. # ****************************************************************************** -file(GLOB_RECURSE LIBRARY_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp) -file(GLOB_RECURSE LIBRARY_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/src/*.hpp) +file(GLOB_RECURSE LIBRARY_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cc) +file(GLOB_RECURSE LIBRARY_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/src/*.hpp ${CMAKE_CURRENT_SOURCE_DIR}/src/*.h) file(GLOB_RECURSE LIBRARY_PUBLIC_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/include/*.hpp) +find_package(Protobuf REQUIRED IMPORTED) +include_directories(${Protobuf_INCLUDE_DIRS}) + set(FRONTEND_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include) # Create named folders for the sources within the .vcproj @@ -41,7 +44,7 @@ endif() # TODO: Add other frontends to the list of dependencies temporary; in the produce version they should be discovered # TODO: in runtime. -target_link_libraries(frontend_manager PRIVATE onnx_importer PUBLIC ngraph) +target_link_libraries(frontend_manager PRIVATE onnx_importer ${Protobuf_LIBRARIES} PUBLIC ngraph) set(FRONTEND_INSTALL_INCLUDE "${NGRAPH_INSTALL_INCLUDE}/ngraph/frontend/generic") target_include_directories(frontend_manager SYSTEM PUBLIC $ diff --git a/ngraph/frontend/generic/include/frontend_manager/frontend_manager.hpp b/ngraph/frontend/generic/include/frontend_manager/frontend_manager.hpp index 1b0e7632994e0d..1ab39acb6f829c 100644 --- a/ngraph/frontend/generic/include/frontend_manager/frontend_manager.hpp +++ b/ngraph/frontend/generic/include/frontend_manager/frontend_manager.hpp @@ -14,6 +14,8 @@ // limitations under the License. //***************************************************************************** +#pragma once + #include #include #include "ngraph/function.hpp" diff --git a/ngraph/frontend/generic/src/frontend_manager.cpp b/ngraph/frontend/generic/src/frontend_manager.cpp index 074dd434467e00..81ac04445c9aee 100644 --- a/ngraph/frontend/generic/src/frontend_manager.cpp +++ b/ngraph/frontend/generic/src/frontend_manager.cpp @@ -18,6 +18,7 @@ #include "onnx_import/onnx.hpp" #include "onnx_import/editor/editor.hpp" #include "frontend_manager/frontend_manager.hpp" +#include "pdpd/pdpd.hpp" namespace ngraph @@ -409,18 +410,22 @@ namespace ngraph FrontEnd::Ptr FrontEndManager::loadByFramework (const std::string& framework, FrontEndCapabilities fec) { - NGRAPH_CHECK(framework == "onnx"); - return std::make_shared(); + if (framework == "onnx") + return std::make_shared(); + else if (framework == "pdpd") + return std::make_shared(); + else + throw "Framework " + framework + " is unknown for FrontEnd manager; cannot load it."; } FrontEnd::Ptr FrontEndManager::loadByModel (const std::string& path, FrontEndCapabilities fec) { - return loadByFramework("onnx"); + FRONT_END_NOT_IMPLEMENTED(loadByModel); } std::vector FrontEndManager::availableFrontEnds () const { - return {"onnx"}; + return {"onnx", "pdpd"}; } } // namespace frontend diff --git a/inference-engine/samples/pdpd_poc/framework.proto b/ngraph/frontend/generic/src/pdpd/framework.proto similarity index 100% rename from inference-engine/samples/pdpd_poc/framework.proto rename to ngraph/frontend/generic/src/pdpd/framework.proto diff --git a/inference-engine/samples/pdpd_poc/main.cpp b/ngraph/frontend/generic/src/pdpd/pdpd.cpp similarity index 97% rename from inference-engine/samples/pdpd_poc/main.cpp rename to ngraph/frontend/generic/src/pdpd/pdpd.cpp index a1ac13d048a7a3..833e1de1482ccf 100644 --- a/inference-engine/samples/pdpd_poc/main.cpp +++ b/ngraph/frontend/generic/src/pdpd/pdpd.cpp @@ -9,22 +9,15 @@ #include #include #include - -#include -#include -#include -#include -#include -#include -#include +#include #include "framework.pb.h" +#include "pdpd.hpp" + #include #include -using namespace InferenceEngine; - using namespace google; using namespace paddle::framework; @@ -413,6 +406,16 @@ std::shared_ptr convert_model(const std::string& model_dir) { return std::make_shared(result_nodes, parameter_nodes); } +std::shared_ptr ngraph::frontend::FrontEndPDPD::convert (InputModel::Ptr model) const +{ + std::string path = std::dynamic_pointer_cast(model)->path; + std::cerr << "[ INFO ] PFrontEndPDPD::convert invoked\n"; + auto f = convert_model(path); + std::cerr << "[ INFO ] Resulting nGraph function contains " << f->get_ops().size() << "\n"; + return f; +} + +#if 0 int main(int argc, char* argv[]) { try { std::string model_path = "/home/slyalin/.paddlehub/modules/resnet_v2_50_imagenet/model"; @@ -429,3 +432,4 @@ int main(int argc, char* argv[]) { return 0; } +#endif \ No newline at end of file diff --git a/ngraph/frontend/generic/src/pdpd/pdpd.hpp b/ngraph/frontend/generic/src/pdpd/pdpd.hpp new file mode 100644 index 00000000000000..6937e1951197e8 --- /dev/null +++ b/ngraph/frontend/generic/src/pdpd/pdpd.hpp @@ -0,0 +1,53 @@ +//***************************************************************************** +// Copyright 2017-2021 Intel Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//***************************************************************************** + +#pragma once + +// TODO: include it by just frontend_manager.hpp without path +#include "../../include/frontend_manager/frontend_manager.hpp" + +namespace ngraph +{ + namespace frontend + { + class InputModelPDPD : public InputModel + { + public: + + std::string path; + + InputModelPDPD (const std::string& _path) : path(_path) {} + }; + + class FrontEndPDPD : public FrontEnd + { + public: + + FrontEndPDPD () + { + } + + virtual InputModel::Ptr loadFromFile (const std::string& path) const override + { + return std::make_shared(path); + } + + virtual std::shared_ptr convert (InputModel::Ptr model) const override; + }; + + } // namespace frontend + +} // namespace ngraph From ea736304e7d4cbc78986a6907f5d773de8bc4cac Mon Sep 17 00:00:00 2001 From: "Lyalin, Sergey" Date: Tue, 9 Mar 2021 23:29:00 +0300 Subject: [PATCH 050/116] Added placehodler for TF frontend --- ngraph/frontend/CMakeLists.txt | 1 + ngraph/frontend/generic/CMakeLists.txt | 16 +- .../frontend/generic/src/frontend_manager.cpp | 5 +- ngraph/frontend/tensorflow/CMakeLists.txt | 66 +++++++ .../tensorflow_frontend/tensorflow.hpp | 54 ++++++ .../src/proto/allocation_description.proto | 29 +++ .../tensorflow/src/proto/api_def.proto | 136 +++++++++++++ .../tensorflow/src/proto/attr_value.proto | 64 +++++++ .../tensorflow/src/proto/cost_graph.proto | 89 +++++++++ .../src/proto/dataset_options.proto | 179 ++++++++++++++++++ .../src/proto/device_attributes.proto | 53 ++++++ .../tensorflow/src/proto/function.proto | 126 ++++++++++++ .../frontend/tensorflow/src/proto/graph.proto | 56 ++++++ .../src/proto/graph_transfer_info.proto | 71 +++++++ .../tensorflow/src/proto/kernel_def.proto | 48 +++++ .../tensorflow/src/proto/log_memory.proto | 95 ++++++++++ .../frontend/tensorflow/src/proto/model.proto | 130 +++++++++++++ .../tensorflow/src/proto/node_def.proto | 88 +++++++++ .../tensorflow/src/proto/op_def.proto | 174 +++++++++++++++++ .../tensorflow/src/proto/reader_base.proto | 18 ++ .../remote_fused_graph_execute_info.proto | 48 +++++ .../src/proto/resource_handle.proto | 45 +++++ .../tensorflow/src/proto/step_stats.proto | 88 +++++++++ .../tensorflow/src/proto/summary.proto | 149 +++++++++++++++ .../tensorflow/src/proto/tensor.proto | 96 ++++++++++ .../src/proto/tensor_description.proto | 24 +++ .../tensorflow/src/proto/tensor_shape.proto | 46 +++++ .../tensorflow/src/proto/tensor_slice.proto | 39 ++++ .../frontend/tensorflow/src/proto/types.proto | 89 +++++++++ .../tensorflow/src/proto/variable.proto | 84 ++++++++ .../tensorflow/src/proto/versions.proto | 33 ++++ ngraph/frontend/tensorflow/src/tensorflow.cpp | 37 ++++ ngraph/python/CMakeLists.txt | 2 +- 33 files changed, 2269 insertions(+), 9 deletions(-) create mode 100644 ngraph/frontend/tensorflow/CMakeLists.txt create mode 100644 ngraph/frontend/tensorflow/include/tensorflow_frontend/tensorflow.hpp create mode 100644 ngraph/frontend/tensorflow/src/proto/allocation_description.proto create mode 100644 ngraph/frontend/tensorflow/src/proto/api_def.proto create mode 100644 ngraph/frontend/tensorflow/src/proto/attr_value.proto create mode 100644 ngraph/frontend/tensorflow/src/proto/cost_graph.proto create mode 100644 ngraph/frontend/tensorflow/src/proto/dataset_options.proto create mode 100644 ngraph/frontend/tensorflow/src/proto/device_attributes.proto create mode 100644 ngraph/frontend/tensorflow/src/proto/function.proto create mode 100644 ngraph/frontend/tensorflow/src/proto/graph.proto create mode 100644 ngraph/frontend/tensorflow/src/proto/graph_transfer_info.proto create mode 100644 ngraph/frontend/tensorflow/src/proto/kernel_def.proto create mode 100644 ngraph/frontend/tensorflow/src/proto/log_memory.proto create mode 100644 ngraph/frontend/tensorflow/src/proto/model.proto create mode 100644 ngraph/frontend/tensorflow/src/proto/node_def.proto create mode 100644 ngraph/frontend/tensorflow/src/proto/op_def.proto create mode 100644 ngraph/frontend/tensorflow/src/proto/reader_base.proto create mode 100644 ngraph/frontend/tensorflow/src/proto/remote_fused_graph_execute_info.proto create mode 100644 ngraph/frontend/tensorflow/src/proto/resource_handle.proto create mode 100644 ngraph/frontend/tensorflow/src/proto/step_stats.proto create mode 100644 ngraph/frontend/tensorflow/src/proto/summary.proto create mode 100644 ngraph/frontend/tensorflow/src/proto/tensor.proto create mode 100644 ngraph/frontend/tensorflow/src/proto/tensor_description.proto create mode 100644 ngraph/frontend/tensorflow/src/proto/tensor_shape.proto create mode 100644 ngraph/frontend/tensorflow/src/proto/tensor_slice.proto create mode 100644 ngraph/frontend/tensorflow/src/proto/types.proto create mode 100644 ngraph/frontend/tensorflow/src/proto/variable.proto create mode 100644 ngraph/frontend/tensorflow/src/proto/versions.proto create mode 100644 ngraph/frontend/tensorflow/src/tensorflow.cpp diff --git a/ngraph/frontend/CMakeLists.txt b/ngraph/frontend/CMakeLists.txt index 6479a7f0fd7d51..d44fb8fc61236b 100644 --- a/ngraph/frontend/CMakeLists.txt +++ b/ngraph/frontend/CMakeLists.txt @@ -16,5 +16,6 @@ if (NGRAPH_ONNX_IMPORT_ENABLE) add_subdirectory(onnx_import) + add_subdirectory(tensorflow) add_subdirectory(generic) endif() diff --git a/ngraph/frontend/generic/CMakeLists.txt b/ngraph/frontend/generic/CMakeLists.txt index 703dbe38828246..a714626469b4c4 100644 --- a/ngraph/frontend/generic/CMakeLists.txt +++ b/ngraph/frontend/generic/CMakeLists.txt @@ -34,7 +34,7 @@ source_group("public include" FILES ${LIBRARY_PUBLIC_HEADERS}) add_library(frontend_manager SHARED ${LIBRARY_SRC} ${LIBRARY_HEADERS} ${LIBRARY_PUBLIC_HEADERS}) add_library(ngraph::frontend_manager ALIAS frontend_manager) -target_include_directories(frontend_manager PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../onnx_import/include) +target_include_directories(frontend_manager PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../tensorflow/include) MESSAGE("HERE4: " ${CMAKE_CURRENT_SOURCE_DIR}) if(COMMAND ie_add_vs_version_file) @@ -44,15 +44,17 @@ endif() # TODO: Add other frontends to the list of dependencies temporary; in the produce version they should be discovered # TODO: in runtime. -target_link_libraries(frontend_manager PRIVATE onnx_importer ${Protobuf_LIBRARIES} PUBLIC ngraph) +target_link_libraries(frontend_manager PRIVATE onnx_importer tensorflow_frontend ${Protobuf_LIBRARIES} PUBLIC ngraph) + +message("tensorflow: " ${TENSORFLOW_FRONTEND_INCLUDE_DIR}) set(FRONTEND_INSTALL_INCLUDE "${NGRAPH_INSTALL_INCLUDE}/ngraph/frontend/generic") -target_include_directories(frontend_manager SYSTEM PUBLIC $ - $ ${ONNX_IMPORT_INCLUDE_DIR}) +target_include_directories(frontend_manager SYSTEM PUBLIC $ + $ ${ONNX_IMPORT_INCLUDE_DIR} ${TENSORFLOW_FRONTEND_INCLUDE_DIR}) target_include_directories(frontend_manager SYSTEM PRIVATE ${NGRAPH_INCLUDE_PATH} ${ONNX_IMPORT_INCLUDE_PATH} ${ONNX_IMPORT_INCLUDE_DIR} - ${FRONTEND_INCLUDE_DIR} ) + ${FRONTEND_INCLUDE_DIR} ${TENSORFLOW_FRONTEND_INCLUDE_DIR}) -target_include_directories(frontend_manager PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src ${ONNX_IMPORT_INCLUDE_DIR}) +target_include_directories(frontend_manager PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src ${ONNX_IMPORT_INCLUDE_DIR} ${TENSORFLOW_FRONTEND_INCLUDE_DIR}) # TODO: Consider to remove the following block (inherited from onnx_import just in case). if (CMAKE_CXX_COMPILER_ID MATCHES "^(Apple)?Clang$") @@ -66,7 +68,7 @@ install(TARGETS frontend_manager EXPORT ngraphTargets ARCHIVE DESTINATION ${NGRAPH_INSTALL_LIB} COMPONENT ngraph LIBRARY DESTINATION ${NGRAPH_INSTALL_LIB} COMPONENT ngraph) -install(DIRECTORY ${FRONTEND_IMPORT_INCLUDE_DIR}/frontend_manager +install(DIRECTORY ${FRONTEND_INCLUDE_DIR}/frontend_manager DESTINATION ${FRONTEND_INSTALL_INCLUDE} COMPONENT ngraph FILES_MATCHING diff --git a/ngraph/frontend/generic/src/frontend_manager.cpp b/ngraph/frontend/generic/src/frontend_manager.cpp index 81ac04445c9aee..8e411d61fc0d85 100644 --- a/ngraph/frontend/generic/src/frontend_manager.cpp +++ b/ngraph/frontend/generic/src/frontend_manager.cpp @@ -17,6 +17,7 @@ #include #include "onnx_import/onnx.hpp" #include "onnx_import/editor/editor.hpp" +#include "tensorflow_frontend/tensorflow.hpp" #include "frontend_manager/frontend_manager.hpp" #include "pdpd/pdpd.hpp" @@ -414,6 +415,8 @@ namespace ngraph return std::make_shared(); else if (framework == "pdpd") return std::make_shared(); + else if (framework == "tf") + return std::make_shared(); else throw "Framework " + framework + " is unknown for FrontEnd manager; cannot load it."; } @@ -425,7 +428,7 @@ namespace ngraph std::vector FrontEndManager::availableFrontEnds () const { - return {"onnx", "pdpd"}; + return {"onnx", "pdpd", "tf"}; } } // namespace frontend diff --git a/ngraph/frontend/tensorflow/CMakeLists.txt b/ngraph/frontend/tensorflow/CMakeLists.txt new file mode 100644 index 00000000000000..be9b3a163fd37c --- /dev/null +++ b/ngraph/frontend/tensorflow/CMakeLists.txt @@ -0,0 +1,66 @@ +# ****************************************************************************** +# Copyright 2017-2021 Intel Corporation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ****************************************************************************** + +file(GLOB_RECURSE LIBRARY_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cc) +file(GLOB_RECURSE LIBRARY_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/src/*.hpp ${CMAKE_CURRENT_SOURCE_DIR}/src/*.h) +file(GLOB_RECURSE LIBRARY_PUBLIC_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/include/*.hpp) + +find_package(Protobuf REQUIRED IMPORTED) +include_directories(${Protobuf_INCLUDE_DIRS}) + +set(TENSORFLOW_FRONTEND_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include) + +# Create named folders for the sources within the .vcproj +# Empty name lists them directly under the .vcproj + +source_group("src" FILES ${LIBRARY_SRC}) +source_group("include" FILES ${LIBRARY_HEADERS}) +source_group("public include" FILES ${LIBRARY_PUBLIC_HEADERS}) + +set(PROTOBUF_GENERATE_CPP_APPEND_PATH ON) +file(GLOB proto_files ${CMAKE_CURRENT_SOURCE_DIR}/src/proto/*.proto) +protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS ${proto_files}) + +include_directories(${Protobuf_INCLUDE_DIRS}) + +# Create shared library +add_library(tensorflow_frontend SHARED ${LIBRARY_SRC} ${LIBRARY_HEADERS} ${LIBRARY_PUBLIC_HEADERS} ${PROTO_SRCS} ${PROTO_HDRS}) +add_library(ngraph::tensorflow_frontend ALIAS tensorflow_frontend) + +target_include_directories(tensorflow_frontend PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../generic/include ${CMAKE_CURRENT_BINARY_DIR}) + +if(COMMAND ie_add_vs_version_file) + ie_add_vs_version_file(NAME tensorflow_frontend + FILEDESCRIPTION "FrontEnd to load and convert Tensorflow file format") +endif() + +target_link_libraries(tensorflow_frontend PRIVATE ${Protobuf_LIBRARIES} PUBLIC ngraph) + +# TODO: Consider to remove the following block (inherited from onnx_import just in case). +if (CMAKE_CXX_COMPILER_ID MATCHES "^(Apple)?Clang$") + target_compile_options(tensorflow_frontend PRIVATE -Wno-undef -Wno-reserved-id-macro -Wno-switch-enum + -Wno-invalid-offsetof -Wno-shorten-64-to-32 -Wno-unused-macros -Wno-missing-variable-declarations + -Wno-unused-private-field -Wno-shadow -Wno-deprecated PUBLIC -Wno-undefined-func-template) +endif() + +install(TARGETS tensorflow_frontend EXPORT ngraphTargets + RUNTIME DESTINATION ${NGRAPH_INSTALL_LIB} COMPONENT ngraph + ARCHIVE DESTINATION ${NGRAPH_INSTALL_LIB} COMPONENT ngraph + LIBRARY DESTINATION ${NGRAPH_INSTALL_LIB} COMPONENT ngraph) + +if (NGRAPH_EXPORT_TARGETS_ENABLE) + export(TARGETS tensorflow_frontend NAMESPACE ngraph:: APPEND FILE "${NGRAPH_TARGETS_FILE}") +endif() diff --git a/ngraph/frontend/tensorflow/include/tensorflow_frontend/tensorflow.hpp b/ngraph/frontend/tensorflow/include/tensorflow_frontend/tensorflow.hpp new file mode 100644 index 00000000000000..fe3083fefbdfb9 --- /dev/null +++ b/ngraph/frontend/tensorflow/include/tensorflow_frontend/tensorflow.hpp @@ -0,0 +1,54 @@ +//***************************************************************************** +// Copyright 2017-2021 Intel Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//***************************************************************************** + +#pragma once + +// TODO: include it by just frontend_manager.hpp without path +//#include "../../include/frontend_manager/frontend_manager.hpp" +#include "frontend_manager/frontend_manager.hpp" + +namespace ngraph +{ + namespace frontend + { + class InputModelTensorflow : public InputModel + { + public: + + std::string path; + + InputModelTensorflow (const std::string& _path) : path(_path) {} + }; + + class FrontEndTensorflow : public FrontEnd + { + public: + + FrontEndTensorflow () + { + } + + virtual InputModel::Ptr loadFromFile (const std::string& path) const override + { + return std::make_shared(path); + } + + virtual std::shared_ptr convert (InputModel::Ptr model) const override; + }; + + } // namespace frontend + +} // namespace ngraph diff --git a/ngraph/frontend/tensorflow/src/proto/allocation_description.proto b/ngraph/frontend/tensorflow/src/proto/allocation_description.proto new file mode 100644 index 00000000000000..f18caa40b2bde7 --- /dev/null +++ b/ngraph/frontend/tensorflow/src/proto/allocation_description.proto @@ -0,0 +1,29 @@ +syntax = "proto3"; + +package tensorflow; + +option cc_enable_arenas = true; +option java_outer_classname = "AllocationDescriptionProtos"; +option java_multiple_files = true; +option java_package = "org.tensorflow.framework"; +option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework/allocation_description_go_proto"; + +message AllocationDescription { + // Total number of bytes requested + int64 requested_bytes = 1; + + // Total number of bytes allocated if known + int64 allocated_bytes = 2; + + // Name of the allocator used + string allocator_name = 3; + + // Identifier of the allocated buffer if known + int64 allocation_id = 4; + + // Set if this tensor only has one remaining reference + bool has_single_reference = 5; + + // Address of the allocation. + uint64 ptr = 6; +} diff --git a/ngraph/frontend/tensorflow/src/proto/api_def.proto b/ngraph/frontend/tensorflow/src/proto/api_def.proto new file mode 100644 index 00000000000000..4d5fedd74ad5c1 --- /dev/null +++ b/ngraph/frontend/tensorflow/src/proto/api_def.proto @@ -0,0 +1,136 @@ +// Defines the text format for including per-op API definition and +// overrides for client language op code generators. + +syntax = "proto3"; + +package tensorflow; +option cc_enable_arenas = true; +option java_outer_classname = "ApiDefProtos"; +option java_multiple_files = true; +option java_package = "org.tensorflow.framework"; +option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework/api_def_go_proto"; +import "attr_value.proto"; + +// Used to specify and override the default API & behavior in the +// generated code for client languages, from what you would get from +// the OpDef alone. There will be a set of ApiDefs that are common +// to all client languages, and another set per client language. +// The per-client-language ApiDefs will inherit values from the +// common ApiDefs which it can either replace or modify. +// +// We separate the API definition from the OpDef so we can evolve the +// API while remaining backwards compatible when interpretting old +// graphs. Overrides go in an "api_def.pbtxt" file with a text-format +// ApiDefs message. +// +// WARNING: Be *very* careful changing the API for any existing op -- +// you can change the semantics of existing code. These changes may +// need to wait until a major release of TensorFlow to avoid breaking +// our compatibility promises. +message ApiDef { + // Name of the op (in the OpDef) to specify the API for. + string graph_op_name = 1; + // If this op is deprecated, set deprecation message to the message + // that should be logged when this op is used. + // The message should indicate alternative op to use, if any. + string deprecation_message = 12; + // Major version when the op will be deleted. For e.g. set this + // value to 2 if op API should be removed in TensorFlow 2.0 and + // deprecated in versions before that. + int32 deprecation_version = 13; + + enum Visibility { + // Normally this is "VISIBLE" unless you are inheriting a + // different value from another ApiDef. + DEFAULT_VISIBILITY = 0; + // Publicly visible in the API. + VISIBLE = 1; + // Do not include this op in the generated API. If visibility is + // set to 'SKIP', other fields are ignored for this op. + SKIP = 2; + // Hide this op by putting it into an internal namespace (or whatever + // is appropriate in the target language). + HIDDEN = 3; + } + Visibility visibility = 2; + + // If you specify any endpoint, this will replace all of the + // inherited endpoints. The first endpoint should be the + // "canonical" endpoint, and should not be deprecated (unless all + // endpoints are deprecated). + message Endpoint { + // Name should be either like "CamelCaseName" or + // "Package.CamelCaseName". Client-language-specific ApiDefs may + // use a snake_case convention instead of CamelCase. + string name = 1; + + // Set if this endpoint is deprecated. If set to true, a message suggesting + // to use a non-deprecated endpoint instead will be printed. If all + // endpoints are deprecated, set deprecation_message in ApiDef instead. + bool deprecated = 3; + + // Major version when an endpoint will be deleted. For e.g. set this + // value to 2 if endpoint should be removed in TensorFlow 2.0 and + // deprecated in versions before that. + int32 deprecation_version = 4; + } + repeated Endpoint endpoint = 3; + + message Arg { + string name = 1; + + // Change the name used to access this arg in the API from what + // is used in the GraphDef. Note that these names in `backticks` + // will also be replaced in the summary & description fields. + string rename_to = 2; + + // Note: this will replace any inherited arg doc. There is no + // current way of modifying arg descriptions (other than replacing + // them entirely) as can be done with op descriptions. + string description = 3; + } + repeated Arg in_arg = 4; + repeated Arg out_arg = 5; + // List of original in_arg names to specify new argument order. + // Length of arg_order should be either empty to keep current order + // or match size of in_arg. + repeated string arg_order = 11; + + // Description of the graph-construction-time configuration of this + // Op. That is to say, this describes the attr fields that will + // be specified in the NodeDef. + message Attr { + string name = 1; + + // Change the name used to access this attr in the API from what + // is used in the GraphDef. Note that these names in `backticks` + // will also be replaced in the summary & description fields. + string rename_to = 2; + + // Specify a new default value to use for this attr. This default + // will be used when creating new graphs, as opposed to the + // default in the OpDef, which will be used when interpreting old + // GraphDefs. + AttrValue default_value = 3; + + // Note: this will replace any inherited attr doc, there is no current + // way of modifying attr descriptions as can be done with op descriptions. + string description = 4; + } + repeated Attr attr = 6; + + // One-line human-readable description of what the Op does. + string summary = 7; + + // Additional, longer human-readable description of what the Op does. + string description = 8; + + // Modify an existing/inherited description by adding text to the beginning + // or end. + string description_prefix = 9; + string description_suffix = 10; +} + +message ApiDefs { + repeated ApiDef op = 1; +} diff --git a/ngraph/frontend/tensorflow/src/proto/attr_value.proto b/ngraph/frontend/tensorflow/src/proto/attr_value.proto new file mode 100644 index 00000000000000..ddf134b239cb70 --- /dev/null +++ b/ngraph/frontend/tensorflow/src/proto/attr_value.proto @@ -0,0 +1,64 @@ +syntax = "proto3"; + +package tensorflow; + +import "tensor.proto"; +import "tensor_shape.proto"; +import "types.proto"; + +option cc_enable_arenas = true; +option java_outer_classname = "AttrValueProtos"; +option java_multiple_files = true; +option java_package = "org.tensorflow.framework"; +option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework/attr_value_go_proto"; + +// Protocol buffer representing the value for an attr used to configure an Op. +// Comment indicates the corresponding attr type. Only the field matching the +// attr type may be filled. +message AttrValue { + // LINT.IfChange + message ListValue { + repeated bytes s = 2; // "list(string)" + repeated int64 i = 3 [packed = true]; // "list(int)" + repeated float f = 4 [packed = true]; // "list(float)" + repeated bool b = 5 [packed = true]; // "list(bool)" + repeated DataType type = 6 [packed = true]; // "list(type)" + repeated TensorShapeProto shape = 7; // "list(shape)" + repeated TensorProto tensor = 8; // "list(tensor)" + repeated NameAttrList func = 9; // "list(attr)" + } + // LINT.ThenChange(https://www.tensorflow.org/code/tensorflow/c/c_api.cc) + + oneof value { + bytes s = 2; // "string" + int64 i = 3; // "int" + float f = 4; // "float" + bool b = 5; // "bool" + DataType type = 6; // "type" + TensorShapeProto shape = 7; // "shape" + TensorProto tensor = 8; // "tensor" + ListValue list = 1; // any "list(...)" + + // "func" represents a function. func.name is a function's name or + // a primitive op's name. func.attr.first is the name of an attr + // defined for that function. func.attr.second is the value for + // that attr in the instantiation. + NameAttrList func = 10; + + // This is a placeholder only used in nodes defined inside a + // function. It indicates the attr value will be supplied when + // the function is instantiated. For example, let us suppose a + // node "N" in function "FN". "N" has an attr "A" with value + // placeholder = "foo". When FN is instantiated with attr "foo" + // set to "bar", the instantiated node N's attr A will have been + // given the value "bar". + string placeholder = 9; + } +} + +// A list of attr names and their values. The whole list is attached +// with a string name. E.g., MatMul[T=float]. +message NameAttrList { + string name = 1; + map attr = 2; +} diff --git a/ngraph/frontend/tensorflow/src/proto/cost_graph.proto b/ngraph/frontend/tensorflow/src/proto/cost_graph.proto new file mode 100644 index 00000000000000..166c130df5fcbc --- /dev/null +++ b/ngraph/frontend/tensorflow/src/proto/cost_graph.proto @@ -0,0 +1,89 @@ +syntax = "proto3"; + +package tensorflow; + +import "tensor_shape.proto"; +import "types.proto"; + +option cc_enable_arenas = true; +option java_outer_classname = "CostGraphProtos"; +option java_multiple_files = true; +option java_package = "org.tensorflow.framework"; +option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework/cost_graph_go_proto"; + +message CostGraphDef { + message Node { + // The name of the node. Names are globally unique. + string name = 1; + + // The device of the node. Can be empty if the node is mapped to the + // default partition or partitioning hasn't been run yet. + string device = 2; + + // The id of the node. Node ids are only unique inside a partition. + int32 id = 3; + + // Inputs of this node. They must be executed before this node can be + // executed. An input is a particular output of another node, specified + // by the node id and the output index. + message InputInfo { + int32 preceding_node = 1; + int32 preceding_port = 2; + } + repeated InputInfo input_info = 4; + + // Outputs of this node. + message OutputInfo { + int64 size = 1; + // If >= 0, the output is an alias of an input. Note that an alias input + // may itself be an alias. The algorithm will therefore need to follow + // those pointers. + int64 alias_input_port = 2; + TensorShapeProto shape = 3; + DataType dtype = 4; + } + repeated OutputInfo output_info = 5; + + // Temporary memory used by this node. + int64 temporary_memory_size = 6; + + // Persistent memory used by this node. + int64 persistent_memory_size = 12; + + int64 host_temp_memory_size = 10 [deprecated = true]; + int64 device_temp_memory_size = 11 [deprecated = true]; + int64 device_persistent_memory_size = 16 [deprecated = true]; + + // Estimate of the computational cost of this node, in microseconds. + int64 compute_cost = 9; + + // Analytical estimate of the computational cost of this node, in + // microseconds. + int64 compute_time = 14; + + // Analytical estimate of the memory access cost of this node, in + // microseconds. + int64 memory_time = 15; + + // If true, the output is permanent: it can't be discarded, because this + // node is part of the "final output". Nodes may depend on final nodes. + bool is_final = 7; + + // Ids of the control inputs for this node. + repeated int32 control_input = 8; + + // Are the costs inaccurate? + bool inaccurate = 17; + } + repeated Node node = 1; + + // Total cost of this graph, typically used for balancing decisions. + message AggregatedCost { + // Aggregated cost value. + float cost = 1; + + // Aggregated cost dimension (e.g. 'memory', 'compute', 'network'). + string dimension = 2; + } + repeated AggregatedCost cost = 2; +} diff --git a/ngraph/frontend/tensorflow/src/proto/dataset_options.proto b/ngraph/frontend/tensorflow/src/proto/dataset_options.proto new file mode 100644 index 00000000000000..05e15e156254e7 --- /dev/null +++ b/ngraph/frontend/tensorflow/src/proto/dataset_options.proto @@ -0,0 +1,179 @@ +syntax = "proto3"; + +package tensorflow.data; + +// Represents the type of auto-sharding we enable. +enum AutoShardPolicy { + AUTO = 0; + FILE = 1; + DATA = 2; + OFF = -1; +} + +message DistributeOptions { + // The type of sharding that auto-shard should attempt. If this is set to + // FILE, then we will attempt to shard by files (each worker will get a set of + // files to process). If we cannot find a set of files to shard for at least + // one file per worker, we will error out. When this option is selected, make + // sure that you have enough files so that each worker gets at least one file. + // There will be a runtime error thrown if there are insufficient files. If + // this is set to DATA, then we will shard by elements produced by the + // dataset, and each worker will process the whole dataset and discard the + // portion that is not for itself. If this is set to OFF, then we will not + // autoshard, and each worker will receive a copy of the full dataset. This + // option is set to AUTO by default, AUTO will attempt to first shard by FILE, + // and fall back to sharding by DATA if we cannot find a set of files to + // shard. + AutoShardPolicy auto_shard_policy = 1; + // The number of devices attached to this input pipeline. + oneof optional_num_devices { + int32 num_devices = 2; + } +} + +message MapVectorization { + // Whether to vectorize map transformations. + oneof optional_enabled { + bool enabled = 1; + } + // Whether to use ChooseFastestBranchDataset with this transformation. If + // True, the pipeline picks between the vectorized and original segment at + // runtime based on their iterations speed. + oneof optional_use_choose_fastest { + bool use_choose_fastest = 2; + } +} + +message OptimizationOptions { + // Whether to apply default graph optimizations. If False, only graph + // optimizations that have been explicitly enabled will be applied. + oneof optional_apply_default_optimizations { + bool apply_default_optimizations = 1; + } + // Whether to automatically tune performance knobs. + oneof optional_autotune { + bool autotune = 2; + } + // When autotuning is enabled (through autotune), determines whether to also + // autotune buffer sizes for datasets with parallelism. + oneof optional_autotune_buffers { + bool autotune_buffers = 3; + } + // When autotuning is enabled (through autotune), determines the CPU budget to + // use. Values greater than the number of schedulable CPU cores are allowed + // but may result in CPU contention. + oneof optional_autotune_cpu_budget { + int32 autotune_cpu_budget = 4; + } + // When autotuning is enabled (through autotune), determines the RAM budget to + // use. Values greater than the available RAM in bytes may result in OOM. If + // 0, defaults to half of the available RAM in bytes. + oneof optional_autotune_ram_budget { + int32 autotune_ram_budget = 5; + } + // Whether to fuse filter transformations. + oneof optional_filter_fusion { + bool filter_fusion = 6; + } + // Whether to fuse filter dataset that predicts random_uniform < rate into a + // sampling dataset. + oneof optional_filter_with_random_uniform_fusion { + bool filter_with_random_uniform_fusion = 7; + } + // Whether to hoist tf.random_uniform() ops out of map transformations. + oneof optional_hoist_random_uniform { + bool hoist_random_uniform = 8; + } + // Whether to fuse map and batch transformations. + oneof optional_map_and_batch_fusion { + bool map_and_batch_fusion = 9; + } + // Whether to fuse map and filter transformations. + oneof optional_map_and_filter_fusion { + bool map_and_filter_fusion = 10; + } + // Whether to fuse map transformations. + oneof optional_map_fusion { + bool map_fusion = 11; + } + // Whether to parallelize stateless map transformations. + oneof optional_map_parallelization { + bool map_parallelization = 12; + } + // The map vectorization options associated with the dataset. + MapVectorization map_vectorization = 13; + // Whether to eliminate no-op transformations. + oneof optional_noop_elimination { + bool noop_elimination = 14; + } + // Whether to parallelize copying of batch elements. This optimization is + // highly experimental and can cause performance degradation (e.g. when the + // parallelization overhead exceeds the benefits of performing the data copies + // in parallel). You should only enable this optimization if a) your input + // pipeline is bottlenecked on batching and b) you have validated that this + // optimization improves performance. + oneof optional_parallel_batch { + bool parallel_batch = 15; + } + // Whether to reorder ops that will discard data to the front of unary + // cardinality preserving transformations, e.g. dataset.map(...).take(3) will + // be optimized to dataset.take(3).map(...). For now this optimization will + // move `skip`, `shard` and `take` to the front of `map` and `prefetch`. This + // optimization is only for performance; it will not affect the output of the + // dataset. + oneof optional_reorder_data_discarding_ops { + bool reorder_data_discarding_ops = 16; + } + // Whether to fuse shuffle and repeat transformations. + oneof optional_shuffle_and_repeat_fusion { + bool shuffle_and_repeat_fusion = 17; + } +} + +message ThreadingOptions { + // If set, it overrides the maximum degree of intra-op parallelism. + oneof optional_max_intra_op_parallelism { + int32 max_intra_op_parallelism = 1; + } + // If set, the dataset will use a private threadpool of the given size. + oneof optional_private_threadpool_size { + int32 private_threadpool_size = 2; + } +} + +// Represents how to handle external state during serialization. +enum ExternalStatePolicy { + WARN = 0; + IGNORE = 1; + FAIL = 2; +} + +// Message stored with Dataset objects to control how datasets are processed and +// optimized. +message Options { + // Whether the outputs need to be produced in deterministic order. + oneof optional_deterministic { + bool deterministic = 1; + } + // The distribution strategy options associated with the dataset. + DistributeOptions distribute_options = 2; + // The optimization options associated with the dataset. + OptimizationOptions optimization_options = 3; + // Whether to introduce 'slack' in the last `prefetch` of the input pipeline, + // if it exists. This may reduce CPU contention with accelerator host-side + // activity at the start of a step. The slack frequency is determined by the + // number of devices attached to this input pipeline. + oneof optional_slack { + bool slack = 4; + } + // The threading options associated with the dataset. + ThreadingOptions threading_options = 5; + // This option can be used to override the default policy for how to handle + // external state when serializing a dataset or checkpointing its iterator. + // There are three settings available - IGNORE: External state is ignored + // without a warning; WARN: External state is ignored and a warning is logged; + // FAIL: External state results in an error. + oneof optional_external_state_policy { + ExternalStatePolicy external_state_policy = 6; + } +} diff --git a/ngraph/frontend/tensorflow/src/proto/device_attributes.proto b/ngraph/frontend/tensorflow/src/proto/device_attributes.proto new file mode 100644 index 00000000000000..4c7a2b87e4f5d7 --- /dev/null +++ b/ngraph/frontend/tensorflow/src/proto/device_attributes.proto @@ -0,0 +1,53 @@ +syntax = "proto3"; + +package tensorflow; + +option cc_enable_arenas = true; +option java_outer_classname = "DeviceAttributesProtos"; +option java_multiple_files = true; +option java_package = "org.tensorflow.framework"; +option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework/device_attributes_go_proto"; + +message InterconnectLink { + int32 device_id = 1; + string type = 2; + int32 strength = 3; +} + +message LocalLinks { + repeated InterconnectLink link = 1; +} + +message DeviceLocality { + // Optional bus locality of device. Default value of 0 means + // no specific locality. Specific localities are indexed from 1. + int32 bus_id = 1; + + // Optional NUMA locality of device. + int32 numa_node = 2; + + // Optional local interconnect links to other devices. + LocalLinks links = 3; +} + +message DeviceAttributes { + // Fully specified name of the device within a cluster. + string name = 1; + + // String representation of device_type. + string device_type = 2; + + // Memory capacity of device in bytes. + int64 memory_limit = 4; + + // Platform-specific data about device that may be useful + // for supporting efficient data transfers. + DeviceLocality locality = 5; + + // A device is assigned a global unique number each time it is + // initialized. "incarnation" should never be 0. + fixed64 incarnation = 6; + + // String representation of the physical device that this device maps to. + string physical_device_desc = 7; +} diff --git a/ngraph/frontend/tensorflow/src/proto/function.proto b/ngraph/frontend/tensorflow/src/proto/function.proto new file mode 100644 index 00000000000000..8502ae5c494b0b --- /dev/null +++ b/ngraph/frontend/tensorflow/src/proto/function.proto @@ -0,0 +1,126 @@ +syntax = "proto3"; + +package tensorflow; + +import "attr_value.proto"; +import "node_def.proto"; +import "op_def.proto"; + +option cc_enable_arenas = true; +option java_outer_classname = "FunctionProtos"; +option java_multiple_files = true; +option java_package = "org.tensorflow.framework"; +option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework/function_go_proto"; + +// A library is a set of named functions. +message FunctionDefLibrary { + repeated FunctionDef function = 1; + repeated GradientDef gradient = 2; +} + +// A function can be instantiated when the runtime can bind every attr +// with a value. When a GraphDef has a call to a function, it must +// have binding for every attr defined in the signature. +// +// TODO(zhifengc): +// * device spec, etc. +message FunctionDef { + // The definition of the function's name, arguments, return values, + // attrs etc. + OpDef signature = 1; + + // Attributes specific to this function definition. + map attr = 5; + + // Attributes for function arguments. These attributes are the same set of + // valid attributes as to _Arg nodes. + message ArgAttrs { + map attr = 1; + } + map arg_attr = 7; + + // Unique IDs for each resource argument, used to track aliasing resources. If + // Argument A and Argument B alias each other, then + // resource_arg_unique_ids[A.index] == resource_arg_unique_ids[B.index]. + // + // If this field is empty, none of the arguments could alias; otherwise, every + // resource argument should have an entry in this field. + // + // When instantiated, the unique IDs will be attached to the _Arg nodes' + // "_resource_arg_unique_id" attribute. + map resource_arg_unique_id = 8; + + // NOTE: field id 2 deleted on Jan 11, 2017, GraphDef version 21. + reserved 2; + + // In both of the following fields, there is the need to specify an + // output that is used as either the input to another node (in + // `node_def`) or as a return value of the function (in `ret`). + // Unlike the NodeDefs in GraphDef, we need to be able to specify a + // list in some cases (instead of just single outputs). Also, we + // need to be able to deal with lists of unknown length (so the + // output index may not be known at function definition time). So + // we use the following format instead: + // * "fun_in" where "fun_in" is the name of a function input arg in + // the `signature` field above. This represents that input, whether + // it is a single tensor or a list. + // * "fun_in:0" gives the first element of a function input arg (a + // non-list input is considered a list of length 1 for these + // purposes). + // * "node:out" where "node" is the name of a node in `node_def` and + // "out" is the name one of its op's output arguments (the name + // comes from the OpDef of the node's op). This represents that + // node's output, whether it is a single tensor or a list. + // Note: We enforce that an op's output arguments are never + // renamed in the backwards-compatibility test. + // * "node:out:0" gives the first element of a node output arg (a + // non-list output is considered a list of length 1 for these + // purposes). + // + // NOT CURRENTLY SUPPORTED (but may be in the future): + // * "node:out:-1" gives last element in a node output list + // * "node:out:1:" gives a list with all but the first element in a + // node output list + // * "node:out::-1" gives a list with all but the last element in a + // node output list + + // The body of the function. Unlike the NodeDefs in a GraphDef, attrs + // may have values of type `placeholder` and the `input` field uses + // the "output" format above. + + // By convention, "op" in node_def is resolved by consulting with a + // user-defined library first. If not resolved, "func" is assumed to + // be a builtin op. + repeated NodeDef node_def = 3; + + // A mapping from the output arg names from `signature` to the + // outputs from `node_def` that should be returned by the function. + map ret = 4; + + // A mapping from control output names from `signature` to node names in + // `node_def` which should be control outputs of this function. + map control_ret = 6; +} + +// GradientDef defines the gradient function of a function defined in +// a function library. +// +// A gradient function g (specified by gradient_func) for a function f +// (specified by function_name) must follow the following: +// +// The function 'f' must be a numerical function which takes N inputs +// and produces M outputs. Its gradient function 'g', which is a +// function taking N + M inputs and produces N outputs. +// +// I.e. if we have +// (y1, y2, ..., y_M) = f(x1, x2, ..., x_N), +// then, g is +// (dL/dx1, dL/dx2, ..., dL/dx_N) = g(x1, x2, ..., x_N, +// dL/dy1, dL/dy2, ..., dL/dy_M), +// where L is a scalar-value function of (x1, x2, ..., xN) (e.g., the +// loss function). dL/dx_i is the partial derivative of L with respect +// to x_i. +message GradientDef { + string function_name = 1; // The function name. + string gradient_func = 2; // The gradient function's name. +} diff --git a/ngraph/frontend/tensorflow/src/proto/graph.proto b/ngraph/frontend/tensorflow/src/proto/graph.proto new file mode 100644 index 00000000000000..76bdf43c02ae83 --- /dev/null +++ b/ngraph/frontend/tensorflow/src/proto/graph.proto @@ -0,0 +1,56 @@ +syntax = "proto3"; + +package tensorflow; + +import "function.proto"; +import "node_def.proto"; +import "versions.proto"; + +option cc_enable_arenas = true; +option java_outer_classname = "GraphProtos"; +option java_multiple_files = true; +option java_package = "org.tensorflow.framework"; +option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework/graph_go_proto"; + +// Represents the graph of operations +message GraphDef { + repeated NodeDef node = 1; + + // Compatibility versions of the graph. See core/public/version.h for version + // history. The GraphDef version is distinct from the TensorFlow version, and + // each release of TensorFlow will support a range of GraphDef versions. + VersionDef versions = 4; + + // Deprecated single version field; use versions above instead. Since all + // GraphDef changes before "versions" was introduced were forward + // compatible, this field is entirely ignored. + int32 version = 3 [deprecated = true]; + + // "library" provides user-defined functions. + // + // Naming: + // * library.function.name are in a flat namespace. + // NOTE: We may need to change it to be hierarchical to support + // different orgs. E.g., + // { "/google/nn", { ... }}, + // { "/google/vision", { ... }} + // { "/org_foo/module_bar", { ... }} + // map named_lib; + // * If node[i].op is the name of one function in "library", + // node[i] is deemed as a function call. Otherwise, node[i].op + // must be a primitive operation supported by the runtime. + // + // + // Function call semantics: + // + // * The callee may start execution as soon as some of its inputs + // are ready. The caller may want to use Tuple() mechanism to + // ensure all inputs are ready in the same time. + // + // * The consumer of return values may start executing as soon as + // the return values the consumer depends on are ready. The + // consumer may want to use Tuple() mechanism to ensure the + // consumer does not start until all return values of the callee + // function are ready. + FunctionDefLibrary library = 2; +} diff --git a/ngraph/frontend/tensorflow/src/proto/graph_transfer_info.proto b/ngraph/frontend/tensorflow/src/proto/graph_transfer_info.proto new file mode 100644 index 00000000000000..bb6af6e990c3f8 --- /dev/null +++ b/ngraph/frontend/tensorflow/src/proto/graph_transfer_info.proto @@ -0,0 +1,71 @@ +syntax = "proto3"; + +package tensorflow; + +import "types.proto"; + +option cc_enable_arenas = true; +option java_outer_classname = "GraphTransferInfoProto"; +option java_multiple_files = true; +option java_package = "org.tensorflow.framework"; +option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework/graph_transfer_info_go_proto"; + +message GraphTransferNodeInput { + int32 node_id = 1; + int32 output_port = 2; +} +message GraphTransferNodeInfo { + string name = 1; + int32 node_id = 2; + string type_name = 3; + int32 soc_op_id = 4; + int32 padding_id = 5; + int32 input_count = 6; + int32 output_count = 7; +} +message GraphTransferConstNodeInfo { + string name = 1; + int32 node_id = 2; + repeated int64 shape = 3; + bytes data = 4; + DataType dtype = 5; +} +message GraphTransferNodeInputInfo { + int32 node_id = 1; + repeated GraphTransferNodeInput node_input = 2; +} +message GraphTransferNodeOutputInfo { + int32 node_id = 1; + repeated int32 max_byte_size = 2; +} +message GraphTransferGraphInputNodeInfo { + string name = 1; + repeated int64 shape = 2; + DataType dtype = 3; +} + +message GraphTransferGraphOutputNodeInfo { + string name = 1; + repeated int64 shape = 2; + DataType dtype = 3; +} + +// Protocol buffer representing a handle to a tensorflow resource. Handles are +// not valid across executions, but can be serialized back and forth from within +// a single run. +message GraphTransferInfo { + enum Destination { + NOP = 0; + HEXAGON = 1; + } + + repeated GraphTransferNodeInfo node_info = 1; + repeated GraphTransferConstNodeInfo const_node_info = 2; + repeated GraphTransferNodeInputInfo node_input_info = 3; + repeated GraphTransferNodeOutputInfo node_output_info = 4; + // Input Node parameters of transferred graph + repeated GraphTransferGraphInputNodeInfo graph_input_node_info = 5; + repeated GraphTransferGraphOutputNodeInfo graph_output_node_info = 6; + // Destination of graph transfer + Destination destination = 7; +} diff --git a/ngraph/frontend/tensorflow/src/proto/kernel_def.proto b/ngraph/frontend/tensorflow/src/proto/kernel_def.proto new file mode 100644 index 00000000000000..de76a496d8cf19 --- /dev/null +++ b/ngraph/frontend/tensorflow/src/proto/kernel_def.proto @@ -0,0 +1,48 @@ +syntax = "proto3"; + +package tensorflow; + +import "attr_value.proto"; + +option cc_enable_arenas = true; +option java_outer_classname = "KernelDefProtos"; +option java_multiple_files = true; +option java_package = "org.tensorflow.framework"; +option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework/kernel_def_go_proto"; + +message KernelDef { + // Must match the name of an Op. + string op = 1; + + // Type of device this kernel runs on. + string device_type = 2; + + message AttrConstraint { + // Name of an attr from the Op. + string name = 1; + + // A list of values that this kernel supports for this attr. + // Like OpDef.AttrDef.allowed_values, except for kernels instead of Ops. + AttrValue allowed_values = 2; + } + repeated AttrConstraint constraint = 3; + + // Names of the Op's input_/output_args that reside in host memory + // instead of device memory. + repeated string host_memory_arg = 4; + + // This allows experimental kernels to be registered for an op that + // won't be used unless the user specifies a "_kernel" attr with + // value matching this. + string label = 5; + + // Prioritization of kernel amongst different devices. By default we assume + // priority is 0. The higher the priority the better. By default (i.e. if + // this is not set), we prefer GPU kernels over CPU. + int32 priority = 6; +} + +// A collection of KernelDefs +message KernelList { + repeated KernelDef kernel = 1; +} diff --git a/ngraph/frontend/tensorflow/src/proto/log_memory.proto b/ngraph/frontend/tensorflow/src/proto/log_memory.proto new file mode 100644 index 00000000000000..aa30cef2aeaf4c --- /dev/null +++ b/ngraph/frontend/tensorflow/src/proto/log_memory.proto @@ -0,0 +1,95 @@ +syntax = "proto3"; + +package tensorflow; + +import "tensor_description.proto"; + +option cc_enable_arenas = true; +option java_outer_classname = "LogMemoryProtos"; +option java_multiple_files = true; +option java_package = "org.tensorflow.framework"; +option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework/log_memory_go_proto"; + +message MemoryLogStep { + // Process-unique step id. + int64 step_id = 1; + + // Handle describing the feeds and fetches of the step. + string handle = 2; +} + +message MemoryLogTensorAllocation { + // Process-unique step id. + int64 step_id = 1; + + // Name of the kernel making the allocation as set in GraphDef, + // e.g., "affine2/weights/Assign". + string kernel_name = 2; + + // Allocated tensor details. + TensorDescription tensor = 3; +} + +message MemoryLogTensorDeallocation { + // Id of the tensor buffer being deallocated, used to match to a + // corresponding allocation. + int64 allocation_id = 1; + + // Name of the allocator used. + string allocator_name = 2; +} + +message MemoryLogTensorOutput { + // Process-unique step id. + int64 step_id = 1; + + // Name of the kernel producing an output as set in GraphDef, e.g., + // "affine2/weights/Assign". + string kernel_name = 2; + + // Index of the output being set. + int32 index = 3; + + // Output tensor details. + TensorDescription tensor = 4; +} + +message MemoryLogRawAllocation { + // Process-unique step id. + int64 step_id = 1; + + // Name of the operation making the allocation. + string operation = 2; + + // Number of bytes in the allocation. + int64 num_bytes = 3; + + // Address of the allocation. + uint64 ptr = 4; + + // Id of the tensor buffer being allocated, used to match to a + // corresponding deallocation. + int64 allocation_id = 5; + + // Name of the allocator used. + string allocator_name = 6; +} + +message MemoryLogRawDeallocation { + // Process-unique step id. + int64 step_id = 1; + + // Name of the operation making the deallocation. + string operation = 2; + + // Id of the tensor buffer being deallocated, used to match to a + // corresponding allocation. + int64 allocation_id = 3; + + // Name of the allocator used. + string allocator_name = 4; + + // True if the deallocation is queued and will be performed later, + // e.g. for GPU lazy freeing of buffers. + bool deferred = 5; +} diff --git a/ngraph/frontend/tensorflow/src/proto/model.proto b/ngraph/frontend/tensorflow/src/proto/model.proto new file mode 100644 index 00000000000000..ba74d7a2b7ee19 --- /dev/null +++ b/ngraph/frontend/tensorflow/src/proto/model.proto @@ -0,0 +1,130 @@ +syntax = "proto3"; + +package tensorflow.data.model; + +option cc_enable_arenas = true; + +// Class of a node in the performance model. +enum NodeClass { + UNKNOWN = 0; + INTERLEAVE_MANY = 1; + ASYNC_INTERLEAVE_MANY = 2; + KNOWN_RATIO = 3; + ASYNC_KNOWN_RATIO = 4; + UNKNOWN_RATIO = 5; +} + +// Algorithm used for model autotuning optimization. +enum AutotuneAlgorithm { + HILL_CLIMB = 0; + GRADIENT_DESCENT = 1; +} + +// Protocol buffer representing the data used by the autotuning modeling +// framework. +message ModelProto { + // General representation of a node in the model. + message Node { + // Unique node ID. + int64 id = 1; + + // Human-readable name of the node. + string name = 2; + + // An indication whether autotuning is enabled for this node. + bool autotune = 3; + + // The number of bytes stored in this node's buffer. + int64 buffered_bytes = 4; + + // The number of elements stored in this node's buffer. + int64 buffered_elements = 5; + + // The number of bytes consumed by the node. + int64 bytes_consumed = 6; + + // The number of bytes produced by the node. + int64 bytes_produced = 7; + + // The number of elements produced by the node. + int64 num_elements = 8; + + // The aggregate processing time spent in this node. + int64 processing_time = 9; + + // An indication whether this node records metrics about produced and + // consumed elements. + bool record_metrics = 10; + + // Represents a node parameter. + message Parameter { + // Human-readable name of the parameter. + string name = 1; + + // Identifies the model value of the parameter. This can be different from + // the actual value (e.g. during optimization search). + double value = 2; + + // The actual value of the parameter. + double state_value = 3; + + // Minimum value of the parameter. + double min = 4; + + // Maximum value of the parameter. + double max = 5; + + // Identifies whether the parameter should participate in autotuning. + bool tunable = 6; + } + + // Parameters of this node. + repeated Parameter parameters = 11; + + // Statistic of inputs processing time history. + double input_processing_time_sum = 12; + int64 input_processing_time_count = 13; + + // Inputs of this node. + repeated Node inputs = 14; + + // Class of this node. + NodeClass node_class = 15; + + // Ratio of input to output elements. This is only used by KNOWN_RATIO and + // ASYNC_KNOWN_RATIO nodes. + double ratio = 16; + + // Ratio identifies how many parallelism calls are introduced by one + // buffered element. This is only used by ASYNC_KNOWN_RATIO nodes. + double memory_ratio = 17; + } + + // Output node of this model. + Node output = 1; + + // Counter for node IDs of this model. + int64 id_counter = 2; + + // Indicates whether the modeling framework should collect resource usage, + // e.g. CPU, memory. + bool collect_resource_usage = 3; + + // Contains parameters of the model autotuning optimization. + message OptimizationParams { + // Algorithm used for autotuning optimization. + AutotuneAlgorithm algorithm = 1; + + // Number of available logical threads. + int64 cpu_budget = 2; + + // Amount of available memory in bytes. + int64 ram_budget = 3; + + // Time between two consecutive `GetNext` calls to the iterator represented + // by the output node. + double model_input_time = 4; + } + + OptimizationParams optimization_params = 4; +} diff --git a/ngraph/frontend/tensorflow/src/proto/node_def.proto b/ngraph/frontend/tensorflow/src/proto/node_def.proto new file mode 100644 index 00000000000000..17d8ecf684b77d --- /dev/null +++ b/ngraph/frontend/tensorflow/src/proto/node_def.proto @@ -0,0 +1,88 @@ +syntax = "proto3"; + +package tensorflow; + +import "attr_value.proto"; + +option cc_enable_arenas = true; +option java_outer_classname = "NodeProto"; +option java_multiple_files = true; +option java_package = "org.tensorflow.framework"; +option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework/node_def_go_proto"; + +message NodeDef { + // The name given to this operator. Used for naming inputs, + // logging, visualization, etc. Unique within a single GraphDef. + // Must match the regexp "[A-Za-z0-9.][A-Za-z0-9_>./]*". + string name = 1; + + // The operation name. There may be custom parameters in attrs. + // Op names starting with an underscore are reserved for internal use. + string op = 2; + + // Each input is "node:src_output" with "node" being a string name and + // "src_output" indicating which output tensor to use from "node". If + // "src_output" is 0 the ":0" suffix can be omitted. Regular inputs + // may optionally be followed by control inputs that have the format + // "^node". + repeated string input = 3; + + // A (possibly partial) specification for the device on which this + // node should be placed. + // The expected syntax for this string is as follows: + // + // DEVICE_SPEC ::= PARTIAL_SPEC + // + // PARTIAL_SPEC ::= ("/" CONSTRAINT) * + // CONSTRAINT ::= ("job:" JOB_NAME) + // | ("replica:" [1-9][0-9]*) + // | ("task:" [1-9][0-9]*) + // | ("device:" [A-Za-z]* ":" ([1-9][0-9]* | "*") ) + // + // Valid values for this string include: + // * "/job:worker/replica:0/task:1/device:GPU:3" (full specification) + // * "/job:worker/device:GPU:3" (partial specification) + // * "" (no specification) + // + // If the constraints do not resolve to a single device (or if this + // field is empty or not present), the runtime will attempt to + // choose a device automatically. + string device = 4; + + // Operation-specific graph-construction-time configuration. + // Note that this should include all attrs defined in the + // corresponding OpDef, including those with a value matching + // the default -- this allows the default to change and makes + // NodeDefs easier to interpret on their own. However, if + // an attr with a default is not specified in this list, the + // default will be used. + // The "names" (keys) must match the regexp "[a-z][a-z0-9_]+" (and + // one of the names from the corresponding OpDef's attr field). + // The values must have a type matching the corresponding OpDef + // attr's type field. + // TODO(josh11b): Add some examples here showing best practices. + map attr = 5; + + message ExperimentalDebugInfo { + // Opaque string inserted into error messages created by the runtime. + // + // This is intended to store the list of names of the nodes from the + // original graph that this node was derived. For example if this node, say + // C, was result of a fusion of 2 nodes A and B, then 'original_node' would + // be {A, B}. This information can be used to map errors originating at the + // current node to some top level source code. + repeated string original_node_names = 1; + + // This is intended to store the list of names of the functions from the + // original graph that this node was derived. For example if this node, say + // C, was result of a fusion of node A in function FA and node B in function + // FB, then `original_funcs` would be {FA, FB}. If the node is in the top + // level graph, the `original_func` is empty. This information, with the + // `original_node_names` can be used to map errors originating at the + // current ndoe to some top level source code. + repeated string original_func_names = 2; + } + + // This stores debug information associated with the node. + ExperimentalDebugInfo experimental_debug_info = 6; +} diff --git a/ngraph/frontend/tensorflow/src/proto/op_def.proto b/ngraph/frontend/tensorflow/src/proto/op_def.proto new file mode 100644 index 00000000000000..5e5412103a7e7b --- /dev/null +++ b/ngraph/frontend/tensorflow/src/proto/op_def.proto @@ -0,0 +1,174 @@ +syntax = "proto3"; + +package tensorflow; +option cc_enable_arenas = true; +option java_outer_classname = "OpDefProtos"; +option java_multiple_files = true; +option java_package = "org.tensorflow.framework"; +option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework/op_def_go_proto"; +import "attr_value.proto"; +import "types.proto"; +import "resource_handle.proto"; + +// Defines an operation. A NodeDef in a GraphDef specifies an Op by +// using the "op" field which should match the name of a OpDef. +// LINT.IfChange +message OpDef { + // Op names starting with an underscore are reserved for internal use. + // Names should be CamelCase and match the regexp "[A-Z][a-zA-Z0-9>_]*". + string name = 1; + + // For describing inputs and outputs. + message ArgDef { + // Name for the input/output. Should match the regexp "[a-z][a-z0-9_]*". + string name = 1; + + // Human readable description. + string description = 2; + + // Describes the type of one or more tensors that are accepted/produced + // by this input/output arg. The only legal combinations are: + // * For a single tensor: either the "type" field is set or the + // "type_attr" field is set to the name of an attr with type "type". + // * For a sequence of tensors with the same type: the "number_attr" + // field will be set to the name of an attr with type "int", and + // either the "type" or "type_attr" field will be set as for + // single tensors. + // * For a sequence of tensors, the "type_list_attr" field will be set + // to the name of an attr with type "list(type)". + DataType type = 3; + string type_attr = 4; // if specified, attr must have type "type" + string number_attr = 5; // if specified, attr must have type "int" + // If specified, attr must have type "list(type)", and none of + // type, type_attr, and number_attr may be specified. + string type_list_attr = 6; + + // The handle data for resource inputs. + repeated ResourceHandleProto.DtypeAndShape handle_data = 7; + + // For inputs: if true, the inputs are required to be refs. + // By default, inputs can be either refs or non-refs. + // For outputs: if true, outputs are refs, otherwise they are not. + bool is_ref = 16; + }; + + // Description of the input(s). + repeated ArgDef input_arg = 2; + + // Description of the output(s). + repeated ArgDef output_arg = 3; + + // Named control outputs for this operation. Useful only for composite + // operations (i.e. functions) which want to name different control outputs. + repeated string control_output = 20; + + // Description of the graph-construction-time configuration of this + // Op. That is to say, this describes the attr fields that will + // be specified in the NodeDef. + message AttrDef { + // A descriptive name for the argument. May be used, e.g. by the + // Python client, as a keyword argument name, and so should match + // the regexp "[a-z][a-z0-9_]+". + string name = 1; + + // One of the type names from attr_value.proto ("string", "list(string)", + // "int", etc.). + string type = 2; + + // A reasonable default for this attribute if the user does not supply + // a value. If not specified, the user must supply a value. + AttrValue default_value = 3; + + // Human-readable description. + string description = 4; + + // TODO(josh11b): bool is_optional? + + // --- Constraints --- + // These constraints are only in effect if specified. Default is no + // constraints. + + // For type == "int", this is a minimum value. For "list(___)" + // types, this is the minimum length. + bool has_minimum = 5; + int64 minimum = 6; + + // The set of allowed values. Has type that is the "list" version + // of the "type" field above (uses the "list" field of AttrValue). + // If type == "type" or "list(type)" above, then the "type" field + // of "allowed_values.list" has the set of allowed DataTypes. + // If type == "string" or "list(string)", then the "s" field of + // "allowed_values.list" has the set of allowed strings. + AttrValue allowed_values = 7; + } + repeated AttrDef attr = 4; + + // Optional deprecation based on GraphDef versions. + OpDeprecation deprecation = 8; + + // One-line human-readable description of what the Op does. + string summary = 5; + + // Additional, longer human-readable description of what the Op does. + string description = 6; + + // ------------------------------------------------------------------------- + // Which optimizations this operation can participate in. + + // True if the operation is commutative ("op(a,b) == op(b,a)" for all inputs) + bool is_commutative = 18; + + // If is_aggregate is true, then this operation accepts N >= 2 + // inputs and produces 1 output all of the same type. Should be + // associative and commutative, and produce output with the same + // shape as the input. The optimizer may replace an aggregate op + // taking input from multiple devices with a tree of aggregate ops + // that aggregate locally within each device (and possibly within + // groups of nearby devices) before communicating. + // TODO(josh11b): Implement that optimization. + bool is_aggregate = 16; // for things like add + + // Other optimizations go here, like + // can_alias_input, rewrite_when_output_unused, partitioning_strategy, etc. + + // ------------------------------------------------------------------------- + // Optimization constraints. + + // Ops are marked as stateful if their behavior depends on some state beyond + // their input tensors (e.g. variable reading op) or if they have + // a side-effect (e.g. printing or asserting ops). Equivalently, stateless ops + // must always produce the same output for the same input and have + // no side-effects. + // + // By default Ops may be moved between devices. Stateful ops should + // either not be moved, or should only be moved if that state can also + // be moved (e.g. via some sort of save / restore). + // Stateful ops are guaranteed to never be optimized away by Common + // Subexpression Elimination (CSE). + bool is_stateful = 17; // for things like variables, queue + + // ------------------------------------------------------------------------- + // Non-standard options. + + // By default, all inputs to an Op must be initialized Tensors. Ops + // that may initialize tensors for the first time should set this + // field to true, to allow the Op to take an uninitialized Tensor as + // input. + bool allows_uninitialized_input = 19; // for Assign, etc. +}; +// LINT.ThenChange( +// https://www.tensorflow.org/code/tensorflow/core/framework/op_def_util.cc) + +// Information about version-dependent deprecation of an op +message OpDeprecation { + // First GraphDef version at which the op is disallowed. + int32 version = 1; + + // Explanation of why it was deprecated and what to use instead. + string explanation = 2; +}; + +// A collection of OpDefs +message OpList { + repeated OpDef op = 1; +}; diff --git a/ngraph/frontend/tensorflow/src/proto/reader_base.proto b/ngraph/frontend/tensorflow/src/proto/reader_base.proto new file mode 100644 index 00000000000000..6fae310248dd40 --- /dev/null +++ b/ngraph/frontend/tensorflow/src/proto/reader_base.proto @@ -0,0 +1,18 @@ +syntax = "proto3"; + +package tensorflow; + +option cc_enable_arenas = true; +option java_outer_classname = "ReaderBaseProtos"; +option java_multiple_files = true; +option java_package = "org.tensorflow.framework"; +option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework/reader_base_go_proto"; + +// For serializing and restoring the state of ReaderBase, see +// reader_base.h for details. +message ReaderBaseState { + int64 work_started = 1; + int64 work_finished = 2; + int64 num_records_produced = 3; + bytes current_work = 4; +} diff --git a/ngraph/frontend/tensorflow/src/proto/remote_fused_graph_execute_info.proto b/ngraph/frontend/tensorflow/src/proto/remote_fused_graph_execute_info.proto new file mode 100644 index 00000000000000..2cdaa6719e0aab --- /dev/null +++ b/ngraph/frontend/tensorflow/src/proto/remote_fused_graph_execute_info.proto @@ -0,0 +1,48 @@ +syntax = "proto3"; + +package tensorflow; + +import "graph.proto"; +import "tensor_shape.proto"; +import "types.proto"; + +option cc_enable_arenas = true; +option java_outer_classname = "RemoteFusedGraphExecuteInfoProto"; +option java_multiple_files = true; +option java_package = "org.tensorflow.framework"; +option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework/remote_fused_graph_execute_info_go_proto"; + +// Protocol buffer representing a handle to a tensorflow resource. Handles are +// not valid across executions, but can be serialized back and forth from within +// a single run. +message RemoteFusedGraphExecuteInfo { + message TensorShapeTypeProto { + DataType dtype = 1; + TensorShapeProto shape = 2; + } + + // Definition of remote graph + GraphDef remote_graph = 1; + + // Remote fused graph input node name + repeated string graph_input_node_name = 2; + + // Remote fused graph output node name + repeated string graph_output_node_name = 3; + + // Executor's name + string executor_name = 4; + + // Optional: Parameters given to the executor + bytes serialized_executor_parameters = 5; + + // Optional: Default graph input tensor shape used to allocate memory + // before executing op + repeated TensorShapeTypeProto default_graph_input_tensor_shape = 6; + + // Optional: Default graph input tensor shape used to allocate memory + // before executing op + // TODO(satok): Remote output tensor shape once shape information is stored + // in NodeDef + repeated TensorShapeTypeProto default_graph_output_tensor_shape = 7; +} diff --git a/ngraph/frontend/tensorflow/src/proto/resource_handle.proto b/ngraph/frontend/tensorflow/src/proto/resource_handle.proto new file mode 100644 index 00000000000000..e2bce956547810 --- /dev/null +++ b/ngraph/frontend/tensorflow/src/proto/resource_handle.proto @@ -0,0 +1,45 @@ +syntax = "proto3"; + +package tensorflow; + +import "tensor_shape.proto"; +import "types.proto"; + +option cc_enable_arenas = true; +option java_outer_classname = "ResourceHandle"; +option java_multiple_files = true; +option java_package = "org.tensorflow.framework"; +option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework/resource_handle_go_proto"; + +// Protocol buffer representing a handle to a tensorflow resource. Handles are +// not valid across executions, but can be serialized back and forth from within +// a single run. +message ResourceHandleProto { + // Unique name for the device containing the resource. + string device = 1; + + // Container in which this resource is placed. + string container = 2; + + // Unique name of this resource. + string name = 3; + + // Hash code for the type of the resource. Is only valid in the same device + // and in the same execution. + uint64 hash_code = 4; + + // For debug-only, the name of the type pointed to by this handle, if + // available. + string maybe_type_name = 5; + + // Protocol buffer representing a pair of (data type, tensor shape). + message DtypeAndShape { + DataType dtype = 1; + TensorShapeProto shape = 2; + } + + // Data types and shapes for the underlying resource. + repeated DtypeAndShape dtypes_and_shapes = 6; + + reserved 7; +} diff --git a/ngraph/frontend/tensorflow/src/proto/step_stats.proto b/ngraph/frontend/tensorflow/src/proto/step_stats.proto new file mode 100644 index 00000000000000..7b97c3a38325de --- /dev/null +++ b/ngraph/frontend/tensorflow/src/proto/step_stats.proto @@ -0,0 +1,88 @@ +syntax = "proto3"; + +package tensorflow; + +import "allocation_description.proto"; +import "tensor_description.proto"; + +option cc_enable_arenas = true; +option java_outer_classname = "StepStatsProtos"; +option java_multiple_files = true; +option java_package = "org.tensorflow.framework"; +option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework/step_stats_go_proto"; + +// An allocation/de-allocation operation performed by the allocator. +message AllocationRecord { + // The timestamp of the operation. + int64 alloc_micros = 1; + // Number of bytes allocated, or de-allocated if negative. + int64 alloc_bytes = 2; +} + +message AllocatorMemoryUsed { + string allocator_name = 1; + // These are per-node allocator memory stats. + int64 total_bytes = 2; + int64 peak_bytes = 3; + // The bytes that are not deallocated. + int64 live_bytes = 4; + // The allocation and deallocation timeline. + repeated AllocationRecord allocation_records = 6; + + // These are snapshots of the overall allocator memory stats. + // The number of live bytes currently allocated by the allocator. + int64 allocator_bytes_in_use = 5; +} + +// Output sizes recorded for a single execution of a graph node. +message NodeOutput { + int32 slot = 1; + TensorDescription tensor_description = 3; +} + +// For memory tracking. +message MemoryStats { + int64 temp_memory_size = 1; + int64 persistent_memory_size = 3; + repeated int64 persistent_tensor_alloc_ids = 5; + + int64 device_temp_memory_size = 2 [deprecated = true]; + int64 device_persistent_memory_size = 4 [deprecated = true]; + repeated int64 device_persistent_tensor_alloc_ids = 6 [deprecated = true]; +} + +// Time/size stats recorded for a single execution of a graph node. +message NodeExecStats { + // TODO(tucker): Use some more compact form of node identity than + // the full string name. Either all processes should agree on a + // global id (cost_id?) for each node, or we should use a hash of + // the name. + string node_name = 1; + int64 all_start_micros = 2; + int64 op_start_rel_micros = 3; + int64 op_end_rel_micros = 4; + int64 all_end_rel_micros = 5; + repeated AllocatorMemoryUsed memory = 6; + repeated NodeOutput output = 7; + string timeline_label = 8; + int64 scheduled_micros = 9; + uint32 thread_id = 10; + repeated AllocationDescription referenced_tensor = 11; + MemoryStats memory_stats = 12; + int64 all_start_nanos = 13; + int64 op_start_rel_nanos = 14; + int64 op_end_rel_nanos = 15; + int64 all_end_rel_nanos = 16; + int64 scheduled_nanos = 17; +} + +message DeviceStepStats { + string device = 1; + repeated NodeExecStats node_stats = 2; + // Its key is thread id. + map thread_names = 3; +} + +message StepStats { + repeated DeviceStepStats dev_stats = 1; +} diff --git a/ngraph/frontend/tensorflow/src/proto/summary.proto b/ngraph/frontend/tensorflow/src/proto/summary.proto new file mode 100644 index 00000000000000..ef1aa2e0d1c587 --- /dev/null +++ b/ngraph/frontend/tensorflow/src/proto/summary.proto @@ -0,0 +1,149 @@ +syntax = "proto3"; + +package tensorflow; + +import "tensor.proto"; + +option cc_enable_arenas = true; +option java_outer_classname = "SummaryProtos"; +option java_multiple_files = true; +option java_package = "org.tensorflow.framework"; +option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework/summary_go_proto"; + +// Metadata associated with a series of Summary data +message SummaryDescription { + // Hint on how plugins should process the data in this series. + // Supported values include "scalar", "histogram", "image", "audio" + string type_hint = 1; +} + +// Serialization format for histogram module in +// core/lib/histogram/histogram.h +message HistogramProto { + double min = 1; + double max = 2; + double num = 3; + double sum = 4; + double sum_squares = 5; + + // Parallel arrays encoding the bucket boundaries and the bucket values. + // bucket(i) is the count for the bucket i. The range for + // a bucket is: + // i == 0: -DBL_MAX .. bucket_limit(0) + // i != 0: bucket_limit(i-1) .. bucket_limit(i) + repeated double bucket_limit = 6 [packed = true]; + repeated double bucket = 7 [packed = true]; +} + +// A SummaryMetadata encapsulates information on which plugins are able to make +// use of a certain summary value. +message SummaryMetadata { + message PluginData { + // The name of the plugin this data pertains to. + string plugin_name = 1; + + // The content to store for the plugin. The best practice is for this to be + // a binary serialized protocol buffer. + bytes content = 2; + } + + // Data that associates a summary with a certain plugin. + PluginData plugin_data = 1; + + // Display name for viewing in TensorBoard. + string display_name = 2; + + // Longform readable description of the summary sequence. Markdown supported. + string summary_description = 3; + + // Class of data stored in this time series. Required for compatibility with + // TensorBoard's generic data facilities (`DataProvider`, et al.). This value + // imposes constraints on the dtype and shape of the corresponding tensor + // values. See `DataClass` docs for details. + DataClass data_class = 4; +} + +enum DataClass { + // Unknown data class, used (implicitly) for legacy data. Will not be + // processed by data ingestion pipelines. + DATA_CLASS_UNKNOWN = 0; + // Scalar time series. Each `Value` for the corresponding tag must have + // `tensor` set to a rank-0 tensor of type `DT_FLOAT` (float32). + DATA_CLASS_SCALAR = 1; + // Tensor time series. Each `Value` for the corresponding tag must have + // `tensor` set. The tensor value is arbitrary, but should be small to + // accommodate direct storage in database backends: an upper bound of a few + // kilobytes is a reasonable rule of thumb. + DATA_CLASS_TENSOR = 2; + // Blob sequence time series. Each `Value` for the corresponding tag must + // have `tensor` set to a rank-1 tensor of bytestring dtype. + DATA_CLASS_BLOB_SEQUENCE = 3; +} + +// A Summary is a set of named values to be displayed by the +// visualizer. +// +// Summaries are produced regularly during training, as controlled by +// the "summary_interval_secs" attribute of the training operation. +// Summaries are also produced at the end of an evaluation. +message Summary { + message Image { + // Dimensions of the image. + int32 height = 1; + int32 width = 2; + // Valid colorspace values are + // 1 - grayscale + // 2 - grayscale + alpha + // 3 - RGB + // 4 - RGBA + // 5 - DIGITAL_YUV + // 6 - BGRA + int32 colorspace = 3; + // Image data in encoded format. All image formats supported by + // image_codec::CoderUtil can be stored here. + bytes encoded_image_string = 4; + } + + message Audio { + // Sample rate of the audio in Hz. + float sample_rate = 1; + // Number of channels of audio. + int64 num_channels = 2; + // Length of the audio in frames (samples per channel). + int64 length_frames = 3; + // Encoded audio data and its associated RFC 2045 content type (e.g. + // "audio/wav"). + bytes encoded_audio_string = 4; + string content_type = 5; + } + + message Value { + // This field is deprecated and will not be set. + string node_name = 7; + + // Tag name for the data. Used by TensorBoard plugins to organize data. Tags + // are often organized by scope (which contains slashes to convey + // hierarchy). For example: foo/bar/0 + string tag = 1; + + // Contains metadata on the summary value such as which plugins may use it. + // Take note that many summary values may lack a metadata field. This is + // because the FileWriter only keeps a metadata object on the first summary + // value with a certain tag for each tag. TensorBoard then remembers which + // tags are associated with which plugins. This saves space. + SummaryMetadata metadata = 9; + + // Value associated with the tag. + oneof value { + float simple_value = 2; + bytes obsolete_old_style_histogram = 3; + Image image = 4; + HistogramProto histo = 5; + Audio audio = 6; + TensorProto tensor = 8; + } + } + + // Set of values for the summary. + repeated Value value = 1; +} diff --git a/ngraph/frontend/tensorflow/src/proto/tensor.proto b/ngraph/frontend/tensorflow/src/proto/tensor.proto new file mode 100644 index 00000000000000..7a25c446e68772 --- /dev/null +++ b/ngraph/frontend/tensorflow/src/proto/tensor.proto @@ -0,0 +1,96 @@ +syntax = "proto3"; + +package tensorflow; + +import "resource_handle.proto"; +import "tensor_shape.proto"; +import "types.proto"; + +option cc_enable_arenas = true; +option java_outer_classname = "TensorProtos"; +option java_multiple_files = true; +option java_package = "org.tensorflow.framework"; +option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework/tensor_go_proto"; + +// Protocol buffer representing a tensor. +message TensorProto { + DataType dtype = 1; + + // Shape of the tensor. TODO(touts): sort out the 0-rank issues. + TensorShapeProto tensor_shape = 2; + + // Only one of the representations below is set, one of "tensor_contents" and + // the "xxx_val" attributes. We are not using oneof because as oneofs cannot + // contain repeated fields it would require another extra set of messages. + + // Version number. + // + // In version 0, if the "repeated xxx" representations contain only one + // element, that element is repeated to fill the shape. This makes it easy + // to represent a constant Tensor with a single value. + int32 version_number = 3; + + // Serialized raw tensor content from either Tensor::AsProtoTensorContent or + // memcpy in tensorflow::grpc::EncodeTensorToByteBuffer. This representation + // can be used for all tensor types. The purpose of this representation is to + // reduce serialization overhead during RPC call by avoiding serialization of + // many repeated small items. + bytes tensor_content = 4; + + // Type specific representations that make it easy to create tensor protos in + // all languages. Only the representation corresponding to "dtype" can + // be set. The values hold the flattened representation of the tensor in + // row major order. + + // DT_HALF, DT_BFLOAT16. Note that since protobuf has no int16 type, we'll + // have some pointless zero padding for each value here. + repeated int32 half_val = 13 [packed = true]; + + // DT_FLOAT. + repeated float float_val = 5 [packed = true]; + + // DT_DOUBLE. + repeated double double_val = 6 [packed = true]; + + // DT_INT32, DT_INT16, DT_INT8, DT_UINT8. + repeated int32 int_val = 7 [packed = true]; + + // DT_STRING + repeated bytes string_val = 8; + + // DT_COMPLEX64. scomplex_val(2*i) and scomplex_val(2*i+1) are real + // and imaginary parts of i-th single precision complex. + repeated float scomplex_val = 9 [packed = true]; + + // DT_INT64 + repeated int64 int64_val = 10 [packed = true]; + + // DT_BOOL + repeated bool bool_val = 11 [packed = true]; + + // DT_COMPLEX128. dcomplex_val(2*i) and dcomplex_val(2*i+1) are real + // and imaginary parts of i-th double precision complex. + repeated double dcomplex_val = 12 [packed = true]; + + // DT_RESOURCE + repeated ResourceHandleProto resource_handle_val = 14; + + // DT_VARIANT + repeated VariantTensorDataProto variant_val = 15; + + // DT_UINT32 + repeated uint32 uint32_val = 16 [packed = true]; + + // DT_UINT64 + repeated uint64 uint64_val = 17 [packed = true]; +} + +// Protocol buffer representing the serialization format of DT_VARIANT tensors. +message VariantTensorDataProto { + // Name of the type of objects being serialized. + string type_name = 1; + // Portions of the object that are not Tensors. + bytes metadata = 2; + // Tensors contained within objects being serialized. + repeated TensorProto tensors = 3; +} diff --git a/ngraph/frontend/tensorflow/src/proto/tensor_description.proto b/ngraph/frontend/tensorflow/src/proto/tensor_description.proto new file mode 100644 index 00000000000000..c162c0e2385533 --- /dev/null +++ b/ngraph/frontend/tensorflow/src/proto/tensor_description.proto @@ -0,0 +1,24 @@ +syntax = "proto3"; + +package tensorflow; + +import "allocation_description.proto"; +import "tensor_shape.proto"; +import "types.proto"; + +option cc_enable_arenas = true; +option java_outer_classname = "TensorDescriptionProtos"; +option java_multiple_files = true; +option java_package = "org.tensorflow.framework"; +option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework/tensor_description_go_proto"; + +message TensorDescription { + // Data type of tensor elements + DataType dtype = 1; + + // Shape of the tensor. + TensorShapeProto shape = 2; + + // Information about the size and allocator used for the data + AllocationDescription allocation_description = 4; +} diff --git a/ngraph/frontend/tensorflow/src/proto/tensor_shape.proto b/ngraph/frontend/tensorflow/src/proto/tensor_shape.proto new file mode 100644 index 00000000000000..45d5b78ecbbc4c --- /dev/null +++ b/ngraph/frontend/tensorflow/src/proto/tensor_shape.proto @@ -0,0 +1,46 @@ +// Protocol buffer representing the shape of tensors. + +syntax = "proto3"; +option cc_enable_arenas = true; +option java_outer_classname = "TensorShapeProtos"; +option java_multiple_files = true; +option java_package = "org.tensorflow.framework"; +option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework/tensor_shape_go_proto"; + +package tensorflow; + +// Dimensions of a tensor. +message TensorShapeProto { + // One dimension of the tensor. + message Dim { + // Size of the tensor in that dimension. + // This value must be >= -1, but values of -1 are reserved for "unknown" + // shapes (values of -1 mean "unknown" dimension). Certain wrappers + // that work with TensorShapeProto may fail at runtime when deserializing + // a TensorShapeProto containing a dim value of -1. + int64 size = 1; + + // Optional name of the tensor dimension. + string name = 2; + }; + + // Dimensions of the tensor, such as {"input", 30}, {"output", 40} + // for a 30 x 40 2D tensor. If an entry has size -1, this + // corresponds to a dimension of unknown size. The names are + // optional. + // + // The order of entries in "dim" matters: It indicates the layout of the + // values in the tensor in-memory representation. + // + // The first entry in "dim" is the outermost dimension used to layout the + // values, the last entry is the innermost dimension. This matches the + // in-memory layout of RowMajor Eigen tensors. + // + // If "dim.size()" > 0, "unknown_rank" must be false. + repeated Dim dim = 2; + + // If true, the number of dimensions in the shape is unknown. + // + // If true, "dim.size()" must be 0. + bool unknown_rank = 3; +}; diff --git a/ngraph/frontend/tensorflow/src/proto/tensor_slice.proto b/ngraph/frontend/tensorflow/src/proto/tensor_slice.proto new file mode 100644 index 00000000000000..4463658d391e2f --- /dev/null +++ b/ngraph/frontend/tensorflow/src/proto/tensor_slice.proto @@ -0,0 +1,39 @@ +// Protocol buffer representing slices of a tensor + +syntax = "proto3"; + +package tensorflow; + +option cc_enable_arenas = true; +option java_outer_classname = "TensorSliceProtos"; +option java_multiple_files = true; +option java_package = "org.tensorflow.framework"; +option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework/tensor_slice_go_proto"; + +// Can only be interpreted if you know the corresponding TensorShape. +message TensorSliceProto { + // Extent of the slice in one dimension. + message Extent { + // Either both or no attributes must be set. When no attribute is set + // means: All data in that dimension. + + // Start index of the slice, starting at 0. + int64 start = 1; + + // Length of the slice: if the length is missing or -1 we will + // interpret this as "everything in this dimension". We use + // "oneof" to preserve information about whether the length is + // present without changing the serialization format from the + // prior proto2 version of this proto. + oneof has_length { + int64 length = 2; + } + } + + // Extent of the slice in all tensor dimensions. + // + // Must have one entry for each of the dimension of the tensor that this + // slice belongs to. The order of sizes is the same as the order of + // dimensions in the TensorShape. + repeated Extent extent = 1; +} diff --git a/ngraph/frontend/tensorflow/src/proto/types.proto b/ngraph/frontend/tensorflow/src/proto/types.proto new file mode 100644 index 00000000000000..e5f33036dcde55 --- /dev/null +++ b/ngraph/frontend/tensorflow/src/proto/types.proto @@ -0,0 +1,89 @@ +syntax = "proto3"; + +package tensorflow; +option cc_enable_arenas = true; +option java_outer_classname = "TypesProtos"; +option java_multiple_files = true; +option java_package = "org.tensorflow.framework"; +option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework/types_go_proto"; + +// (== suppress_warning documentation-presence ==) +// LINT.IfChange +enum DataType { + // Not a legal value for DataType. Used to indicate a DataType field + // has not been set. + DT_INVALID = 0; + + // Data types that all computation devices are expected to be + // capable to support. + DT_FLOAT = 1; + DT_DOUBLE = 2; + DT_INT32 = 3; + DT_UINT8 = 4; + DT_INT16 = 5; + DT_INT8 = 6; + DT_STRING = 7; + DT_COMPLEX64 = 8; // Single-precision complex + DT_INT64 = 9; + DT_BOOL = 10; + DT_QINT8 = 11; // Quantized int8 + DT_QUINT8 = 12; // Quantized uint8 + DT_QINT32 = 13; // Quantized int32 + DT_BFLOAT16 = 14; // Float32 truncated to 16 bits. Only for cast ops. + DT_QINT16 = 15; // Quantized int16 + DT_QUINT16 = 16; // Quantized uint16 + DT_UINT16 = 17; + DT_COMPLEX128 = 18; // Double-precision complex + DT_HALF = 19; + DT_RESOURCE = 20; + DT_VARIANT = 21; // Arbitrary C++ data types + DT_UINT32 = 22; + DT_UINT64 = 23; + + // Do not use! These are only for parameters. Every enum above + // should have a corresponding value below (verified by types_test). + DT_FLOAT_REF = 101; + DT_DOUBLE_REF = 102; + DT_INT32_REF = 103; + DT_UINT8_REF = 104; + DT_INT16_REF = 105; + DT_INT8_REF = 106; + DT_STRING_REF = 107; + DT_COMPLEX64_REF = 108; + DT_INT64_REF = 109; + DT_BOOL_REF = 110; + DT_QINT8_REF = 111; + DT_QUINT8_REF = 112; + DT_QINT32_REF = 113; + DT_BFLOAT16_REF = 114; + DT_QINT16_REF = 115; + DT_QUINT16_REF = 116; + DT_UINT16_REF = 117; + DT_COMPLEX128_REF = 118; + DT_HALF_REF = 119; + DT_RESOURCE_REF = 120; + DT_VARIANT_REF = 121; + DT_UINT32_REF = 122; + DT_UINT64_REF = 123; +} +// LINT.ThenChange( +// https://www.tensorflow.org/code/tensorflow/c/tf_datatype.h, +// https://www.tensorflow.org/code/tensorflow/go/tensor.go, +// https://www.tensorflow.org/code/tensorflow/core/framework/tensor.cc, +// https://www.tensorflow.org/code/tensorflow/core/framework/types.h, +// https://www.tensorflow.org/code/tensorflow/core/framework/types.cc, +// https://www.tensorflow.org/code/tensorflow/python/framework/dtypes.py, +// https://www.tensorflow.org/code/tensorflow/python/framework/function.py) + +// For identifying the underlying type of a variant. For variants, the types +// listed here are a subset of the types in the variant type registry, +// corresponding to commonly used variants which must occasionally be +// special-cased. +enum SpecializedType { + // Invalid/unknown specialized type. + ST_INVALID = 0; + // "tensorflow::TensorList" in the variant type registry. + ST_TENSOR_LIST = 1; + // "tensorflow::data::Optional" in the variant type registry. + ST_OPTIONAL = 2; +} diff --git a/ngraph/frontend/tensorflow/src/proto/variable.proto b/ngraph/frontend/tensorflow/src/proto/variable.proto new file mode 100644 index 00000000000000..09d7fb3d45c95a --- /dev/null +++ b/ngraph/frontend/tensorflow/src/proto/variable.proto @@ -0,0 +1,84 @@ +syntax = "proto3"; + +package tensorflow; + +option cc_enable_arenas = true; +option java_outer_classname = "VariableProtos"; +option java_multiple_files = true; +option java_package = "org.tensorflow.framework"; +option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework/variable_go_proto"; + +// Indicates when a distributed variable will be synced. +enum VariableSynchronization { + // `AUTO`: Indicates that the synchronization will be determined by the + // current `DistributionStrategy` (eg. With `MirroredStrategy` this would be + // `ON_WRITE`). + VARIABLE_SYNCHRONIZATION_AUTO = 0; + // `NONE`: Indicates that there will only be one copy of the variable, so + // there is no need to sync. + VARIABLE_SYNCHRONIZATION_NONE = 1; + // `ON_WRITE`: Indicates that the variable will be updated across devices + // every time it is written. + VARIABLE_SYNCHRONIZATION_ON_WRITE = 2; + // `ON_READ`: Indicates that the variable will be aggregated across devices + // when it is read (eg. when checkpointing or when evaluating an op that uses + // the variable). + VARIABLE_SYNCHRONIZATION_ON_READ = 3; +} + +// Indicates how a distributed variable will be aggregated. +enum VariableAggregation { + // `NONE`: This is the default, giving an error if you use a + // variable-update operation with multiple replicas. + VARIABLE_AGGREGATION_NONE = 0; + // `SUM`: Add the updates across replicas. + VARIABLE_AGGREGATION_SUM = 1; + // `MEAN`: Take the arithmetic mean ("average") of the updates across + // replicas. + VARIABLE_AGGREGATION_MEAN = 2; + // `ONLY_FIRST_REPLICA`: This is for when every replica is performing the same + // update, but we only want to perform the update once. Used, e.g., for the + // global step counter. + VARIABLE_AGGREGATION_ONLY_FIRST_REPLICA = 3; +} + +// Protocol buffer representing a Variable. +message VariableDef { + // Name of the variable tensor. + string variable_name = 1; + + // Name of the tensor holding the variable's initial value. + string initial_value_name = 6; + + // Name of the initializer op. + string initializer_name = 2; + + // Name of the snapshot tensor. + string snapshot_name = 3; + + // Support for saving variables as slices of a larger variable. + SaveSliceInfoDef save_slice_info_def = 4; + + // Whether to represent this as a ResourceVariable. + bool is_resource = 5; + + // Whether this variable should be trained. + bool trainable = 7; + + // Indicates when a distributed variable will be synced. + VariableSynchronization synchronization = 8; + + // Indicates how a distributed variable will be aggregated. + VariableAggregation aggregation = 9; +} + +message SaveSliceInfoDef { + // Name of the full variable of which this is a slice. + string full_name = 1; + // Shape of the full variable. + repeated int64 full_shape = 2; + // Offset of this variable into the full variable. + repeated int64 var_offset = 3; + // Shape of this variable. + repeated int64 var_shape = 4; +} diff --git a/ngraph/frontend/tensorflow/src/proto/versions.proto b/ngraph/frontend/tensorflow/src/proto/versions.proto new file mode 100644 index 00000000000000..2cca6e37d325dc --- /dev/null +++ b/ngraph/frontend/tensorflow/src/proto/versions.proto @@ -0,0 +1,33 @@ +syntax = "proto3"; + +package tensorflow; + +option cc_enable_arenas = true; +option java_outer_classname = "VersionsProtos"; +option java_multiple_files = true; +option java_package = "org.tensorflow.framework"; +option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework/versions_go_proto"; + +// Version information for a piece of serialized data +// +// There are different types of versions for each type of data +// (GraphDef, etc.), but they all have the same common shape +// described here. +// +// Each consumer has "consumer" and "min_producer" versions (specified +// elsewhere). A consumer is allowed to consume this data if +// +// producer >= min_producer +// consumer >= min_consumer +// consumer not in bad_consumers +// +message VersionDef { + // The version of the code that produced this data. + int32 producer = 1; + + // Any consumer below this version is not allowed to consume this data. + int32 min_consumer = 2; + + // Specific consumer versions which are disallowed (e.g. due to bugs). + repeated int32 bad_consumers = 3; +} diff --git a/ngraph/frontend/tensorflow/src/tensorflow.cpp b/ngraph/frontend/tensorflow/src/tensorflow.cpp new file mode 100644 index 00000000000000..b8498bca70cb0a --- /dev/null +++ b/ngraph/frontend/tensorflow/src/tensorflow.cpp @@ -0,0 +1,37 @@ +//***************************************************************************** +// Copyright 2017-2021 Intel Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//***************************************************************************** + + +#include +#include "graph.pb.h" + +#include "../include/tensorflow_frontend/tensorflow.hpp" + +using namespace google; + +std::shared_ptr ngraph::frontend::FrontEndTensorflow::convert (InputModel::Ptr model) const +{ + std::string path = std::dynamic_pointer_cast(model)->path; + std::cerr << "[ INFO ] FrontEndTensorflow::convert invoked\n"; + tensorflow::GraphDef fw_model; + std::ifstream pb_stream(path, std::ios::binary); + std::cout << "[ INFO ] Model Parsed: " << fw_model.ParseFromIstream(&pb_stream) << std::endl; + std::cout << "[ INFO ] Loaded model contains " << fw_model.node_size() << " nodes." << std::endl; + auto f = std::make_shared(ngraph::NodeVector{}, ngraph::ParameterVector{}); + std::cerr << "[ ERROR ] Convetion functionality is not implemented; an empty function will be returned."; + std::cerr << "[ INFO ] Resulting nGraph function contains " << f->get_ops().size() << " nodes." << std::endl; + return f; +} diff --git a/ngraph/python/CMakeLists.txt b/ngraph/python/CMakeLists.txt index d8641da0ac680d..1d673ecebc9b61 100644 --- a/ngraph/python/CMakeLists.txt +++ b/ngraph/python/CMakeLists.txt @@ -73,7 +73,7 @@ pybind11_add_module(_${PROJECT_NAME} MODULE ${SOURCES}) target_include_directories(_${PROJECT_NAME} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src") target_include_directories(_${PROJECT_NAME} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../frontend/generic/include") -target_link_libraries(_${PROJECT_NAME} PRIVATE ngraph::ngraph ngraph::onnx_importer ngraph::frontend_manager) +target_link_libraries(_${PROJECT_NAME} PRIVATE ngraph::ngraph ngraph::onnx_importer ngraph::frontend_manager ngraph::tensorflow_frontend) if(OpenVINO_MAIN_SOURCE_DIR OR InferenceEngineDeveloperPackage_FOUND) ie_cpack_add_component(pyngraph_${PYTHON_VERSION}) From 4d0bdd4bdd84f304fe4d76795680fd895904a1de Mon Sep 17 00:00:00 2001 From: "Lyalin, Sergey" Date: Wed, 10 Mar 2021 00:13:08 +0300 Subject: [PATCH 051/116] Export TF FE classes from shared library --- .../tensorflow/include/tensorflow_frontend/tensorflow.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ngraph/frontend/tensorflow/include/tensorflow_frontend/tensorflow.hpp b/ngraph/frontend/tensorflow/include/tensorflow_frontend/tensorflow.hpp index fe3083fefbdfb9..9e0b03aa7b8d23 100644 --- a/ngraph/frontend/tensorflow/include/tensorflow_frontend/tensorflow.hpp +++ b/ngraph/frontend/tensorflow/include/tensorflow_frontend/tensorflow.hpp @@ -24,7 +24,7 @@ namespace ngraph { namespace frontend { - class InputModelTensorflow : public InputModel + class NGRAPH_API InputModelTensorflow : public InputModel { public: @@ -33,7 +33,7 @@ namespace ngraph InputModelTensorflow (const std::string& _path) : path(_path) {} }; - class FrontEndTensorflow : public FrontEnd + class NGRAPH_API FrontEndTensorflow : public FrontEnd { public: From 177cea7a0d6535d37200284c757673156b29a8d4 Mon Sep 17 00:00:00 2001 From: "Lyalin, Sergey" Date: Fri, 12 Mar 2021 11:25:45 +0300 Subject: [PATCH 052/116] Start migration of tf bridge code with tf-to-ngraph conversion to OV without TF dependencies; many things are temporary disabled --- .../frontend/tensorflow/src/default_opset.h | 32 + .../tensorflow/src/ngraph_builder.cpp | 2999 +++++++++++++++++ .../frontend/tensorflow/src/ngraph_builder.h | 198 ++ .../tensorflow/src/ngraph_conversions.cpp | 106 + .../tensorflow/src/ngraph_conversions.h | 126 + 5 files changed, 3461 insertions(+) create mode 100644 ngraph/frontend/tensorflow/src/default_opset.h create mode 100644 ngraph/frontend/tensorflow/src/ngraph_builder.cpp create mode 100644 ngraph/frontend/tensorflow/src/ngraph_builder.h create mode 100644 ngraph/frontend/tensorflow/src/ngraph_conversions.cpp create mode 100644 ngraph/frontend/tensorflow/src/ngraph_conversions.h diff --git a/ngraph/frontend/tensorflow/src/default_opset.h b/ngraph/frontend/tensorflow/src/default_opset.h new file mode 100644 index 00000000000000..ebd00c7cfa8b68 --- /dev/null +++ b/ngraph/frontend/tensorflow/src/default_opset.h @@ -0,0 +1,32 @@ +/******************************************************************************* + * Copyright 2017-2020 Intel Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *******************************************************************************/ + +#ifndef NGRAPH_TF_BRIDGE_DEFAULT_OPSET_H_ +#define NGRAPH_TF_BRIDGE_DEFAULT_OPSET_H_ +#pragma once + +#include "ngraph/opsets/opset5.hpp" + +namespace tensorflow { +namespace ngraph_bridge { + +namespace opset = ngraph::opset5; +namespace default_opset = ngraph::opset5; + +} // namespace ngraph_bridge +} // namespace tensorflow + +#endif \ No newline at end of file diff --git a/ngraph/frontend/tensorflow/src/ngraph_builder.cpp b/ngraph/frontend/tensorflow/src/ngraph_builder.cpp new file mode 100644 index 00000000000000..6c024c0776222f --- /dev/null +++ b/ngraph/frontend/tensorflow/src/ngraph_builder.cpp @@ -0,0 +1,2999 @@ +/******************************************************************************* + * Copyright 2017-2020 Intel Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *******************************************************************************/ + +#include "graph.pb.h" +#include "tensor.pb.h" + +#include "ngraph/op/util/logical_reduction.hpp" +#include "ngraph/pass/constant_folding.hpp" +#include "ngraph/pass/manager.hpp" +#include "ngraph/pass/pass_config.hpp" +#include "ngraph/slice_plan.hpp" + +#include "ngraph_builder.h" +#include "ngraph_conversions.h" +#include "default_opset.h" +#if 0 +#include "api.h" +#include "logging/ngraph_log.h" +#include "ngraph_bridge/ngraph_mark_for_clustering.h" +#include "ngraph_bridge/ngraph_utils.h" +#include "ngraph_bridge/pass/transpose_sinking.h" +#endif + +using namespace std; +namespace ng = ngraph; + +namespace tensorflow { + +namespace ngraph_bridge { + +static bool VecStrCmp(const std::vector& a, + const std::vector& b) { + return a == b; +} + +static Status ValidateInputCount(const NodeWrapper* op, int32_t count) { + if (op->num_inputs() != count) { + std::ostringstream buf; + buf << "\"" << op->name() << "\" requires " << count << + " input(s), got " << op->num_inputs() << + " instead"; + return errors::InvalidArgument(buf.str()); + } + return Status::OK(); +} + +static Status ValidateInputCountMin(const NodeWrapper* op, int32_t count) { + if (op->num_inputs() < count) { + std::ostringstream buf; + buf << "\"" << op->name() << "\" requires at least " << + count << " input(s), got " << op->num_inputs() << + " instead"; + return errors::InvalidArgument(buf.str()); + } + return Status::OK(); +} + +// Check to make sure the axis dimension for reduction are in within range. +// Returns error if axis is out of range. Otherwise returns Status::OK(). +static Status CheckAxisDimInRange(std::vector axes, size_t rank) { + for (auto i : axes) { + if (i < (int)-rank || i >= (int)rank) { + std::ostringstream buf; + buf << "Axis Dimension is out of range. Got " << i << + ", should be in range [-" << rank << ", " << + rank << ")"; + return errors::InvalidArgument(buf.str()); + } + } + return Status::OK(); +} + +// +// Helper for storing ops in ng_op_map. +// For most of the cases, op would have one output so +// vector ng_op_map[op_name] would contain one element. +// +// If storing more than one output_nodes, make sure it's in +// the same order as tensorflow would do that. +// +// Parameters: +// Builder::OpMap& ng_op_map - The TF-to-nGraph op map. +// std::string op_name - Name of the op. +// +// ng::Output output_node - ng::Node to store +// + +static void SaveNgOp(Builder::OpMap& ng_op_map, const std::string& op_name, + ng::Output output_node) { + // no need to try-catch, map[key] will create vector object + // if not exists + ng_op_map[op_name].push_back(output_node); +} + +void Builder::SetTracingInfo(const std::string& op_name, + const ng::Output ng_node) { + auto node = ng_node.get_node_shared_ptr(); + node->set_friendly_name(op_name + "/" + node->get_name()); + node->add_provenance_tag(op_name); +#if 0 + if (api::IsLoggingPlacement()) { + cout << "TF_to_NG: " << op_name << " --> " << node << "\n"; + } +#endif +} + +template +ng::Output ConstructNgNode(const std::string& op_name, + TArg&&... Args) { + auto ng_node = std::make_shared(std::forward(Args)...); + Builder::SetTracingInfo(op_name, ng_node); + return ng_node; +} + +// Helper for fetching correct input node from ng_op_map. +// Handles edge checking to make sure correct input node is +// fetched. +// +// Reduces some boilerplate code (incorrect from now) like this: +// +// NodeWrapper* tf_input; +// TF_RETURN_IF_ERROR(op->input_node(0, &tf_input)); +// +// ng::Output ng_input; +// try { +// ng_input = ng_op_map.at(tf_input->name()); +// } catch (const std::out_of_range&) { +// return errors::NotFound(tf_input->name(), +// " is not found in the ng_op_map"); +// } +// +// Into 2 lines: +// +// ng::Output ng_input; +// TF_RETURN_IF_ERROR(GetInputNode(ng_op_map, op, 0, &ng_input)) +// +// +// +// Parameters: +// Builder::OpMap& ng_op_map - The TF-to-nGraph op map. +// NodeWrapper* op - TF op being translated. +// input_idx - index of input +// +// ng::Output *result - ng::Node pointer where result +// will be written +// +// + +static Status GetInputNode(const Builder::OpMap& ng_op_map, const NodeWrapper* op, + size_t input_idx, ng::Output& result) { + // Stub + #if 0 + // input op may have resulted in more than one ng::Node (eg. Split) + // we need to look at Edge to check index of the input op + std::vector edges; + TF_RETURN_IF_ERROR(op->input_edges(&edges)); + size_t src_output_idx; + try { + src_output_idx = edges.at(input_idx)->src_output(); + } catch (const out_of_range&) { + return Status(error::NOT_FOUND, "Edge not found"); + } + + NodeWrapper* tf_input; + TF_RETURN_IF_ERROR(op->input_node(input_idx, &tf_input)); + std::vector> ng_op; + try { + ng_op = ng_op_map.at(tf_input->name()); + } catch (const out_of_range&) { + return Status(error::NOT_FOUND, + string("Ngraph op not found for ") + tf_input->name()); + } + try { + result = ng_op.at(src_output_idx); + } catch (const out_of_range&) { + return Status(error::NOT_FOUND, string("Input node not found at index ") + + to_string(src_output_idx)); + } + return Status::OK(); + +#endif + + throw "Not supported!"; +} + +namespace detail { +static Status GetInputNodes(const Builder::OpMap&, const NodeWrapper*, size_t) { + return Status::OK(); +} + +template +static Status GetInputNodes(const Builder::OpMap& ng_op_map, const NodeWrapper* op, + size_t index, ng::Output& result, + Arguments&... remaining) { + TF_RETURN_IF_ERROR(GetInputNode(ng_op_map, op, index, result)); + return GetInputNodes(ng_op_map, op, index + 1, remaining...); +} +} // namespace detail + +template +static Status GetInputNodes(const Builder::OpMap& ng_op_map, const NodeWrapper* op, + Arguments&... remaining) { + constexpr size_t args_len = sizeof...(Arguments); + TF_RETURN_IF_ERROR(ValidateInputCount(op, args_len)); + return detail::GetInputNodes(ng_op_map, op, 0, remaining...); +} + +static Status GetStaticNodeTensor( + const NodeWrapper* node, const std::vector& static_input_map, + TensorWrapper* result) { + if (node->IsArg()) { + int arg_index; + TF_RETURN_IF_ERROR(GetNodeAttr(node->attrs(), "index", &arg_index)); + const TensorWrapper* source_tensor = static_input_map[arg_index]; + if (source_tensor == nullptr) { + return errors::Internal( + "GetStaticNodeTensor called on _Arg but input tensor is missing from " + "static input map"); + } + *result = *source_tensor; + return Status::OK(); + } else if (node->type_string() == "Const") { + if (GetNodeAttr(node->attrs(), "value", &result).status != 0) { + return errors::Internal( + "GetStaticNodeTensor: Const tensor proto parsing failed"); + } + return Status::OK(); + } else { + return errors::Internal("GetStaticNodeTensor called on node with type " + + node->type_string() + "; _Arg or Const expected"); + } +} + +template +static void ConvertTensorDataToVector(const TensorWrapper& tensor, + std::vector* vector) { + const Ttensor* data = tensor.flat().data(); + vector->resize(tensor.NumElements()); + for (int64_t i = 0; i < tensor.NumElements(); i++) { + (*vector)[i] = Tvector(data[i]); + } +} + +template +static Status TensorDataToVector(const TensorWrapper& tensor, std::vector* vector) { +// stub + #if 0 + DataType dt = tensor.dtype(); + + // If dt and T match, we can just copy. + if (dt == DataTypeToEnum::value) { + *vector = std::vector(tensor.flat().data(), + tensor.flat().data() + tensor.NumElements()); + } + // Else we have to convert. + else { + switch (dt) { + case DT_FLOAT: + ConvertTensorDataToVector(tensor, vector); + break; + case DT_DOUBLE: + ConvertTensorDataToVector(tensor, vector); + break; + case DT_INT8: + ConvertTensorDataToVector(tensor, vector); + break; + case DT_INT16: + ConvertTensorDataToVector(tensor, vector); + break; + case DT_INT32: + ConvertTensorDataToVector(tensor, vector); + break; + case DT_INT64: + ConvertTensorDataToVector(tensor, vector); + break; + case DT_UINT8: + ConvertTensorDataToVector(tensor, vector); + break; + case DT_UINT16: + ConvertTensorDataToVector(tensor, vector); + break; + case DT_UINT32: + ConvertTensorDataToVector(tensor, vector); + break; + case DT_UINT64: + ConvertTensorDataToVector(tensor, vector); + break; + case DT_BOOL: + ConvertTensorDataToVector(tensor, vector); + break; + default: + return errors::Internal("TensorDataToVector: tensor has element type ", + DataType_Name(dt), ", vector has type ", + DataType_Name(DataTypeToEnum::value), + "; don't know how to convert"); + } + } + return Status::OK(); + #endif + + throw "Not implemented!"; +} + +template +static Status GetStaticInputVector( + const NodeWrapper* op, int64_t input_index, + const std::vector& static_input_map, + std::vector* vector) { + NodeWrapper* input_node; + TF_RETURN_IF_ERROR(op->input_node(input_index, &input_node)); + TensorWrapper input_tensor; + TF_RETURN_IF_ERROR( + GetStaticNodeTensor(input_node, static_input_map, &input_tensor)); + TF_RETURN_IF_ERROR(TensorDataToVector(input_tensor, vector)); + return Status::OK(); +} + +static Status GetStaticInputNode( + const NodeWrapper* op, int64_t input_index, + const std::vector& static_input_map, DataType dt, + ng::Output& node_) { + ng::element::Type type; + TF_RETURN_IF_ERROR(TFDataTypeToNGraphElementType(dt, &type)); + switch (dt) { + case DataType::DT_FLOAT: { + std::vector vec_float; + TF_RETURN_IF_ERROR( + GetStaticInputVector(op, input_index, static_input_map, &vec_float)); + node_ = ConstructNgNode(op->name(), type, ng::Shape{}, + vec_float[0]); + } break; + case DataType::DT_DOUBLE: { + std::vector vec_double; + TF_RETURN_IF_ERROR( + GetStaticInputVector(op, input_index, static_input_map, &vec_double)); + node_ = ConstructNgNode(op->name(), type, ng::Shape{}, + vec_double[0]); + } break; + case DataType::DT_INT32: { + std::vector vec_i32; + TF_RETURN_IF_ERROR( + GetStaticInputVector(op, input_index, static_input_map, &vec_i32)); + node_ = ConstructNgNode(op->name(), type, ng::Shape{}, + vec_i32[0]); + } break; + case DataType::DT_INT64: { + std::vector vec_i64; + TF_RETURN_IF_ERROR( + GetStaticInputVector(op, input_index, static_input_map, &vec_i64)); + node_ = ConstructNgNode(op->name(), type, ng::Shape{}, + vec_i64[0]); + } break; + default: + return errors::Internal("GetStaticInputNode: TF data type " + + DataType_Name(dt) + " not supported."); + break; + } + return Status::OK(); +} + +// Taken from: tensorflow/core/grappler/optimizers/arithmetic_optimizer.cc +// Extract values from a Const op to `values`. Returns true if succeeds. +// +// Modified with an extra `VecT` parameter to handle the case where the type +// in the vector does not match TensorFlow's notion of what the C++ type +// should be (e.g. when T is `bool`, we actually need a vector of `char` for +// compatibility with nGraph). +template +static Status ValuesFromConstNode(const NodeWrapper* node, + ngraph::Shape* const_tensor_shape, + std::vector* values) { +#if 0 + if (node.op() != "Const") { + return errors::InvalidArgument("NodeWrapper not a Const"); + } + + if (node.attr().at("dtype").type() != DataTypeToEnum::value) { + std::stringstream ss; + ss << "Invalid data type defined for Const. Defined: " + << node.attr().at("dtype").type(); + return errors::InvalidArgument(ss.str()); + } + + // TensorWrapper represents the content of the tensor in either _val or + // tensor_content. + const TensorWrapper& tensor = node.attr().at("value").tensor(); + typename checkpoint::SaveTypeTraits::RepeatedField* tensor_values = + checkpoint::MutableTensorProtoData(const_cast(&tensor)); + + const TensorShapeProto& shape = tensor.tensor_shape(); + *const_tensor_shape = shape; + if (!tensor_values->empty() && tensor.has_tensor_shape()) { + // When tensor_shape is set, theoretically the representation of the data + // could be compressed. So, before copying values to the returned vector, + // make sure no compression happens. + if (shape.dim_size() == 1 && shape.dim(0).size() == tensor_values->size()) { + values->insert(values->end(), tensor_values->begin(), + tensor_values->end()); + return Status::OK(); + } + } + + const auto tensor_content_size = tensor.tensor_content().size(); + CHECK_EQ(0, tensor_content_size % sizeof(VecT)) + << " tensor_content_size (" << tensor_content_size + << ") is not a multiple of " << sizeof(VecT); + + // If tensor_content_size is zero, we'll have to take the values from + // int_val, float_val, etc. + if (tensor_content_size == 0) { + int64_t n_elements = 1; + for (auto i = 0; i < shape.dim_size(); i++) { + if (shape.dim(i).size() < 0) { + return errors::InvalidArgument( + "Const node has empty tensor and an unknown dimension size"); + } + n_elements *= shape.dim(i).size(); + } + values->resize(n_elements); + + auto val_lastsaved = (T)0; // cast + + for (auto i = 0; i < n_elements; i++) { + auto& tensor = node.attr().at("value").tensor(); + auto dt = node.attr().at("dtype").type(); + int64_t val_size = 0; + auto val_i = (T)0; // cast + switch (dt) { + // TODO(amprocte/NGRAPH-2502): there are more element types to support + // here + case DT_INT32: + val_size = tensor.int_val_size(); + if (val_size > 0) val_i = tensor.int_val()[i]; + break; + case DT_INT64: + val_size = tensor.int64_val_size(); + if (val_size > 0) val_i = tensor.int64_val()[i]; + break; + case DT_FLOAT: + val_size = tensor.float_val_size(); + if (val_size > 0) val_i = tensor.float_val()[i]; + break; + case DT_BOOL: + val_size = tensor.bool_val_size(); + if (val_size > 0) val_i = tensor.bool_val()[i]; + break; + case DT_DOUBLE: + val_size = tensor.double_val_size(); + if (val_size > 0) val_i = tensor.double_val()[i]; + break; + default: + NGRAPH_VLOG(0) + << "Const node has empty tensor and we don't know how to " + "handle this element type"; + NGRAPH_VLOG(0) << node.DebugString(); + NGRAPH_VLOG(0) << shape.DebugString(); + return errors::Unimplemented("Encountered unknown element type ", + DataType_Name(dt), + " on an empty tensor"); + } + if (val_size == 0) { + return errors::InvalidArgument("Empty values vector"); + } else if (i < val_size) { + (*values)[i] = val_i; + val_lastsaved = val_i; + } else { + (*values)[i] = val_lastsaved; + } + } + } else { + values->resize(tensor_content_size / sizeof(VecT)); + port::CopyToArray(tensor.tensor_content(), + reinterpret_cast(values->data())); + } + + return Status::OK(); +#endif + + throw "Not implemented"; +} + +// Helper for Builder::TranslateGraph ("Const" op) +template +static Status MakeConstOp(const NodeWrapper* op, ng::element::Type et, + ng::Output& ng_node) { + vector const_values; + ngraph::Shape ng_shape; + + TF_RETURN_IF_ERROR( + (ValuesFromConstNode(op, &ng_shape, &const_values))); + + ng_node = + ConstructNgNode(op->name(), et, ng_shape, const_values); + return Status::OK(); +} + +const Builder::ConstMap& Builder::TF_NGRAPH_CONST_MAP() { + static const Builder::ConstMap the_map = { + {DataType::DT_FLOAT, make_pair(MakeConstOp, ng::element::f32)}, + {DataType::DT_DOUBLE, make_pair(MakeConstOp, ng::element::f64)}, + {DataType::DT_INT8, make_pair(MakeConstOp, ng::element::i8)}, + {DataType::DT_INT16, make_pair(MakeConstOp, ng::element::i16)}, +#if 0 + {DataType::DT_QINT8, make_pair(MakeConstOp, ng::element::i8)}, + {DataType::DT_QUINT8, make_pair(MakeConstOp, ng::element::u8)}, + {DataType::DT_QUINT16, make_pair(MakeConstOp, ng::element::u16)}, +#endif + {DataType::DT_INT32, make_pair(MakeConstOp, ng::element::i32)}, + {DataType::DT_INT64, make_pair(MakeConstOp, ng::element::i64)}, + {DataType::DT_UINT8, make_pair(MakeConstOp, ng::element::u8)}, + {DataType::DT_UINT16, make_pair(MakeConstOp, ng::element::u16)}, + {DataType::DT_BOOL, + make_pair(MakeConstOp, ng::element::boolean)}}; + return the_map; +} + +// Helper function to translate a unary op. +// +// Parameters: +// +// NodeWrapper* op - TF op being translated. Must have one input. +// const std::vector& static_input_map +// - the static input map +// Builder::OpMap& ng_op_map - The TF-to-nGraph op map. +// +// std::function(ng::Output> +// create_unary_op - Function to construct the graph implementing +// the unary op, given the input to the unop +// as an argument. +// +// Example usage: +// +// if (n->type_string == "Square") { +// TF_RETURN_IF_ERROR(TranslateUnaryOp(n, static_input_map, ng_op_map, +// [] (ng::Output n) { +// return +// (ng::Output(n,n)); +// }); +// } +static Status TranslateUnaryOp( + const NodeWrapper* op, const std::vector&, + Builder::OpMap& ng_op_map, + std::function(ng::Output)> create_unary_op) { + ng::Output ng_input; + TF_RETURN_IF_ERROR(GetInputNodes(ng_op_map, op, ng_input)); + auto ng_node = create_unary_op(ng_input); + if (ng_node != ng_input) { + Builder::SetTracingInfo(op->name(), ng_node); + } + SaveNgOp(ng_op_map, op->name(), ng_node); + return Status::OK(); +} + +// Helper function to translate a unary op in cases where there is a one-to-one +// mapping from TensorFlow ops to nGraph ops. +// +// Example usage: +// +// if (n->type_string == "Abs") { +// TF_RETURN_IF_ERROR(TranslateUnaryOp(n, static_input_map, +// ng_op_map)); +// } +// +template +static Status TranslateUnaryOp( + const NodeWrapper* op, const std::vector& static_input_map, + Builder::OpMap& ng_op_map) { + return TranslateUnaryOp(op, static_input_map, ng_op_map, + [&op](ng::Output n) { + return ConstructNgNode(op->name(), n); + }); +} + +// Helper function to translate a binary op +// Parameters: +// +// NodeWrapper* op - TF op being translated. Must have only two +// inputs. +// const std::vector& static_input_map - the static input map +// Builder::OpMap& ng_op_map - The TF-to-nGraph op map. +// std::function(ng::Output, +// ng::Output)> +// create_binary_op - Function to construct the graph implementing +// the binary op, given the 2 ng_inputs to the +// binaryop +// Example Usage: +// +// if (op->type_string() == "SquaredDifference") { +// TF_RETURN_IF_ERROR(TranslateBinaryOp(op, ng_op_map, +// [](ng::Output ng_input1, ng::Output +// ng_input2) { +// auto ng_diff = ng::Output(input1, +// input2); +// return ng::Output(ng_diff,ng_diff); +// })); +// } +// + +static Status TranslateBinaryOp( + const NodeWrapper* op, const std::vector&, + Builder::OpMap& ng_op_map, + std::function(ng::Output&, + ng::Output&)> + create_binary_op) { + ng::Output ng_lhs, ng_rhs; + TF_RETURN_IF_ERROR(GetInputNodes(ng_op_map, op, ng_lhs, ng_rhs)); + auto ng_node = create_binary_op(ng_lhs, ng_rhs); + if (ng_node != ng_lhs && ng_node != ng_rhs) { + Builder::SetTracingInfo(op->name(), ng_node); + } + SaveNgOp(ng_op_map, op->name(), ng_node); + return Status::OK(); +} + +// Helper function to translate a binary op in cases where there is a one-to-one +// mapping from TensorFlow ops to nGraph ops. +// +// Example usage: +// +// if (n->type_string == "Add") { +// TF_RETURN_IF_ERROR(TranslateBinaryOp(op, +// static_input_map, +// ng_op_map)); +// } +// +template +static Status TranslateBinaryOp( + const NodeWrapper* op, const std::vector& static_input_map, + Builder::OpMap& ng_op_map) { + return TranslateBinaryOp( + op, static_input_map, ng_op_map, + [&op](ng::Output& ng_lhs, ng::Output& ng_rhs) { + return ConstructNgNode(op->name(), ng_lhs, ng_rhs); + }); +} + +static Status TranslateAddNOp(const NodeWrapper* op, const std::vector&, + Builder::OpMap& ng_op_map) { + std::vector> ng_arg_vec(op->num_inputs()); + + for (int inp_idx = 0; inp_idx < op->num_inputs(); inp_idx++) + TF_RETURN_IF_ERROR( + GetInputNode(ng_op_map, op, inp_idx, ng_arg_vec[inp_idx])); + auto ng_addn = std::accumulate( + std::next(ng_arg_vec.begin()), ng_arg_vec.end(), ng_arg_vec.at(0), + [&op](ng::Output a, ng::Output b) { + return ConstructNgNode(op->name(), a, b); + }); // accumulation: start with + // first element. default op is + // addition + SaveNgOp(ng_op_map, op->name(), ng_addn); + return Status::OK(); +} +static Status TranslateArgMinMax( + const NodeWrapper* op, const std::vector& static_input_map, + Builder::OpMap& ng_op_map, std::string mode) { + ng::Output ng_input; + TF_RETURN_IF_ERROR(GetInputNode(ng_op_map, op, 0, ng_input)); + + std::vector tf_dim; + TF_RETURN_IF_ERROR(GetStaticInputVector(op, 1, static_input_map, &tf_dim)); + + ng::Shape input_shape = ng_input.get_shape(); + size_t input_rank = input_shape.size(); + + if (tf_dim.size() != 1) { + return errors::InvalidArgument( + "ArgMax Op: dimension must be scalar, operates on a single axis"); + } + + // If input dimension is negative, make it positive + if (tf_dim[0] < 0) { + NGRAPH_VLOG(3) << "Input dimension is negative, make it positive " + << tf_dim[0]; + tf_dim[0] = (int64_t)input_rank + tf_dim[0]; + } + NGRAPH_VLOG(3) << "Axis along which to compute " << tf_dim[0]; + size_t k_axis = tf_dim[0]; + + DataType dtype; + TF_RETURN_IF_ERROR(GetNodeAttr(op->attrs(), "output_type", &dtype)); + + ng::element::Type ng_et; + TF_RETURN_IF_ERROR(TFDataTypeToNGraphElementType(dtype, &ng_et)); + + auto ng_k = ConstructNgNode( + op->name(), ng::element::i64, ng::Shape{}, std::vector({1})); + + std::string sort = "none"; + auto ng_topk = + std::make_shared(ng_input, ng_k, k_axis, mode, sort, ng_et); + auto ng_indices = ng_topk->output(1); + int axis = ng_topk->get_axis(); + auto axis_to_remove = ConstructNgNode( + op->name(), ng::element::i64, ng::Shape{1}, std::vector({axis})); + auto reshaped_indices = + ConstructNgNode(op->name(), ng_indices, axis_to_remove); + Builder::SetTracingInfo(op->name(), reshaped_indices); + SaveNgOp(ng_op_map, op->name(), reshaped_indices); + return Status::OK(); +} + +static Status TranslateArgMaxOp( + const NodeWrapper* op, const std::vector& static_input_map, + Builder::OpMap& ng_op_map) { + return (TranslateArgMinMax(op, static_input_map, ng_op_map, "max")); +} + +static Status TranslateArgMinOp( + const NodeWrapper* op, const std::vector& static_input_map, + Builder::OpMap& ng_op_map) { + return (TranslateArgMinMax(op, static_input_map, ng_op_map, "min")); +} + +static Status TranslateAvgPoolOp(const NodeWrapper* op, + const std::vector&, + Builder::OpMap& ng_op_map) { + ng::Output ng_input; + TF_RETURN_IF_ERROR(GetInputNodes(ng_op_map, op, ng_input)); + + std::vector tf_strides; + std::vector tf_ksize; + std::string tf_padding_type; + std::string tf_data_format; + TF_RETURN_IF_ERROR(GetNodeAttr(op->attrs(), "strides", &tf_strides)); + TF_RETURN_IF_ERROR(GetNodeAttr(op->attrs(), "ksize", &tf_ksize)); + TF_RETURN_IF_ERROR(GetNodeAttr(op->attrs(), "padding", &tf_padding_type)); + TF_RETURN_IF_ERROR(GetNodeAttr(op->attrs(), "data_format", &tf_data_format)); + + if (tf_data_format != "NHWC" && tf_data_format != "NCHW") { + return errors::InvalidArgument( + "AvgPool data format is neither NHWC nor NCHW"); + } + + bool is_nhwc = (tf_data_format == "NHWC"); + + NGRAPH_VLOG(3) << ng::join(tf_strides); + NGRAPH_VLOG(3) << ng::join(tf_ksize); + NGRAPH_VLOG(3) << tf_padding_type; + NGRAPH_VLOG(3) << tf_data_format; + + ng::Strides ng_strides(2); + ng::Shape ng_image_shape(2); + ng::Shape ng_kernel_shape(2); + NHWCtoHW(is_nhwc, tf_strides, ng_strides); + NHWCtoHW(is_nhwc, ng_input.get_shape(), ng_image_shape); + NHWCtoHW(is_nhwc, tf_ksize, ng_kernel_shape); + NHWCtoNCHW(op->name(), is_nhwc, ng_input); + NGRAPH_VLOG(3) << "ng_strides: " << ng::join(ng_strides); + NGRAPH_VLOG(3) << "ng_image_shape: " << ng::join(ng_image_shape); + NGRAPH_VLOG(3) << "ng_kernel_shape: " << ng::join(ng_kernel_shape); + + ng::CoordinateDiff padding_below; + ng::CoordinateDiff padding_above; + ng::Shape ng_dilations{1, 1}; + Builder::MakePadding(tf_padding_type, ng_image_shape, ng_kernel_shape, + ng_strides, ng_dilations, padding_below, padding_above); + + // TODO: remove this once nGraph supports negative padding + // (CoordinateDiff) for AvgPool + ng::Shape ng_padding_below(padding_below.begin(), padding_below.end()); + ng::Shape ng_padding_above(padding_above.begin(), padding_above.end()); + + ng::Output ng_avgpool = ConstructNgNode( + op->name(), ng_input, ng_strides, ng_padding_below, ng_padding_above, + ng_kernel_shape, true, ng::op::RoundingType::FLOOR); + + NCHWtoNHWC(op->name(), is_nhwc, ng_avgpool); + NGRAPH_VLOG(3) << "avgpool outshape: {" << ng::join(ng_avgpool.get_shape()) + << "}"; + + SaveNgOp(ng_op_map, op->name(), ng_avgpool); + return Status::OK(); +} + +static Status TranslateBiasAddOp( + const NodeWrapper* op, const std::vector& static_input_map, + Builder::OpMap& ng_op_map) { + ng::Output ng_input, ng_bias; + TF_RETURN_IF_ERROR(GetInputNodes(ng_op_map, op, ng_input, ng_bias)); + + std::string tf_data_format; + if (GetNodeAttr(op->attrs(), "data_format", &tf_data_format) != + Status::OK()) { + tf_data_format = "NHWC"; + } + + if (tf_data_format != "NHWC" && tf_data_format != "NCHW") { + return errors::InvalidArgument( + "BiasAdd data format is neither NHWC nor NCHW"); + } + + auto ng_input_shape = ng_input.get_shape(); + auto ng_bias_shape = ng_bias.get_shape(); + if (ng_bias_shape.size() != 1) { + return errors::InvalidArgument( + "Bias argument to BiasAdd does not have one dimension"); + } + + // We'll choose reshape over broadcast + // Reshape the bias to (1, C, 1, ...) if input is channels-first. + ng::Output ng_bias_reshaped = ng_bias; + if (tf_data_format == "NCHW") { + auto channel_dim = ng_input_shape[1]; + std::vector target_shape(ng_input_shape.size()); + for (int64_t i = 0; i < ng_input_shape.size(); i++) { + if (i == 1) { + target_shape[i] = channel_dim; + } else { + target_shape[i] = 1; + } + } + auto target_shape_node = make_shared( + ng::element::i64, ng::Shape{ng_input_shape.size()}, target_shape); + ng_bias_reshaped = ConstructNgNode( + op->name(), ng_bias, target_shape_node, false); + } + + ng::Output ng_add = + ConstructNgNode(op->name(), ng_input, ng_bias_reshaped); + + SaveNgOp(ng_op_map, op->name(), ng_add); + return Status::OK(); +} + +static Status TranslateCastOp(const NodeWrapper* op, const std::vector&, + Builder::OpMap& ng_op_map) { + ng::Output ng_input; + TF_RETURN_IF_ERROR(GetInputNodes(ng_op_map, op, ng_input)); + + DataType dtype; + TF_RETURN_IF_ERROR(GetNodeAttr(op->attrs(), "DstT", &dtype)); + + ng::element::Type ng_et; + TF_RETURN_IF_ERROR(TFDataTypeToNGraphElementType(dtype, &ng_et)); + + try { + SaveNgOp(ng_op_map, op->name(), + ConstructNgNode(op->name(), ng_input, ng_et)); + } catch (const std::out_of_range&) { + return errors::Unimplemented("Failed to convert TF data type: " + + DataType_Name(dtype)); + } + return Status::OK(); +} + +static Status TranslateConcatV2Op( + const NodeWrapper* op, const std::vector& static_input_map, + Builder::OpMap& ng_op_map) { + TF_RETURN_IF_ERROR(ValidateInputCountMin(op, 2)); + + std::vector tf_concat_axis_vec; + TF_RETURN_IF_ERROR(GetStaticInputVector( + op, op->num_inputs() - 1, static_input_map, &tf_concat_axis_vec)); + + int64_t concat_axis = tf_concat_axis_vec[0]; + + if (concat_axis < 0) { + ng::Output ng_first_arg; + TF_RETURN_IF_ERROR(GetInputNode(ng_op_map, op, 0, ng_first_arg)); + + concat_axis += int64_t(ng_first_arg.get_shape().size()); + } + + ng::OutputVector ng_args; + + for (int i = 0; i < op->num_inputs() - 1; i++) { + ng::Output ng_arg; + TF_RETURN_IF_ERROR(GetInputNode(ng_op_map, op, i, ng_arg)); + ng_args.push_back(ng_arg); + } + + SaveNgOp( + ng_op_map, op->name(), + ConstructNgNode(op->name(), ng_args, size_t(concat_axis))); + return Status::OK(); +} + +static Status TranslateConstOp(const NodeWrapper* op, + const std::vector&, + Builder::OpMap& ng_op_map) { + DataType dtype; + TF_RETURN_IF_ERROR(GetNodeAttr(op->attrs(), "dtype", &dtype)); + + ng::Output ng_node; + + // For some reason the following do not work (no specialization of + // tensorflow::checkpoint::SavedTypeTraits...) + // case DataType::DT_UINT32: + // TF_RETURN_IF_ERROR(MakeConstOp(op, ng::element::u32, + // &ng_node)); + // break; + // case DataType::DT_UINT64: + // TF_RETURN_IF_ERROR(MakeConstOp(op, ng::element::u64, + // &ng_node)); + // break; + try { + const auto& func_param = Builder::TF_NGRAPH_CONST_MAP().at(dtype); + TF_RETURN_IF_ERROR(func_param.first(op, func_param.second, ng_node)); + } catch (const std::out_of_range&) { + return errors::Unimplemented("Failed to translate Constant with TF type:" + + DataType_Name(dtype)); + } + + SaveNgOp(ng_op_map, op->name(), ng_node); + return Status::OK(); +} + +static Status TranslateConv2DOp(const NodeWrapper* op, + const std::vector&, + Builder::OpMap& ng_op_map) { + ng::Output ng_input, ng_filter; + TF_RETURN_IF_ERROR(GetInputNodes(ng_op_map, op, ng_input, ng_filter)); + + std::vector tf_strides; + std::vector tf_dilations; + std::string tf_padding_type; + std::string tf_data_format; + TF_RETURN_IF_ERROR(GetNodeAttr(op->attrs(), "strides", &tf_strides)); + TF_RETURN_IF_ERROR(GetNodeAttr(op->attrs(), "dilations", &tf_dilations)); + TF_RETURN_IF_ERROR(GetNodeAttr(op->attrs(), "padding", &tf_padding_type)); + TF_RETURN_IF_ERROR(GetNodeAttr(op->attrs(), "data_format", &tf_data_format)); + + if (tf_data_format != "NHWC" && tf_data_format != "NCHW") { + return errors::InvalidArgument( + "Conv2D data format is neither NHWC nor NCHW"); + } + + bool is_nhwc = (tf_data_format == "NHWC"); + + // TF Kernel Test Checks + // Strides in the batch and depth dimension is not supported + if (tf_strides[0] != 1 || tf_strides[is_nhwc ? 3 : 1] != 1) { + return errors::InvalidArgument( + "Strides in batch and depth dimensions is not supported: " + + op->type_string()); + } + + NGRAPH_VLOG(3) << ng::join(tf_strides); + NGRAPH_VLOG(3) << ng::join(tf_dilations); + NGRAPH_VLOG(3) << tf_padding_type; + NGRAPH_VLOG(3) << tf_data_format; + + ng::Strides ng_strides(2); + ng::Strides ng_dilations(2); + ng::Shape ng_image_shape(2); + ng::Shape ng_kernel_shape(2); + + NHWCtoHW(is_nhwc, tf_strides, ng_strides); + NHWCtoHW(is_nhwc, ng_input.get_shape(), ng_image_shape); + NHWCtoHW(is_nhwc, tf_dilations, ng_dilations); + NHWCtoNCHW(op->name(), is_nhwc, ng_input); + + NGRAPH_VLOG(3) << "ng_strides: " << ng::join(ng_strides); + NGRAPH_VLOG(3) << "ng_dilations: " << ng::join(ng_dilations); + NGRAPH_VLOG(3) << "ng_image_shape: " << ng::join(ng_image_shape); + + auto& ng_filter_shape = ng_filter.get_shape(); + ng_kernel_shape[0] = ng_filter_shape[0]; + ng_kernel_shape[1] = ng_filter_shape[1]; + Transpose<3, 2, 0, 1>(ng_filter); + Builder::SetTracingInfo(op->name(), ng_filter); + + NGRAPH_VLOG(3) << "ng_kernel_shape: " << ng::join(ng_kernel_shape); + + ng::CoordinateDiff ng_padding_below; + ng::CoordinateDiff ng_padding_above; + Builder::MakePadding(tf_padding_type, ng_image_shape, ng_kernel_shape, + ng_strides, ng_dilations, ng_padding_below, + ng_padding_above); + + ng::Output ng_conv = ConstructNgNode( + op->name(), ng_input, ng_filter, ng_strides, ng_padding_below, + ng_padding_above, ng_dilations); + + NCHWtoNHWC(op->name(), is_nhwc, ng_conv); + SaveNgOp(ng_op_map, op->name(), ng_conv); + return Status::OK(); +} + +static Status TranslateConv2DBackpropInputOp( + const NodeWrapper* op, const std::vector& static_input_map, + Builder::OpMap& ng_op_map) { + ng::Output ng_filter, ng_out_backprop, ng_unused; + TF_RETURN_IF_ERROR( + GetInputNodes(ng_op_map, op, ng_unused, ng_filter, ng_out_backprop)); + + // TODO: refactor me to be less redundant with other convolution ops + std::vector tf_strides; + std::vector tf_dilations; + std::string tf_padding_type; + std::string tf_data_format; + TF_RETURN_IF_ERROR(GetNodeAttr(op->attrs(), "strides", &tf_strides)); + TF_RETURN_IF_ERROR(GetNodeAttr(op->attrs(), "dilations", &tf_dilations)); + TF_RETURN_IF_ERROR(GetNodeAttr(op->attrs(), "padding", &tf_padding_type)); + TF_RETURN_IF_ERROR(GetNodeAttr(op->attrs(), "data_format", &tf_data_format)); + + if (tf_data_format != "NHWC" && tf_data_format != "NCHW") { + return errors::InvalidArgument( + "Conv2DBackpropInput data format is neither NHWC nor NCHW: %s" + + tf_data_format); + } + + std::vector tf_input_sizes; + TF_RETURN_IF_ERROR( + GetStaticInputVector(op, 0, static_input_map, &tf_input_sizes)); + + if (std::any_of(tf_input_sizes.begin(), tf_input_sizes.end(), + [](int32_t size) { return size <= 0; })) { + return errors::InvalidArgument( + "Conv2DBackpropInput input sizes must be positive integers"); + } + + bool is_nhwc = (tf_data_format == "NHWC"); + + NGRAPH_VLOG(3) << ng::join(tf_strides); + NGRAPH_VLOG(3) << ng::join(tf_dilations); + NGRAPH_VLOG(3) << tf_padding_type; + NGRAPH_VLOG(3) << tf_data_format; + + ng::Strides ng_strides(2); + ng::Strides ng_dilations(2); + ng::Shape ng_image_shape(2); + ng::Shape ng_kernel_shape(2); + ng::Shape ng_batch_shape(4); + + NHWCtoHW(is_nhwc, tf_strides, ng_strides); + NHWCtoHW(is_nhwc, tf_dilations, ng_dilations); + NHWCtoHW(is_nhwc, tf_input_sizes, ng_image_shape); + NHWCtoNCHW(op->name(), is_nhwc, ng_out_backprop); + if (is_nhwc) { + ng_batch_shape = {static_cast(tf_input_sizes[0]), + static_cast(tf_input_sizes[3]), + static_cast(tf_input_sizes[1]), + static_cast(tf_input_sizes[2])}; + } else { + ng_batch_shape = {static_cast(tf_input_sizes[0]), + static_cast(tf_input_sizes[1]), + static_cast(tf_input_sizes[2]), + static_cast(tf_input_sizes[3])}; + } + + NGRAPH_VLOG(3) << "ng_strides: " << ng::join(ng_strides); + NGRAPH_VLOG(3) << "ng_dilations: " << ng::join(ng_dilations); + NGRAPH_VLOG(3) << "ng_image_shape: " << ng::join(ng_image_shape); + + auto& ng_filter_shape = ng_filter.get_shape(); + ng_kernel_shape[0] = ng_filter_shape[0]; + ng_kernel_shape[1] = ng_filter_shape[1]; + Transpose<3, 2, 0, 1>(ng_filter); + Builder::SetTracingInfo(op->name(), ng_filter); + + NGRAPH_VLOG(3) << "ng_kernel_shape: " << ng::join(ng_kernel_shape); + + ng::CoordinateDiff ng_padding_below; + ng::CoordinateDiff ng_padding_above; + Builder::MakePadding(tf_padding_type, ng_image_shape, ng_kernel_shape, + ng_strides, ng_dilations, ng_padding_below, + ng_padding_above); + + auto ng_output_shape = ConstructNgNode( + op->name(), ng::element::i64, ng::Shape{ng_batch_shape.size() - 2}, + vector(ng_batch_shape.begin() + 2, ng_batch_shape.end())); + + auto ng_data = ConstructNgNode( + op->name(), ng_out_backprop, ng_filter, ng_output_shape, ng_strides, + ng_padding_below, ng_padding_above, ng_dilations); + + NCHWtoNHWC(op->name(), is_nhwc, ng_data); + SaveNgOp(ng_op_map, op->name(), ng_data); + return Status::OK(); +} + +// Translate Conv3D Op +static Status TranslateConv3DOp(const NodeWrapper* op, + const std::vector&, + Builder::OpMap& ng_op_map) { + ng::Output ng_input, ng_filter; + TF_RETURN_IF_ERROR(GetInputNodes(ng_op_map, op, ng_input, ng_filter)); + + std::vector tf_strides; + std::vector tf_dilations; + std::string tf_padding_type; + std::string tf_data_format; + TF_RETURN_IF_ERROR(GetNodeAttr(op->attrs(), "strides", &tf_strides)); + TF_RETURN_IF_ERROR(GetNodeAttr(op->attrs(), "dilations", &tf_dilations)); + TF_RETURN_IF_ERROR(GetNodeAttr(op->attrs(), "padding", &tf_padding_type)); + TF_RETURN_IF_ERROR(GetNodeAttr(op->attrs(), "data_format", &tf_data_format)); + + if (tf_data_format != "NDHWC" && tf_data_format != "NCDHW") { + return errors::InvalidArgument( + "Conv3D data format is neither NDHWC nor NCDHW"); + } + + bool is_ndhwc = (tf_data_format == "NDHWC"); + + // TODO: in 3D + // TF Kernel Test Checks + // // Strides in the batch and depth dimension is not supported + // if (tf_strides[0] != 1 || tf_strides[is_nhwc ? 3 : 1] != 1) { + // return errors::InvalidArgument( + // "Strides in batch and depth dimensions is not supported: ", + // op->type_string()); + // } + + NGRAPH_VLOG(3) << ng::join(tf_strides); + NGRAPH_VLOG(3) << ng::join(tf_dilations); + NGRAPH_VLOG(3) << tf_padding_type; + NGRAPH_VLOG(3) << tf_data_format; + + ng::Strides ng_strides(3); + ng::Strides ng_dilations(3); + ng::Shape ng_image_shape(3); + ng::Shape ng_kernel_shape(3); + + NHWCtoHW(is_ndhwc, tf_strides, ng_strides); + NHWCtoHW(is_ndhwc, ng_input.get_shape(), ng_image_shape); + NHWCtoHW(is_ndhwc, tf_dilations, ng_dilations); + NHWCtoNCHW(op->name(), is_ndhwc, ng_input); + + NGRAPH_VLOG(3) << "ng_strides: " << ng::join(ng_strides); + NGRAPH_VLOG(3) << "ng_dilations: " << ng::join(ng_dilations); + NGRAPH_VLOG(3) << "ng_image_shape: " << ng::join(ng_image_shape); + + auto& ng_filter_shape = ng_filter.get_shape(); + ng_kernel_shape[0] = ng_filter_shape[0]; + ng_kernel_shape[1] = ng_filter_shape[1]; + ng_kernel_shape[2] = ng_filter_shape[2]; + Transpose3D<4, 3, 0, 1, 2>(ng_filter); + Builder::SetTracingInfo(op->name(), ng_filter); + + NGRAPH_VLOG(3) << "ng_kernel_shape: " << ng::join(ng_kernel_shape); + + ng::CoordinateDiff ng_padding_below; + ng::CoordinateDiff ng_padding_above; + Builder::MakePadding(tf_padding_type, ng_image_shape, ng_kernel_shape, + ng_strides, ng_dilations, ng_padding_below, + ng_padding_above); + + ng::Output ng_conv = ConstructNgNode( + op->name(), ng_input, ng_filter, ng_strides, ng_padding_below, + ng_padding_above, ng_dilations); + + NCHWtoNHWC(op->name(), is_ndhwc, ng_conv); + SaveNgOp(ng_op_map, op->name(), ng_conv); + return Status::OK(); +} + +static Status TranslateCumsumOp(const NodeWrapper* op, + const std::vector&, + Builder::OpMap& ng_op_map) { + ng::Output ng_x, ng_axis; + TF_RETURN_IF_ERROR(GetInputNodes(ng_op_map, op, ng_x, ng_axis)); + bool exclusive, reverse; + TF_RETURN_IF_ERROR(GetNodeAttr(op->attrs(), "exclusive", &exclusive)); + TF_RETURN_IF_ERROR(GetNodeAttr(op->attrs(), "reverse", &reverse)); + + SaveNgOp(ng_op_map, op->name(), + ConstructNgNode(op->name(), ng_x, ng_axis, exclusive, + reverse)); + return Status::OK(); +} + +// Translate DepthToSpace op +static Status TranslateDepthToSpaceOp(const NodeWrapper* op, + const std::vector&, + Builder::OpMap& ng_op_map) { + ng::Output ng_input; + TF_RETURN_IF_ERROR(GetInputNodes(ng_op_map, op, ng_input)); + + // Get the attributes + int64_t block_size; + std::string tf_data_format; + TF_RETURN_IF_ERROR(GetNodeAttr(op->attrs(), "block_size", &block_size)); + TF_RETURN_IF_ERROR(GetNodeAttr(op->attrs(), "data_format", &tf_data_format)); + + if (tf_data_format != "NHWC" && tf_data_format != "NCHW") { + return errors::InvalidArgument( + "DepthToSpace data format is neither NHWC nor NCHW"); + } + + bool is_nhwc = (tf_data_format == "NHWC"); + + NHWCtoNCHW(op->name(), is_nhwc, ng_input); + auto ng_mode = opset::DepthToSpace::DepthToSpaceMode::BLOCKS_FIRST; + ng::Output depth_to_space = ConstructNgNode( + op->name(), ng_input, ng_mode, block_size); + NCHWtoNHWC(op->name(), is_nhwc, depth_to_space); + SaveNgOp(ng_op_map, op->name(), depth_to_space); + return Status::OK(); +} + +static Status TranslateDepthwiseConv2dNativeOp( + const NodeWrapper* op, const std::vector&, + Builder::OpMap& ng_op_map) { + ng::Output ng_input, ng_filter; + TF_RETURN_IF_ERROR(GetInputNodes(ng_op_map, op, ng_input, ng_filter)); + + std::vector tf_strides; + std::vector tf_dilations; + std::string tf_padding_type; + std::string tf_data_format; + TF_RETURN_IF_ERROR(GetNodeAttr(op->attrs(), "strides", &tf_strides)); + TF_RETURN_IF_ERROR(GetNodeAttr(op->attrs(), "dilations", &tf_dilations)); + TF_RETURN_IF_ERROR(GetNodeAttr(op->attrs(), "padding", &tf_padding_type)); + TF_RETURN_IF_ERROR(GetNodeAttr(op->attrs(), "data_format", &tf_data_format)); + + if (tf_data_format != "NHWC" && tf_data_format != "NCHW") { + return errors::InvalidArgument( + "DepthwiseConv2D data format is neither NHWC nor NCHW"); + } + + bool is_nhwc = (tf_data_format == "NHWC"); + + NGRAPH_VLOG(3) << ng::join(tf_strides); + NGRAPH_VLOG(3) << ng::join(tf_dilations); + NGRAPH_VLOG(3) << tf_padding_type; + NGRAPH_VLOG(3) << tf_data_format; + + ng::Strides ng_strides(2); + ng::Strides ng_dilations(2); + ng::Shape ng_image_shape(2); + ng::Shape ng_kernel_shape(2); + + NHWCtoHW(is_nhwc, ng_input.get_shape(), ng_image_shape); + NHWCtoHW(is_nhwc, tf_strides, ng_strides); + NHWCtoHW(is_nhwc, tf_dilations, ng_dilations); + NHWCtoNCHW(op->name(), is_nhwc, ng_input); + + NGRAPH_VLOG(3) << "ng_strides: " << ng::join(ng_strides); + NGRAPH_VLOG(3) << "ng_dilations: " << ng::join(ng_dilations); + NGRAPH_VLOG(3) << "ng_image_shape: " << ng::join(ng_image_shape); + + auto& ng_filter_shape = ng_filter.get_shape(); + ng_kernel_shape[0] = ng_filter_shape[0]; + ng_kernel_shape[1] = ng_filter_shape[1]; + + NGRAPH_VLOG(3) << "ng_kernel_shape: " << ng::join(ng_kernel_shape); + + ng::CoordinateDiff ng_padding_below; + ng::CoordinateDiff ng_padding_above; + Builder::MakePadding(tf_padding_type, ng_image_shape, ng_kernel_shape, + ng_strides, ng_dilations, ng_padding_below, + ng_padding_above); + + // H W I M -> H W I 1 M + auto filter_shape = ConstructNgNode( + op->name(), ng::element::u64, ng::Shape{5}, + ngraph::Shape{ng_filter_shape[0], ng_filter_shape[1], ng_filter_shape[2], + 1, ng_filter_shape[3]}); + auto reshaped_filter = ConstructNgNode(op->name(), ng_filter, + filter_shape, false); + + // H W I 1 M -> I M 1 H W + auto order = ConstructNgNode( + op->name(), ng::element::i64, ng::Shape{5}, vector{2, 4, 3, 0, 1}); + auto transposed_filter = + ConstructNgNode(op->name(), reshaped_filter, order); + + auto ng_conv = ConstructNgNode( + op->name(), ng_input, transposed_filter, ng_strides, ng_padding_below, + ng_padding_above, ng_dilations); + + NCHWtoNHWC(op->name(), is_nhwc, ng_conv); + SaveNgOp(ng_op_map, op->name(), ng_conv); + return Status::OK(); +} + +static Status TranslateExpandDimsOp( + const NodeWrapper* op, const std::vector& static_input_map, + Builder::OpMap& ng_op_map) { + ng::Output ng_input; + TF_RETURN_IF_ERROR(GetInputNode(ng_op_map, op, 0, ng_input)); + std::vector dims; + TF_RETURN_IF_ERROR(GetStaticInputVector(op, 1, static_input_map, &dims)); + auto ng_dims = ConstructNgNode( + op->name(), ng::element::i64, ngraph::Shape{dims.size()}, dims); + SaveNgOp(ng_op_map, op->name(), + ConstructNgNode(op->name(), ng_input, ng_dims)); + return Status::OK(); +} + +static Status TranslateFillOp( + const NodeWrapper* op, const std::vector& static_input_map, + Builder::OpMap& ng_op_map) { + ng::Output ng_value, ng_dims; + TF_RETURN_IF_ERROR(GetInputNodes(ng_op_map, op, ng_dims, ng_value)); + SaveNgOp(ng_op_map, op->name(), + ConstructNgNode(op->name(), ng_value, ng_dims)); + return Status::OK(); +} + +static Status TranslateFloorDivOp( + const NodeWrapper* op, const std::vector& static_input_map, + Builder::OpMap& ng_op_map) { + auto floordiv_fn = [&op](ng::Output x, ng::Output y) { + return ConstructNgNode( + op->name(), ConstructNgNode(op->name(), x, y)); + }; + return TranslateBinaryOp(op, static_input_map, ng_op_map, floordiv_fn); +} + +static Status TranslateFusedBatchNormOp( + const NodeWrapper* op, const std::vector& static_input_map, + Builder::OpMap& ng_op_map) { + ng::Output ng_input, ng_scale, ng_offset, ng_mean, ng_variance; + bool is_v3 = op->type_string() == "FusedBatchNormV3"; + + TF_RETURN_IF_ERROR(GetInputNodes(ng_op_map, op, ng_input, ng_scale, ng_offset, + ng_mean, ng_variance)); + + std::string tf_data_format; + TF_RETURN_IF_ERROR(GetNodeAttr(op->attrs(), "data_format", &tf_data_format)); + + if (tf_data_format != "NHWC" && tf_data_format != "NCHW") { + return errors::InvalidArgument( + "Conv2D data format is neither NHWC nor NCHW"); + } + + bool is_nhwc = (tf_data_format == "NHWC"); + + NGRAPH_VLOG(3) << "data_format: " << tf_data_format; + + float tf_epsilon; + if (GetNodeAttr(op->attrs(), "epsilon", &tf_epsilon) != Status::OK()) { + NGRAPH_VLOG(3) << "epsilon attribute not present, setting to 0.0001"; + // TensorFlow default + tf_epsilon = 0.0001; + } + + NGRAPH_VLOG(3) << "epsilon: " << tf_epsilon; + + NHWCtoNCHW(op->name(), is_nhwc, ng_input); + + auto ng_batch_norm = ConstructNgNode( + op->name(), ng_input, ng_scale, ng_offset, ng_mean, ng_variance, + tf_epsilon); + NCHWtoNHWC(op->name(), is_nhwc, ng_batch_norm); + SaveNgOp(ng_op_map, op->name(), ng_batch_norm); + SaveNgOp(ng_op_map, op->name(), ng_mean); + SaveNgOp(ng_op_map, op->name(), ng_variance); + SaveNgOp(ng_op_map, op->name(), ng_mean); // reserve_space_1 + SaveNgOp(ng_op_map, op->name(), ng_variance); // reserve_space_2 + if (is_v3) { + // FusedBatchNormV3 has 6 outputs + SaveNgOp(ng_op_map, op->name(), ng_mean); // reserve_space_3 + } + return Status::OK(); +} + +static Status TranslateFusedMatMulOp(const NodeWrapper* op, + const std::vector&, + Builder::OpMap& ng_op_map) { + int num_args; + TF_RETURN_IF_ERROR(GetNodeAttr(op->attrs(), "num_args", &num_args)); + + std::vector fused_ops; + TF_RETURN_IF_ERROR(GetNodeAttr(op->attrs(), "fused_ops", &fused_ops)); + + // Transpose arguments if requested. + bool transpose_a = false; + TF_RETURN_IF_ERROR(GetNodeAttr(op->attrs(), "transpose_a", &transpose_a)); + + bool transpose_b = false; + TF_RETURN_IF_ERROR(GetNodeAttr(op->attrs(), "transpose_b", &transpose_b)); + + ng::Output ng_lhs, ng_rhs, ng_bias, ng_matmul; + TF_RETURN_IF_ERROR(GetInputNodes(ng_op_map, op, ng_lhs, ng_rhs, ng_bias)); + ng_matmul = ConstructNgNode(op->name(), ng_lhs, ng_rhs, + transpose_a, transpose_b); + + auto ng_matmul_shape = ng_matmul.get_shape(); + auto ng_bias_shape = ng_bias.get_shape(); + + if (ng_bias_shape.size() != 1) { + return errors::InvalidArgument( + "Bias argument to BiasAdd does not have one dimension"); + } + + auto ng_add = ConstructNgNode(op->name(), ng_matmul, ng_bias); + if (fused_ops.size() == 1) { // Only fusing BiasAdd + SaveNgOp(ng_op_map, op->name(), ng_add); + } else if (fused_ops.size() == 2) { // Also has activation + if (fused_ops[1] == "Relu") { + SaveNgOp(ng_op_map, op->name(), + ConstructNgNode(op->name(), ng_add)); + } else if (fused_ops[1] == "Relu6") { + SaveNgOp(ng_op_map, op->name(), + ConstructNgNode(op->name(), ng_add, 0, 6)); + } else { + return errors::Internal( + "Expected activation to be Relu or Relu6 but got " + fused_ops[1]); + } + } else { + // Adding this here to catch future changes in _FusedMatMul + return errors::Internal("Unsupported combination"); + } + + return Status::OK(); +} + +// See .../tensorflow/include/tensorflow/cc/ops/array_ops.h +// and .../openvino/ngraph/core/include/ngraph/op/gather.hpp +static Status TranslateGatherOp( + const NodeWrapper* op, const std::vector& static_input_map, + Builder::OpMap& ng_op_map) { + ng::Output ng_input, ng_input_indices; + TF_RETURN_IF_ERROR(GetInputNodes(ng_op_map, op, ng_input, ng_input_indices)); + + auto ng_axis = ConstructNgNode(op->name(), ng::element::i64, + ng::Shape{}, 0); + + auto gather_op = ConstructNgNode(op->name(), ng_input, + ng_input_indices, ng_axis); + + SaveNgOp(ng_op_map, op->name(), gather_op); + return Status::OK(); +} + +static Status TranslateGatherV2Op( + const NodeWrapper* op, const std::vector& static_input_map, + Builder::OpMap& ng_op_map) { + ng::Output ng_input, ng_input_coords, ng_unused; + TF_RETURN_IF_ERROR( + GetInputNodes(ng_op_map, op, ng_input, ng_input_coords, ng_unused)); + + std::vector tf_axis; + TF_RETURN_IF_ERROR(GetStaticInputVector(op, 2, static_input_map, &tf_axis)); + + if (tf_axis.size() > 1) { + std::ostringstream buf; + buf << "Found axis in GatherV2 op (" << op->name() << + ") translation to be non scalar, of size " << + tf_axis.size(); + return errors::Internal(buf.str()); + } + + // Negative axis is supported. Accounting for that + auto ng_input_shape = ng_input.get_shape(); + size_t ng_input_rank = ng_input_shape.size(); + int axis; + if (tf_axis[0] >= 0) { + axis = tf_axis[0]; + } else { + axis = tf_axis[0] + ng_input_rank; + } + if (axis < 0 || axis >= ng_input_rank) { + std:ostringstream buf; + buf << "Expected axis in the range [-" << + ng_input_rank << ", " << ng_input_rank << + "), but got " << tf_axis[0]; + return errors::InvalidArgument(buf.str()); + } + + auto ng_axis = ConstructNgNode( + op->name(), ng::element::i64, ng::Shape{tf_axis.size()}, tf_axis); + + auto gather_op = ConstructNgNode(op->name(), ng_input, + ng_input_coords, ng_axis); + + SaveNgOp(ng_op_map, op->name(), gather_op); + return Status::OK(); +} + +static Status TranslateFusedConv2DOp(const NodeWrapper* op, + const std::vector&, + Builder::OpMap& ng_op_map) { + int num_args; + TF_RETURN_IF_ERROR(GetNodeAttr(op->attrs(), "num_args", &num_args)); + + std::vector fused_ops; + TF_RETURN_IF_ERROR(GetNodeAttr(op->attrs(), "fused_ops", &fused_ops)); + + std::string tf_data_format; + TF_RETURN_IF_ERROR(GetNodeAttr(op->attrs(), "data_format", &tf_data_format)); + bool is_nhwc = (tf_data_format == "NHWC"); + + auto CreateNgConv = [&](ng::Output& ng_input, + ng::Output& ng_filter, + ng::Output& ng_conv) { + std::vector tf_strides; + std::vector tf_dilations; + std::string tf_padding_type; + TF_RETURN_IF_ERROR(GetNodeAttr(op->attrs(), "strides", &tf_strides)); + TF_RETURN_IF_ERROR(GetNodeAttr(op->attrs(), "dilations", &tf_dilations)); + TF_RETURN_IF_ERROR(GetNodeAttr(op->attrs(), "padding", &tf_padding_type)); + + if (tf_data_format != "NHWC" && tf_data_format != "NCHW") { + return errors::InvalidArgument( + "Conv2D data format is neither NHWC nor NCHW"); + } + + // TF Kernel Test Checks + // Strides in the batch and depth dimension is not supported + if (tf_strides[0] != 1 || tf_strides[is_nhwc ? 3 : 1] != 1) { + return errors::InvalidArgument( + "Strides in batch and depth dimensions is not supported: " + + op->type_string()); + } + + NGRAPH_VLOG(3) << ng::join(tf_strides); + NGRAPH_VLOG(3) << ng::join(tf_dilations); + NGRAPH_VLOG(3) << tf_padding_type; + NGRAPH_VLOG(3) << tf_data_format; + + ng::Strides ng_strides(2); + ng::Strides ng_dilations(2); + ng::Shape ng_image_shape(2); + ng::Shape ng_kernel_shape(2); + + NHWCtoHW(is_nhwc, tf_strides, ng_strides); + NHWCtoHW(is_nhwc, ng_input.get_shape(), ng_image_shape); + NHWCtoHW(is_nhwc, tf_dilations, ng_dilations); + NHWCtoNCHW(op->name(), is_nhwc, ng_input); + + NGRAPH_VLOG(3) << "ng_strides: " << ng::join(ng_strides); + NGRAPH_VLOG(3) << "ng_dilations: " << ng::join(ng_dilations); + NGRAPH_VLOG(3) << "ng_image_shape: " << ng::join(ng_image_shape); + + auto& ng_filter_shape = ng_filter.get_shape(); + ng_kernel_shape[0] = ng_filter_shape[0]; + ng_kernel_shape[1] = ng_filter_shape[1]; + Transpose<3, 2, 0, 1>(ng_filter); + Builder::SetTracingInfo(op->name(), ng_filter); + + NGRAPH_VLOG(3) << "ng_kernel_shape: " << ng::join(ng_kernel_shape); + + ng::CoordinateDiff ng_padding_below; + ng::CoordinateDiff ng_padding_above; + Builder::MakePadding(tf_padding_type, ng_image_shape, ng_kernel_shape, + ng_strides, ng_dilations, ng_padding_below, + ng_padding_above); + + ng_conv = ConstructNgNode( + op->name() + "_FusedConv2D_Conv", ng_input, ng_filter, ng_strides, + ng_padding_below, ng_padding_above, ng_dilations); + + return Status::OK(); + }; + + if (VecStrCmp(fused_ops, {"BiasAdd"}) || + VecStrCmp(fused_ops, {"BiasAdd", "Relu"}) || + VecStrCmp(fused_ops, {"BiasAdd", "Relu6"})) { + if (num_args != 1) { + return errors::InvalidArgument( + "FusedConv2DBiasAdd has incompatible num_args"); + } + + ng::Output ng_input, ng_filter, ng_bias, ng_conv; + TF_RETURN_IF_ERROR( + GetInputNodes(ng_op_map, op, ng_input, ng_filter, ng_bias)); + + TF_RETURN_IF_ERROR(CreateNgConv(ng_input, ng_filter, ng_conv)); + + auto ng_conv_shape = ng_conv.get_shape(); + auto ng_bias_shape = ng_bias.get_shape(); + if (ng_bias_shape.size() != 1) { + return errors::InvalidArgument( + "Bias argument to BiasAdd does not have one dimension"); + } + + std::vector reshape_pattern_values(ng_conv_shape.size(), 1U); + reshape_pattern_values[1] = ng_bias.get_shape().front(); + auto reshape_pattern = make_shared( + ng::element::u64, ng::Shape{reshape_pattern_values.size()}, + reshape_pattern_values); + auto ng_bias_reshaped = ConstructNgNode( + op->name(), ng_bias, reshape_pattern, false); + + auto ng_add = ConstructNgNode( + op->name() + "_FusedConv2D_BiasAdd", ng_conv, ng_bias_reshaped); + + if (VecStrCmp(fused_ops, {"BiasAdd", "Relu"})) { + auto ng_relu = ConstructNgNode( + op->name() + "_FusedConv2D_Relu", ng_add); + NCHWtoNHWC(op->name(), is_nhwc, ng_relu); + SaveNgOp(ng_op_map, op->name(), ng_relu); + } else if (VecStrCmp(fused_ops, {"BiasAdd", "Relu6"})) { + auto ng_relu6 = ConstructNgNode( + op->name() + "_FusedConv2D_Relu6", ng_add, 0, 6); + NCHWtoNHWC(op->name(), is_nhwc, ng_relu6); + SaveNgOp(ng_op_map, op->name(), ng_relu6); + } else { + NCHWtoNHWC(op->name(), is_nhwc, ng_add); + SaveNgOp(ng_op_map, op->name(), ng_add); + } + } else if (VecStrCmp(fused_ops, {"FusedBatchNorm"}) || + VecStrCmp(fused_ops, {"FusedBatchNorm", "Relu"}) || + VecStrCmp(fused_ops, {"FusedBatchNorm", "Relu6"})) { + if (num_args != 4) { + return errors::InvalidArgument( + "FusedConv2D with FusedBatchNorm has incompatible num_args"); + } + + ng::Output ng_input, ng_filter, ng_conv, ng_scale, ng_offset, + ng_mean, ng_variance; + TF_RETURN_IF_ERROR(GetInputNodes(ng_op_map, op, ng_input, ng_filter, + ng_scale, ng_offset, ng_mean, + ng_variance)); + TF_RETURN_IF_ERROR(CreateNgConv(ng_input, ng_filter, ng_conv)); + + float tf_epsilon; + TF_RETURN_IF_ERROR(GetNodeAttr(op->attrs(), "epsilon", &tf_epsilon)); + + auto ng_batch_norm = ConstructNgNode( + op->name() + "_FusedConv2D_BatchNorm", ng_conv, ng_scale, ng_offset, + ng_mean, ng_variance, tf_epsilon); + + if (VecStrCmp(fused_ops, {"FusedBatchNorm", "Relu"})) { + auto ng_relu = ConstructNgNode( + op->name() + "_FusedConv2D_BatchNormRelu", ng_batch_norm); + NCHWtoNHWC(op->name(), is_nhwc, ng_relu); + SaveNgOp(ng_op_map, op->name(), ng_relu); + } else if (VecStrCmp(fused_ops, {"FusedBatchNorm", "Relu6"})) { + auto ng_relu6 = ConstructNgNode( + op->name() + "_FusedConv2D_BatchNormRelu", ng_batch_norm, 0, 6); + NCHWtoNHWC(op->name(), is_nhwc, ng_relu6); + SaveNgOp(ng_op_map, op->name(), ng_relu6); + } else { + NCHWtoNHWC(op->name(), is_nhwc, ng_batch_norm); + SaveNgOp(ng_op_map, op->name(), ng_batch_norm); + } + } else { + return errors::Unimplemented("Unsupported _FusedConv2D " + + StrJoin(fused_ops, ",")); + } + return Status::OK(); +} + +static Status TranslateIdentityOp(const NodeWrapper* op, + const std::vector&, + Builder::OpMap& ng_op_map) { + ng::Output ng_arg; + TF_RETURN_IF_ERROR(GetInputNodes(ng_op_map, op, ng_arg)); + SaveNgOp(ng_op_map, op->name(), ng_arg); + return Status::OK(); +} + +static Status TranslateIsFiniteOp( + const NodeWrapper* op, const std::vector& static_input_map, + Builder::OpMap& ng_op_map) { + // Implemented tf.is_finite by checking: + // (in != inf) && (in != -inf) && (in == in) + // ^^^^^^^^ checks for NaN's + ng::Output ng_input; + TF_RETURN_IF_ERROR(GetInputNodes(ng_op_map, op, ng_input)); + + auto const_inf = ConstructNgNode( + op->name(), ng_input.get_element_type(), ng::Shape{}, + std::vector{std::numeric_limits::infinity()}); + + auto const_neg_inf = ConstructNgNode( + op->name(), ng_input.get_element_type(), ng::Shape{}, + std::vector{-std::numeric_limits::infinity()}); + + auto neq_inf = + ConstructNgNode(op->name(), ng_input, const_inf); + auto neq_neg_inf = + ConstructNgNode(op->name(), ng_input, const_neg_inf); + auto eq_nan = ConstructNgNode(op->name(), ng_input, ng_input); + + auto neq_inf_and_neq_neg_inf = + ConstructNgNode(op->name(), neq_inf, neq_neg_inf); + auto is_finite = ConstructNgNode( + op->name(), neq_inf_and_neq_neg_inf, eq_nan); + + SaveNgOp(ng_op_map, op->name(), is_finite); + return Status::OK(); +} + +static Status TranslateL2LossOp(const NodeWrapper* op, + const std::vector&, + Builder::OpMap& ng_op_map) { + ng::Output ng_input; + TF_RETURN_IF_ERROR(GetInputNodes(ng_op_map, op, ng_input)); + + std::vector val; + val.push_back(2.0); + auto const_2 = ConstructNgNode( + op->name(), ng_input.get_element_type(), ng::Shape{}, val[0]); + + auto ng_pow = + ConstructNgNode(op->name(), ng_input, ng_input); + + size_t input_rank = ng_input.get_shape().size(); + std::vector axes; + for (size_t i = 0; i < input_rank; ++i) { + axes.push_back(i); + } + + auto ng_reduction_axes = ConstructNgNode( + op->name(), ng::element::i64, ng::Shape{axes.size()}, axes); + auto ng_sum = + ConstructNgNode(op->name(), ng_pow, ng_reduction_axes); + auto ng_l2loss = ConstructNgNode(op->name(), ng_sum, const_2); + SaveNgOp(ng_op_map, op->name(), ng_l2loss); + return Status::OK(); +} + +static Status TranslateLog1pOp( + const NodeWrapper* op, const std::vector& static_input_map, + Builder::OpMap& ng_op_map) { + return TranslateUnaryOp( + op, static_input_map, ng_op_map, [&op](ng::Output n) { + auto et = n.get_element_type(); + auto shape = n.get_shape(); + std::vector val_1(ng::shape_size(shape), "1"); + auto ng_const1 = + ConstructNgNode(op->name(), et, shape, val_1); + auto ng_add = ConstructNgNode(op->name(), ng_const1, n); + return ConstructNgNode(op->name(), ng_add); + }); +} + +static Status TranslateLRNOp(const NodeWrapper* op, + const std::vector& static_input_map, + Builder::OpMap& ng_op_map) { + ng::Output ng_inp; + TF_RETURN_IF_ERROR(GetInputNodes(ng_op_map, op, ng_inp)); + + float alpha; + TF_RETURN_IF_ERROR(GetNodeAttr(op->attrs(), "alpha", &alpha)); + float beta; + TF_RETURN_IF_ERROR(GetNodeAttr(op->attrs(), "beta", &beta)); + float bias; + TF_RETURN_IF_ERROR(GetNodeAttr(op->attrs(), "bias", &bias)); + int64_t depth_radius; + TF_RETURN_IF_ERROR(GetNodeAttr(op->attrs(), "depth_radius", &depth_radius)); + + // OV: Each input value is divided by (bias+(alpha/size)*sum(xi^2 for every xi + // in the local region))^beta + // TF: sqr_sum[a, b, c, d] = sum(input[a, b, c, d - depth_radius : d + + // depth_radius + 1] ** 2) + // output = input / (bias + alpha * sqr_sum) ** beta + int64_t size = depth_radius * 2 + 1; + alpha = alpha * size; + // nGraph expects the input to be in NCHW format + NHWCtoNCHW(op->name(), true, ng_inp); + auto ng_output = ConstructNgNode(op->name(), ng_inp, alpha, beta, + bias, (size_t)size); + NCHWtoNHWC(op->name(), true, ng_output); + SaveNgOp(ng_op_map, op->name(), ng_output); + return Status::OK(); +} + +static Status TranslateLogSoftmaxOp(const NodeWrapper* op, + const std::vector&, + Builder::OpMap& ng_op_map) { + ng::Output ng_inp; + TF_RETURN_IF_ERROR(GetInputNodes(ng_op_map, op, ng_inp)); + auto inp_shape = ng_inp.get_shape(); + size_t rank = inp_shape.size(); + int64_t axes = rank - 1; + + auto ng_output = ConstructNgNode(op->name(), ng_inp, axes); + SaveNgOp(ng_op_map, op->name(), ng_output); + return Status::OK(); +} + +static Status TranslateMatMulOp(const NodeWrapper* op, + const std::vector&, + Builder::OpMap& ng_op_map) { + ng::Output ng_lhs, ng_rhs; + TF_RETURN_IF_ERROR(GetInputNodes(ng_op_map, op, ng_lhs, ng_rhs)); + + // Transpose arguments if requested. + bool transpose_a = false; + TF_RETURN_IF_ERROR(GetNodeAttr(op->attrs(), "transpose_a", &transpose_a)); + + bool transpose_b = false; + TF_RETURN_IF_ERROR(GetNodeAttr(op->attrs(), "transpose_b", &transpose_b)); + + SaveNgOp(ng_op_map, op->name(), + ConstructNgNode(op->name(), ng_lhs, ng_rhs, + transpose_a, transpose_b)); + return Status::OK(); +} + +template +static Status TranslateMaxPoolOp(const NodeWrapper* op, + const std::vector&, + Builder::OpMap& ng_op_map) { + ng::Output ng_input; + TF_RETURN_IF_ERROR(GetInputNodes(ng_op_map, op, ng_input)); + + std::vector tf_strides; + std::vector tf_ksize; + std::string tf_padding_type; + std::string tf_data_format; + TF_RETURN_IF_ERROR(GetNodeAttr(op->attrs(), "strides", &tf_strides)); + TF_RETURN_IF_ERROR(GetNodeAttr(op->attrs(), "ksize", &tf_ksize)); + TF_RETURN_IF_ERROR(GetNodeAttr(op->attrs(), "padding", &tf_padding_type)); + TF_RETURN_IF_ERROR(GetNodeAttr(op->attrs(), "data_format", &tf_data_format)); + + bool is_nhwc = (tf_data_format == "NHWC") || (tf_data_format == "NDHWC"); + + NGRAPH_VLOG(3) << ng::join(tf_strides); + NGRAPH_VLOG(3) << ng::join(tf_ksize); + NGRAPH_VLOG(3) << tf_padding_type; + NGRAPH_VLOG(3) << tf_data_format; + + ng::Strides ng_strides(N); + ng::Shape ng_image_shape(N); + ng::Shape ng_kernel_shape(N); + ng::Shape ng_dilations(N, 1); + + NHWCtoHW(is_nhwc, tf_strides, ng_strides); + NHWCtoHW(is_nhwc, ng_input.get_shape(), ng_image_shape); + NHWCtoHW(is_nhwc, tf_ksize, ng_kernel_shape); + NHWCtoNCHW(op->name(), is_nhwc, ng_input); + NGRAPH_VLOG(3) << "ng_strides: " << ng::join(ng_strides); + NGRAPH_VLOG(3) << "ng_image_shape: " << ng::join(ng_image_shape); + NGRAPH_VLOG(3) << "ng_kernel_shape: " << ng::join(ng_kernel_shape); + + ng::CoordinateDiff padding_below; + ng::CoordinateDiff padding_above; + Builder::MakePadding(tf_padding_type, ng_image_shape, ng_kernel_shape, + ng_strides, ng_dilations, padding_below, padding_above); + + // TODO: remove this once nGraph supports negative padding + // (CoordinateDiff) for MaxPool + ng::Shape ng_padding_below(padding_below.begin(), padding_below.end()); + ng::Shape ng_padding_above(padding_above.begin(), padding_above.end()); + + auto ng_maxpool = ConstructNgNode( + op->name(), ng_input, ng_strides, ng_padding_below, ng_padding_above, + ng_kernel_shape, ng::op::RoundingType::FLOOR); + + NCHWtoNHWC(op->name(), is_nhwc, ng_maxpool); + + NGRAPH_VLOG(3) << "maxpool outshape: {" << ng::join(ng_maxpool.get_shape()) + << "}"; + + SaveNgOp(ng_op_map, op->name(), ng_maxpool); + return Status::OK(); +} + +static Status TranslateNonMaxSuppressionV2Op( + const NodeWrapper* op, const std::vector& static_input_map, + Builder::OpMap& ng_op_map) { + ng::Output ng_boxes, ng_scores, ng_unused, ng_iou_threshold; + TF_RETURN_IF_ERROR(GetInputNodes(ng_op_map, op, ng_boxes, ng_scores, + ng_unused, ng_iou_threshold)); + + auto ng_axis_boxes = ConstructNgNode( + op->name(), ng::element::i64, ng::Shape{1}, std::vector({0})); + auto ng_boxes_unsqueezed = + ConstructNgNode(op->name(), ng_boxes, ng_axis_boxes); + + auto ng_axis_scores = ConstructNgNode( + op->name(), ng::element::i64, ng::Shape{1}, std::vector({0})); + auto ng_scores_unsqueezed1 = + ConstructNgNode(op->name(), ng_scores, ng_axis_scores); + auto ng_scores_unsqueezed2 = ConstructNgNode( + op->name(), ng_scores_unsqueezed1, ng_axis_scores); + + std::vector max_output_size; + TF_RETURN_IF_ERROR( + GetStaticInputVector(op, 2, static_input_map, &max_output_size)); + + // max_output_size must be scalar + if (max_output_size.size() != 1) { + return errors::InvalidArgument( + "NonMaxSuppression Op: max_output_size of nms must be scalar " + + to_string(max_output_size.size())); + } + + auto ng_max_output_size = ConstructNgNode( + op->name(), ng::element::i64, ng::Shape{}, max_output_size[0]); + NGRAPH_VLOG(5) << "ng_max_output_size " << max_output_size[0]; + + auto ng_nmsv = ConstructNgNode( + op->name(), ng_boxes_unsqueezed, ng_scores_unsqueezed2, + ng_max_output_size, ng_iou_threshold, + opset::NonMaxSuppression::BoxEncodingType::CORNER, false, + ngraph::element::Type_t::i32); + + auto begin = ConstructNgNode( + op->name(), ng::element::i64, ng::Shape{2}, std::vector({0, 2})); + auto end = ConstructNgNode( + op->name(), ng::element::i64, ng::Shape{2}, + std::vector({max_output_size[0], 3})); + auto ng_nmsv_slice = ConstructNgNode( + op->name(), ng_nmsv, begin, end, std::vector{0, 0}, + std::vector{0, 0}, std::vector{0, 0}, + std::vector{0, 1}); + + Builder::SetTracingInfo(op->name(), ng_nmsv_slice); + SaveNgOp(ng_op_map, op->name(), ng_nmsv_slice); + return Status::OK(); +} + +static Status TranslateReduceOp( + const NodeWrapper* op, const std::vector& static_input_map, + Builder::OpMap& ng_op_map, + std::function(ng::Output, + ng::Output, const bool)> + create_ng_node) { + ng::Output ng_input; + TF_RETURN_IF_ERROR(GetInputNode(ng_op_map, op, 0, ng_input)); + bool tf_keep_dims; + if (GetNodeAttr(op->attrs(), "keep_dims", &tf_keep_dims) != Status::OK()) { + tf_keep_dims = false; + } + + std::vector axes; + TF_RETURN_IF_ERROR(GetStaticInputVector(op, 1, static_input_map, &axes)); + + ng::Shape input_shape = ng_input.get_shape(); + size_t input_rank = input_shape.size(); + + TF_RETURN_IF_ERROR(CheckAxisDimInRange(axes, input_rank)); + + std::vector ng_reduction_axes_vect(axes.size()); + std::transform( + axes.begin(), axes.end(), ng_reduction_axes_vect.begin(), + [input_rank](int idx) { return idx + (idx < 0 ? (int)input_rank : 0); }); + auto ng_reduction_axes = ConstructNgNode( + op->name(), ng::element::i64, ng::Shape{ng_reduction_axes_vect.size()}, + ng_reduction_axes_vect); + + ng::Output ng_node = + create_ng_node(ng_input, ng_reduction_axes, tf_keep_dims); + + SaveNgOp(ng_op_map, op->name(), ng_node); + return Status::OK(); +} + +template +static Status TranslateDirectReduceOp( + const NodeWrapper* op, const std::vector& static_input_map, + Builder::OpMap& ng_op_map) { + // ensure its either an arithmetic or a logical reduction + if (!(std::is_base_of::value || + std::is_base_of::value)) { + return errors::InvalidArgument( + "Expected node to be either a valid logical or arithmetic reduction " + "type"); + } + return TranslateReduceOp( + op, static_input_map, ng_op_map, + [&op](ng::Output ng_input, + ng::Output ng_reduction_axes, const bool keep_dims) { + return ConstructNgNode(op->name(), ng_input, ng_reduction_axes, + keep_dims); + }); +} + +static Status TranslateOneHotOp( + const NodeWrapper* op, const std::vector& static_input_map, + Builder::OpMap& ng_op_map) { + ng::Output ng_features, ng_unused, ng_on, ng_off, ng_depth; + TF_RETURN_IF_ERROR( + GetInputNodes(ng_op_map, op, ng_features, ng_unused, ng_on, ng_off)); + + auto ng_features_shape = ng_features.get_shape(); + std::vector depth; + TF_RETURN_IF_ERROR(GetStaticInputVector(op, 1, static_input_map, &depth)); + + // Depth must be scalar + if (depth.size() != 1) { + return errors::InvalidArgument( + "OneHot Op: depth of one hot dimension must be scalar " + to_string(depth.size())); + } + + auto const_depth = ConstructNgNode( + op->name(), ng::element::i64, ng::Shape{}, depth); + + int one_hot_axis; + TF_RETURN_IF_ERROR(GetNodeAttr(op->attrs(), "axis", &one_hot_axis)); + + auto ng_onehot = ConstructNgNode( + op->name(), ng_features, const_depth, ng_on, ng_off, one_hot_axis); + SaveNgOp(ng_op_map, op->name(), ng_onehot); + return Status::OK(); +} + +static Status TranslatePackOp(const NodeWrapper* op, const std::vector&, + Builder::OpMap& ng_op_map) { + TF_RETURN_IF_ERROR(ValidateInputCountMin(op, 1)); + + int32_t tf_axis; + TF_RETURN_IF_ERROR(GetNodeAttr(op->attrs(), "axis", &tf_axis)); + auto ng_axis = ConstructNgNode( + op->name(), ng::element::i64, ng::Shape{1}, + std::vector({tf_axis})); + + ng::OutputVector ng_concat_inputs; + for (int32_t i = 0; i < op->num_inputs(); ++i) { + ng::Output ng_input; + TF_RETURN_IF_ERROR(GetInputNode(ng_op_map, op, i, ng_input)); + auto unsqueezed_input = + ConstructNgNode(op->name(), ng_input, ng_axis); + ng_concat_inputs.push_back(unsqueezed_input); + } + + // if inputs shape is (2, 3, 4), and axis is 1, then we want + // to create output_shape (2, num_inputs, 3, 4) + SaveNgOp(ng_op_map, op->name(), ConstructNgNode( + op->name(), ng_concat_inputs, tf_axis)); + return Status::OK(); +} + +// 3 different Pad Ops: Pad, PadV2, MirrorPad +// See https://www.tensorflow.org/api_docs/cc/class/tensorflow/ops/pad +// See https://www.tensorflow.org/api_docs/cc/class/tensorflow/ops/pad-v2 +// See https://www.tensorflow.org/api_docs/cc/class/tensorflow/ops/mirror-pad +static Status TranslatePadOp(const NodeWrapper* op, + const std::vector& static_input_map, + Builder::OpMap& ng_op_map) { + ng::Output ng_input, ng_paddings_op, pad_val_op, result_pad_op; + + // Set inputs and pad_val_op + if (op->type_string() == "Pad" || op->type_string() == "MirrorPad") { + TF_RETURN_IF_ERROR(GetInputNodes(ng_op_map, op, ng_input, ng_paddings_op)); + pad_val_op = ConstructNgNode( + op->name(), ng_input.get_element_type(), ng::Shape(), + std::vector({0})); + } else if (op->type_string() == "PadV2") { + TF_RETURN_IF_ERROR( + GetInputNodes(ng_op_map, op, ng_input, ng_paddings_op, pad_val_op)); + } else { + return errors::InvalidArgument("Incorrect TF Pad OpType: " + + op->type_string()); + } + + // Set pad_mode + auto pad_mode = ng::op::PadMode::CONSTANT; + if (op->type_string() == "MirrorPad") { + std::string pad_mode_str; + TF_RETURN_IF_ERROR(GetNodeAttr(op->attrs(), "mode", &pad_mode_str)); + if (pad_mode_str == "REFLECT") { + pad_mode = ng::op::PadMode::REFLECT; + } else if (pad_mode_str == "SYMMETRIC") { + pad_mode = ng::op::PadMode::SYMMETRIC; + } else { + return errors::InvalidArgument(pad_mode_str + + " is not an allowed padding mode."); + } + } + + // Set pads_begin & pads_end (from the pad_val_op) + std::vector paddings; + TF_RETURN_IF_ERROR(GetStaticInputVector(op, 1, static_input_map, &paddings)); + NGRAPH_VLOG(3) << op->name() << " pads {" << ng::join(paddings) << "}"; + if (paddings.size() % 2 != 0) { + return errors::InvalidArgument( + "Constant node for paddings does not have an even number of " + "elements"); + } + std::vector pad_begin(paddings.size() / 2); + std::vector pad_end(paddings.size() / 2); + for (size_t i = 0; i < paddings.size() / 2; i++) { + pad_begin[i] = paddings[2 * i]; + pad_end[i] = paddings[2 * i + 1]; + } + auto pads_begin_node = ConstructNgNode( + op->name(), ng::element::i64, ng::Shape{pad_begin.size()}, pad_begin); + auto pads_end_node = ConstructNgNode( + op->name(), ng::element::i64, ng::Shape{pad_end.size()}, pad_end); + + // Create final Op + result_pad_op = + ConstructNgNode(op->name(), ng_input, pads_begin_node, + pads_end_node, pad_val_op, pad_mode); + + SaveNgOp(ng_op_map, op->name(), result_pad_op); + return Status::OK(); +} + +static Status TranslateRangeOp( + const NodeWrapper* op, const std::vector& static_input_map, + Builder::OpMap& ng_op_map) { + ng::Output ng_start, ng_stop, ng_step; + TF_RETURN_IF_ERROR(GetInputNodes(ng_op_map, op, ng_start, ng_stop, ng_step)); + + DataType start_type = op->input_type(0); + DataType stop_type = op->input_type(1); + DataType step_type = op->input_type(2); + ng::element::Type out_type; + TF_RETURN_IF_ERROR( + TFDataTypeToNGraphElementType(op->output_type(0), &out_type)); + ng::Output start_node, stop_node, step_node; + TF_RETURN_IF_ERROR( + GetStaticInputNode(op, 0, static_input_map, start_type, start_node)); + TF_RETURN_IF_ERROR( + GetStaticInputNode(op, 1, static_input_map, stop_type, stop_node)); + TF_RETURN_IF_ERROR( + GetStaticInputNode(op, 2, static_input_map, step_type, step_node)); + auto ng_range = ConstructNgNode(op->name(), start_node, + stop_node, step_node, out_type); + + SaveNgOp(ng_op_map, op->name(), ng_range); + return Status::OK(); +} + +static Status TranslateRankOp(const NodeWrapper* op, const std::vector&, + Builder::OpMap& ng_op_map) { + ng::Output ng_input; + TF_RETURN_IF_ERROR(GetInputNodes(ng_op_map, op, ng_input)); + + ng::Shape input_shape = ng_input.get_shape(); + auto input_rank = static_cast(input_shape.size()); + + auto ng_rank = ConstructNgNode( + op->name(), ng::element::i32, ng::Shape(), + std::vector({input_rank})); + + SaveNgOp(ng_op_map, op->name(), ng_rank); + return Status::OK(); +} + +static Status TranslateReciprocalOp( + const NodeWrapper* op, const std::vector& static_input_map, + Builder::OpMap& ng_op_map) { + return TranslateUnaryOp( + op, static_input_map, ng_op_map, [&op](ng::Output n) { + // Create a constant tensor populated with the value -1. + // (1/x = x^(-1)) + auto et = n.get_element_type(); + auto shape = n.get_shape(); + std::vector constant_values(ng::shape_size(shape), "-1"); + auto ng_exponent = ConstructNgNode( + op->name(), et, shape, constant_values); + + // Raise each element of the input to the power -1. + return ConstructNgNode(op->name(), n, ng_exponent); + }); +} + +static Status TranslateRelu6Op(const NodeWrapper* op, + const std::vector&, + Builder::OpMap& ng_op_map) { + ng::Output ng_input; + TF_RETURN_IF_ERROR(GetInputNodes(ng_op_map, op, ng_input)); + SaveNgOp(ng_op_map, op->name(), + ConstructNgNode(op->name(), ng_input, 0, 6)); + return Status::OK(); +} + +static Status TranslateReshapeOp( + const NodeWrapper* op, const std::vector& static_input_map, + Builder::OpMap& ng_op_map) { + ng::Output ng_input, ng_shape_op; + TF_RETURN_IF_ERROR(GetInputNodes(ng_op_map, op, ng_input, ng_shape_op)); + + NGRAPH_VLOG(3) << "Input shape: " << ng::join(ng_input.get_shape()); + + std::vector shape; + TF_RETURN_IF_ERROR(GetStaticInputVector(op, 1, static_input_map, &shape)); + + NGRAPH_VLOG(3) << "Requested result shape: " << ng::join(shape); + + auto ng_shape = ConstructNgNode( + op->name(), ng::element::i64, ng::Shape{shape.size()}, shape); + SaveNgOp(ng_op_map, op->name(), ConstructNgNode( + op->name(), ng_input, ng_shape, false)); + return Status::OK(); +} + +static Status TranslateRsqrtOp( + const NodeWrapper* op, const std::vector& static_input_map, + Builder::OpMap& ng_op_map) { + return TranslateUnaryOp( + op, static_input_map, ng_op_map, [&op](ng::Output n) { + // Create a constant tensor populated with the value -1/2. + // (1/sqrt(x) = x^(-1/2)) + auto et = n.get_element_type(); + auto shape = n.get_shape(); + std::vector constant_values(ng::shape_size(shape), "-0.5"); + auto ng_exponent = ConstructNgNode( + op->name(), et, shape, constant_values); + + // Raise each element of the input to the power -0.5. + return ConstructNgNode(op->name(), n, ng_exponent); + }); +} + +static Status TranslateShapeOp(const NodeWrapper* op, + const std::vector&, + Builder::OpMap& ng_op_map) { + ng::Output ng_input; + TF_RETURN_IF_ERROR(GetInputNode(ng_op_map, op, 0, ng_input)); + + DataType dtype; + TF_RETURN_IF_ERROR(GetNodeAttr(op->attrs(), "out_type", &dtype)); + + ng::element::Type type; + TF_RETURN_IF_ERROR(TFDataTypeToNGraphElementType(dtype, &type)); + + // default output_type = element::i64 + SaveNgOp(ng_op_map, op->name(), + ConstructNgNode(op->name(), ng_input, type)); + return Status::OK(); +} + +static Status TranslateSizeOp(const NodeWrapper* op, const std::vector&, + Builder::OpMap& ng_op_map) { + ng::Output ng_input; + TF_RETURN_IF_ERROR(GetInputNodes(ng_op_map, op, ng_input)); + + DataType dtype; + TF_RETURN_IF_ERROR(GetNodeAttr(op->attrs(), "out_type", &dtype)); + + // Size has an attribute to specify output, int32_t or int64_t + ng::element::Type type; + TF_RETURN_IF_ERROR(TFDataTypeToNGraphElementType(dtype, &type)); + + auto ng_input_shape = ng_input.get_shape(); + int64_t result = 1; + for (auto dim : ng_input_shape) { + result *= dim; + } + + // make a scalar with value equals to result + auto ng_result = ConstructNgNode( + op->name(), type, ng::Shape(0), std::vector({result})); + + SaveNgOp(ng_op_map, op->name(), ng_result); + return Status::OK(); +} + +static Status TranslateSliceOp( + const NodeWrapper* op, const std::vector& static_input_map, + Builder::OpMap& ng_op_map) { + ng::Output ng_input, ng_begin, ng_size; + TF_RETURN_IF_ERROR(GetInputNodes(ng_op_map, op, ng_input, ng_begin, ng_size)); + + std::vector begin_vec; + std::vector size_vec; + TF_RETURN_IF_ERROR(GetStaticInputVector(op, 1, static_input_map, &begin_vec)); + TF_RETURN_IF_ERROR(GetStaticInputVector(op, 2, static_input_map, &size_vec)); + + if (begin_vec.size() != size_vec.size()) + return errors::InvalidArgument( + "Cannot translate slice op: size of begin = " + to_string(begin_vec.size()) + + ", size of size_vec = " + to_string(size_vec.size()) + ". Expected them to match."); + + NGRAPH_VLOG(3) << "Begin input for Slice: " << ng::join(begin_vec); + NGRAPH_VLOG(3) << "Size input for Slice: " << ng::join(size_vec); + + std::vector end_vec(begin_vec.size()); + const auto ng_input_shape = ng_input.get_shape(); + stringstream err_stream; + string err_msg; + for (size_t i = 0; i < size_vec.size(); i++) { + if (size_vec[i] != -1) { + end_vec[i] = begin_vec[i] + size_vec[i]; + } else { + // support -1 for size_vec, to the end of the tensor + end_vec[i] = ng_input_shape[i]; + } + + // check for this condition: 0 <= begin[i] <= begin[i] + size[i] <= Di + if (0 > begin_vec[i]) + err_stream << "lower < 0: " << begin_vec[i] + << ". It should have been positive.\n"; + if (begin_vec[i] > end_vec[i]) + err_stream << "upper < lower: upper = " << end_vec[i] + << ", lower = " << begin_vec[i] << "\n"; + if (begin_vec[i] > ng_input_shape[i]) + err_stream << "dim < upper: dim = " << ng_input_shape[i] + << ", upper = " << end_vec[i] << "\n"; + + err_msg = err_stream.str(); + if (!err_msg.empty()) + return errors::InvalidArgument("Cannot translate slice op at position " + + to_string(i) + " of " + to_string(size_vec.size()) + + ". The reasons are:\n" + err_msg); + } + + auto begin = ConstructNgNode( + op->name(), ng::element::i64, ng::Shape{begin_vec.size()}, begin_vec); + auto end = ConstructNgNode( + op->name(), ng::element::i64, ng::Shape{end_vec.size()}, end_vec); + + SaveNgOp(ng_op_map, op->name(), + ConstructNgNode(op->name(), ng_input, begin, + end, std::vector{}, + std::vector{})); + return Status::OK(); +} + +static Status TranslateSoftmaxOp(const NodeWrapper* op, + const std::vector&, + Builder::OpMap& ng_op_map) { + ng::Output ng_input; + TF_RETURN_IF_ERROR(GetInputNodes(ng_op_map, op, ng_input)); + + auto input_shape = ng_input.get_shape(); + auto rank = input_shape.size(); + if (rank < 1) { + return errors::InvalidArgument("TF Softmax logits must be >=1 dimension"); + } + + SaveNgOp(ng_op_map, op->name(), + ConstructNgNode(op->name(), ng_input, rank - 1)); + return Status::OK(); +} + +// Translate SpaceToDepthOp +static Status TranslateSpaceToDepthOp(const NodeWrapper* op, + const std::vector&, + Builder::OpMap& ng_op_map) { + ng::Output ng_input; + TF_RETURN_IF_ERROR(GetInputNodes(ng_op_map, op, ng_input)); + + // Get the attributes + int64_t block_size; + std::string tf_data_format; + TF_RETURN_IF_ERROR(GetNodeAttr(op->attrs(), "block_size", &block_size)); + TF_RETURN_IF_ERROR(GetNodeAttr(op->attrs(), "data_format", &tf_data_format)); + + if (tf_data_format != "NHWC" && tf_data_format != "NCHW") { + return errors::InvalidArgument( + "DepthToSpace data format is neither NHWC nor NCHW"); + } + + bool is_nhwc = (tf_data_format == "NHWC"); + + NHWCtoNCHW(op->name(), is_nhwc, ng_input); + auto ng_mode = opset::SpaceToDepth::SpaceToDepthMode::BLOCKS_FIRST; + auto space_to_depth = ConstructNgNode( + op->name(), ng_input, ng_mode, block_size); + NCHWtoNHWC(op->name(), is_nhwc, space_to_depth); + SaveNgOp(ng_op_map, op->name(), space_to_depth); + return Status::OK(); +} + +static Status TranslateSplitOp( + const NodeWrapper* op, const std::vector& static_input_map, + Builder::OpMap& ng_op_map) { + ng::Output ng_input; + TF_RETURN_IF_ERROR(GetInputNode(ng_op_map, op, 1, ng_input)); + // num_split : The number of ways to split. Must evenly divide + // value.shape[split_dim] + int32_t num_split; + TF_RETURN_IF_ERROR(GetNodeAttr(op->attrs(), "num_split", &num_split)); + + ng::Shape shape = ng_input.get_shape(); + int rank = shape.size(); + + std::vector split_dim_vec; + TF_RETURN_IF_ERROR( + GetStaticInputVector(op, 0, static_input_map, &split_dim_vec)); + int split_dim = split_dim_vec[0] + (split_dim_vec[0] < 0 ? (int64_t)rank : 0); + auto ng_split_dim = ConstructNgNode( + op->name(), ng::element::u64, ng::Shape{}, split_dim); + auto ng_split = make_shared(ng_input, ng_split_dim, num_split); + + for (int i = 0; i < num_split; ++i) { + auto out = ng_split->output(i); + Builder::SetTracingInfo(op->name(), out); + SaveNgOp(ng_op_map, op->name(), out); + } + return Status::OK(); +} + +static Status TranslateSplitVOp( + const NodeWrapper* op, const std::vector& static_input_map, + Builder::OpMap& ng_op_map) { + ng::Output ng_input, ng_split_length, ng_split_dim; + + TF_RETURN_IF_ERROR(GetInputNode(ng_op_map, op, 0, ng_input)); + + ng::Shape shape = ng_input.get_shape(); + int rank = shape.size(); + + std::vector split_dim_vec; + TF_RETURN_IF_ERROR( + GetStaticInputVector(op, 2, static_input_map, &split_dim_vec)); + // there should be at least one element specified as axis and not more than + // one as axis is 0-D + if (split_dim_vec.size() != 1) { + return errors::InvalidArgument( + "split_dim_tensor must have " + "exactly one element."); + } + TF_RETURN_IF_ERROR(CheckAxisDimInRange(split_dim_vec, rank)); + int split_dim = split_dim_vec[0] + (split_dim_vec[0] < 0 ? (int64_t)rank : 0); + ng_split_dim = ConstructNgNode(op->name(), ng::element::i32, + ng::Shape{}, split_dim); + + std::vector split_lengths_vec; + TF_RETURN_IF_ERROR( + GetStaticInputVector(op, 1, static_input_map, &split_lengths_vec)); + + // length: Length of size_splits + int length = 0; + int idx = -1; + + // Find out the total length of the splits and locate -1 's index, if any + bool has_one_neg = false; + for (size_t i = 0; i < split_lengths_vec.size(); ++i) { + if (split_lengths_vec[i] != -1) { + length += split_lengths_vec[i]; + } else { + if (has_one_neg) { + return errors::InvalidArgument("size_splits can only have one -1"); + } else { + idx = i; + has_one_neg = true; + } + } + } + + // Size splits must sum to the dimension of value along split_dim + if (idx > 0) { + split_lengths_vec[idx] = shape[split_dim] - length; + } + + if ((!has_one_neg && length != shape[split_dim]) || + (has_one_neg && split_lengths_vec[idx] < 0)) { + return errors::InvalidArgument( + "The length of size_splits must sum to the value of the dimension " + "along split_dim"); + } + + ng_split_length = ConstructNgNode( + op->name(), ng::element::i32, ng::Shape{split_lengths_vec.size()}, + split_lengths_vec); + + if (split_lengths_vec.size() != 1) { + auto ng_split = make_shared(ng_input, ng_split_dim, + ng_split_length); + for (size_t i = 0; i < split_lengths_vec.size(); ++i) { + auto out = ng_split->output(i); + Builder::SetTracingInfo(op->name(), out); + SaveNgOp(ng_op_map, op->name(), out); + } + } else { + SaveNgOp(ng_op_map, op->name(), ng_input); + } + + return Status::OK(); +} + +static Status TranslateSquareOp( + const NodeWrapper* op, const std::vector& static_input_map, + Builder::OpMap& ng_op_map) { + return TranslateUnaryOp( + op, static_input_map, ng_op_map, [&op](ng::Output n) { + return ConstructNgNode(op->name(), n, n); + }); +} + +static Status TranslateSqueezeOp(const NodeWrapper* op, + const std::vector&, + Builder::OpMap& ng_op_map) { + ng::Output ng_input; + TF_RETURN_IF_ERROR(GetInputNodes(ng_op_map, op, ng_input)); + size_t input_dims = ng_input.get_shape().size(); + + std::vector tf_axis; + TF_RETURN_IF_ERROR(GetNodeAttr(op->attrs(), "squeeze_dims", &tf_axis)); + + // If input dimension is negative, make it positive + for (size_t i = 0; i < tf_axis.size(); i++) { + tf_axis[i] = tf_axis[i] < 0 ? (int32_t)(input_dims) + tf_axis[i] : tf_axis[i]; + } + + auto ng_const = ConstructNgNode( + op->name(), ng::element::i32, ng::Shape{tf_axis.size()}, tf_axis); + + SaveNgOp(ng_op_map, op->name(), + ConstructNgNode(op->name(), ng_input, ng_const)); + return Status::OK(); +} + +static Status TranslateStridedSliceOp( + const NodeWrapper* op, const std::vector& static_input_map, + Builder::OpMap& ng_op_map) { + ng::Output ng_input; + TF_RETURN_IF_ERROR(GetInputNode(ng_op_map, op, 0, ng_input)); + + int32_t begin_mask, end_mask, new_axis_mask, shrink_axis_mask, ellipsis_mask; + TF_RETURN_IF_ERROR(GetNodeAttr(op->attrs(), "begin_mask", &begin_mask)); + TF_RETURN_IF_ERROR(GetNodeAttr(op->attrs(), "end_mask", &end_mask)); + TF_RETURN_IF_ERROR(GetNodeAttr(op->attrs(), "new_axis_mask", &new_axis_mask)); + TF_RETURN_IF_ERROR( + GetNodeAttr(op->attrs(), "shrink_axis_mask", &shrink_axis_mask)); + TF_RETURN_IF_ERROR(GetNodeAttr(op->attrs(), "ellipsis_mask", &ellipsis_mask)); + + NGRAPH_VLOG(5) << "strided slice attributes: " + << " begin mask: " << begin_mask << " end mask: " << end_mask + << " new axis mask: " << new_axis_mask + << " shrink axis mask: " << shrink_axis_mask + << " ellipsis mask: " << ellipsis_mask; + + std::vector begin_vec; + TF_RETURN_IF_ERROR(GetStaticInputVector(op, 1, static_input_map, &begin_vec)); + std::vector end_vec; + TF_RETURN_IF_ERROR(GetStaticInputVector(op, 2, static_input_map, &end_vec)); + std::vector stride_vec; + TF_RETURN_IF_ERROR( + GetStaticInputVector(op, 3, static_input_map, &stride_vec)); + + auto begin = ConstructNgNode( + op->name(), ng::element::i64, ng::Shape{begin_vec.size()}, begin_vec); + auto end = ConstructNgNode( + op->name(), ng::element::i64, ng::Shape{end_vec.size()}, end_vec); + auto strides = ConstructNgNode( + op->name(), ng::element::i64, ng::Shape{stride_vec.size()}, stride_vec); + + auto mask_to_vec = [](int32_t mask) { + auto length = sizeof(mask) * CHAR_BIT; + std::vector vec(length, 0); + if (mask == 0) { + return vec; + } + for (auto i = 0; i < length; ++i) { + if ((unsigned char)(mask >> i & 0x01) == 1) { + vec[i] = 1; + } + } + return vec; + }; + + SaveNgOp( + ng_op_map, op->name(), + ConstructNgNode( + op->name(), ng_input, begin, end, strides, mask_to_vec(begin_mask), + mask_to_vec(end_mask), mask_to_vec(new_axis_mask), + mask_to_vec(shrink_axis_mask), mask_to_vec(ellipsis_mask))); + return Status::OK(); +} + +static Status TranslateTileOp( + const NodeWrapper* op, const std::vector& static_input_map, + Builder::OpMap& ng_op_map) { + ng::Output ng_input, ng_multiples; + TF_RETURN_IF_ERROR(GetInputNodes(ng_op_map, op, ng_input, ng_multiples)); + + std::vector multiples; + TF_RETURN_IF_ERROR(GetStaticInputVector(op, 1, static_input_map, &multiples)); + + auto ng_repeats = ConstructNgNode( + op->name(), ng::element::i64, ng::Shape{multiples.size()}, multiples); + SaveNgOp(ng_op_map, op->name(), + ConstructNgNode(op->name(), ng_input, ng_repeats)); + return Status::OK(); +} + +// Translate TopKV2 Op using ngraph core op TopK +static Status TranslateTopKV2Op( + const NodeWrapper* op, const std::vector& static_input_map, + Builder::OpMap& ng_op_map) { + ng::Output ng_input; + + TF_RETURN_IF_ERROR(ValidateInputCount(op, 2)); + TF_RETURN_IF_ERROR(GetInputNode(ng_op_map, op, 0, ng_input)); + + // axis along which to compute top k indices + int64_t k_axis = ng_input.get_shape().size() - 1; + + // scalar input tensor specifying how many max/min elts should be computed + // CPU backend only supports element type i64 + std::vector ng_k_vec; + TF_RETURN_IF_ERROR(GetStaticInputVector(op, 1, static_input_map, &ng_k_vec)); + auto ng_k = ConstructNgNode(op->name(), ng::element::i64, + ng::Shape{}, ng_k_vec[0]); + + std::string mode = "max"; + + std::string sort = "value"; + bool sorted = true; + TF_RETURN_IF_ERROR(GetNodeAttr(op->attrs(), "sorted", &sorted)); + if (!sorted) { + sort = "index"; + } + + auto ng_result = + std::make_shared(ng_input, ng_k, k_axis, mode, sort); + + ng::Output ng_values = ng_result->output(0); + Builder::SetTracingInfo(op->name(), ng_values); + ng::Output ng_indices = ng_result->output(1); + Builder::SetTracingInfo(op->name(), ng_indices); + + SaveNgOp(ng_op_map, op->name(), ng_values); + SaveNgOp(ng_op_map, op->name(), ng_indices); + + return Status::OK(); +} + +static Status TranslateTransposeOp( + const NodeWrapper* op, const std::vector& static_input_map, + Builder::OpMap& ng_op_map) { + ng::Output ng_input, ng_permutation; + TF_RETURN_IF_ERROR(GetInputNodes(ng_op_map, op, ng_input, ng_permutation)); + SaveNgOp(ng_op_map, op->name(), ConstructNgNode( + op->name(), ng_input, ng_permutation)); + return Status::OK(); +} + +static Status TranslateUnpackOp(const NodeWrapper* op, + const std::vector&, + Builder::OpMap& ng_op_map) { + TF_RETURN_IF_ERROR(ValidateInputCount(op, 1)); + + ng::Output ng_input; + TF_RETURN_IF_ERROR(GetInputNode(ng_op_map, op, 0, ng_input)); + int32_t tf_axis; + TF_RETURN_IF_ERROR(GetNodeAttr(op->attrs(), "axis", &tf_axis)); + int32_t num_outputs; + TF_RETURN_IF_ERROR(GetNodeAttr(op->attrs(), "num", &num_outputs)); + + auto input_shape = ng_input.get_shape(); + auto rank = input_shape.size(); + for (int i = 0; i < num_outputs; ++i) { + std::vector begin(rank, 0); + std::vector end(rank, 0); + begin[tf_axis] = i; + end[tf_axis] = i + 1; + auto ng_begin = ConstructNgNode( + op->name(), ng::element::i64, ng::Shape{begin.size()}, begin); + auto ng_end = ConstructNgNode(op->name(), ng::element::i64, + ng::Shape{end.size()}, end); + std::vector begin_mask(rank, 1); + begin_mask[tf_axis] = 0; + std::vector end_mask(rank, 1); + end_mask[tf_axis] = 0; + std::vector new_axis_mask(rank, 0); + std::vector shrink_axis_mask(rank, 0); + shrink_axis_mask[tf_axis] = 1; + auto slice = ConstructNgNode( + op->name(), ng_input, ng_begin, ng_end, begin_mask, end_mask, + new_axis_mask, shrink_axis_mask); + SaveNgOp(ng_op_map, op->name(), slice); + } + return Status::OK(); +} + +static Status TranslateXdivyOp( + const NodeWrapper* op, const std::vector& static_input_map, + Builder::OpMap& ng_op_map) { + ng::Output ng_x, ng_y; + TF_RETURN_IF_ERROR(GetInputNodes(ng_op_map, op, ng_x, ng_y)); + auto zero = + ConstructNgNode(op->name(), ng_x.get_element_type(), + ngraph::Shape{}, std::vector({0})); + auto x_is_zero = ConstructNgNode(op->name(), ng_x, zero); + auto ng_xdivy = ConstructNgNode(op->name(), ng_x, ng_y); + SaveNgOp(ng_op_map, op->name(), ConstructNgNode( + op->name(), x_is_zero, ng_x, ng_xdivy)); + return Status::OK(); +} + +static Status TranslateSelectOp(const NodeWrapper* op, + const std::vector&, + Builder::OpMap& ng_op_map) { + ng::Output ng_input1, ng_input2, ng_input3; + TF_RETURN_IF_ERROR( + GetInputNodes(ng_op_map, op, ng_input1, ng_input2, ng_input3)); + auto ng_select = ConstructNgNode(op->name(), ng_input1, + ng_input2, ng_input3); + SaveNgOp(ng_op_map, op->name(), ng_select); + return Status::OK(); +} + +static Status TranslateWhereOp( + const NodeWrapper* op, const std::vector& static_input_map, + Builder::OpMap& ng_op_map) { + ng::Output ng_cond; + TF_RETURN_IF_ERROR(GetInputNodes(ng_op_map, op, ng_cond)); + auto non_zero = ConstructNgNode(op->name(), ng_cond); + auto transpose_order = ConstructNgNode( + op->name(), ngraph::element::i64, ngraph::Shape{2}, + std::vector({1, 0})); + SaveNgOp(ng_op_map, op->name(), ConstructNgNode( + op->name(), non_zero, transpose_order)); + return Status::OK(); +} + +static Status TranslateZerosLikeOp(const NodeWrapper* op, + const std::vector&, + Builder::OpMap& ng_op_map) { + ng::Output ng_input; + TF_RETURN_IF_ERROR(GetInputNodes(ng_op_map, op, ng_input)); + + ng::Shape input_shape = ng_input.get_shape(); + std::vector const_values(ng::shape_size(input_shape), "0"); + auto ng_result = ConstructNgNode( + op->name(), ng_input.get_element_type(), input_shape, const_values); + SaveNgOp(ng_op_map, op->name(), ng_result); + return Status::OK(); +} + +const static std::map< + const string, + const function&, + Builder::OpMap&)>> + TRANSLATE_OP_MAP{ + {"Abs", TranslateUnaryOp}, + {"Acos", TranslateUnaryOp}, + {"Acosh", TranslateUnaryOp}, + {"Add", TranslateBinaryOp}, + {"AddN", TranslateAddNOp}, + {"AddV2", TranslateBinaryOp}, + {"Any", TranslateDirectReduceOp}, + {"All", TranslateDirectReduceOp}, + {"ArgMax", TranslateArgMaxOp}, + {"ArgMin", TranslateArgMinOp}, + {"Asin", TranslateUnaryOp}, + {"Asinh", TranslateUnaryOp}, + {"Atan", TranslateUnaryOp}, + {"Atanh", TranslateUnaryOp}, + {"AvgPool", TranslateAvgPoolOp}, + {"BiasAdd", TranslateBiasAddOp}, + {"Cast", TranslateCastOp}, + {"Ceil", TranslateUnaryOp}, + {"ConcatV2", TranslateConcatV2Op}, + {"Const", TranslateConstOp}, + {"Conv2D", TranslateConv2DOp}, + {"Conv2DBackpropInput", TranslateConv2DBackpropInputOp}, + {"Conv3D", TranslateConv3DOp}, + {"Cos", TranslateUnaryOp}, + {"Cosh", TranslateUnaryOp}, + {"Cumsum", TranslateCumsumOp}, + {"DepthToSpace", TranslateDepthToSpaceOp}, + {"DepthwiseConv2dNative", TranslateDepthwiseConv2dNativeOp}, + {"Equal", TranslateBinaryOp}, + {"Exp", TranslateUnaryOp}, + {"ExpandDims", TranslateExpandDimsOp}, + {"Fill", TranslateFillOp}, + {"Floor", TranslateUnaryOp}, + {"FloorDiv", TranslateFloorDivOp}, + {"FloorMod", TranslateBinaryOp}, + {"FusedBatchNorm", TranslateFusedBatchNormOp}, + {"FusedBatchNormV2", TranslateFusedBatchNormOp}, + {"FusedBatchNormV3", TranslateFusedBatchNormOp}, + {"Gather", TranslateGatherOp}, + {"GatherV2", TranslateGatherV2Op}, + {"_FusedConv2D", TranslateFusedConv2DOp}, + {"_FusedMatMul", TranslateFusedMatMulOp}, + {"Greater", TranslateBinaryOp}, + {"GreaterEqual", TranslateBinaryOp}, + {"Identity", TranslateIdentityOp}, + {"IsFinite", TranslateIsFiniteOp}, + {"L2Loss", TranslateL2LossOp}, + {"LogSoftmax", TranslateLogSoftmaxOp}, + {"Less", TranslateBinaryOp}, + {"LessEqual", TranslateBinaryOp}, + {"Log", TranslateUnaryOp}, + {"Log1p", TranslateLog1pOp}, + {"LogicalAnd", TranslateBinaryOp}, + {"LogicalNot", TranslateUnaryOp}, + {"LogicalOr", TranslateBinaryOp}, + {"LRN", TranslateLRNOp}, + {"MatMul", TranslateMatMulOp}, + {"Max", TranslateDirectReduceOp}, + {"Maximum", TranslateBinaryOp}, + {"MaxPool", TranslateMaxPoolOp<2>}, + {"MaxPool3D", TranslateMaxPoolOp<3>}, + {"NonMaxSuppressionV2", TranslateNonMaxSuppressionV2Op}, + {"Mean", TranslateDirectReduceOp}, + {"Min", TranslateDirectReduceOp}, + {"Minimum", TranslateBinaryOp}, + {"MirrorPad", TranslatePadOp}, + {"Mul", TranslateBinaryOp}, + {"Mod", TranslateBinaryOp}, + {"Neg", TranslateUnaryOp}, + {"NotEqual", TranslateBinaryOp}, + // Do nothing! NoOps sometimes get placed on nGraph for bureaucratic + // reasons, but they have no data flow inputs or outputs. + {"NoOp", [](const NodeWrapper*, const std::vector&, + Builder::OpMap&) { return Status::OK(); }}, + {"OneHot", TranslateOneHotOp}, + {"Pack", TranslatePackOp}, + {"Pad", TranslatePadOp}, + {"PadV2", TranslatePadOp}, + {"Pow", TranslateBinaryOp}, + // PreventGradient is just Identity in dataflow terms, so reuse that. + {"PreventGradient", TranslateIdentityOp}, + {"Prod", TranslateDirectReduceOp}, + {"Range", TranslateRangeOp}, + {"Rank", TranslateRankOp}, + {"RealDiv", TranslateBinaryOp}, + {"Reciprocal", TranslateReciprocalOp}, + {"Relu", TranslateUnaryOp}, + {"Relu6", TranslateRelu6Op}, + {"Reshape", TranslateReshapeOp}, + {"Rsqrt", TranslateRsqrtOp}, + {"Select", TranslateSelectOp}, + {"SelectV2", TranslateSelectOp}, + {"Shape", TranslateShapeOp}, + {"Sigmoid", TranslateUnaryOp}, + {"Sin", TranslateUnaryOp}, + {"Sinh", TranslateUnaryOp}, + {"Size", TranslateSizeOp}, + {"Sign", TranslateUnaryOp}, + {"Slice", TranslateSliceOp}, + {"Snapshot", TranslateIdentityOp}, + {"Softmax", TranslateSoftmaxOp}, + {"Softplus", TranslateUnaryOp}, + {"SpaceToDepth", TranslateSpaceToDepthOp}, + {"Split", TranslateSplitOp}, + {"SplitV", TranslateSplitVOp}, + {"Sqrt", TranslateUnaryOp}, + {"Square", TranslateSquareOp}, + {"SquaredDifference", TranslateBinaryOp}, + {"Squeeze", TranslateSqueezeOp}, + {"StridedSlice", TranslateStridedSliceOp}, + {"Sub", TranslateBinaryOp}, + {"Sum", TranslateDirectReduceOp}, + {"Tan", TranslateUnaryOp}, + {"Tanh", TranslateUnaryOp}, + {"Tile", TranslateTileOp}, + {"TopKV2", TranslateTopKV2Op}, + {"Transpose", TranslateTransposeOp}, + {"Unpack", TranslateUnpackOp}, + {"Where", TranslateWhereOp}, + {"Xdivy", TranslateXdivyOp}, + {"ZerosLike", TranslateZerosLikeOp}}; + +Status Builder::TranslateGraph( + const std::vector& inputs, + const std::vector& static_input_map, const GraphDef* input_graph, + const std::string name, std::shared_ptr& ng_function) { + // + // We will visit ops in topological order. + // + // ought to be `const NodeWrapper*`, but GetReversePostOrder doesn't use `const` + + vector ordered; + throw "Not impelemnted GetReversePostOrder"; + //GetReversePostOrder(*input_graph, &ordered, NodeComparatorName()); + + // + // Split ops into params, retvals, and all others. + // + vector tf_params; + vector tf_ret_vals; + vector tf_ops; + + for (const auto n : ordered) { + if (n->IsSink() || n->IsSource()) { + continue; + } + + if (n->IsControlFlow()) { + return errors::Unimplemented( + "Encountered a control flow op in the nGraph bridge: " + + n->DebugString()); + } + + if (n->IsArg()) { + tf_params.push_back(n); + } else if (n->IsRetval()) { + tf_ret_vals.push_back(n); + } else { + tf_ops.push_back(n); + } + } + + // + // The op map holds a mapping from TensorFlow op names (strings) to + // vector of generated nGraph Output. + // + Builder::OpMap ng_op_map; + + // + // Populate the parameter list, and also put parameters into the op map. + // + ng::ParameterVector ng_parameter_list(tf_params.size()); + + for (auto parm : tf_params) { + DataType dtype; + if (GetNodeAttr(parm->attrs(), "T", &dtype) != Status::OK()) { + return errors::InvalidArgument("No data type defined for _Arg"); + } + int index; + if (GetNodeAttr(parm->attrs(), "index", &index) != Status::OK()) { + return errors::InvalidArgument("No index defined for _Arg"); + } + + ng::element::Type ng_et; + TF_RETURN_IF_ERROR(TFDataTypeToNGraphElementType(dtype, &ng_et)); + + ng::PartialShape ng_shape = inputs[index]; +#if 0 + TF_RETURN_IF_ERROR( + TFTensorShapeToNGraphShape(inputs[index], &ng_shape)); +#endif + + string prov_tag; + GetNodeAttr(parm->attrs(), "_prov_tag", &prov_tag); + auto ng_param = + ConstructNgNode(prov_tag, ng_et, ng_shape); + SaveNgOp(ng_op_map, parm->name(), ng_param); + ng_parameter_list[index] = + ngraph::as_type_ptr(ng_param.get_node_shared_ptr()); + } + + // + // Now create the nGraph ops from TensorFlow ops. + // + for (auto op : tf_ops) { + NGRAPH_VLOG(2) << "Constructing op " << op->name() << " which is " + << op->type_string(); + + const function&, + Builder::OpMap&)>* op_fun; + + try { + op_fun = &(TRANSLATE_OP_MAP.at(op->type_string())); + } catch (const std::out_of_range&) { + // ----------------------------- + // Catch-all for unsupported ops + // ----------------------------- + NGRAPH_VLOG(3) << "No translation handler registered for op: " + << op->name() << " (" << op->type_string() << ")"; + NGRAPH_VLOG(3) << op->DebugString(); + return errors::InvalidArgument( + "No translation handler registered for op: " + op->name() + " (" + + op->type_string() + ")\n" + op->DebugString()); + } + + try { + TF_RETURN_IF_ERROR((*op_fun)(op, static_input_map, ng_op_map)); + } catch (const std::exception& e) { + return errors::Internal("Unhandled exception in op handler: " + op->name() + + " (" + op->type_string() + ")\n" + + op->DebugString() + "\n" + "what(): " + + e.what()); + } + } + + // + // Populate the result list. + // + ng::ResultVector ng_result_list(tf_ret_vals.size()); + + for (auto n : tf_ret_vals) { + // Make sure that this _Retval only has one input node. + if (n->num_inputs() != 1) { + return errors::InvalidArgument("_Retval has " + to_string(n->num_inputs()) + + " inputs, should have 1"); + } + + int index; + if (GetNodeAttr(n->attrs(), "index", &index) != Status::OK()) { + return errors::InvalidArgument("No index defined for _Retval"); + } + + ng::Output result; + TF_RETURN_IF_ERROR(GetInputNode(ng_op_map, n, 0, result)); + auto ng_result = ConstructNgNode(n->name(), result); + ng_result_list[index] = + ngraph::as_type_ptr(ng_result.get_node_shared_ptr()); + } + + // + // Create the nGraph function. + // + ng_function = + make_shared(ng_result_list, ng_parameter_list, name); + + // + // Apply additional passes on the nGraph function here. + // + { +#if 0 + ngraph::pass::Manager passes; + if (util::GetEnv("NGRAPH_TF_CONSTANT_FOLDING") == "1") { + passes.register_pass(); + } + if (util::GetEnv("NGRAPH_TF_TRANSPOSE_SINKING") != "0") { + passes.register_pass(); + } + passes.run_passes(ng_function); +#endif + } + NGRAPH_VLOG(5) << "Done with passes"; + // + // Request row-major layout on results. + // + for (auto result : ng_function->get_results()) { + result->set_needs_default_layout(true); + } + NGRAPH_VLOG(5) << "Done with translations"; + return Status::OK(); +} + +} // namespace ngraph_bridge +} // namespace tensorflow diff --git a/ngraph/frontend/tensorflow/src/ngraph_builder.h b/ngraph/frontend/tensorflow/src/ngraph_builder.h new file mode 100644 index 00000000000000..7ae9602fb96b62 --- /dev/null +++ b/ngraph/frontend/tensorflow/src/ngraph_builder.h @@ -0,0 +1,198 @@ +/******************************************************************************* + * Copyright 2017-2020 Intel Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *******************************************************************************/ +#ifndef NGRAPH_TF_BRIDGE_BUILDER_H_ +#define NGRAPH_TF_BRIDGE_BUILDER_H_ + +#include +#include +#include +#include +#include + +#include "graph.pb.h" + +#include "ngraph/ngraph.hpp" + +namespace tensorflow { + +// Stub for TF class +class Status +{ +public: + int status = 0; + std::string message; + + static Status OK () { return Status(); } + + Status (const std::string& x) : message(x), status(1) {} + Status () {} +}; + +inline bool operator!= (const Status& x, const Status& y) +{ + return x.status != y.status; +} + +#define TF_RETURN_IF_ERROR(S) if((S).status != 0)return S; + +// Stub for tf error system +class errors +{ +public: + + static Status InvalidArgument (const std::string& x) + { + return Status("InvalidArgument: " + x); + } + + static Status Internal (const std::string& x) + { + return Status("Internal: " + x); + } + + static Status Unimplemented (const std::string& x) + { + return Status("Unimplemented: " + x); + } +}; + + +namespace ngraph_bridge { + + class TensorWrapper; + +// ABI-free wrapper for TF node +class NodeWrapper +{ +public: + + // a hack to minimize amount of code + NodeWrapper& attrs () const { return const_cast(*this); } + virtual void getAttrValue (const char* name, std::vector* x) = 0; + virtual void getAttrValue (const char* name, std::vector* x) = 0; + virtual void getAttrValue (const char* name, int32_t* x) = 0; + virtual void getAttrValue (const char* name, DataType* x) = 0; + virtual void getAttrValue (const char* name, std::string* x) = 0; + virtual void getAttrValue (const char* name, bool* x) = 0; + virtual void getAttrValue (const char* name, long int* x) = 0; + virtual void getAttrValue (const char* name, float* x) = 0; + virtual void getAttrValue (const char* name, std::vector* x) = 0; + + // a way to read Const value as a tensor + virtual void getAttrValue (const char* name, TensorWrapper** x) = 0; + + virtual unsigned int num_inputs () const = 0; + virtual std::string name () const = 0; + virtual bool IsArg () const = 0; + virtual std::string type_string () const = 0; + + virtual Status input_node (size_t index, NodeWrapper**) const = 0; + virtual DataType input_type (size_t index) const = 0; + virtual DataType output_type (size_t index) const = 0; + + virtual bool IsSink () const = 0; + virtual bool IsSource () const = 0; + virtual bool IsControlFlow () const = 0; + virtual std::string DebugString () const = 0; + virtual bool IsRetval () const = 0; +}; + +class TensorWrapper +{ +public: + + // a hack to minimize amount of code + TensorWrapper &attrs() const { return const_cast(*this); } + + //virtual void getAttrValue(const char *name, std::vector &x) = 0; + + template + std::vector flat () const; + + size_t NumElements () const; + + DataType dtype () const; +}; + +template +Status GetNodeAttr (NodeWrapper& attrs, const char* attr_name, T* result) +{ + attrs.getAttrValue(attr_name, result); + return Status::OK(); +} + +#define NGRAPH_VLOG(I) std::cerr + + + class Builder { + public: + static Status TranslateGraph( + const std::vector& inputs, + const std::vector& static_input_map, const GraphDef* tf_graph, + const std::string name, std::shared_ptr& ng_function); + + using OpMap = std::unordered_map>>; + using ConstMap = std::map< + DataType, + std::pair&)>, + const ngraph::element::Type>>; + static const Builder::ConstMap& TF_NGRAPH_CONST_MAP(); + + template + static void MakePadding(const std::string& tf_padding_type, + const ngraph::Shape& ng_image_shape, + const ngraph::Shape& ng_kernel_shape, + const ngraph::Strides& ng_strides, + const ngraph::Shape& ng_dilations, + T& ng_padding_below, T& ng_padding_above) { + if (tf_padding_type == "SAME") { + ngraph::Shape img_shape = {0, 0}; + img_shape.insert(img_shape.end(), ng_image_shape.begin(), + ng_image_shape.end()); + ngraph::infer_auto_padding(img_shape, ng_kernel_shape, ng_strides, + ng_dilations, ngraph::op::PadType::SAME_UPPER, + ng_padding_above, ng_padding_below); + } else if (tf_padding_type == "VALID") { + ng_padding_below.assign(ng_image_shape.size(), 0); + ng_padding_above.assign(ng_image_shape.size(), 0); + } + } + + // This function is used to trace which ng node came from which tf node + // It does 3 things: + // 1. Attaches provenance tags. This is guaranteed to propagate the tag info + // to all nodes. + // The next 2 are not guaranteed to be present for all nodes. + // But when present they are correct and agree with provenance tags + // 2. Attaches friendly names. + // 3. Prints a log if NGRAPH_TF_LOG_PLACEMENT=1 + static void SetTracingInfo(const std::string& op_name, + const ngraph::Output ng_node); +}; + +inline std::string StrJoin (const std::vector& strs, const char* sep) +{ + std::ostringstream str; + std::copy(strs.begin(), strs.end(), std::ostream_iterator(str, sep)); + return str.str(); +} + +} // namespace ngraph_bridge +} // namespace tensorflow + +#endif diff --git a/ngraph/frontend/tensorflow/src/ngraph_conversions.cpp b/ngraph/frontend/tensorflow/src/ngraph_conversions.cpp new file mode 100644 index 00000000000000..c2bd8452c5c7e7 --- /dev/null +++ b/ngraph/frontend/tensorflow/src/ngraph_conversions.cpp @@ -0,0 +1,106 @@ +/******************************************************************************* + * Copyright 2017-2020 Intel Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *******************************************************************************/ + +#include "ngraph_conversions.h" + +namespace tensorflow { +namespace ngraph_bridge { + +void NHWCtoNCHW(const std::string& op_name, bool is_nhwc, + ngraph::Output& node) { + if (is_nhwc) { + auto rank = node.get_shape().size(); + if (rank == 4) { + Transpose<0, 3, 1, 2>(node); + } else if (rank == 5) { + Transpose3D<0, 4, 1, 2, 3>(node); + } + Builder::SetTracingInfo(op_name, node); + } +} + +void NCHWtoNHWC(const std::string& op_name, bool is_nhwc, + ngraph::Output& node) { + if (is_nhwc) { + auto rank = node.get_shape().size(); + if (rank == 4) { + Transpose<0, 2, 3, 1>(node); + } else if (rank == 5) { + Transpose3D<0, 2, 3, 4, 1>(node); + } + Builder::SetTracingInfo(op_name, node); + } +} + + + Status TFDataTypeToNGraphElementType(DataType tf_dt, + ngraph::element::Type* ng_et) { + switch (tf_dt) { + case DataType::DT_FLOAT: + *ng_et = ngraph::element::f32; + break; + case DataType::DT_DOUBLE: + *ng_et = ngraph::element::f64; + break; + case DataType::DT_INT32: + *ng_et = ngraph::element::i32; + break; + case DataType::DT_UINT8: + *ng_et = ngraph::element::u8; + break; + case DataType::DT_INT8: + *ng_et = ngraph::element::i8; + break; + case DataType::DT_UINT16: + *ng_et = ngraph::element::u16; + break; + case DataType::DT_INT64: + *ng_et = ngraph::element::i64; + break; + case DataType::DT_UINT32: + *ng_et = ngraph::element::u32; + break; + case DataType::DT_UINT64: + *ng_et = ngraph::element::u64; + break; + case DataType::DT_BOOL: + *ng_et = ngraph::element::boolean; + break; + case DataType::DT_QINT8: + *ng_et = ngraph::element::i8; + break; + case DataType::DT_QUINT8: + *ng_et = ngraph::element::u8; + break; + case DataType::DT_QINT32: + *ng_et = ngraph::element::i32; + break; + case DataType::DT_BFLOAT16: + *ng_et = ngraph::element::bf16; + break; + case DataType::DT_HALF: + *ng_et = ngraph::element::f16; + break; + default: + return errors::Unimplemented("Unsupported TensorFlow data type: " + + DataType_Name(tf_dt)); + } + return Status::OK(); + } + + +} // namespace ngraph_bridge +} // namespace tensorflow diff --git a/ngraph/frontend/tensorflow/src/ngraph_conversions.h b/ngraph/frontend/tensorflow/src/ngraph_conversions.h new file mode 100644 index 00000000000000..d04776fed091d1 --- /dev/null +++ b/ngraph/frontend/tensorflow/src/ngraph_conversions.h @@ -0,0 +1,126 @@ +/******************************************************************************* + * Copyright 2017-2020 Intel Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *******************************************************************************/ + +#ifndef NGRAPH_TF_BRIDGE_CONVERSIONS_H_ +#define NGRAPH_TF_BRIDGE_CONVERSIONS_H_ +#pragma once + +#include + +//#include "logging/ngraph_log.h" +#include "default_opset.h" +#include "ngraph_builder.h" + +namespace tensorflow { +namespace ngraph_bridge { + + // Converts a TensorFlow DataType to an nGraph element::Type. Returns +// errors::Unimplemented if the element type is not supported by nGraph +// Core. Otherwise returns Status::OK(). + Status TFDataTypeToNGraphElementType(DataType tf_dt, + ngraph::element::Type* ng_et); + +template +void Transpose(ngraph::Output& node) { + static_assert(a < 4 && b < 4 && c < 4 && d < 4, + "Number of dimensions cannot exceed 4"); + static_assert(a != b && a != c && a != d && b != c && b != d && c != d, + "Dimensions indices cannot be equal"); + auto& s = node.get_shape(); + ngraph::Shape reshaped_shape{s[a], s[b], s[c], s[d]}; + ngraph::Shape transpose_order{a, b, c, d}; + NGRAPH_VLOG(3) << "transposing " << ngraph::join(s) << " to " + << ngraph::join(reshaped_shape) << " axis-order " + << ngraph::join(transpose_order); + auto input_order = std::make_shared( + ngraph::element::u64, ngraph::Shape{transpose_order.size()}, + transpose_order); + node = std::make_shared(node, input_order); +} + +template +void Transpose(std::shared_ptr& node) { + Transpose(node->get_default_output()); +} + +template +void Transpose3D(ngraph::Output& node) { + static_assert(a < 5 && b < 5 && c < 5 && d < 5 && e < 5, + "Number of dimensions cannot exceed 5"); + static_assert(a != b && a != c && a != d && a != e && b != c && b != d && + b != e && c != d && c != e && d != e, + "Dimensions indices cannot be equal"); + auto& s = node.get_shape(); + ngraph::Shape reshaped_shape{s[a], s[b], s[c], s[d], s[e]}; + ngraph::Shape transpose_order{a, b, c, d, e}; + NGRAPH_VLOG(3) << "transposing " << ngraph::join(s) << " to " + << ngraph::join(reshaped_shape) << "axis-order " + << ngraph::join(transpose_order); + auto input_order = std::make_shared( + ngraph::element::u64, ngraph::Shape{transpose_order.size()}, + transpose_order); + node = std::make_shared(node, input_order); +} + +template +void Transpose3D(std::shared_ptr& node) { + Transpose3D(node->get_default_output()); +} + +namespace detail { +template +void NHWCtoHW(const std::vector& src, std::vector& dst) { + if (dst.size() >= 2) { + dst[0] = src[1]; + dst[1] = src[2]; + } + if (dst.size() >= 3) { + dst[2] = src[3]; + } +} + +template +void NCHWtoHW(const std::vector& src, std::vector& dst) { + if (dst.size() >= 2) { + dst[0] = src[2]; + dst[1] = src[3]; + } + if (dst.size() >= 3) { + dst[2] = src[4]; + } +} +} + +void NHWCtoNCHW(const std::string& op_name, bool is_nhwc, + ngraph::Output& ng_input); + +void NCHWtoNHWC(const std::string& op_name, bool is_nhwc, + ngraph::Output& ng_node); + +template +void NHWCtoHW(bool is_nhwc, const std::vector& src, + std::vector& dst) { + if (is_nhwc) { + detail::NHWCtoHW(src, dst); + } else { + detail::NCHWtoHW(src, dst); + } +} + +} // namespace ngraph_bridge +} // namespace tensorflow + +#endif // NGRAPH_TF_BRIDGE_CONVERSIONS_H_ From 998dbe7dcff2f18dc4de12cd32fb4ce29840f78c Mon Sep 17 00:00:00 2001 From: "Lyalin, Sergey" Date: Mon, 15 Mar 2021 11:07:23 +0300 Subject: [PATCH 053/116] Moving forward with TF/proto decoder implemenation: placehoder class NodeProtoWrapper was created --- .../frontend/tensorflow/src/default_opset.h | 2 + .../tensorflow/src/ngraph_builder.cpp | 59 +++++++++++++++++-- ngraph/frontend/tensorflow/src/tensorflow.cpp | 6 +- 3 files changed, 61 insertions(+), 6 deletions(-) diff --git a/ngraph/frontend/tensorflow/src/default_opset.h b/ngraph/frontend/tensorflow/src/default_opset.h index ebd00c7cfa8b68..bcd360e2261ef5 100644 --- a/ngraph/frontend/tensorflow/src/default_opset.h +++ b/ngraph/frontend/tensorflow/src/default_opset.h @@ -26,6 +26,8 @@ namespace ngraph_bridge { namespace opset = ngraph::opset5; namespace default_opset = ngraph::opset5; +#define NGRAPH_TF_FE_NOT_IMPLEMENTED { std::cerr << "[ NOT IMPLEMENTED ] source: " << __FILE__ << ":" << __LINE__ << "\n"; throw "NOT IMPLEMENTED"; } + } // namespace ngraph_bridge } // namespace tensorflow diff --git a/ngraph/frontend/tensorflow/src/ngraph_builder.cpp b/ngraph/frontend/tensorflow/src/ngraph_builder.cpp index 6c024c0776222f..1ebc7312796987 100644 --- a/ngraph/frontend/tensorflow/src/ngraph_builder.cpp +++ b/ngraph/frontend/tensorflow/src/ngraph_builder.cpp @@ -193,7 +193,7 @@ static Status GetInputNode(const Builder::OpMap& ng_op_map, const NodeWrapper* o #endif - throw "Not supported!"; + NGRAPH_TF_FE_NOT_IMPLEMENTED } namespace detail { @@ -311,7 +311,7 @@ static Status TensorDataToVector(const TensorWrapper& tensor, std::vector* ve return Status::OK(); #endif - throw "Not implemented!"; + NGRAPH_TF_FE_NOT_IMPLEMENTED } template @@ -489,7 +489,7 @@ static Status ValuesFromConstNode(const NodeWrapper* node, return Status::OK(); #endif - throw "Not implemented"; + NGRAPH_TF_FE_NOT_IMPLEMENTED } // Helper for Builder::TranslateGraph ("Const" op) @@ -2826,6 +2826,55 @@ const static std::map< {"Xdivy", TranslateXdivyOp}, {"ZerosLike", TranslateZerosLikeOp}}; +class NodeProtoWrapper : public NodeWrapper +{ + const NodeDef* node_def; +public: + + NodeProtoWrapper(const NodeDef* _node_def) : node_def(_node_def) {} + + virtual void getAttrValue (const char* name, std::vector* x) override { NGRAPH_TF_FE_NOT_IMPLEMENTED; } + virtual void getAttrValue (const char* name, std::vector* x) override { NGRAPH_TF_FE_NOT_IMPLEMENTED; } + virtual void getAttrValue (const char* name, int32_t* x) override { NGRAPH_TF_FE_NOT_IMPLEMENTED; } + virtual void getAttrValue (const char* name, DataType* x) override { NGRAPH_TF_FE_NOT_IMPLEMENTED; } + virtual void getAttrValue (const char* name, std::string* x) override { NGRAPH_TF_FE_NOT_IMPLEMENTED; } + virtual void getAttrValue (const char* name, bool* x) override { NGRAPH_TF_FE_NOT_IMPLEMENTED; } + virtual void getAttrValue (const char* name, long int* x) override { NGRAPH_TF_FE_NOT_IMPLEMENTED; } + virtual void getAttrValue (const char* name, float* x) override { NGRAPH_TF_FE_NOT_IMPLEMENTED; } + virtual void getAttrValue (const char* name, std::vector* x) override { NGRAPH_TF_FE_NOT_IMPLEMENTED; } + + // a way to read Const value as a tensor + virtual void getAttrValue (const char* name, TensorWrapper** x) override { NGRAPH_TF_FE_NOT_IMPLEMENTED; } + + virtual unsigned int num_inputs () const override { NGRAPH_TF_FE_NOT_IMPLEMENTED; } + virtual std::string name () const override { NGRAPH_TF_FE_NOT_IMPLEMENTED; } + virtual bool IsArg () const override { NGRAPH_TF_FE_NOT_IMPLEMENTED; } + virtual std::string type_string () const override { NGRAPH_TF_FE_NOT_IMPLEMENTED; } + + virtual Status input_node (size_t index, NodeWrapper**) const override { NGRAPH_TF_FE_NOT_IMPLEMENTED; } + virtual DataType input_type (size_t index) const override { NGRAPH_TF_FE_NOT_IMPLEMENTED; } + virtual DataType output_type (size_t index) const override { NGRAPH_TF_FE_NOT_IMPLEMENTED; } + + virtual bool IsSink () const override { NGRAPH_TF_FE_NOT_IMPLEMENTED; } + virtual bool IsSource () const override { NGRAPH_TF_FE_NOT_IMPLEMENTED; } + virtual bool IsControlFlow () const override { NGRAPH_TF_FE_NOT_IMPLEMENTED; } + virtual std::string DebugString () const override { NGRAPH_TF_FE_NOT_IMPLEMENTED; } + virtual bool IsRetval () const override { NGRAPH_TF_FE_NOT_IMPLEMENTED; } + +}; + +void PopulateNodesTopologicallySorted (const GraphDef* input_graph, std::vector* result) +{ + // WARNING! We suppose that input_graph contains nodes in topologically sorted order + // TODO: sort it if it is not the case + + result->reserve(input_graph->node_size()); + for(int i = 0; i < input_graph->node_size(); ++i) + { + result->push_back(new NodeProtoWrapper(&input_graph->node(i))); + } +} + Status Builder::TranslateGraph( const std::vector& inputs, const std::vector& static_input_map, const GraphDef* input_graph, @@ -2835,9 +2884,9 @@ Status Builder::TranslateGraph( // // ought to be `const NodeWrapper*`, but GetReversePostOrder doesn't use `const` - vector ordered; - throw "Not impelemnted GetReversePostOrder"; + std::vector ordered; //GetReversePostOrder(*input_graph, &ordered, NodeComparatorName()); + PopulateNodesTopologicallySorted(input_graph, &ordered); // // Split ops into params, retvals, and all others. diff --git a/ngraph/frontend/tensorflow/src/tensorflow.cpp b/ngraph/frontend/tensorflow/src/tensorflow.cpp index b8498bca70cb0a..4e26d094da1910 100644 --- a/ngraph/frontend/tensorflow/src/tensorflow.cpp +++ b/ngraph/frontend/tensorflow/src/tensorflow.cpp @@ -20,6 +20,8 @@ #include "../include/tensorflow_frontend/tensorflow.hpp" +#include "ngraph_builder.h" + using namespace google; std::shared_ptr ngraph::frontend::FrontEndTensorflow::convert (InputModel::Ptr model) const @@ -30,7 +32,9 @@ std::shared_ptr ngraph::frontend::FrontEndTensorflow::convert std::ifstream pb_stream(path, std::ios::binary); std::cout << "[ INFO ] Model Parsed: " << fw_model.ParseFromIstream(&pb_stream) << std::endl; std::cout << "[ INFO ] Loaded model contains " << fw_model.node_size() << " nodes." << std::endl; - auto f = std::make_shared(ngraph::NodeVector{}, ngraph::ParameterVector{}); + std::shared_ptr f; + tensorflow::ngraph_bridge::Builder::TranslateGraph({}, {}, &fw_model, "here_should_be_a_graph_name", f); + //auto f = std::make_shared(ngraph::NodeVector{}, ngraph::ParameterVector{}); std::cerr << "[ ERROR ] Convetion functionality is not implemented; an empty function will be returned."; std::cerr << "[ INFO ] Resulting nGraph function contains " << f->get_ops().size() << " nodes." << std::endl; return f; From c22f50533b19a41d2c07da4b327825461ff02ff3 Mon Sep 17 00:00:00 2001 From: "Lyalin, Sergey" Date: Mon, 15 Mar 2021 11:55:03 +0300 Subject: [PATCH 054/116] Generate pdpd proto src/hdr files automatically in cmake --- ngraph/frontend/generic/CMakeLists.txt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ngraph/frontend/generic/CMakeLists.txt b/ngraph/frontend/generic/CMakeLists.txt index a714626469b4c4..e7dc34b13ddb30 100644 --- a/ngraph/frontend/generic/CMakeLists.txt +++ b/ngraph/frontend/generic/CMakeLists.txt @@ -19,6 +19,11 @@ file(GLOB_RECURSE LIBRARY_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/src/*.hpp ${CMAKE_ file(GLOB_RECURSE LIBRARY_PUBLIC_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/include/*.hpp) find_package(Protobuf REQUIRED IMPORTED) + +set(PROTOBUF_GENERATE_CPP_APPEND_PATH ON) +file(GLOB proto_files ${CMAKE_CURRENT_SOURCE_DIR}/src/pdpd/*.proto) +protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS ${proto_files}) + include_directories(${Protobuf_INCLUDE_DIRS}) set(FRONTEND_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include) @@ -31,10 +36,10 @@ source_group("include" FILES ${LIBRARY_HEADERS}) source_group("public include" FILES ${LIBRARY_PUBLIC_HEADERS}) # Create shared library -add_library(frontend_manager SHARED ${LIBRARY_SRC} ${LIBRARY_HEADERS} ${LIBRARY_PUBLIC_HEADERS}) +add_library(frontend_manager SHARED ${LIBRARY_SRC} ${LIBRARY_HEADERS} ${LIBRARY_PUBLIC_HEADERS} ${PROTO_SRCS} ${PROTO_HDRS}) add_library(ngraph::frontend_manager ALIAS frontend_manager) -target_include_directories(frontend_manager PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../tensorflow/include) +target_include_directories(frontend_manager PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../tensorflow/include ${CMAKE_CURRENT_BINARY_DIR}) MESSAGE("HERE4: " ${CMAKE_CURRENT_SOURCE_DIR}) if(COMMAND ie_add_vs_version_file) From 7796bab04ef97e7924a7b392abf21741c47c3e41 Mon Sep 17 00:00:00 2001 From: "Lyalin, Sergey" Date: Thu, 18 Mar 2021 19:35:01 +0300 Subject: [PATCH 055/116] Rename NodeWrapper to TFNodeDecoder --- .../tensorflow/src/ngraph_builder.cpp | 190 +++++++++--------- .../frontend/tensorflow/src/ngraph_builder.h | 10 +- 2 files changed, 100 insertions(+), 100 deletions(-) diff --git a/ngraph/frontend/tensorflow/src/ngraph_builder.cpp b/ngraph/frontend/tensorflow/src/ngraph_builder.cpp index 1ebc7312796987..47624fd9ac33a5 100644 --- a/ngraph/frontend/tensorflow/src/ngraph_builder.cpp +++ b/ngraph/frontend/tensorflow/src/ngraph_builder.cpp @@ -46,7 +46,7 @@ static bool VecStrCmp(const std::vector& a, return a == b; } -static Status ValidateInputCount(const NodeWrapper* op, int32_t count) { +static Status ValidateInputCount(const TFNodeDecoder* op, int32_t count) { if (op->num_inputs() != count) { std::ostringstream buf; buf << "\"" << op->name() << "\" requires " << count << @@ -57,7 +57,7 @@ static Status ValidateInputCount(const NodeWrapper* op, int32_t count) { return Status::OK(); } -static Status ValidateInputCountMin(const NodeWrapper* op, int32_t count) { +static Status ValidateInputCountMin(const TFNodeDecoder* op, int32_t count) { if (op->num_inputs() < count) { std::ostringstream buf; buf << "\"" << op->name() << "\" requires at least " << @@ -131,7 +131,7 @@ ng::Output ConstructNgNode(const std::string& op_name, // // Reduces some boilerplate code (incorrect from now) like this: // -// NodeWrapper* tf_input; +// TFNodeDecoder* tf_input; // TF_RETURN_IF_ERROR(op->input_node(0, &tf_input)); // // ng::Output ng_input; @@ -151,7 +151,7 @@ ng::Output ConstructNgNode(const std::string& op_name, // // Parameters: // Builder::OpMap& ng_op_map - The TF-to-nGraph op map. -// NodeWrapper* op - TF op being translated. +// TFNodeDecoder* op - TF op being translated. // input_idx - index of input // // ng::Output *result - ng::Node pointer where result @@ -159,7 +159,7 @@ ng::Output ConstructNgNode(const std::string& op_name, // // -static Status GetInputNode(const Builder::OpMap& ng_op_map, const NodeWrapper* op, +static Status GetInputNode(const Builder::OpMap& ng_op_map, const TFNodeDecoder* op, size_t input_idx, ng::Output& result) { // Stub #if 0 @@ -174,7 +174,7 @@ static Status GetInputNode(const Builder::OpMap& ng_op_map, const NodeWrapper* o return Status(error::NOT_FOUND, "Edge not found"); } - NodeWrapper* tf_input; + TFNodeDecoder* tf_input; TF_RETURN_IF_ERROR(op->input_node(input_idx, &tf_input)); std::vector> ng_op; try { @@ -197,12 +197,12 @@ static Status GetInputNode(const Builder::OpMap& ng_op_map, const NodeWrapper* o } namespace detail { -static Status GetInputNodes(const Builder::OpMap&, const NodeWrapper*, size_t) { +static Status GetInputNodes(const Builder::OpMap&, const TFNodeDecoder*, size_t) { return Status::OK(); } template -static Status GetInputNodes(const Builder::OpMap& ng_op_map, const NodeWrapper* op, +static Status GetInputNodes(const Builder::OpMap& ng_op_map, const TFNodeDecoder* op, size_t index, ng::Output& result, Arguments&... remaining) { TF_RETURN_IF_ERROR(GetInputNode(ng_op_map, op, index, result)); @@ -211,7 +211,7 @@ static Status GetInputNodes(const Builder::OpMap& ng_op_map, const NodeWrapper* } // namespace detail template -static Status GetInputNodes(const Builder::OpMap& ng_op_map, const NodeWrapper* op, +static Status GetInputNodes(const Builder::OpMap& ng_op_map, const TFNodeDecoder* op, Arguments&... remaining) { constexpr size_t args_len = sizeof...(Arguments); TF_RETURN_IF_ERROR(ValidateInputCount(op, args_len)); @@ -219,7 +219,7 @@ static Status GetInputNodes(const Builder::OpMap& ng_op_map, const NodeWrapper* } static Status GetStaticNodeTensor( - const NodeWrapper* node, const std::vector& static_input_map, + const TFNodeDecoder* node, const std::vector& static_input_map, TensorWrapper* result) { if (node->IsArg()) { int arg_index; @@ -316,10 +316,10 @@ static Status TensorDataToVector(const TensorWrapper& tensor, std::vector* ve template static Status GetStaticInputVector( - const NodeWrapper* op, int64_t input_index, + const TFNodeDecoder* op, int64_t input_index, const std::vector& static_input_map, std::vector* vector) { - NodeWrapper* input_node; + TFNodeDecoder* input_node; TF_RETURN_IF_ERROR(op->input_node(input_index, &input_node)); TensorWrapper input_tensor; TF_RETURN_IF_ERROR( @@ -329,7 +329,7 @@ static Status GetStaticInputVector( } static Status GetStaticInputNode( - const NodeWrapper* op, int64_t input_index, + const TFNodeDecoder* op, int64_t input_index, const std::vector& static_input_map, DataType dt, ng::Output& node_) { ng::element::Type type; @@ -379,12 +379,12 @@ static Status GetStaticInputNode( // should be (e.g. when T is `bool`, we actually need a vector of `char` for // compatibility with nGraph). template -static Status ValuesFromConstNode(const NodeWrapper* node, +static Status ValuesFromConstNode(const TFNodeDecoder* node, ngraph::Shape* const_tensor_shape, std::vector* values) { #if 0 if (node.op() != "Const") { - return errors::InvalidArgument("NodeWrapper not a Const"); + return errors::InvalidArgument("TFNodeDecoder not a Const"); } if (node.attr().at("dtype").type() != DataTypeToEnum::value) { @@ -494,7 +494,7 @@ static Status ValuesFromConstNode(const NodeWrapper* node, // Helper for Builder::TranslateGraph ("Const" op) template -static Status MakeConstOp(const NodeWrapper* op, ng::element::Type et, +static Status MakeConstOp(const TFNodeDecoder* op, ng::element::Type et, ng::Output& ng_node) { vector const_values; ngraph::Shape ng_shape; @@ -531,7 +531,7 @@ const Builder::ConstMap& Builder::TF_NGRAPH_CONST_MAP() { // // Parameters: // -// NodeWrapper* op - TF op being translated. Must have one input. +// TFNodeDecoder* op - TF op being translated. Must have one input. // const std::vector& static_input_map // - the static input map // Builder::OpMap& ng_op_map - The TF-to-nGraph op map. @@ -551,7 +551,7 @@ const Builder::ConstMap& Builder::TF_NGRAPH_CONST_MAP() { // }); // } static Status TranslateUnaryOp( - const NodeWrapper* op, const std::vector&, + const TFNodeDecoder* op, const std::vector&, Builder::OpMap& ng_op_map, std::function(ng::Output)> create_unary_op) { ng::Output ng_input; @@ -576,7 +576,7 @@ static Status TranslateUnaryOp( // template static Status TranslateUnaryOp( - const NodeWrapper* op, const std::vector& static_input_map, + const TFNodeDecoder* op, const std::vector& static_input_map, Builder::OpMap& ng_op_map) { return TranslateUnaryOp(op, static_input_map, ng_op_map, [&op](ng::Output n) { @@ -587,7 +587,7 @@ static Status TranslateUnaryOp( // Helper function to translate a binary op // Parameters: // -// NodeWrapper* op - TF op being translated. Must have only two +// TFNodeDecoder* op - TF op being translated. Must have only two // inputs. // const std::vector& static_input_map - the static input map // Builder::OpMap& ng_op_map - The TF-to-nGraph op map. @@ -610,7 +610,7 @@ static Status TranslateUnaryOp( // static Status TranslateBinaryOp( - const NodeWrapper* op, const std::vector&, + const TFNodeDecoder* op, const std::vector&, Builder::OpMap& ng_op_map, std::function(ng::Output&, ng::Output&)> @@ -638,7 +638,7 @@ static Status TranslateBinaryOp( // template static Status TranslateBinaryOp( - const NodeWrapper* op, const std::vector& static_input_map, + const TFNodeDecoder* op, const std::vector& static_input_map, Builder::OpMap& ng_op_map) { return TranslateBinaryOp( op, static_input_map, ng_op_map, @@ -647,7 +647,7 @@ static Status TranslateBinaryOp( }); } -static Status TranslateAddNOp(const NodeWrapper* op, const std::vector&, +static Status TranslateAddNOp(const TFNodeDecoder* op, const std::vector&, Builder::OpMap& ng_op_map) { std::vector> ng_arg_vec(op->num_inputs()); @@ -665,7 +665,7 @@ static Status TranslateAddNOp(const NodeWrapper* op, const std::vector& static_input_map, + const TFNodeDecoder* op, const std::vector& static_input_map, Builder::OpMap& ng_op_map, std::string mode) { ng::Output ng_input; TF_RETURN_IF_ERROR(GetInputNode(ng_op_map, op, 0, ng_input)); @@ -714,18 +714,18 @@ static Status TranslateArgMinMax( } static Status TranslateArgMaxOp( - const NodeWrapper* op, const std::vector& static_input_map, + const TFNodeDecoder* op, const std::vector& static_input_map, Builder::OpMap& ng_op_map) { return (TranslateArgMinMax(op, static_input_map, ng_op_map, "max")); } static Status TranslateArgMinOp( - const NodeWrapper* op, const std::vector& static_input_map, + const TFNodeDecoder* op, const std::vector& static_input_map, Builder::OpMap& ng_op_map) { return (TranslateArgMinMax(op, static_input_map, ng_op_map, "min")); } -static Status TranslateAvgPoolOp(const NodeWrapper* op, +static Status TranslateAvgPoolOp(const TFNodeDecoder* op, const std::vector&, Builder::OpMap& ng_op_map) { ng::Output ng_input; @@ -787,7 +787,7 @@ static Status TranslateAvgPoolOp(const NodeWrapper* op, } static Status TranslateBiasAddOp( - const NodeWrapper* op, const std::vector& static_input_map, + const TFNodeDecoder* op, const std::vector& static_input_map, Builder::OpMap& ng_op_map) { ng::Output ng_input, ng_bias; TF_RETURN_IF_ERROR(GetInputNodes(ng_op_map, op, ng_input, ng_bias)); @@ -836,7 +836,7 @@ static Status TranslateBiasAddOp( return Status::OK(); } -static Status TranslateCastOp(const NodeWrapper* op, const std::vector&, +static Status TranslateCastOp(const TFNodeDecoder* op, const std::vector&, Builder::OpMap& ng_op_map) { ng::Output ng_input; TF_RETURN_IF_ERROR(GetInputNodes(ng_op_map, op, ng_input)); @@ -858,7 +858,7 @@ static Status TranslateCastOp(const NodeWrapper* op, const std::vector& static_input_map, + const TFNodeDecoder* op, const std::vector& static_input_map, Builder::OpMap& ng_op_map) { TF_RETURN_IF_ERROR(ValidateInputCountMin(op, 2)); @@ -889,7 +889,7 @@ static Status TranslateConcatV2Op( return Status::OK(); } -static Status TranslateConstOp(const NodeWrapper* op, +static Status TranslateConstOp(const TFNodeDecoder* op, const std::vector&, Builder::OpMap& ng_op_map) { DataType dtype; @@ -919,7 +919,7 @@ static Status TranslateConstOp(const NodeWrapper* op, return Status::OK(); } -static Status TranslateConv2DOp(const NodeWrapper* op, +static Status TranslateConv2DOp(const TFNodeDecoder* op, const std::vector&, Builder::OpMap& ng_op_map) { ng::Output ng_input, ng_filter; @@ -992,7 +992,7 @@ static Status TranslateConv2DOp(const NodeWrapper* op, } static Status TranslateConv2DBackpropInputOp( - const NodeWrapper* op, const std::vector& static_input_map, + const TFNodeDecoder* op, const std::vector& static_input_map, Builder::OpMap& ng_op_map) { ng::Output ng_filter, ng_out_backprop, ng_unused; TF_RETURN_IF_ERROR( @@ -1085,7 +1085,7 @@ static Status TranslateConv2DBackpropInputOp( } // Translate Conv3D Op -static Status TranslateConv3DOp(const NodeWrapper* op, +static Status TranslateConv3DOp(const TFNodeDecoder* op, const std::vector&, Builder::OpMap& ng_op_map) { ng::Output ng_input, ng_filter; @@ -1159,7 +1159,7 @@ static Status TranslateConv3DOp(const NodeWrapper* op, return Status::OK(); } -static Status TranslateCumsumOp(const NodeWrapper* op, +static Status TranslateCumsumOp(const TFNodeDecoder* op, const std::vector&, Builder::OpMap& ng_op_map) { ng::Output ng_x, ng_axis; @@ -1175,7 +1175,7 @@ static Status TranslateCumsumOp(const NodeWrapper* op, } // Translate DepthToSpace op -static Status TranslateDepthToSpaceOp(const NodeWrapper* op, +static Status TranslateDepthToSpaceOp(const TFNodeDecoder* op, const std::vector&, Builder::OpMap& ng_op_map) { ng::Output ng_input; @@ -1204,7 +1204,7 @@ static Status TranslateDepthToSpaceOp(const NodeWrapper* op, } static Status TranslateDepthwiseConv2dNativeOp( - const NodeWrapper* op, const std::vector&, + const TFNodeDecoder* op, const std::vector&, Builder::OpMap& ng_op_map) { ng::Output ng_input, ng_filter; TF_RETURN_IF_ERROR(GetInputNodes(ng_op_map, op, ng_input, ng_filter)); @@ -1280,7 +1280,7 @@ static Status TranslateDepthwiseConv2dNativeOp( } static Status TranslateExpandDimsOp( - const NodeWrapper* op, const std::vector& static_input_map, + const TFNodeDecoder* op, const std::vector& static_input_map, Builder::OpMap& ng_op_map) { ng::Output ng_input; TF_RETURN_IF_ERROR(GetInputNode(ng_op_map, op, 0, ng_input)); @@ -1294,7 +1294,7 @@ static Status TranslateExpandDimsOp( } static Status TranslateFillOp( - const NodeWrapper* op, const std::vector& static_input_map, + const TFNodeDecoder* op, const std::vector& static_input_map, Builder::OpMap& ng_op_map) { ng::Output ng_value, ng_dims; TF_RETURN_IF_ERROR(GetInputNodes(ng_op_map, op, ng_dims, ng_value)); @@ -1304,7 +1304,7 @@ static Status TranslateFillOp( } static Status TranslateFloorDivOp( - const NodeWrapper* op, const std::vector& static_input_map, + const TFNodeDecoder* op, const std::vector& static_input_map, Builder::OpMap& ng_op_map) { auto floordiv_fn = [&op](ng::Output x, ng::Output y) { return ConstructNgNode( @@ -1314,7 +1314,7 @@ static Status TranslateFloorDivOp( } static Status TranslateFusedBatchNormOp( - const NodeWrapper* op, const std::vector& static_input_map, + const TFNodeDecoder* op, const std::vector& static_input_map, Builder::OpMap& ng_op_map) { ng::Output ng_input, ng_scale, ng_offset, ng_mean, ng_variance; bool is_v3 = op->type_string() == "FusedBatchNormV3"; @@ -1361,7 +1361,7 @@ static Status TranslateFusedBatchNormOp( return Status::OK(); } -static Status TranslateFusedMatMulOp(const NodeWrapper* op, +static Status TranslateFusedMatMulOp(const TFNodeDecoder* op, const std::vector&, Builder::OpMap& ng_op_map) { int num_args; @@ -1415,7 +1415,7 @@ static Status TranslateFusedMatMulOp(const NodeWrapper* op, // See .../tensorflow/include/tensorflow/cc/ops/array_ops.h // and .../openvino/ngraph/core/include/ngraph/op/gather.hpp static Status TranslateGatherOp( - const NodeWrapper* op, const std::vector& static_input_map, + const TFNodeDecoder* op, const std::vector& static_input_map, Builder::OpMap& ng_op_map) { ng::Output ng_input, ng_input_indices; TF_RETURN_IF_ERROR(GetInputNodes(ng_op_map, op, ng_input, ng_input_indices)); @@ -1431,7 +1431,7 @@ static Status TranslateGatherOp( } static Status TranslateGatherV2Op( - const NodeWrapper* op, const std::vector& static_input_map, + const TFNodeDecoder* op, const std::vector& static_input_map, Builder::OpMap& ng_op_map) { ng::Output ng_input, ng_input_coords, ng_unused; TF_RETURN_IF_ERROR( @@ -1475,7 +1475,7 @@ static Status TranslateGatherV2Op( return Status::OK(); } -static Status TranslateFusedConv2DOp(const NodeWrapper* op, +static Status TranslateFusedConv2DOp(const TFNodeDecoder* op, const std::vector&, Builder::OpMap& ng_op_map) { int num_args; @@ -1640,7 +1640,7 @@ static Status TranslateFusedConv2DOp(const NodeWrapper* op, return Status::OK(); } -static Status TranslateIdentityOp(const NodeWrapper* op, +static Status TranslateIdentityOp(const TFNodeDecoder* op, const std::vector&, Builder::OpMap& ng_op_map) { ng::Output ng_arg; @@ -1650,7 +1650,7 @@ static Status TranslateIdentityOp(const NodeWrapper* op, } static Status TranslateIsFiniteOp( - const NodeWrapper* op, const std::vector& static_input_map, + const TFNodeDecoder* op, const std::vector& static_input_map, Builder::OpMap& ng_op_map) { // Implemented tf.is_finite by checking: // (in != inf) && (in != -inf) && (in == in) @@ -1681,7 +1681,7 @@ static Status TranslateIsFiniteOp( return Status::OK(); } -static Status TranslateL2LossOp(const NodeWrapper* op, +static Status TranslateL2LossOp(const TFNodeDecoder* op, const std::vector&, Builder::OpMap& ng_op_map) { ng::Output ng_input; @@ -1711,7 +1711,7 @@ static Status TranslateL2LossOp(const NodeWrapper* op, } static Status TranslateLog1pOp( - const NodeWrapper* op, const std::vector& static_input_map, + const TFNodeDecoder* op, const std::vector& static_input_map, Builder::OpMap& ng_op_map) { return TranslateUnaryOp( op, static_input_map, ng_op_map, [&op](ng::Output n) { @@ -1725,7 +1725,7 @@ static Status TranslateLog1pOp( }); } -static Status TranslateLRNOp(const NodeWrapper* op, +static Status TranslateLRNOp(const TFNodeDecoder* op, const std::vector& static_input_map, Builder::OpMap& ng_op_map) { ng::Output ng_inp; @@ -1756,7 +1756,7 @@ static Status TranslateLRNOp(const NodeWrapper* op, return Status::OK(); } -static Status TranslateLogSoftmaxOp(const NodeWrapper* op, +static Status TranslateLogSoftmaxOp(const TFNodeDecoder* op, const std::vector&, Builder::OpMap& ng_op_map) { ng::Output ng_inp; @@ -1770,7 +1770,7 @@ static Status TranslateLogSoftmaxOp(const NodeWrapper* op, return Status::OK(); } -static Status TranslateMatMulOp(const NodeWrapper* op, +static Status TranslateMatMulOp(const TFNodeDecoder* op, const std::vector&, Builder::OpMap& ng_op_map) { ng::Output ng_lhs, ng_rhs; @@ -1790,7 +1790,7 @@ static Status TranslateMatMulOp(const NodeWrapper* op, } template -static Status TranslateMaxPoolOp(const NodeWrapper* op, +static Status TranslateMaxPoolOp(const TFNodeDecoder* op, const std::vector&, Builder::OpMap& ng_op_map) { ng::Output ng_input; @@ -1849,7 +1849,7 @@ static Status TranslateMaxPoolOp(const NodeWrapper* op, } static Status TranslateNonMaxSuppressionV2Op( - const NodeWrapper* op, const std::vector& static_input_map, + const TFNodeDecoder* op, const std::vector& static_input_map, Builder::OpMap& ng_op_map) { ng::Output ng_boxes, ng_scores, ng_unused, ng_iou_threshold; TF_RETURN_IF_ERROR(GetInputNodes(ng_op_map, op, ng_boxes, ng_scores, @@ -1904,7 +1904,7 @@ static Status TranslateNonMaxSuppressionV2Op( } static Status TranslateReduceOp( - const NodeWrapper* op, const std::vector& static_input_map, + const TFNodeDecoder* op, const std::vector& static_input_map, Builder::OpMap& ng_op_map, std::function(ng::Output, ng::Output, const bool)> @@ -1941,7 +1941,7 @@ static Status TranslateReduceOp( template static Status TranslateDirectReduceOp( - const NodeWrapper* op, const std::vector& static_input_map, + const TFNodeDecoder* op, const std::vector& static_input_map, Builder::OpMap& ng_op_map) { // ensure its either an arithmetic or a logical reduction if (!(std::is_base_of::value || @@ -1960,7 +1960,7 @@ static Status TranslateDirectReduceOp( } static Status TranslateOneHotOp( - const NodeWrapper* op, const std::vector& static_input_map, + const TFNodeDecoder* op, const std::vector& static_input_map, Builder::OpMap& ng_op_map) { ng::Output ng_features, ng_unused, ng_on, ng_off, ng_depth; TF_RETURN_IF_ERROR( @@ -1988,7 +1988,7 @@ static Status TranslateOneHotOp( return Status::OK(); } -static Status TranslatePackOp(const NodeWrapper* op, const std::vector&, +static Status TranslatePackOp(const TFNodeDecoder* op, const std::vector&, Builder::OpMap& ng_op_map) { TF_RETURN_IF_ERROR(ValidateInputCountMin(op, 1)); @@ -2018,7 +2018,7 @@ static Status TranslatePackOp(const NodeWrapper* op, const std::vector& static_input_map, Builder::OpMap& ng_op_map) { ng::Output ng_input, ng_paddings_op, pad_val_op, result_pad_op; @@ -2082,7 +2082,7 @@ static Status TranslatePadOp(const NodeWrapper* op, } static Status TranslateRangeOp( - const NodeWrapper* op, const std::vector& static_input_map, + const TFNodeDecoder* op, const std::vector& static_input_map, Builder::OpMap& ng_op_map) { ng::Output ng_start, ng_stop, ng_step; TF_RETURN_IF_ERROR(GetInputNodes(ng_op_map, op, ng_start, ng_stop, ng_step)); @@ -2107,7 +2107,7 @@ static Status TranslateRangeOp( return Status::OK(); } -static Status TranslateRankOp(const NodeWrapper* op, const std::vector&, +static Status TranslateRankOp(const TFNodeDecoder* op, const std::vector&, Builder::OpMap& ng_op_map) { ng::Output ng_input; TF_RETURN_IF_ERROR(GetInputNodes(ng_op_map, op, ng_input)); @@ -2124,7 +2124,7 @@ static Status TranslateRankOp(const NodeWrapper* op, const std::vector& static_input_map, + const TFNodeDecoder* op, const std::vector& static_input_map, Builder::OpMap& ng_op_map) { return TranslateUnaryOp( op, static_input_map, ng_op_map, [&op](ng::Output n) { @@ -2141,7 +2141,7 @@ static Status TranslateReciprocalOp( }); } -static Status TranslateRelu6Op(const NodeWrapper* op, +static Status TranslateRelu6Op(const TFNodeDecoder* op, const std::vector&, Builder::OpMap& ng_op_map) { ng::Output ng_input; @@ -2152,7 +2152,7 @@ static Status TranslateRelu6Op(const NodeWrapper* op, } static Status TranslateReshapeOp( - const NodeWrapper* op, const std::vector& static_input_map, + const TFNodeDecoder* op, const std::vector& static_input_map, Builder::OpMap& ng_op_map) { ng::Output ng_input, ng_shape_op; TF_RETURN_IF_ERROR(GetInputNodes(ng_op_map, op, ng_input, ng_shape_op)); @@ -2172,7 +2172,7 @@ static Status TranslateReshapeOp( } static Status TranslateRsqrtOp( - const NodeWrapper* op, const std::vector& static_input_map, + const TFNodeDecoder* op, const std::vector& static_input_map, Builder::OpMap& ng_op_map) { return TranslateUnaryOp( op, static_input_map, ng_op_map, [&op](ng::Output n) { @@ -2189,7 +2189,7 @@ static Status TranslateRsqrtOp( }); } -static Status TranslateShapeOp(const NodeWrapper* op, +static Status TranslateShapeOp(const TFNodeDecoder* op, const std::vector&, Builder::OpMap& ng_op_map) { ng::Output ng_input; @@ -2207,7 +2207,7 @@ static Status TranslateShapeOp(const NodeWrapper* op, return Status::OK(); } -static Status TranslateSizeOp(const NodeWrapper* op, const std::vector&, +static Status TranslateSizeOp(const TFNodeDecoder* op, const std::vector&, Builder::OpMap& ng_op_map) { ng::Output ng_input; TF_RETURN_IF_ERROR(GetInputNodes(ng_op_map, op, ng_input)); @@ -2234,7 +2234,7 @@ static Status TranslateSizeOp(const NodeWrapper* op, const std::vector& static_input_map, + const TFNodeDecoder* op, const std::vector& static_input_map, Builder::OpMap& ng_op_map) { ng::Output ng_input, ng_begin, ng_size; TF_RETURN_IF_ERROR(GetInputNodes(ng_op_map, op, ng_input, ng_begin, ng_size)); @@ -2294,7 +2294,7 @@ static Status TranslateSliceOp( return Status::OK(); } -static Status TranslateSoftmaxOp(const NodeWrapper* op, +static Status TranslateSoftmaxOp(const TFNodeDecoder* op, const std::vector&, Builder::OpMap& ng_op_map) { ng::Output ng_input; @@ -2312,7 +2312,7 @@ static Status TranslateSoftmaxOp(const NodeWrapper* op, } // Translate SpaceToDepthOp -static Status TranslateSpaceToDepthOp(const NodeWrapper* op, +static Status TranslateSpaceToDepthOp(const TFNodeDecoder* op, const std::vector&, Builder::OpMap& ng_op_map) { ng::Output ng_input; @@ -2341,7 +2341,7 @@ static Status TranslateSpaceToDepthOp(const NodeWrapper* op, } static Status TranslateSplitOp( - const NodeWrapper* op, const std::vector& static_input_map, + const TFNodeDecoder* op, const std::vector& static_input_map, Builder::OpMap& ng_op_map) { ng::Output ng_input; TF_RETURN_IF_ERROR(GetInputNode(ng_op_map, op, 1, ng_input)); @@ -2370,7 +2370,7 @@ static Status TranslateSplitOp( } static Status TranslateSplitVOp( - const NodeWrapper* op, const std::vector& static_input_map, + const TFNodeDecoder* op, const std::vector& static_input_map, Builder::OpMap& ng_op_map) { ng::Output ng_input, ng_split_length, ng_split_dim; @@ -2449,7 +2449,7 @@ static Status TranslateSplitVOp( } static Status TranslateSquareOp( - const NodeWrapper* op, const std::vector& static_input_map, + const TFNodeDecoder* op, const std::vector& static_input_map, Builder::OpMap& ng_op_map) { return TranslateUnaryOp( op, static_input_map, ng_op_map, [&op](ng::Output n) { @@ -2457,7 +2457,7 @@ static Status TranslateSquareOp( }); } -static Status TranslateSqueezeOp(const NodeWrapper* op, +static Status TranslateSqueezeOp(const TFNodeDecoder* op, const std::vector&, Builder::OpMap& ng_op_map) { ng::Output ng_input; @@ -2481,7 +2481,7 @@ static Status TranslateSqueezeOp(const NodeWrapper* op, } static Status TranslateStridedSliceOp( - const NodeWrapper* op, const std::vector& static_input_map, + const TFNodeDecoder* op, const std::vector& static_input_map, Builder::OpMap& ng_op_map) { ng::Output ng_input; TF_RETURN_IF_ERROR(GetInputNode(ng_op_map, op, 0, ng_input)); @@ -2539,7 +2539,7 @@ static Status TranslateStridedSliceOp( } static Status TranslateTileOp( - const NodeWrapper* op, const std::vector& static_input_map, + const TFNodeDecoder* op, const std::vector& static_input_map, Builder::OpMap& ng_op_map) { ng::Output ng_input, ng_multiples; TF_RETURN_IF_ERROR(GetInputNodes(ng_op_map, op, ng_input, ng_multiples)); @@ -2556,7 +2556,7 @@ static Status TranslateTileOp( // Translate TopKV2 Op using ngraph core op TopK static Status TranslateTopKV2Op( - const NodeWrapper* op, const std::vector& static_input_map, + const TFNodeDecoder* op, const std::vector& static_input_map, Builder::OpMap& ng_op_map) { ng::Output ng_input; @@ -2597,7 +2597,7 @@ static Status TranslateTopKV2Op( } static Status TranslateTransposeOp( - const NodeWrapper* op, const std::vector& static_input_map, + const TFNodeDecoder* op, const std::vector& static_input_map, Builder::OpMap& ng_op_map) { ng::Output ng_input, ng_permutation; TF_RETURN_IF_ERROR(GetInputNodes(ng_op_map, op, ng_input, ng_permutation)); @@ -2606,7 +2606,7 @@ static Status TranslateTransposeOp( return Status::OK(); } -static Status TranslateUnpackOp(const NodeWrapper* op, +static Status TranslateUnpackOp(const TFNodeDecoder* op, const std::vector&, Builder::OpMap& ng_op_map) { TF_RETURN_IF_ERROR(ValidateInputCount(op, 1)); @@ -2645,7 +2645,7 @@ static Status TranslateUnpackOp(const NodeWrapper* op, } static Status TranslateXdivyOp( - const NodeWrapper* op, const std::vector& static_input_map, + const TFNodeDecoder* op, const std::vector& static_input_map, Builder::OpMap& ng_op_map) { ng::Output ng_x, ng_y; TF_RETURN_IF_ERROR(GetInputNodes(ng_op_map, op, ng_x, ng_y)); @@ -2659,7 +2659,7 @@ static Status TranslateXdivyOp( return Status::OK(); } -static Status TranslateSelectOp(const NodeWrapper* op, +static Status TranslateSelectOp(const TFNodeDecoder* op, const std::vector&, Builder::OpMap& ng_op_map) { ng::Output ng_input1, ng_input2, ng_input3; @@ -2672,7 +2672,7 @@ static Status TranslateSelectOp(const NodeWrapper* op, } static Status TranslateWhereOp( - const NodeWrapper* op, const std::vector& static_input_map, + const TFNodeDecoder* op, const std::vector& static_input_map, Builder::OpMap& ng_op_map) { ng::Output ng_cond; TF_RETURN_IF_ERROR(GetInputNodes(ng_op_map, op, ng_cond)); @@ -2685,7 +2685,7 @@ static Status TranslateWhereOp( return Status::OK(); } -static Status TranslateZerosLikeOp(const NodeWrapper* op, +static Status TranslateZerosLikeOp(const TFNodeDecoder* op, const std::vector&, Builder::OpMap& ng_op_map) { ng::Output ng_input; @@ -2701,7 +2701,7 @@ static Status TranslateZerosLikeOp(const NodeWrapper* op, const static std::map< const string, - const function&, + const function&, Builder::OpMap&)>> TRANSLATE_OP_MAP{ {"Abs", TranslateUnaryOp}, @@ -2776,7 +2776,7 @@ const static std::map< {"NotEqual", TranslateBinaryOp}, // Do nothing! NoOps sometimes get placed on nGraph for bureaucratic // reasons, but they have no data flow inputs or outputs. - {"NoOp", [](const NodeWrapper*, const std::vector&, + {"NoOp", [](const TFNodeDecoder*, const std::vector&, Builder::OpMap&) { return Status::OK(); }}, {"OneHot", TranslateOneHotOp}, {"Pack", TranslatePackOp}, @@ -2826,7 +2826,7 @@ const static std::map< {"Xdivy", TranslateXdivyOp}, {"ZerosLike", TranslateZerosLikeOp}}; -class NodeProtoWrapper : public NodeWrapper +class NodeProtoWrapper : public TFNodeDecoder { const NodeDef* node_def; public: @@ -2851,7 +2851,7 @@ class NodeProtoWrapper : public NodeWrapper virtual bool IsArg () const override { NGRAPH_TF_FE_NOT_IMPLEMENTED; } virtual std::string type_string () const override { NGRAPH_TF_FE_NOT_IMPLEMENTED; } - virtual Status input_node (size_t index, NodeWrapper**) const override { NGRAPH_TF_FE_NOT_IMPLEMENTED; } + virtual Status input_node (size_t index, TFNodeDecoder**) const override { NGRAPH_TF_FE_NOT_IMPLEMENTED; } virtual DataType input_type (size_t index) const override { NGRAPH_TF_FE_NOT_IMPLEMENTED; } virtual DataType output_type (size_t index) const override { NGRAPH_TF_FE_NOT_IMPLEMENTED; } @@ -2863,7 +2863,7 @@ class NodeProtoWrapper : public NodeWrapper }; -void PopulateNodesTopologicallySorted (const GraphDef* input_graph, std::vector* result) +void PopulateNodesTopologicallySorted (const GraphDef* input_graph, std::vector* result) { // WARNING! We suppose that input_graph contains nodes in topologically sorted order // TODO: sort it if it is not the case @@ -2882,18 +2882,18 @@ Status Builder::TranslateGraph( // // We will visit ops in topological order. // - // ought to be `const NodeWrapper*`, but GetReversePostOrder doesn't use `const` + // ought to be `const TFNodeDecoder*`, but GetReversePostOrder doesn't use `const` - std::vector ordered; + std::vector ordered; //GetReversePostOrder(*input_graph, &ordered, NodeComparatorName()); PopulateNodesTopologicallySorted(input_graph, &ordered); // // Split ops into params, retvals, and all others. // - vector tf_params; - vector tf_ret_vals; - vector tf_ops; + vector tf_params; + vector tf_ret_vals; + vector tf_ops; for (const auto n : ordered) { if (n->IsSink() || n->IsSource()) { @@ -2917,7 +2917,7 @@ Status Builder::TranslateGraph( // // The op map holds a mapping from TensorFlow op names (strings) to - // vector of generated nGraph Output. + // vector of generated nGraph Output. // Builder::OpMap ng_op_map; @@ -2961,7 +2961,7 @@ Status Builder::TranslateGraph( NGRAPH_VLOG(2) << "Constructing op " << op->name() << " which is " << op->type_string(); - const function&, + const function&, Builder::OpMap&)>* op_fun; try { diff --git a/ngraph/frontend/tensorflow/src/ngraph_builder.h b/ngraph/frontend/tensorflow/src/ngraph_builder.h index 7ae9602fb96b62..0739bce77080d1 100644 --- a/ngraph/frontend/tensorflow/src/ngraph_builder.h +++ b/ngraph/frontend/tensorflow/src/ngraph_builder.h @@ -75,12 +75,12 @@ namespace ngraph_bridge { class TensorWrapper; // ABI-free wrapper for TF node -class NodeWrapper +class TFNodeDecoder { public: // a hack to minimize amount of code - NodeWrapper& attrs () const { return const_cast(*this); } + TFNodeDecoder& attrs () const { return const_cast(*this); } virtual void getAttrValue (const char* name, std::vector* x) = 0; virtual void getAttrValue (const char* name, std::vector* x) = 0; virtual void getAttrValue (const char* name, int32_t* x) = 0; @@ -99,7 +99,7 @@ class NodeWrapper virtual bool IsArg () const = 0; virtual std::string type_string () const = 0; - virtual Status input_node (size_t index, NodeWrapper**) const = 0; + virtual Status input_node (size_t index, TFNodeDecoder**) const = 0; virtual DataType input_type (size_t index) const = 0; virtual DataType output_type (size_t index) const = 0; @@ -128,7 +128,7 @@ class TensorWrapper }; template -Status GetNodeAttr (NodeWrapper& attrs, const char* attr_name, T* result) +Status GetNodeAttr (TFNodeDecoder& attrs, const char* attr_name, T* result) { attrs.getAttrValue(attr_name, result); return Status::OK(); @@ -148,7 +148,7 @@ Status GetNodeAttr (NodeWrapper& attrs, const char* attr_name, T* result) std::vector>>; using ConstMap = std::map< DataType, - std::pair&)>, const ngraph::element::Type>>; static const Builder::ConstMap& TF_NGRAPH_CONST_MAP(); From ed4c612de3193582c0ca8e224f3ba9ca102c0a76 Mon Sep 17 00:00:00 2001 From: "Lyalin, Sergey" Date: Tue, 23 Mar 2021 11:12:13 +0300 Subject: [PATCH 056/116] More documentation for Front-end API --- .../frontend_manager/frontend_manager.hpp | 418 ++++++++++++------ .../frontend/generic/src/frontend_manager.cpp | 46 +- 2 files changed, 327 insertions(+), 137 deletions(-) diff --git a/ngraph/frontend/generic/include/frontend_manager/frontend_manager.hpp b/ngraph/frontend/generic/include/frontend_manager/frontend_manager.hpp index 1ab39acb6f829c..2d5597fe414456 100644 --- a/ngraph/frontend/generic/include/frontend_manager/frontend_manager.hpp +++ b/ngraph/frontend/generic/include/frontend_manager/frontend_manager.hpp @@ -23,129 +23,299 @@ namespace ngraph { - namespace frontend - { - class NGRAPH_API Place - { - public: - - typedef std::shared_ptr Ptr; - - // All associated names that uniquely identify this place in the graph - // from the FW perspective - virtual std::vector getNames () const; - // -1 means port 0 is selected if it is exists and exception otherwise - virtual std::vector getConsumingOperations (int outputPortIndex = -1) const; - virtual Ptr getTargetTensor (int outputPortIndex = -1) const; - virtual Ptr getProducingOperation (int inputPortIndex = -1) const; - virtual Ptr getProducingPort () const; - virtual Ptr getInputPort (int inputPortIndex) const; - virtual Ptr getOutputPort (int outputPortIndex) const; - virtual std::vector getConsumingPorts () const; - }; - - class NGRAPH_API InputModel - { - public: - - typedef std::shared_ptr Ptr; - - virtual std::vector getInputs () const; - virtual std::vector getOutputs () const; - - virtual Place::Ptr getPlaceByTensorName (const std::string& tensorName); - virtual Place::Ptr getPlaceByOperationName (const std::string& operationName); - virtual Place::Ptr getPlaceByOperationAndInputPort (const std::string& operationName, int inputPortIndex); - virtual Place::Ptr getPlaceByOperationAndOutputPort (const std::string& operationName, int outputPortIndex); - - // Naming and annotation - virtual void setNameForTensor (Place::Ptr tensor, const std::string& newName); - virtual void addNameForTensor (Place::Ptr tensor, const std::string& newName); - virtual void setNameForOperation (Place::Ptr operation, const std::string& newName); - virtual void freeNameForTensor (const std::string& name); - virtual void freeNameForOperation (const std::string& name); - virtual void setNameForDimension (Place::Ptr place, const std::string& dimName); - - // Topology Editing - virtual void cutAndAddNewInput (Place::Ptr place, const std::string& newNameOptional = ""); - virtual void cutAndAddNewOutput (Place::Ptr place, const std::string& newNameOptional = ""); - virtual void addOutput (Place::Ptr place); - virtual void removeOutput (Place::Ptr place); - virtual void removeInput (Place::Ptr place); // is it really needed? that means that input is not available and all dataflow below should be removed - virtual void overrideAllOutputs (const std::vector& outputs); - virtual void overrideAllInputs (const std::vector& inputs); - virtual void extractSubgraph (const std::vector& inputs, const std::vector& outputs); - - // Setting tensor properties - virtual void setDefaultShape (Place::Ptr place, const ngraph::Shape&); - virtual void setPartialShape (Place::Ptr place, const ngraph::PartialShape&); - virtual void setElementType (Place::Ptr place, const ngraph::element::Type&); - virtual void setTensorValue (Place::Ptr place, const void* value); - virtual void setTensorPartialValue (Place::Ptr place, const void* minValue, const void* maxValue); - - // Standard specializations: "N", "C", "H", "W", "D", "L" - // Issues: name collisions; too bulky to select simple layouts "NCHW" - virtual void setTensorDimSpecialization (Place::Ptr place, unsigned int dimIndex, const std::string& specialization); - - // Traversing - // TODO - - // Support querying - // TODO - }; - - class NGRAPH_API FrontEnd - { - public: - typedef std::shared_ptr Ptr; - - virtual InputModel::Ptr loadFromFile (const std::string& path) const; - virtual InputModel::Ptr loadFromFiles (const std::vector& paths) const; - virtual InputModel::Ptr loadFromMemory (const void* model) const; - virtual InputModel::Ptr loadFromMemoryFragments (const std::vector& modelParts) const; - virtual InputModel::Ptr loadFromStream (std::istream& path) const; - virtual InputModel::Ptr loadFromStreams (const std::vector& paths) const; - - // Extra ctors may be provided by FW-specialized data structure for graph representaion - - // Completely convert and normalize entire function, throws if it is not possible - virtual std::shared_ptr convert (InputModel::Ptr model) const; - - // Convert only those parts of the model that can be converted, leaving others as-is - // Converted parts are not normalized by additional transformations; normalize function - // should be called to finalize the conversion process. - virtual std::shared_ptr convertPartially (InputModel::Ptr model) const; - - // Convert operations 1:1 representing each FW operation as a single nGraph node with all attributes - // represented in FW-independent way - virtual std::shared_ptr convertDecodingOnly (InputModel::Ptr model) const; - - // Convert operations 1:1 with deconding only basic attributes that are required for node - // identificatoin (like name of nodes and tensors), leaving other attributes undecoded and keeping - // original FW descriptor for the node - virtual std::shared_ptr convertNoDecoding (InputModel::Ptr model) const; - - // Runs normalization passes on function that was loaded with partial conversion - virtual void normalize (std::shared_ptr function) const; - }; - - enum FrontEndCapabilities { - FEC_DEFAULT = 0, // Just reading and conversion, w/o any modifications; intended to be used in Reader - FEC_CUT = 1, - FEC_NAMES = 2, - FEC_REPLACE = 4, - FEC_TRAVERSE = 8, - FEC_WILDCARDS = 16, - }; - - class NGRAPH_API FrontEndManager - { - public: - FrontEndManager () {} - FrontEnd::Ptr loadByFramework (const std::string& framework, FrontEndCapabilities fec = FEC_DEFAULT); - FrontEnd::Ptr loadByModel (const std::string& path, FrontEndCapabilities fec = FEC_DEFAULT); - std::vector availableFrontEnds () const; - }; - } // namespace frontend +namespace frontend +{ + + +/// \brief An interface for identifying a place in a graph and iterate over it; can refer to an operation node, tensor, port etc. +/// +/// \note Each front end implementation provides specialization of this interface to represent a place +/// in a model graph. Various methods in the front end classes accept and retrieve instances +/// of Place to point to particular node part which should be modified or satisfies some criteria. +/// For example, this class is used to report model inputs and outputs, for searching operations and tensors +/// by name, for setting shape etc. +/// +/// Place can refer to Tensor, Input Edge, Input Port, Operation, Output Port, Output Edge +/// +/// [Tensor A] +/// | +/// | [Input Edge] +/// | +/// V +/// ------------------- +/// [ [Input Port 0] ] +/// [ ] +/// [ Operation A ] +/// [ ] +/// [ [Output Port 0] ] +/// ------------------- +/// | +/// | [Output Edge] +/// | +/// V +/// [Tensor B] +/// | +/// | [Input Edge] +/// | +/// V +/// ------------------- +/// [ [Input Port 0] ] +/// [ ] +/// [ Operation B ] +/// [ ] +/// [ [Output Port 0] ] +/// ------------------- +/// | +/// | [Output Edge] +/// | +/// V +/// [Tensor C] +/// +class NGRAPH_API Place +{ +public: + + typedef std::shared_ptr Ptr; + + /// \brief All associated names (synonyms) that identify this place in the graph in a framework specific way + /// \return A vector of strings each representing a name that identifies this place in the graph. + /// Can be empty if there are no names associated with this place or name cannot be attached. + virtual std::vector getNames () const; + + /// \brief Returns references to all operation nodes that consume data from this place + /// \note It can be called for any kind of graph place searching for the first consuming opertions. + /// + /// \param outputPortIndex If place is an operational node it specifies which output port should be considered + /// \return A vector with all operation node references that consumes data from this place + virtual std::vector getConsumingOperations (int outputPortIndex = -1) const; + + /// \brief Returns a tensor place that gets data from this place; applicable for operations, output ports and output edges + /// + /// \param outputPortIndex Output port index if the current place is an operation node and has multiple output ports + /// \return A tensor place which hold the resulting value for this place + virtual Ptr getTargetTensor (int outputPortIndex = -1) const; + + /// \brief Returns a tensor place that supplies data for this place; applicable for operations, input ports and input edges + /// + /// \param inputPortIndex Input port index for operational nodes + /// \return A tensor place which supplies data for this place + virtual Ptr getSourceTensor (int inputPortIndex = -1) const; + + /// \brief Get an operation node place that immediately produces data for this place + /// + /// \param inputPortIndex If a given place is itself an operation node, this specifies a port index + /// \return An operation place that produces data for this place + virtual Ptr getProducingOperation (int inputPortIndex = -1) const; + + /// Returns a port that produces data for this place + virtual Ptr getProducingPort () const; + + /// For operation node returns reference to an input port with specified index + virtual Ptr getInputPort (int inputPortIndex = -1) const; + + /// For operation node returns reference to an output port with specified index + virtual Ptr getOutputPort (int outputPortIndex = -1) const; + + /// Returns all input ports that consume data flows through this place + virtual std::vector getConsumingPorts () const; + + /// Returns true if this place is input for a model. + virtual bool isInput () const; + + /// Returns true if this place is output for a model. + virtual bool isOutput () const; + + /// Returns true if another place is the same as this place. + virtual bool isEqual (Ptr another) const; + + /// \brief Returns true if another place points to the same data. + /// \note The same data means all places on path: output port -> output edge -> tensor -> input edge -> input port. + virtual bool isEqualData (Ptr another) const; +}; + + +/// \brief InputModel class represents an original, not yet converted model graph in a framework format given +/// services to find places of interest in a graph or specialize/edit the model before conversion. +/// +/// \note Class methods are divided into several groups: searching for places, naming and annotation, +/// topology editing, setting tensor properties. +/// +/// Editing requests may affect ability to convert the original model to nGraph function. Aim to provide +/// these editing capabilities is to unlock conversion for models that are not natively supported "as-is" +/// because of undefined shapes, types or operations. +/// +/// Specific front-end implementation is supposed to have a lazy implementation for all methods, not doing +/// a complete load of a model without an explicit method call. For example, the list of all inputs +/// are not pre-fetched by InputModel derived class instance creation, but only when getInputs method is called. +/// But it is not an obligation, the most convenient way should be chosen depending on the framework model +/// representation. +/// +/// All editing requests affect the model representation that is held behind the scene and successive method +/// calls observe a new graph structure. +class NGRAPH_API InputModel +{ +public: + + typedef std::shared_ptr Ptr; + + + ///// Searching for places ///// + + + /// \brief Returns all inputs for a model + /// An input is a place in a graph where data is supposed to flow inside graph from outside. + /// It can be a tensor, port, operation; which kind of place can be an output is FW dependent. + /// Usually framework models have a dedicated artifact to code model input, it can be a tensor without producer, + /// that writes to it in ONNX, or a special operation like Placeholder in TensorFlow. + /// \return A vector of input place references + virtual std::vector getInputs () const; + + /// \brief Returns all output for a model + /// An output is a terminal place in a graph where data escapes the flow. It can be a tensor, port, operation; + /// which kind of place can be an output is FW dependent. In comparison to a graph input, the output is less + /// formally defined thing and determination of initial list of outputs may include some conventions defined + /// by a frontend itself, not a framework. For example, all output ports without consumers may be considered + /// as outputs. + /// \return A vector of output place references + virtual std::vector getOutputs () const; + + /// Returns a tensor place by a tensor name following framework conventions, or nullptr if a tensor with this name doesn't exist. + virtual Place::Ptr getPlaceByTensorName (const std::string& tensorName); + + /// Returns an operation place by a tensor name following framework conventions, or nullptr if an operation with this name doesn't exist. + virtual Place::Ptr getPlaceByOperationName (const std::string& operationName); + + /// Returns an input port. + virtual Place::Ptr getPlaceByOperationAndInputPort (const std::string& operationName, int inputPortIndex); + + /// Returns an output port. + virtual Place::Ptr getPlaceByOperationAndOutputPort (const std::string& operationName, int outputPortIndex); + + + ///// Naming and annotation ///// + + + virtual void setNameForTensor (Place::Ptr tensor, const std::string& newName); + virtual void addNameForTensor (Place::Ptr tensor, const std::string& newName); + virtual void setNameForOperation (Place::Ptr operation, const std::string& newName); + virtual void freeNameForTensor (const std::string& name); + virtual void freeNameForOperation (const std::string& name); + virtual void setNameForDimension (Place::Ptr place, size_t shapeDimIndex, const std::string& dimName); + + + ///// Topology Editing ///// + + /// Cut immediately before this place and assign this place as new input; prune all nodes that don't contribute to any output. + virtual void cutAndAddNewInput (Place::Ptr place, const std::string& newNameOptional = ""); + + /// Cut immediately after this place and assign this place as new output; prune all nodes that don't contribute to any output. + virtual void cutAndAddNewOutput (Place::Ptr place, const std::string& newNameOptional = ""); + + /// \brief Assign this place as new output or add necessary nodes to represent a new output. + /// + /// \param place Anchor point to add an output + /// \return new output place, may be the same as a given place + virtual Place::Ptr addOutput (Place::Ptr place); + + /// Removes any sinks directly attached to this place with all inbound data flow if it is not required by any other output. + virtual void removeOutput (Place::Ptr place); + + /// Removes an input place and all data flow that depends on it. + // TODO: remove it as something not practically useful in the API? + virtual void removeInput (Place::Ptr place); + + /// Replaces all existing outputs with new ones removing all data flow that is not required for new outputs. + /// + /// \param outputs Vector with places that will become new outputs; may intersect existing outputs. + virtual void overrideAllOutputs (const std::vector& outputs); + + /// \brief Modifies the graph to use new inputs instead of existing ones. New inputs should completely satisfy all existing outputs. + virtual void overrideAllInputs (const std::vector& inputs); + + /// Leaves only subgraph that are defined by new inputs and new outputs. + virtual void extractSubgraph (const std::vector& inputs, const std::vector& outputs); + + ///// Setting tensor properties ///// + + /// Sets shape that would be used by default for this place; place should be uniquely refer to some data. + // TODO: define clearly which scenario requires it -- currently it should satisfy requirement to have statically defined shapes for tensors + virtual void setDefaultShape (Place::Ptr place, const ngraph::Shape&); + + /// Defines all possible shape that may be used for this place; place should be uniquely refer to some data. + /// This partial shape will be converted to corresponding shape of results ngraph nodes and will define shape inference + /// when the model is converted to ngraph. + virtual void setPartialShape (Place::Ptr place, const ngraph::PartialShape&); + + /// Sets new element type for a place. + virtual void setElementType (Place::Ptr place, const ngraph::element::Type&); + + /// Freezes a tensor with statically defined value or replace existing value for already constant node or tensor. + virtual void setTensorValue (Place::Ptr place, const void* value); + + /// Defines partial value (lower bound and upper bound) for a tensor place. + // TODO: more details for minValue and maxValue format; who defines shape? + virtual void setTensorPartialValue (Place::Ptr place, const void* minValue, const void* maxValue); + + // TODO: Document "inputs/output assymetry" in more details + + // Traversing + // TODO: remove or add something; most likely will have only a single method that provides a list of operation nodes sorted topologically + + // Support querying + // TODO: remove or add something; there are no candidates, all queries can be satisfied without any API extension here +}; + +class NGRAPH_API FrontEnd +{ +public: + typedef std::shared_ptr Ptr; + + virtual InputModel::Ptr loadFromFile (const std::string& path) const; + virtual InputModel::Ptr loadFromFiles (const std::vector& paths) const; + virtual InputModel::Ptr loadFromMemory (const void* model) const; + virtual InputModel::Ptr loadFromMemoryFragments (const std::vector& modelParts) const; + virtual InputModel::Ptr loadFromStream (std::istream& path) const; + virtual InputModel::Ptr loadFromStreams (const std::vector& paths) const; + + // Extra ctors may be provided by FW-specialized data structure for graph representaion + + /// Completely convert and normalize entire function, throws if it is not possible + virtual std::shared_ptr convert (InputModel::Ptr model) const; + + /// Completely convert the remaining, not converted part of a function. + virtual std::shared_ptr convert (std::shared_ptr partiallyConverted) const; + + /// Convert only those parts of the model that can be converted leaving others as-is. + /// Converted parts are not normalized by additional transformations; normalize function + /// or another form of convert function should be called to finalize the conversion process. + virtual std::shared_ptr convertPartially (InputModel::Ptr model) const; + + /// Convert operations with one-to-one mapping with decoding nodes. + /// Each decoding node is an nGraph node representing a single FW operation node with all attributes + /// represented in FW-independent way. + virtual std::shared_ptr decode (InputModel::Ptr model) const; + + /// Runs normalization passes on function that was loaded with partial conversion + virtual void normalize (std::shared_ptr function) const; +}; + +enum FrontEndCapabilities { + FEC_DEFAULT = 0, // Just reading and conversion, w/o any modifications; intended to be used in Reader + FEC_CUT = 1, + FEC_NAMES = 2, + FEC_REPLACE = 4, + FEC_TRAVERSE = 8, + FEC_WILDCARDS = 16, +}; + +class NGRAPH_API FrontEndManager +{ +public: + FrontEndManager () {} + FrontEnd::Ptr loadByFramework (const std::string& framework, FrontEndCapabilities fec = FEC_DEFAULT); + FrontEnd::Ptr loadByModel (const std::string& path, FrontEndCapabilities fec = FEC_DEFAULT); + std::vector availableFrontEnds () const; +}; +} // namespace frontend } // namespace ngraph diff --git a/ngraph/frontend/generic/src/frontend_manager.cpp b/ngraph/frontend/generic/src/frontend_manager.cpp index 8e411d61fc0d85..9628b8cd24043e 100644 --- a/ngraph/frontend/generic/src/frontend_manager.cpp +++ b/ngraph/frontend/generic/src/frontend_manager.cpp @@ -84,7 +84,7 @@ namespace ngraph FRONT_END_NOT_IMPLEMENTED(freeNameForOperation); } - void InputModel::setNameForDimension (Place::Ptr place, const std::string& dimName) + void InputModel::setNameForDimension (Place::Ptr place, size_t shapeDimIndex, const std::string& dimName) { FRONT_END_NOT_IMPLEMENTED(setNameForDimension); } @@ -99,7 +99,7 @@ namespace ngraph FRONT_END_NOT_IMPLEMENTED(cutAndAddNewOutput); } - void InputModel::addOutput (Place::Ptr place) + Place::Ptr InputModel::addOutput (Place::Ptr place) { FRONT_END_NOT_IMPLEMENTED(addOutput); } @@ -155,11 +155,6 @@ namespace ngraph FRONT_END_NOT_IMPLEMENTED(setTensorPartialValue); } - void InputModel::setTensorDimSpecialization (Place::Ptr place, unsigned int dimIndex, const std::string& specialization) - { - FRONT_END_NOT_IMPLEMENTED(setTensorDimSpecialization); - } - std::vector Place::getNames () const { FRONT_END_NOT_IMPLEMENTED(getNames); @@ -200,6 +195,31 @@ namespace ngraph FRONT_END_NOT_IMPLEMENTED(getConsumingPorts); } + bool Place::isInput () const + { + FRONT_END_NOT_IMPLEMENTED(isInput); + } + + bool Place::isOutput () const + { + FRONT_END_NOT_IMPLEMENTED(isOutput); + } + + bool Place::isEqual (Ptr another) const + { + FRONT_END_NOT_IMPLEMENTED(isEqual); + } + + bool Place::isEqualData (Ptr another) const + { + FRONT_END_NOT_IMPLEMENTED(isEqualData); + } + + Place::Ptr Place::getSourceTensor (int inputPortIndex) const + { + FRONT_END_NOT_IMPLEMENTED(getSourceTensor); + } + class PlaceInputEdgeONNX : public Place { public: @@ -389,19 +409,19 @@ namespace ngraph FRONT_END_NOT_IMPLEMENTED(convert); } - std::shared_ptr FrontEnd::convertPartially (InputModel::Ptr model) const + std::shared_ptr FrontEnd::convert (std::shared_ptr) const { - FRONT_END_NOT_IMPLEMENTED(convertPartially); + FRONT_END_NOT_IMPLEMENTED(convert); } - std::shared_ptr FrontEnd::convertDecodingOnly (InputModel::Ptr model) const + std::shared_ptr FrontEnd::convertPartially (InputModel::Ptr model) const { - FRONT_END_NOT_IMPLEMENTED(convertDecodingOnly); + FRONT_END_NOT_IMPLEMENTED(convertPartially); } - std::shared_ptr FrontEnd::convertNoDecoding (InputModel::Ptr model) const + std::shared_ptr FrontEnd::decode (InputModel::Ptr model) const { - FRONT_END_NOT_IMPLEMENTED(convertNoDecoding); + FRONT_END_NOT_IMPLEMENTED(convertDecodingOnly); } void FrontEnd::normalize (std::shared_ptr function) const From 67ede6a4906715bce2f4fd5a664d07f79ffae709 Mon Sep 17 00:00:00 2001 From: "Lyalin, Sergey" Date: Tue, 23 Mar 2021 21:09:07 +0300 Subject: [PATCH 057/116] Fixed overloaded pybind11 definition --- ngraph/python/src/pyngraph/frontend_manager.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ngraph/python/src/pyngraph/frontend_manager.cpp b/ngraph/python/src/pyngraph/frontend_manager.cpp index c71a208d91cb17..d5955408bdcd75 100644 --- a/ngraph/python/src/pyngraph/frontend_manager.cpp +++ b/ngraph/python/src/pyngraph/frontend_manager.cpp @@ -41,7 +41,8 @@ void regclass_pyngraph_FrontEnd(py::module m) fem.doc() = "ngraph.impl.FrontEnd wraps ngraph::frontend::FrontEnd"; fem.def("loadFromFile", &ngraph::frontend::FrontEnd::loadFromFile); - fem.def("convert", &ngraph::frontend::FrontEnd::convert); + fem.def("convert", static_cast (ngraph::frontend::FrontEnd::*)(ngraph::frontend::InputModel::Ptr)const>(&ngraph::frontend::FrontEnd::convert)); + fem.def("convert", static_cast (ngraph::frontend::FrontEnd::*)(std::shared_ptr)const>(&ngraph::frontend::FrontEnd::convert)); } void regclass_pyngraph_Place(py::module m) From 2449fc3103ab964f258d338e6d628f9890592be2 Mon Sep 17 00:00:00 2001 From: "Lyalin, Sergey" Date: Wed, 24 Mar 2021 00:16:03 +0300 Subject: [PATCH 058/116] Further progress with TF bridge code adoptation --- .../tensorflow/src/ngraph_builder.cpp | 169 ++++++++++++++---- .../frontend/tensorflow/src/ngraph_builder.h | 7 + .../tensorflow/src/ngraph_conversions.cpp | 9 + .../tensorflow/src/ngraph_conversions.h | 3 + ngraph/frontend/tensorflow/src/tensorflow.cpp | 2 +- 5 files changed, 153 insertions(+), 37 deletions(-) diff --git a/ngraph/frontend/tensorflow/src/ngraph_builder.cpp b/ngraph/frontend/tensorflow/src/ngraph_builder.cpp index 47624fd9ac33a5..c29e6c1768f946 100644 --- a/ngraph/frontend/tensorflow/src/ngraph_builder.cpp +++ b/ngraph/frontend/tensorflow/src/ngraph_builder.cpp @@ -174,24 +174,26 @@ static Status GetInputNode(const Builder::OpMap& ng_op_map, const TFNodeDecoder* return Status(error::NOT_FOUND, "Edge not found"); } +#endif + TFNodeDecoder* tf_input; - TF_RETURN_IF_ERROR(op->input_node(input_idx, &tf_input)); + size_t src_output_idx; + TF_RETURN_IF_ERROR(op->input_node(input_idx, &tf_input, &src_output_idx)); std::vector> ng_op; try { ng_op = ng_op_map.at(tf_input->name()); } catch (const out_of_range&) { - return Status(error::NOT_FOUND, - string("Ngraph op not found for ") + tf_input->name()); + return Status(string("Ngraph op not found for ") + tf_input->name()); } try { result = ng_op.at(src_output_idx); } catch (const out_of_range&) { - return Status(error::NOT_FOUND, string("Input node not found at index ") + + return Status(string("Input node not found at index ") + to_string(src_output_idx)); } return Status::OK(); -#endif + NGRAPH_TF_FE_NOT_IMPLEMENTED } @@ -489,7 +491,7 @@ static Status ValuesFromConstNode(const TFNodeDecoder* node, return Status::OK(); #endif - NGRAPH_TF_FE_NOT_IMPLEMENTED + NGRAPH_TF_FE_NOT_IMPLEMENTED } // Helper for Builder::TranslateGraph ("Const" op) @@ -2826,41 +2828,116 @@ const static std::map< {"Xdivy", TranslateXdivyOp}, {"ZerosLike", TranslateZerosLikeOp}}; + + class NodeProtoWrapper : public TFNodeDecoder { const NodeDef* node_def; + const GraphDef* graph_def; + std::vector* nodes; public: - NodeProtoWrapper(const NodeDef* _node_def) : node_def(_node_def) {} + NodeProtoWrapper(const NodeDef* _node_def, const GraphDef* _graph_def, std::vector* _nodes) : + node_def(_node_def), graph_def(_graph_def), nodes(_nodes) {} + +#define GET_ATTR_VALUE(TYPE, FIELD) virtual void getAttrValue (const char* name, TYPE* x) override { *x = node_def->attr().at(name).FIELD(); } + virtual void getAttrValue (const char* name, std::vector* x) override { NGRAPH_TF_FE_NOT_IMPLEMENTED; } virtual void getAttrValue (const char* name, std::vector* x) override { NGRAPH_TF_FE_NOT_IMPLEMENTED; } - virtual void getAttrValue (const char* name, int32_t* x) override { NGRAPH_TF_FE_NOT_IMPLEMENTED; } - virtual void getAttrValue (const char* name, DataType* x) override { NGRAPH_TF_FE_NOT_IMPLEMENTED; } - virtual void getAttrValue (const char* name, std::string* x) override { NGRAPH_TF_FE_NOT_IMPLEMENTED; } - virtual void getAttrValue (const char* name, bool* x) override { NGRAPH_TF_FE_NOT_IMPLEMENTED; } - virtual void getAttrValue (const char* name, long int* x) override { NGRAPH_TF_FE_NOT_IMPLEMENTED; } - virtual void getAttrValue (const char* name, float* x) override { NGRAPH_TF_FE_NOT_IMPLEMENTED; } + GET_ATTR_VALUE(int32_t, i) + + virtual void getAttrValue (const char* name, DataType* x) override + { + *x = node_def->attr().at(name).type(); + } + + virtual void getAttrValue (const char* name, ngraph::PartialShape* x) override { + TFTensorShapeToNGraphShape(node_def->attr().at(name).shape(), x); + } + + GET_ATTR_VALUE(std::string, s) + GET_ATTR_VALUE(bool, b) + GET_ATTR_VALUE(long int, i) + GET_ATTR_VALUE(float, f) + virtual void getAttrValue (const char* name, std::vector* x) override { NGRAPH_TF_FE_NOT_IMPLEMENTED; } // a way to read Const value as a tensor virtual void getAttrValue (const char* name, TensorWrapper** x) override { NGRAPH_TF_FE_NOT_IMPLEMENTED; } - virtual unsigned int num_inputs () const override { NGRAPH_TF_FE_NOT_IMPLEMENTED; } - virtual std::string name () const override { NGRAPH_TF_FE_NOT_IMPLEMENTED; } - virtual bool IsArg () const override { NGRAPH_TF_FE_NOT_IMPLEMENTED; } - virtual std::string type_string () const override { NGRAPH_TF_FE_NOT_IMPLEMENTED; } + virtual unsigned int num_inputs () const override { return node_def->input_size(); } + + virtual std::string name () const override + { + return node_def->name(); + } + + virtual std::string type_string () const override + { + return node_def->op(); + } virtual Status input_node (size_t index, TFNodeDecoder**) const override { NGRAPH_TF_FE_NOT_IMPLEMENTED; } + + virtual Status input_node (size_t index, TFNodeDecoder** retnode, size_t* outputPortIndex) const override + { + std::string input_name = node_def->input(index); + if(input_name.find(':') != std::string::npos) { + std::cerr << "input_name: " << input_name << "\n"; + NGRAPH_TF_FE_NOT_IMPLEMENTED; + } + // TODO: don't search linearly every time!!! + for(auto node: *nodes) + { + if(node->name() == input_name) + { + *retnode = node; + *outputPortIndex = 0; + return Status::OK(); + } + } + return Status("Node is not found " + input_name + " when searched as an input for node " + name()); + } + virtual DataType input_type (size_t index) const override { NGRAPH_TF_FE_NOT_IMPLEMENTED; } virtual DataType output_type (size_t index) const override { NGRAPH_TF_FE_NOT_IMPLEMENTED; } - virtual bool IsSink () const override { NGRAPH_TF_FE_NOT_IMPLEMENTED; } - virtual bool IsSource () const override { NGRAPH_TF_FE_NOT_IMPLEMENTED; } - virtual bool IsControlFlow () const override { NGRAPH_TF_FE_NOT_IMPLEMENTED; } - virtual std::string DebugString () const override { NGRAPH_TF_FE_NOT_IMPLEMENTED; } - virtual bool IsRetval () const override { NGRAPH_TF_FE_NOT_IMPLEMENTED; } + virtual bool IsSink () const override + { + // TODO: recognize special op in TF runtime; don't know similar node for proto graph representation + return false; + } + virtual bool IsSource () const override + { + // TODO: populate with other source operation types + std::cerr << "IsSource for " << node_def->op() << "\n"; + return node_def->op() == "Placeholder"; + } + + virtual bool IsControlFlow () const override + { + // TODO + return false; + } + + virtual std::string DebugString () const override + { + return node_def->op() + "(with name " + node_def->name() + ")"; + } + + virtual bool IsArg () const override + { + // TODO + return IsSource(); + } + + virtual bool IsRetval () const override + { + // TODO + return IsSink(); + } }; void PopulateNodesTopologicallySorted (const GraphDef* input_graph, std::vector* result) @@ -2871,7 +2948,7 @@ void PopulateNodesTopologicallySorted (const GraphDef* input_graph, std::vector< result->reserve(input_graph->node_size()); for(int i = 0; i < input_graph->node_size(); ++i) { - result->push_back(new NodeProtoWrapper(&input_graph->node(i))); + result->push_back(new NodeProtoWrapper(&input_graph->node(i), input_graph, result)); } } @@ -2896,9 +2973,12 @@ Status Builder::TranslateGraph( vector tf_ops; for (const auto n : ordered) { - if (n->IsSink() || n->IsSource()) { +#if 0 + // TODO: Investigate why do we need it + if (n->IsSink() || n->IsSource()) { continue; } +#endif if (n->IsControlFlow()) { return errors::Unimplemented( @@ -2924,34 +3004,51 @@ Status Builder::TranslateGraph( // // Populate the parameter list, and also put parameters into the op map. // + std::cerr << "[ INFO ] Detected " << tf_params.size() << " parameters\n"; ng::ParameterVector ng_parameter_list(tf_params.size()); + // enumerate placeholders in some random order, count them and use counter as an index + int index = 0; for (auto parm : tf_params) { + std::cerr << "processing " << parm->name() << "\n"; DataType dtype; - if (GetNodeAttr(parm->attrs(), "T", &dtype) != Status::OK()) { + // TODO: replace dtype by T when converting Arg + if (GetNodeAttr(parm->attrs(), "dtype", &dtype) != Status::OK()) { return errors::InvalidArgument("No data type defined for _Arg"); } - int index; - if (GetNodeAttr(parm->attrs(), "index", &index) != Status::OK()) { - return errors::InvalidArgument("No index defined for _Arg"); - } + + // TODO: use this code for Arg + //if (GetNodeAttr(parm->attrs(), "index", &index) != Status::OK()) { + // return errors::InvalidArgument("No index defined for _Arg"); + //} ng::element::Type ng_et; TF_RETURN_IF_ERROR(TFDataTypeToNGraphElementType(dtype, &ng_et)); - ng::PartialShape ng_shape = inputs[index]; -#if 0 - TF_RETURN_IF_ERROR( - TFTensorShapeToNGraphShape(inputs[index], &ng_shape)); -#endif + std::cerr << "\nX\n"; + + ng::PartialShape ng_shape; + try + { + GetNodeAttr(parm->attrs(), "shape", &ng_shape); + } + catch (google::protobuf::FatalException) + { + // suppose there is no shape + // TODO: do it in a good way + } +#if 0 string prov_tag; GetNodeAttr(parm->attrs(), "_prov_tag", &prov_tag); +#endif auto ng_param = - ConstructNgNode(prov_tag, ng_et, ng_shape); + ConstructNgNode(parm->name(), ng_et, ng_shape); SaveNgOp(ng_op_map, parm->name(), ng_param); ng_parameter_list[index] = ngraph::as_type_ptr(ng_param.get_node_shared_ptr()); + + index++; } // @@ -2959,7 +3056,7 @@ Status Builder::TranslateGraph( // for (auto op : tf_ops) { NGRAPH_VLOG(2) << "Constructing op " << op->name() << " which is " - << op->type_string(); + << op->type_string() << "\n"; const function&, Builder::OpMap&)>* op_fun; diff --git a/ngraph/frontend/tensorflow/src/ngraph_builder.h b/ngraph/frontend/tensorflow/src/ngraph_builder.h index 0739bce77080d1..7025a00966dd9a 100644 --- a/ngraph/frontend/tensorflow/src/ngraph_builder.h +++ b/ngraph/frontend/tensorflow/src/ngraph_builder.h @@ -46,6 +46,11 @@ inline bool operator!= (const Status& x, const Status& y) return x.status != y.status; } +inline std::ostream& operator<< (std::ostream& out, const Status& s) +{ + return out << s.message; +} + #define TF_RETURN_IF_ERROR(S) if((S).status != 0)return S; // Stub for tf error system @@ -90,6 +95,7 @@ class TFNodeDecoder virtual void getAttrValue (const char* name, long int* x) = 0; virtual void getAttrValue (const char* name, float* x) = 0; virtual void getAttrValue (const char* name, std::vector* x) = 0; + virtual void getAttrValue (const char* name, ngraph::PartialShape* x) = 0; // a way to read Const value as a tensor virtual void getAttrValue (const char* name, TensorWrapper** x) = 0; @@ -100,6 +106,7 @@ class TFNodeDecoder virtual std::string type_string () const = 0; virtual Status input_node (size_t index, TFNodeDecoder**) const = 0; + virtual Status input_node (size_t index, TFNodeDecoder**, size_t* outputPortIndex) const = 0; virtual DataType input_type (size_t index) const = 0; virtual DataType output_type (size_t index) const = 0; diff --git a/ngraph/frontend/tensorflow/src/ngraph_conversions.cpp b/ngraph/frontend/tensorflow/src/ngraph_conversions.cpp index c2bd8452c5c7e7..b018041bf5e1e5 100644 --- a/ngraph/frontend/tensorflow/src/ngraph_conversions.cpp +++ b/ngraph/frontend/tensorflow/src/ngraph_conversions.cpp @@ -101,6 +101,15 @@ void NCHWtoNHWC(const std::string& op_name, bool is_nhwc, return Status::OK(); } + Status TFTensorShapeToNGraphShape(const ::tensorflow::TensorShapeProto& tf_shape, + ngraph::PartialShape* ng_shape) { + std::vector dims; + for (int i = 0; i < tf_shape.dim_size(); i++) { + dims.push_back(tf_shape.dim(i).size()); + } + *ng_shape = ngraph::PartialShape(dims); + return Status::OK(); + } } // namespace ngraph_bridge } // namespace tensorflow diff --git a/ngraph/frontend/tensorflow/src/ngraph_conversions.h b/ngraph/frontend/tensorflow/src/ngraph_conversions.h index d04776fed091d1..b7f456b66f4c3f 100644 --- a/ngraph/frontend/tensorflow/src/ngraph_conversions.h +++ b/ngraph/frontend/tensorflow/src/ngraph_conversions.h @@ -33,6 +33,9 @@ namespace ngraph_bridge { Status TFDataTypeToNGraphElementType(DataType tf_dt, ngraph::element::Type* ng_et); + Status TFTensorShapeToNGraphShape(const ::tensorflow::TensorShapeProto& tf_shape, + ngraph::PartialShape* ng_shape); + template void Transpose(ngraph::Output& node) { static_assert(a < 4 && b < 4 && c < 4 && d < 4, diff --git a/ngraph/frontend/tensorflow/src/tensorflow.cpp b/ngraph/frontend/tensorflow/src/tensorflow.cpp index 4e26d094da1910..a4279355dbbead 100644 --- a/ngraph/frontend/tensorflow/src/tensorflow.cpp +++ b/ngraph/frontend/tensorflow/src/tensorflow.cpp @@ -33,7 +33,7 @@ std::shared_ptr ngraph::frontend::FrontEndTensorflow::convert std::cout << "[ INFO ] Model Parsed: " << fw_model.ParseFromIstream(&pb_stream) << std::endl; std::cout << "[ INFO ] Loaded model contains " << fw_model.node_size() << " nodes." << std::endl; std::shared_ptr f; - tensorflow::ngraph_bridge::Builder::TranslateGraph({}, {}, &fw_model, "here_should_be_a_graph_name", f); + std::cerr << "[ STATUS ] TranslateGraph return: " << tensorflow::ngraph_bridge::Builder::TranslateGraph({}, {}, &fw_model, "here_should_be_a_graph_name", f); //auto f = std::make_shared(ngraph::NodeVector{}, ngraph::ParameterVector{}); std::cerr << "[ ERROR ] Convetion functionality is not implemented; an empty function will be returned."; std::cerr << "[ INFO ] Resulting nGraph function contains " << f->get_ops().size() << " nodes." << std::endl; From 4ac4bf563db122abe4420236320d48bf5fbe4aa7 Mon Sep 17 00:00:00 2001 From: mbencer Date: Thu, 11 Mar 2021 12:02:28 +0100 Subject: [PATCH 059/116] introduce high-level api structs --- .../include/onnx_editor/editor.hpp | 3 ++ .../include/onnx_editor/editor_types.hpp | 41 +++++++++++++++++++ ngraph/frontend/onnx_editor/src/editor.cpp | 11 +++++ 3 files changed, 55 insertions(+) diff --git a/ngraph/frontend/onnx_editor/include/onnx_editor/editor.hpp b/ngraph/frontend/onnx_editor/include/onnx_editor/editor.hpp index af65485882835f..34e9f799e53eb5 100644 --- a/ngraph/frontend/onnx_editor/include/onnx_editor/editor.hpp +++ b/ngraph/frontend/onnx_editor/include/onnx_editor/editor.hpp @@ -122,6 +122,9 @@ namespace ngraph /// \param out_file_path A path to the file where the modified model should be dumped. void serialize(const std::string& out_file_path) const; + InputEdge to_input_edge(Node node, Input in); + OutputEdge to_output_edge(Node node, Output out); + private: const std::string m_model_path; diff --git a/ngraph/frontend/onnx_editor/include/onnx_editor/editor_types.hpp b/ngraph/frontend/onnx_editor/include/onnx_editor/editor_types.hpp index 80bf070ec2395e..3f00e6223ce0eb 100644 --- a/ngraph/frontend/onnx_editor/include/onnx_editor/editor_types.hpp +++ b/ngraph/frontend/onnx_editor/include/onnx_editor/editor_types.hpp @@ -72,5 +72,46 @@ namespace ngraph /// OutputEdge(5, "out1") /// OutputEdge(5, "out2") using OutputEdge = Edge; + struct Input + { + Input() = delete; + Input(std::string input_name) + : m_input_name{std::move(input_name)} + { + } + Input(int input_index) + : m_input_index{std::move(input_index)} + { + } + const std::string m_input_name = ""; + const int m_input_index = -1; + }; + struct Output + { + Output() = delete; + Output(std::string output_name) + : m_output_name{std::move(output_name)} + { + } + Output(int output_index) + : m_output_index{std::move(output_index)} + { + } + const std::string m_output_name = ""; + const int m_output_index = -1; + }; + + struct Node + { + Node(std::string output_name) + : m_output_name{std::move(output_name)} + { + } + Node(Output output) + : m_output_name{output.m_output_name} + { + } + const std::string m_output_name = ""; + }; } } diff --git a/ngraph/frontend/onnx_editor/src/editor.cpp b/ngraph/frontend/onnx_editor/src/editor.cpp index 359c274a072253..d38025ccb11434 100644 --- a/ngraph/frontend/onnx_editor/src/editor.cpp +++ b/ngraph/frontend/onnx_editor/src/editor.cpp @@ -25,6 +25,7 @@ #include "onnx_editor/editor.hpp" using namespace ngraph; +using namespace ngraph::onnx_editor; namespace { @@ -369,3 +370,13 @@ void onnx_editor::ONNXModelEditor::set_input_values( modify_initializer(*onnx_initializer, name, values, onnx_input); } } + +InputEdge onnx_editor::ONNXModelEditor::to_input_edge(Node node, Input in) +{ + return InputEdge{-1, ""}; +} + +OutputEdge onnx_editor::ONNXModelEditor::to_output_edge(Node node, Output out) +{ + return OutputEdge{-1, ""}; +} From 2f76de04d9a301f8d595014efa395b8ace376266 Mon Sep 17 00:00:00 2001 From: mbencer Date: Thu, 18 Mar 2021 17:53:26 +0100 Subject: [PATCH 060/116] added EdgeMapper --- .../include/onnx_editor/editor.hpp | 15 +++- .../include/onnx_editor/editor_types.hpp | 5 +- ngraph/frontend/onnx_editor/src/editor.cpp | 51 ++++++++++- .../subgraph__inception_head.prototxt | 6 +- ngraph/test/onnx/onnx_editor.cpp | 84 ++++++++++++++++++- 5 files changed, 149 insertions(+), 12 deletions(-) diff --git a/ngraph/frontend/onnx_editor/include/onnx_editor/editor.hpp b/ngraph/frontend/onnx_editor/include/onnx_editor/editor.hpp index 34e9f799e53eb5..2de240b6d9c043 100644 --- a/ngraph/frontend/onnx_editor/include/onnx_editor/editor.hpp +++ b/ngraph/frontend/onnx_editor/include/onnx_editor/editor.hpp @@ -37,6 +37,18 @@ namespace ngraph { namespace onnx_editor { + class EdgeMapper + { + public: + EdgeMapper(const std::multimap& node_name_to_index_map); + + InputEdge to_input_edge(Node node, Input in) const; + OutputEdge to_output_edge(Node node, Output out) const; + + private: + int find_index(std::vector keys) const; + std::multimap m_node_name_to_index; + }; /// \brief A class representing a set of utilities allowing modification of an ONNX model /// /// \note This class can be used to modify an ONNX model before it gets translated to @@ -122,8 +134,7 @@ namespace ngraph /// \param out_file_path A path to the file where the modified model should be dumped. void serialize(const std::string& out_file_path) const; - InputEdge to_input_edge(Node node, Input in); - OutputEdge to_output_edge(Node node, Output out); + EdgeMapper create_edge_mapper() const; private: const std::string m_model_path; diff --git a/ngraph/frontend/onnx_editor/include/onnx_editor/editor_types.hpp b/ngraph/frontend/onnx_editor/include/onnx_editor/editor_types.hpp index 3f00e6223ce0eb..ce155de32fe17d 100644 --- a/ngraph/frontend/onnx_editor/include/onnx_editor/editor_types.hpp +++ b/ngraph/frontend/onnx_editor/include/onnx_editor/editor_types.hpp @@ -103,14 +103,15 @@ namespace ngraph struct Node { - Node(std::string output_name) - : m_output_name{std::move(output_name)} + Node(std::string node_name) + : m_node_name{std::move(node_name)} { } Node(Output output) : m_output_name{output.m_output_name} { } + const std::string m_node_name = ""; const std::string m_output_name = ""; }; } diff --git a/ngraph/frontend/onnx_editor/src/editor.cpp b/ngraph/frontend/onnx_editor/src/editor.cpp index d38025ccb11434..967e794937fa80 100644 --- a/ngraph/frontend/onnx_editor/src/editor.cpp +++ b/ngraph/frontend/onnx_editor/src/editor.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include "detail/subgraph_extraction.hpp" #include "ngraph/log.hpp" @@ -371,12 +372,56 @@ void onnx_editor::ONNXModelEditor::set_input_values( } } -InputEdge onnx_editor::ONNXModelEditor::to_input_edge(Node node, Input in) +EdgeMapper onnx_editor::ONNXModelEditor::create_edge_mapper() const { - return InputEdge{-1, ""}; + int topological_index = 0; + std::multimap node_name_to_index_map; + for (const auto& node_proto : m_pimpl->m_model_proto.graph().node()) + { + for (const auto& out_name : node_proto.output()) + { + // node output name is unique + node_name_to_index_map.emplace(out_name, topological_index); + std::cout << "output: " << topological_index << ", " << out_name << "\n"; + } + if (!node_proto.name().empty()) + { + // node name can identify node, but it can be ambiguous + node_name_to_index_map.emplace(node_proto.name(), topological_index); + std::cout << "node_name: " << node_proto.name() << "\n"; + } + ++topological_index; + } + return EdgeMapper{node_name_to_index_map}; +} + +onnx_editor::EdgeMapper::EdgeMapper(const std::multimap& node_name_to_index_map) + : m_node_name_to_index{node_name_to_index_map} +{ +} + +int onnx_editor::EdgeMapper::find_index(std::vector keys) const +{ + for (const auto& key : keys) + { + const auto& index_iter = m_node_name_to_index.find(key); + if (index_iter != std::end(m_node_name_to_index)) + { + return index_iter->second; + } + } + // TODO: throw exception + return -1; +}; + +InputEdge onnx_editor::EdgeMapper::to_input_edge(Node node, Input in) const +{ + // identification can be both based on node name and output name + const auto node_index = find_index({node.m_node_name, node.m_output_name}); + return InputEdge{node_index, in.m_input_name}; } -OutputEdge onnx_editor::ONNXModelEditor::to_output_edge(Node node, Output out) +OutputEdge onnx_editor::EdgeMapper::to_output_edge(Node node, Output out) const { return OutputEdge{-1, ""}; } diff --git a/ngraph/test/models/onnx/model_editor/subgraph__inception_head.prototxt b/ngraph/test/models/onnx/model_editor/subgraph__inception_head.prototxt index f41a21428ab232..1b024156b0e825 100644 --- a/ngraph/test/models/onnx/model_editor/subgraph__inception_head.prototxt +++ b/ngraph/test/models/onnx/model_editor/subgraph__inception_head.prototxt @@ -8,7 +8,7 @@ graph { input: "conv1/7x7_s2_w_0" input: "conv1/7x7_s2_b_0" output: "conv1/7x7_s2_1" - name: "" + name: "conv1" op_type: "Conv" attribute { name: "strides" @@ -34,13 +34,13 @@ graph { node { input: "conv1/7x7_s2_1" output: "conv1/7x7_s2_2" - name: "" + name: "relu1" op_type: "Relu" } node { input: "conv1/7x7_s2_2" output: "pool1/3x3_s2_1" - name: "" + name: "maxpool1" op_type: "MaxPool" attribute { name: "strides" diff --git a/ngraph/test/onnx/onnx_editor.cpp b/ngraph/test/onnx/onnx_editor.cpp index aa1ec04d076941..4f2b19c27d44f5 100644 --- a/ngraph/test/onnx/onnx_editor.cpp +++ b/ngraph/test/onnx/onnx_editor.cpp @@ -33,8 +33,8 @@ NGRAPH_SUPPRESS_DEPRECATED_START using namespace ngraph; -using namespace ngraph::onnx_import; -using namespace ngraph::onnx_editor; +// TODO it should be removed +using namespace onnx_editor; using namespace ngraph::test; static std::string s_manifest = "${MANIFEST}"; @@ -688,6 +688,86 @@ NGRAPH_TEST(onnx_editor, subgraph__inputs_getter) EXPECT_EQ(editor.model_inputs(), (std::vector{"conv1/7x7_s2_2:conv1/7x7_s2_1"})); } +NGRAPH_TEST(onnx_editor, editor_api_select_input_edge_by_output_name_and_input_name) +{ + ONNXModelEditor editor{file_util::path_join( + SERIALIZED_ZOO, "onnx/model_editor/subgraph__inception_head.prototxt")}; + const auto edge_mapper = editor.create_edge_mapper(); + + const InputEdge edge = + edge_mapper.to_input_edge(onnx_editor::Node{onnx_editor::Output{"conv1/7x7_s2_2"}}, + onnx_editor::Input{"conv1/7x7_s2_1"}); + EXPECT_EQ(edge.m_node_idx, 1); + EXPECT_EQ(edge.m_tensor_name, "conv1/7x7_s2_1"); + + const InputEdge edge2 = edge_mapper.to_input_edge( + onnx_editor::Node{onnx_editor::Output{"conv1/7x7_s2_1"}}, onnx_editor::Input{"data_0"}); + EXPECT_EQ(edge2.m_node_idx, 0); + EXPECT_EQ(edge2.m_tensor_name, "data_0"); +} +/* +NGRAPH_TEST(onnx_editor, editor_api_select_input_edge_by_output_name_and_input_index) +{ + ONNXModelEditor editor{file_util::path_join( + SERIALIZED_ZOO, "onnx/model_editor/subgraph__inception_head.prototxt")}; + const auto edge_mapper = editor.create_edge_mapper(); + + const InputEdge edge = +edge_mapper.to_input_edge(onnx_editor::Node{onnx_editor::Output{"conv1/7x7_s2_2"}}, +onnx_editor::Input{0}); EXPECT_EQ(edge.m_node_idx, 1); EXPECT_EQ(edge.m_tensor_name, +"conv1/7x7_s2_1"); + + const InputEdge edge2 = +edge_mapper.to_input_edge(onnx_editor::Node{onnx_editor::Output{"conv1/7x7_s2_1"}}, +onnx_editor::Input{0}); EXPECT_EQ(edge2.m_node_idx, 0); EXPECT_EQ(edge2.m_tensor_name, "data_0"); +} +*/ +NGRAPH_TEST(onnx_editor, editor_api_select_input_edge_by_node_name_and_input_name) +{ + ONNXModelEditor editor{file_util::path_join( + SERIALIZED_ZOO, "onnx/model_editor/subgraph__inception_head.prototxt")}; + const auto edge_mapper = editor.create_edge_mapper(); + + const InputEdge edge = + edge_mapper.to_input_edge(onnx_editor::Node{"relu1"}, onnx_editor::Input{"conv1/7x7_s2_1"}); + EXPECT_EQ(edge.m_node_idx, 1); + EXPECT_EQ(edge.m_tensor_name, "conv1/7x7_s2_1"); + + const InputEdge edge2 = edge_mapper.to_input_edge( + onnx_editor::Node{onnx_editor::Output{"conv1"}}, onnx_editor::Input{"data_0"}); + EXPECT_EQ(edge2.m_node_idx, 0); + EXPECT_EQ(edge2.m_tensor_name, "data_0"); +} + +// High level API tests +NGRAPH_TEST(onnx_editor, xxx_subgraph__linear_model_head_cut) +{ + ONNXModelEditor editor{file_util::path_join( + SERIALIZED_ZOO, "onnx/model_editor/subgraph__inception_head.prototxt")}; + const auto edge_mapper = editor.create_edge_mapper(); + + // define node by output name + // const InputEdge edge = + // edge_mapper.to_input_edge(onnx_editor::Node{onnx_editor::Output{"conv1/7x7_s2_2"}}, + // onnx_editor::Input{"conv1/7x7_s2_1"}); + /*editor.cut_graph_fragment({{edge}}, {}); + + const auto ref_model = file_util::path_join( + SERIALIZED_ZOO, "onnx/model_editor/reference/subgraph__linear_model_head_cut.prototxt"); + + const auto result = compare_onnx_models(editor.model_string(), ref_model); + + EXPECT_TRUE(result.is_ok) << result.error_message;*/ +} + +// combinations to test: +// - to input/output edge +// - node by name/ by output name +// - input/output by name/ by index +// - 2 heads +// - const network +// - node names dublicates! + using TestEngine = test::INTERPRETER_Engine; NGRAPH_TEST(onnx_editor, values__append_one_initializer) From 96a16765b77616b5d6de2c976f843651c5822ae2 Mon Sep 17 00:00:00 2001 From: mbencer Date: Mon, 22 Mar 2021 14:37:46 +0100 Subject: [PATCH 061/116] Added handling OutputEdge --- .../include/onnx_editor/editor.hpp | 8 +- .../include/onnx_editor/editor_types.hpp | 1 + ngraph/frontend/onnx_editor/src/editor.cpp | 84 +++++++++--- .../subgraph_extraction_tests.prototxt | 2 + ngraph/test/onnx/onnx_editor.cpp | 121 ++++++++++++++++-- 5 files changed, 184 insertions(+), 32 deletions(-) diff --git a/ngraph/frontend/onnx_editor/include/onnx_editor/editor.hpp b/ngraph/frontend/onnx_editor/include/onnx_editor/editor.hpp index 2de240b6d9c043..75893f498823fd 100644 --- a/ngraph/frontend/onnx_editor/include/onnx_editor/editor.hpp +++ b/ngraph/frontend/onnx_editor/include/onnx_editor/editor.hpp @@ -31,6 +31,7 @@ namespace ONNX_NAMESPACE // forward declaration to avoid the necessity of include paths setting in components // that don't directly depend on the ONNX library class ModelProto; + class GraphProto; } // namespace ONNX_NAMESPACE namespace ngraph @@ -40,13 +41,16 @@ namespace ngraph class EdgeMapper { public: - EdgeMapper(const std::multimap& node_name_to_index_map); + EdgeMapper(const ONNX_NAMESPACE::GraphProto& graph_proto); InputEdge to_input_edge(Node node, Input in) const; OutputEdge to_output_edge(Node node, Output out) const; private: - int find_index(std::vector keys) const; + const ONNX_NAMESPACE::GraphProto* m_graph_proto; + int find_node_index(std::vector keys) const; + std::string find_node_input_name(int node_index, int input_index) const; + std::string find_node_output_name(int node_index, int output_index) const; std::multimap m_node_name_to_index; }; /// \brief A class representing a set of utilities allowing modification of an ONNX model diff --git a/ngraph/frontend/onnx_editor/include/onnx_editor/editor_types.hpp b/ngraph/frontend/onnx_editor/include/onnx_editor/editor_types.hpp index ce155de32fe17d..f196cbe7a54c4d 100644 --- a/ngraph/frontend/onnx_editor/include/onnx_editor/editor_types.hpp +++ b/ngraph/frontend/onnx_editor/include/onnx_editor/editor_types.hpp @@ -72,6 +72,7 @@ namespace ngraph /// OutputEdge(5, "out1") /// OutputEdge(5, "out2") using OutputEdge = Edge; + // TODO: REmove m_ prefix struct Input { Input() = delete; diff --git a/ngraph/frontend/onnx_editor/src/editor.cpp b/ngraph/frontend/onnx_editor/src/editor.cpp index 967e794937fa80..3e4e70e881b5dd 100644 --- a/ngraph/frontend/onnx_editor/src/editor.cpp +++ b/ngraph/frontend/onnx_editor/src/editor.cpp @@ -20,6 +20,7 @@ #include #include "detail/subgraph_extraction.hpp" +#include "ngraph/except.hpp" #include "ngraph/log.hpp" #include "onnx_common/parser.hpp" #include "onnx_common/utils.hpp" @@ -373,55 +374,104 @@ void onnx_editor::ONNXModelEditor::set_input_values( } EdgeMapper onnx_editor::ONNXModelEditor::create_edge_mapper() const +{ + return EdgeMapper{m_pimpl->m_model_proto.graph()}; +} + +onnx_editor::EdgeMapper::EdgeMapper(const ONNX_NAMESPACE::GraphProto& graph_proto) + : m_graph_proto{&graph_proto} { int topological_index = 0; - std::multimap node_name_to_index_map; - for (const auto& node_proto : m_pimpl->m_model_proto.graph().node()) + for (const auto& node_proto : graph_proto.node()) { for (const auto& out_name : node_proto.output()) { // node output name is unique - node_name_to_index_map.emplace(out_name, topological_index); + m_node_name_to_index.emplace(out_name, topological_index); std::cout << "output: " << topological_index << ", " << out_name << "\n"; } if (!node_proto.name().empty()) { // node name can identify node, but it can be ambiguous - node_name_to_index_map.emplace(node_proto.name(), topological_index); - std::cout << "node_name: " << node_proto.name() << "\n"; + m_node_name_to_index.emplace(node_proto.name(), topological_index); + std::cout << "node_name: " << topological_index << ", " << node_proto.name() << "\n"; } ++topological_index; } - return EdgeMapper{node_name_to_index_map}; -} - -onnx_editor::EdgeMapper::EdgeMapper(const std::multimap& node_name_to_index_map) - : m_node_name_to_index{node_name_to_index_map} -{ } -int onnx_editor::EdgeMapper::find_index(std::vector keys) const +int onnx_editor::EdgeMapper::find_node_index(std::vector keys) const { for (const auto& key : keys) { + std::cout << "key: " << key << "\n"; const auto& index_iter = m_node_name_to_index.find(key); if (index_iter != std::end(m_node_name_to_index)) { return index_iter->second; } } - // TODO: throw exception - return -1; + throw ngraph_error("Node with given name was not found"); }; +std::string onnx_editor::EdgeMapper::find_node_output_name(int node_index, int output_index) const +{ + std::cout << "node_index: " << node_index << ", output_index: " << output_index << "\n"; + if (m_graph_proto == nullptr) + { + throw ngraph_error("Edge mapper should be used in ONNXEditor scope"); + } + const auto& node = m_graph_proto->node(node_index); + const auto& output_name = node.output(output_index); + return output_name; +} + +std::string onnx_editor::EdgeMapper::find_node_input_name(int node_index, int input_index) const +{ + std::cout << "node_index: " << node_index << ", input_index: " << input_index << "\n"; + if (m_graph_proto == nullptr) + { + throw ngraph_error("Edge mapper should be used in ONNXEditor scope"); + } + const auto& node = m_graph_proto->node(node_index); + const auto& input_name = node.input(input_index); + return input_name; +} + InputEdge onnx_editor::EdgeMapper::to_input_edge(Node node, Input in) const { // identification can be both based on node name and output name - const auto node_index = find_index({node.m_node_name, node.m_output_name}); - return InputEdge{node_index, in.m_input_name}; + const auto node_index = find_node_index({node.m_node_name, node.m_output_name}); + if (!in.m_input_name.empty()) + { + return InputEdge{node_index, in.m_input_name}; + } + else if (in.m_input_index != -1) // input index is set + { + const auto& input_name = find_node_input_name(node_index, in.m_input_index); + return InputEdge{node_index, input_name}; + } + else + { + throw ngraph_error("Not enough information to determine input edge"); + } } OutputEdge onnx_editor::EdgeMapper::to_output_edge(Node node, Output out) const { - return OutputEdge{-1, ""}; + // identification can be both based on node name and output name + const auto node_index = find_node_index({node.m_node_name, node.m_output_name}); + if (!out.m_output_name.empty()) + { + return OutputEdge{node_index, out.m_output_name}; + } + else if (out.m_output_index != -1) // output index is set + { + const auto& output_name = find_node_output_name(node_index, out.m_output_index); + return OutputEdge{node_index, output_name}; + } + else + { + throw ngraph_error("Not enough information to determine output edge"); + } } diff --git a/ngraph/test/models/onnx/model_editor/subgraph_extraction_tests.prototxt b/ngraph/test/models/onnx/model_editor/subgraph_extraction_tests.prototxt index 9e79acc9cf9411..57ceee32f8cb22 100644 --- a/ngraph/test/models/onnx/model_editor/subgraph_extraction_tests.prototxt +++ b/ngraph/test/models/onnx/model_editor/subgraph_extraction_tests.prototxt @@ -5,6 +5,7 @@ graph { input: "in1" output: "relu1" op_type: "Relu" + name: "relu1_name" } node { input: "relu1" @@ -40,6 +41,7 @@ graph { i: 1 type: INT } + name: "split_name" } node { input: "relu1" diff --git a/ngraph/test/onnx/onnx_editor.cpp b/ngraph/test/onnx/onnx_editor.cpp index 4f2b19c27d44f5..3a4a619726415f 100644 --- a/ngraph/test/onnx/onnx_editor.cpp +++ b/ngraph/test/onnx/onnx_editor.cpp @@ -688,6 +688,8 @@ NGRAPH_TEST(onnx_editor, subgraph__inputs_getter) EXPECT_EQ(editor.model_inputs(), (std::vector{"conv1/7x7_s2_2:conv1/7x7_s2_1"})); } +// HIGHT LEVEL API TESTS +// INPUT EDGES TEST NGRAPH_TEST(onnx_editor, editor_api_select_input_edge_by_output_name_and_input_name) { ONNXModelEditor editor{file_util::path_join( @@ -705,23 +707,29 @@ NGRAPH_TEST(onnx_editor, editor_api_select_input_edge_by_output_name_and_input_n EXPECT_EQ(edge2.m_node_idx, 0); EXPECT_EQ(edge2.m_tensor_name, "data_0"); } -/* + NGRAPH_TEST(onnx_editor, editor_api_select_input_edge_by_output_name_and_input_index) { ONNXModelEditor editor{file_util::path_join( SERIALIZED_ZOO, "onnx/model_editor/subgraph__inception_head.prototxt")}; const auto edge_mapper = editor.create_edge_mapper(); - const InputEdge edge = -edge_mapper.to_input_edge(onnx_editor::Node{onnx_editor::Output{"conv1/7x7_s2_2"}}, -onnx_editor::Input{0}); EXPECT_EQ(edge.m_node_idx, 1); EXPECT_EQ(edge.m_tensor_name, -"conv1/7x7_s2_1"); + const InputEdge edge = edge_mapper.to_input_edge( + onnx_editor::Node{onnx_editor::Output{"conv1/7x7_s2_2"}}, onnx_editor::Input{0}); + EXPECT_EQ(edge.m_node_idx, 1); + EXPECT_EQ(edge.m_tensor_name, "conv1/7x7_s2_1"); - const InputEdge edge2 = -edge_mapper.to_input_edge(onnx_editor::Node{onnx_editor::Output{"conv1/7x7_s2_1"}}, -onnx_editor::Input{0}); EXPECT_EQ(edge2.m_node_idx, 0); EXPECT_EQ(edge2.m_tensor_name, "data_0"); + const InputEdge edge2 = edge_mapper.to_input_edge( + onnx_editor::Node{onnx_editor::Output{"conv1/7x7_s2_1"}}, onnx_editor::Input{1}); + EXPECT_EQ(edge2.m_node_idx, 0); + EXPECT_EQ(edge2.m_tensor_name, "conv1/7x7_s2_w_0"); + + const InputEdge edge3 = edge_mapper.to_input_edge( + onnx_editor::Node{onnx_editor::Output{"conv1/7x7_s2_1"}}, onnx_editor::Input{2}); + EXPECT_EQ(edge3.m_node_idx, 0); + EXPECT_EQ(edge3.m_tensor_name, "conv1/7x7_s2_b_0"); } -*/ + NGRAPH_TEST(onnx_editor, editor_api_select_input_edge_by_node_name_and_input_name) { ONNXModelEditor editor{file_util::path_join( @@ -733,13 +741,98 @@ NGRAPH_TEST(onnx_editor, editor_api_select_input_edge_by_node_name_and_input_nam EXPECT_EQ(edge.m_node_idx, 1); EXPECT_EQ(edge.m_tensor_name, "conv1/7x7_s2_1"); - const InputEdge edge2 = edge_mapper.to_input_edge( - onnx_editor::Node{onnx_editor::Output{"conv1"}}, onnx_editor::Input{"data_0"}); + const InputEdge edge2 = edge_mapper.to_input_edge(onnx_editor::Node{"conv1"}, + onnx_editor::Input{"conv1/7x7_s2_w_0"}); EXPECT_EQ(edge2.m_node_idx, 0); - EXPECT_EQ(edge2.m_tensor_name, "data_0"); + EXPECT_EQ(edge2.m_tensor_name, "conv1/7x7_s2_w_0"); +} + +NGRAPH_TEST(onnx_editor, editor_api_select_input_edge_by_node_name_and_input_index) +{ + ONNXModelEditor editor{file_util::path_join( + SERIALIZED_ZOO, "onnx/model_editor/subgraph_extraction_tests.prototxt")}; + const auto edge_mapper = editor.create_edge_mapper(); + + const InputEdge edge = + edge_mapper.to_input_edge(onnx_editor::Node{"relu1_name"}, onnx_editor::Input{0}); + EXPECT_EQ(edge.m_node_idx, 0); + EXPECT_EQ(edge.m_tensor_name, "in1"); + + const InputEdge edge2 = + edge_mapper.to_input_edge(onnx_editor::Node{"split_name"}, onnx_editor::Input{0}); + EXPECT_EQ(edge2.m_node_idx, 5); + EXPECT_EQ(edge2.m_tensor_name, "add2"); +} + +// OUTPUT EDGES TEST +NGRAPH_TEST(onnx_editor, editor_api_select_output_edge_by_output_name_and_input_name) +{ + ONNXModelEditor editor{file_util::path_join( + SERIALIZED_ZOO, "onnx/model_editor/subgraph_extraction_tests.prototxt")}; + const auto edge_mapper = editor.create_edge_mapper(); + + const OutputEdge edge = edge_mapper.to_output_edge( + onnx_editor::Node{onnx_editor::Output{"mul2"}}, onnx_editor::Output{"mul2"}); + EXPECT_EQ(edge.m_node_idx, 4); + EXPECT_EQ(edge.m_tensor_name, "mul2"); + + const OutputEdge edge2 = edge_mapper.to_output_edge( + onnx_editor::Node{onnx_editor::Output{"split1"}}, onnx_editor::Output{"split2"}); + EXPECT_EQ(edge2.m_node_idx, 5); + EXPECT_EQ(edge2.m_tensor_name, "split2"); +} + +NGRAPH_TEST(onnx_editor, editor_api_select_output_edge_by_output_name_and_output_index) +{ + ONNXModelEditor editor{file_util::path_join( + SERIALIZED_ZOO, "onnx/model_editor/subgraph_extraction_tests.prototxt")}; + const auto edge_mapper = editor.create_edge_mapper(); + + const OutputEdge edge = edge_mapper.to_output_edge( + onnx_editor::Node{onnx_editor::Output{"add2"}}, onnx_editor::Output{0}); + EXPECT_EQ(edge.m_node_idx, 3); + EXPECT_EQ(edge.m_tensor_name, "add2"); + + const OutputEdge edge2 = edge_mapper.to_output_edge( + onnx_editor::Node{onnx_editor::Output{"split1"}}, onnx_editor::Output{1}); + EXPECT_EQ(edge2.m_node_idx, 5); + EXPECT_EQ(edge2.m_tensor_name, "split2"); +} + +NGRAPH_TEST(onnx_editor, editor_api_select_output_edge_by_node_name_and_output_name) +{ + ONNXModelEditor editor{file_util::path_join( + SERIALIZED_ZOO, "onnx/model_editor/subgraph_extraction_tests.prototxt")}; + const auto edge_mapper = editor.create_edge_mapper(); + + const OutputEdge edge = + edge_mapper.to_output_edge(onnx_editor::Node{"relu1_name"}, onnx_editor::Output{"relu1"}); + EXPECT_EQ(edge.m_node_idx, 0); + EXPECT_EQ(edge.m_tensor_name, "relu1"); + + const OutputEdge edge2 = + edge_mapper.to_output_edge(onnx_editor::Node{"split_name"}, onnx_editor::Output{"split2"}); + EXPECT_EQ(edge2.m_node_idx, 5); + EXPECT_EQ(edge2.m_tensor_name, "split2"); +} + +NGRAPH_TEST(onnx_editor, editor_api_select_output_edge_by_node_name_and_output_index) +{ + ONNXModelEditor editor{file_util::path_join( + SERIALIZED_ZOO, "onnx/model_editor/subgraph_extraction_tests.prototxt")}; + const auto edge_mapper = editor.create_edge_mapper(); + + const OutputEdge edge = + edge_mapper.to_output_edge(onnx_editor::Node{"relu1_name"}, onnx_editor::Output{0}); + EXPECT_EQ(edge.m_node_idx, 0); + EXPECT_EQ(edge.m_tensor_name, "relu1"); + + const OutputEdge edge2 = + edge_mapper.to_output_edge(onnx_editor::Node{"split_name"}, onnx_editor::Output{1}); + EXPECT_EQ(edge2.m_node_idx, 5); + EXPECT_EQ(edge2.m_tensor_name, "split2"); } -// High level API tests NGRAPH_TEST(onnx_editor, xxx_subgraph__linear_model_head_cut) { ONNXModelEditor editor{file_util::path_join( @@ -767,6 +860,8 @@ NGRAPH_TEST(onnx_editor, xxx_subgraph__linear_model_head_cut) // - 2 heads // - const network // - node names dublicates! +// edge mapper should share state ?? +// check mapper lifestyle using TestEngine = test::INTERPRETER_Engine; From cb7a09b4088f9d3073160b85268c92f5f7373d03 Mon Sep 17 00:00:00 2001 From: mbencer Date: Mon, 22 Mar 2021 16:33:10 +0100 Subject: [PATCH 062/116] error handling + code refactor --- .../include/onnx_editor/editor.hpp | 10 +-- ngraph/frontend/onnx_editor/src/editor.cpp | 62 ++++++++++++------- .../subgraph_extraction_tests_2.prototxt | 2 + ngraph/test/onnx/onnx_editor.cpp | 35 +++++++++-- 4 files changed, 79 insertions(+), 30 deletions(-) diff --git a/ngraph/frontend/onnx_editor/include/onnx_editor/editor.hpp b/ngraph/frontend/onnx_editor/include/onnx_editor/editor.hpp index 75893f498823fd..e41ea52167d8be 100644 --- a/ngraph/frontend/onnx_editor/include/onnx_editor/editor.hpp +++ b/ngraph/frontend/onnx_editor/include/onnx_editor/editor.hpp @@ -47,10 +47,12 @@ namespace ngraph OutputEdge to_output_edge(Node node, Output out) const; private: - const ONNX_NAMESPACE::GraphProto* m_graph_proto; - int find_node_index(std::vector keys) const; - std::string find_node_input_name(int node_index, int input_index) const; - std::string find_node_output_name(int node_index, int output_index) const; + int find_node_index(const std::string& node_name, const std::string& output_name) const; + std::string get_node_input_name(int node_index, int input_index) const; + std::string get_node_output_name(int node_index, int output_index) const; + + std::vector> m_node_inputs; + std::vector> m_node_outputs; std::multimap m_node_name_to_index; }; /// \brief A class representing a set of utilities allowing modification of an ONNX model diff --git a/ngraph/frontend/onnx_editor/src/editor.cpp b/ngraph/frontend/onnx_editor/src/editor.cpp index 3e4e70e881b5dd..1aa8729ca7d542 100644 --- a/ngraph/frontend/onnx_editor/src/editor.cpp +++ b/ngraph/frontend/onnx_editor/src/editor.cpp @@ -379,17 +379,24 @@ EdgeMapper onnx_editor::ONNXModelEditor::create_edge_mapper() const } onnx_editor::EdgeMapper::EdgeMapper(const ONNX_NAMESPACE::GraphProto& graph_proto) - : m_graph_proto{&graph_proto} { int topological_index = 0; + m_node_inputs.resize(graph_proto.node().size()); + m_node_outputs.resize(graph_proto.node().size()); for (const auto& node_proto : graph_proto.node()) { for (const auto& out_name : node_proto.output()) { // node output name is unique m_node_name_to_index.emplace(out_name, topological_index); + m_node_outputs[topological_index].push_back(out_name); std::cout << "output: " << topological_index << ", " << out_name << "\n"; } + for (const auto& in_name : node_proto.input()) + { + std::cout << "in_name: " << topological_index << ", " << in_name << "\n"; + m_node_inputs[topological_index].push_back(in_name); + } if (!node_proto.name().empty()) { // node name can identify node, but it can be ambiguous @@ -400,55 +407,68 @@ onnx_editor::EdgeMapper::EdgeMapper(const ONNX_NAMESPACE::GraphProto& graph_prot } } -int onnx_editor::EdgeMapper::find_node_index(std::vector keys) const +int onnx_editor::EdgeMapper::find_node_index(const std::string& node_name, + const std::string& output_name) const { - for (const auto& key : keys) + for (const auto& key : {node_name, output_name}) { - std::cout << "key: " << key << "\n"; + if (key.empty()) + { + continue; + } const auto& index_iter = m_node_name_to_index.find(key); if (index_iter != std::end(m_node_name_to_index)) { return index_iter->second; } } - throw ngraph_error("Node with given name was not found"); + throw ngraph_error("Node with name: " + node_name + " and output_name: " + output_name + + " was not found"); }; -std::string onnx_editor::EdgeMapper::find_node_output_name(int node_index, int output_index) const +std::string onnx_editor::EdgeMapper::get_node_output_name(int node_index, int output_index) const { - std::cout << "node_index: " << node_index << ", output_index: " << output_index << "\n"; - if (m_graph_proto == nullptr) + if (node_index >= m_node_outputs.size()) { - throw ngraph_error("Edge mapper should be used in ONNXEditor scope"); + throw ngraph_error("Node with index: " + std::to_string(node_index) + + "is out of scope outputs list"); } - const auto& node = m_graph_proto->node(node_index); - const auto& output_name = node.output(output_index); + if (output_index >= m_node_outputs[node_index].size()) + { + throw ngraph_error("Node with index: " + std::to_string(node_index) + + " has not output with index: " + std::to_string(output_index)); + } + const auto output_name = m_node_outputs[node_index][output_index]; return output_name; } -std::string onnx_editor::EdgeMapper::find_node_input_name(int node_index, int input_index) const +std::string onnx_editor::EdgeMapper::get_node_input_name(int node_index, int input_index) const { - std::cout << "node_index: " << node_index << ", input_index: " << input_index << "\n"; - if (m_graph_proto == nullptr) + if (node_index >= m_node_inputs.size()) + { + throw ngraph_error("Node with index: " + std::to_string(node_index) + + "is out of scope inputs list"); + } + if (input_index >= m_node_inputs[node_index].size()) { - throw ngraph_error("Edge mapper should be used in ONNXEditor scope"); + throw ngraph_error("Node with index: " + std::to_string(node_index) + + " has not input with index: " + std::to_string(input_index)); } - const auto& node = m_graph_proto->node(node_index); - const auto& input_name = node.input(input_index); + const auto input_name = m_node_inputs[node_index][input_index]; return input_name; } InputEdge onnx_editor::EdgeMapper::to_input_edge(Node node, Input in) const { // identification can be both based on node name and output name - const auto node_index = find_node_index({node.m_node_name, node.m_output_name}); + const auto node_index = find_node_index(node.m_node_name, node.m_output_name); if (!in.m_input_name.empty()) { return InputEdge{node_index, in.m_input_name}; } else if (in.m_input_index != -1) // input index is set { - const auto& input_name = find_node_input_name(node_index, in.m_input_index); + const auto& input_name = get_node_input_name(node_index, in.m_input_index); return InputEdge{node_index, input_name}; } else @@ -460,14 +480,14 @@ InputEdge onnx_editor::EdgeMapper::to_input_edge(Node node, Input in) const OutputEdge onnx_editor::EdgeMapper::to_output_edge(Node node, Output out) const { // identification can be both based on node name and output name - const auto node_index = find_node_index({node.m_node_name, node.m_output_name}); + const auto node_index = find_node_index(node.m_node_name, node.m_output_name); if (!out.m_output_name.empty()) { return OutputEdge{node_index, out.m_output_name}; } else if (out.m_output_index != -1) // output index is set { - const auto& output_name = find_node_output_name(node_index, out.m_output_index); + const auto& output_name = get_node_output_name(node_index, out.m_output_index); return OutputEdge{node_index, output_name}; } else diff --git a/ngraph/test/models/onnx/model_editor/subgraph_extraction_tests_2.prototxt b/ngraph/test/models/onnx/model_editor/subgraph_extraction_tests_2.prototxt index 76d8587d9e8cb2..7982b52d1bc78a 100644 --- a/ngraph/test/models/onnx/model_editor/subgraph_extraction_tests_2.prototxt +++ b/ngraph/test/models/onnx/model_editor/subgraph_extraction_tests_2.prototxt @@ -20,12 +20,14 @@ graph { input: "in2" output: "relu4" op_type: "Relu" + name: "relu4_name" } node { input: "relu1" input: "relu2" output: "add1" op_type: "Add" + name: "add1_name" } node { input: "relu2" diff --git a/ngraph/test/onnx/onnx_editor.cpp b/ngraph/test/onnx/onnx_editor.cpp index 3a4a619726415f..cc3a69f1dcc677 100644 --- a/ngraph/test/onnx/onnx_editor.cpp +++ b/ngraph/test/onnx/onnx_editor.cpp @@ -797,6 +797,11 @@ NGRAPH_TEST(onnx_editor, editor_api_select_output_edge_by_output_name_and_output onnx_editor::Node{onnx_editor::Output{"split1"}}, onnx_editor::Output{1}); EXPECT_EQ(edge2.m_node_idx, 5); EXPECT_EQ(edge2.m_tensor_name, "split2"); + + const OutputEdge edge3 = edge_mapper.to_output_edge( + onnx_editor::Node{onnx_editor::Output{"split2"}}, onnx_editor::Output{0}); + EXPECT_EQ(edge3.m_node_idx, 5); + EXPECT_EQ(edge3.m_tensor_name, "split1"); } NGRAPH_TEST(onnx_editor, editor_api_select_output_edge_by_node_name_and_output_name) @@ -833,6 +838,28 @@ NGRAPH_TEST(onnx_editor, editor_api_select_output_edge_by_node_name_and_output_i EXPECT_EQ(edge2.m_tensor_name, "split2"); } +NGRAPH_TEST(onnx_editor, editor_api_select_edge_const_network) +{ + ONNXModelEditor editor{file_util::path_join( + SERIALIZED_ZOO, "onnx/model_editor/subgraph_extraction_tests_2.prototxt")}; + const auto edge_mapper = editor.create_edge_mapper(); + + const InputEdge edge = edge_mapper.to_input_edge( + onnx_editor::Node{onnx_editor::Output{"relu4"}}, onnx_editor::Input{0}); + EXPECT_EQ(edge.m_node_idx, 3); + EXPECT_EQ(edge.m_tensor_name, "in2"); + + const OutputEdge edge2 = + edge_mapper.to_output_edge(onnx_editor::Node{"relu4_name"}, onnx_editor::Output{0}); + EXPECT_EQ(edge2.m_node_idx, 3); + EXPECT_EQ(edge2.m_tensor_name, "relu4"); + + const OutputEdge edge3 = + edge_mapper.to_output_edge(onnx_editor::Node{"add1_name"}, onnx_editor::Output{0}); + EXPECT_EQ(edge3.m_node_idx, 4); + EXPECT_EQ(edge3.m_tensor_name, "add1"); +} + NGRAPH_TEST(onnx_editor, xxx_subgraph__linear_model_head_cut) { ONNXModelEditor editor{file_util::path_join( @@ -854,14 +881,12 @@ NGRAPH_TEST(onnx_editor, xxx_subgraph__linear_model_head_cut) } // combinations to test: -// - to input/output edge -// - node by name/ by output name -// - input/output by name/ by index -// - 2 heads -// - const network // - node names dublicates! // edge mapper should share state ?? // check mapper lifestyle +// complete test with cutter +// Node with given identifier was not found +// input/output index exception using TestEngine = test::INTERPRETER_Engine; From d4029864c9b53c69d5cb3a0726f4a8f383b3a4ef Mon Sep 17 00:00:00 2001 From: mbencer Date: Mon, 22 Mar 2021 17:30:06 +0100 Subject: [PATCH 063/116] Error handling + using with model cutter tests --- ngraph/frontend/onnx_editor/src/editor.cpp | 3 +- ngraph/test/onnx/onnx_editor.cpp | 92 ++++++++++++++++++---- 2 files changed, 78 insertions(+), 17 deletions(-) diff --git a/ngraph/frontend/onnx_editor/src/editor.cpp b/ngraph/frontend/onnx_editor/src/editor.cpp index 1aa8729ca7d542..62daa788085cce 100644 --- a/ngraph/frontend/onnx_editor/src/editor.cpp +++ b/ngraph/frontend/onnx_editor/src/editor.cpp @@ -422,7 +422,8 @@ int onnx_editor::EdgeMapper::find_node_index(const std::string& node_name, return index_iter->second; } } - throw ngraph_error("Node with name: " + node_name + " and output_name: " + output_name + + throw ngraph_error("Node with name: " + (node_name.empty() ? "not_given" : node_name) + + " and output_name: " + (output_name.empty() ? "not_given" : output_name) + " was not found"); }; diff --git a/ngraph/test/onnx/onnx_editor.cpp b/ngraph/test/onnx/onnx_editor.cpp index cc3a69f1dcc677..7691fb81de0c32 100644 --- a/ngraph/test/onnx/onnx_editor.cpp +++ b/ngraph/test/onnx/onnx_editor.cpp @@ -33,7 +33,6 @@ NGRAPH_SUPPRESS_DEPRECATED_START using namespace ngraph; -// TODO it should be removed using namespace onnx_editor; using namespace ngraph::test; @@ -860,33 +859,94 @@ NGRAPH_TEST(onnx_editor, editor_api_select_edge_const_network) EXPECT_EQ(edge3.m_tensor_name, "add1"); } -NGRAPH_TEST(onnx_editor, xxx_subgraph__linear_model_head_cut) +NGRAPH_TEST(onnx_editor, editor_api_select_edge_error_handling) { ONNXModelEditor editor{file_util::path_join( - SERIALIZED_ZOO, "onnx/model_editor/subgraph__inception_head.prototxt")}; + SERIALIZED_ZOO, "onnx/model_editor/subgraph_extraction_tests_2.prototxt")}; const auto edge_mapper = editor.create_edge_mapper(); - // define node by output name - // const InputEdge edge = - // edge_mapper.to_input_edge(onnx_editor::Node{onnx_editor::Output{"conv1/7x7_s2_2"}}, - // onnx_editor::Input{"conv1/7x7_s2_1"}); - /*editor.cut_graph_fragment({{edge}}, {}); + // node with given output name not found + try + { + const InputEdge edge = edge_mapper.to_input_edge( + onnx_editor::Node{onnx_editor::Output{"not_existed"}}, onnx_editor::Input{0}); + } + catch (const std::exception& e) + { + std::string msg{e.what()}; + EXPECT_TRUE( + msg.find("Node with name: not_given and output_name: not_existed was not found") != + std::string::npos); + } - const auto ref_model = file_util::path_join( - SERIALIZED_ZOO, "onnx/model_editor/reference/subgraph__linear_model_head_cut.prototxt"); + // node with given name not found + try + { + const InputEdge edge = + edge_mapper.to_input_edge(onnx_editor::Node{"not_existed"}, onnx_editor::Input{0}); + } + catch (const std::exception& e) + { + std::string msg{e.what()}; + EXPECT_TRUE( + msg.find("Node with name: not_existed and output_name: not_given was not found") != + std::string::npos); + } + + // input index out of scope + try + { + const InputEdge edge = + edge_mapper.to_input_edge(onnx_editor::Node{"relu4_name"}, onnx_editor::Input{1}); + } + catch (const std::exception& e) + { + std::string msg{e.what()}; + EXPECT_TRUE(msg.find("Node with index: 3 has not input with index: 1") != + std::string::npos); + } + + // output index out of scope + try + { + const OutputEdge edge = + edge_mapper.to_output_edge(onnx_editor::Node{"relu4_name"}, onnx_editor::Output{1}); + } + catch (const std::exception& e) + { + std::string msg{e.what()}; + EXPECT_TRUE(msg.find("Node with index: 3 has not output with index: 1") != + std::string::npos); + } +} + +NGRAPH_TEST(onnx_editor, editor_api_use_edge_mapper_with_graph_cutter) +{ + ONNXModelEditor editor{file_util::path_join( + SERIALIZED_ZOO, "onnx/model_editor/subgraph_extraction_tests.prototxt")}; + const auto mapper = editor.create_edge_mapper(); + + editor.cut_graph_fragment( + {/*{InputEdge{1, "in2"}*/ mapper.to_input_edge( + onnx_editor::Node(onnx_editor::Output("add1")), onnx_editor::Input(1)), + /*InputEdge{2, "in3"}*/ mapper.to_input_edge( + onnx_editor::Node(onnx_editor::Output("conv1")), onnx_editor::Input(0))}, + {/*{OutputEdge{4, "mul2"}*/ mapper.to_output_edge( + onnx_editor::Node(onnx_editor::Output("mul2")), onnx_editor::Output(0))}); + + const auto ref_model = + file_util::path_join(SERIALIZED_ZOO, + "onnx/model_editor/reference/" + "subgraph__existing_inputs_and_outputs_based_extraction.prototxt"); const auto result = compare_onnx_models(editor.model_string(), ref_model); - EXPECT_TRUE(result.is_ok) << result.error_message;*/ + EXPECT_TRUE(result.is_ok) << result.error_message; } // combinations to test: // - node names dublicates! -// edge mapper should share state ?? -// check mapper lifestyle -// complete test with cutter -// Node with given identifier was not found -// input/output index exception +// mapper to separate file using TestEngine = test::INTERPRETER_Engine; From d49bdc2474d8afe990e5d86519bfdf74ef9bdb86 Mon Sep 17 00:00:00 2001 From: mbencer Date: Mon, 22 Mar 2021 17:39:47 +0100 Subject: [PATCH 064/116] added editor class aliases --- .../include/onnx_editor/editor_types.hpp | 8 +- ngraph/test/onnx/onnx_editor.cpp | 98 +++++++++---------- 2 files changed, 51 insertions(+), 55 deletions(-) diff --git a/ngraph/frontend/onnx_editor/include/onnx_editor/editor_types.hpp b/ngraph/frontend/onnx_editor/include/onnx_editor/editor_types.hpp index f196cbe7a54c4d..ad9c87605da54d 100644 --- a/ngraph/frontend/onnx_editor/include/onnx_editor/editor_types.hpp +++ b/ngraph/frontend/onnx_editor/include/onnx_editor/editor_types.hpp @@ -72,7 +72,7 @@ namespace ngraph /// OutputEdge(5, "out1") /// OutputEdge(5, "out2") using OutputEdge = Edge; - // TODO: REmove m_ prefix + struct Input { Input() = delete; @@ -87,6 +87,7 @@ namespace ngraph const std::string m_input_name = ""; const int m_input_index = -1; }; + struct Output { Output() = delete; @@ -115,5 +116,10 @@ namespace ngraph const std::string m_node_name = ""; const std::string m_output_name = ""; }; + + // Aliases to avoid name conflicts with classes from ngraph namespace + using EditorInput = Input; + using EditorOutput = Output; + using EditorNode = Node; } } diff --git a/ngraph/test/onnx/onnx_editor.cpp b/ngraph/test/onnx/onnx_editor.cpp index 7691fb81de0c32..2aa4963fa99b60 100644 --- a/ngraph/test/onnx/onnx_editor.cpp +++ b/ngraph/test/onnx/onnx_editor.cpp @@ -695,14 +695,13 @@ NGRAPH_TEST(onnx_editor, editor_api_select_input_edge_by_output_name_and_input_n SERIALIZED_ZOO, "onnx/model_editor/subgraph__inception_head.prototxt")}; const auto edge_mapper = editor.create_edge_mapper(); - const InputEdge edge = - edge_mapper.to_input_edge(onnx_editor::Node{onnx_editor::Output{"conv1/7x7_s2_2"}}, - onnx_editor::Input{"conv1/7x7_s2_1"}); + const InputEdge edge = edge_mapper.to_input_edge(EditorNode{EditorOutput{"conv1/7x7_s2_2"}}, + EditorInput{"conv1/7x7_s2_1"}); EXPECT_EQ(edge.m_node_idx, 1); EXPECT_EQ(edge.m_tensor_name, "conv1/7x7_s2_1"); - const InputEdge edge2 = edge_mapper.to_input_edge( - onnx_editor::Node{onnx_editor::Output{"conv1/7x7_s2_1"}}, onnx_editor::Input{"data_0"}); + const InputEdge edge2 = edge_mapper.to_input_edge(EditorNode{EditorOutput{"conv1/7x7_s2_1"}}, + EditorInput{"data_0"}); EXPECT_EQ(edge2.m_node_idx, 0); EXPECT_EQ(edge2.m_tensor_name, "data_0"); } @@ -713,18 +712,18 @@ NGRAPH_TEST(onnx_editor, editor_api_select_input_edge_by_output_name_and_input_i SERIALIZED_ZOO, "onnx/model_editor/subgraph__inception_head.prototxt")}; const auto edge_mapper = editor.create_edge_mapper(); - const InputEdge edge = edge_mapper.to_input_edge( - onnx_editor::Node{onnx_editor::Output{"conv1/7x7_s2_2"}}, onnx_editor::Input{0}); + const InputEdge edge = + edge_mapper.to_input_edge(EditorNode{EditorOutput{"conv1/7x7_s2_2"}}, EditorInput{0}); EXPECT_EQ(edge.m_node_idx, 1); EXPECT_EQ(edge.m_tensor_name, "conv1/7x7_s2_1"); - const InputEdge edge2 = edge_mapper.to_input_edge( - onnx_editor::Node{onnx_editor::Output{"conv1/7x7_s2_1"}}, onnx_editor::Input{1}); + const InputEdge edge2 = + edge_mapper.to_input_edge(EditorNode{EditorOutput{"conv1/7x7_s2_1"}}, EditorInput{1}); EXPECT_EQ(edge2.m_node_idx, 0); EXPECT_EQ(edge2.m_tensor_name, "conv1/7x7_s2_w_0"); - const InputEdge edge3 = edge_mapper.to_input_edge( - onnx_editor::Node{onnx_editor::Output{"conv1/7x7_s2_1"}}, onnx_editor::Input{2}); + const InputEdge edge3 = + edge_mapper.to_input_edge(EditorNode{EditorOutput{"conv1/7x7_s2_1"}}, EditorInput{2}); EXPECT_EQ(edge3.m_node_idx, 0); EXPECT_EQ(edge3.m_tensor_name, "conv1/7x7_s2_b_0"); } @@ -736,12 +735,12 @@ NGRAPH_TEST(onnx_editor, editor_api_select_input_edge_by_node_name_and_input_nam const auto edge_mapper = editor.create_edge_mapper(); const InputEdge edge = - edge_mapper.to_input_edge(onnx_editor::Node{"relu1"}, onnx_editor::Input{"conv1/7x7_s2_1"}); + edge_mapper.to_input_edge(EditorNode{"relu1"}, EditorInput{"conv1/7x7_s2_1"}); EXPECT_EQ(edge.m_node_idx, 1); EXPECT_EQ(edge.m_tensor_name, "conv1/7x7_s2_1"); - const InputEdge edge2 = edge_mapper.to_input_edge(onnx_editor::Node{"conv1"}, - onnx_editor::Input{"conv1/7x7_s2_w_0"}); + const InputEdge edge2 = + edge_mapper.to_input_edge(EditorNode{"conv1"}, EditorInput{"conv1/7x7_s2_w_0"}); EXPECT_EQ(edge2.m_node_idx, 0); EXPECT_EQ(edge2.m_tensor_name, "conv1/7x7_s2_w_0"); } @@ -752,13 +751,11 @@ NGRAPH_TEST(onnx_editor, editor_api_select_input_edge_by_node_name_and_input_ind SERIALIZED_ZOO, "onnx/model_editor/subgraph_extraction_tests.prototxt")}; const auto edge_mapper = editor.create_edge_mapper(); - const InputEdge edge = - edge_mapper.to_input_edge(onnx_editor::Node{"relu1_name"}, onnx_editor::Input{0}); + const InputEdge edge = edge_mapper.to_input_edge(EditorNode{"relu1_name"}, EditorInput{0}); EXPECT_EQ(edge.m_node_idx, 0); EXPECT_EQ(edge.m_tensor_name, "in1"); - const InputEdge edge2 = - edge_mapper.to_input_edge(onnx_editor::Node{"split_name"}, onnx_editor::Input{0}); + const InputEdge edge2 = edge_mapper.to_input_edge(EditorNode{"split_name"}, EditorInput{0}); EXPECT_EQ(edge2.m_node_idx, 5); EXPECT_EQ(edge2.m_tensor_name, "add2"); } @@ -770,13 +767,13 @@ NGRAPH_TEST(onnx_editor, editor_api_select_output_edge_by_output_name_and_input_ SERIALIZED_ZOO, "onnx/model_editor/subgraph_extraction_tests.prototxt")}; const auto edge_mapper = editor.create_edge_mapper(); - const OutputEdge edge = edge_mapper.to_output_edge( - onnx_editor::Node{onnx_editor::Output{"mul2"}}, onnx_editor::Output{"mul2"}); + const OutputEdge edge = + edge_mapper.to_output_edge(EditorNode{EditorOutput{"mul2"}}, EditorOutput{"mul2"}); EXPECT_EQ(edge.m_node_idx, 4); EXPECT_EQ(edge.m_tensor_name, "mul2"); - const OutputEdge edge2 = edge_mapper.to_output_edge( - onnx_editor::Node{onnx_editor::Output{"split1"}}, onnx_editor::Output{"split2"}); + const OutputEdge edge2 = + edge_mapper.to_output_edge(EditorNode{EditorOutput{"split1"}}, EditorOutput{"split2"}); EXPECT_EQ(edge2.m_node_idx, 5); EXPECT_EQ(edge2.m_tensor_name, "split2"); } @@ -787,18 +784,18 @@ NGRAPH_TEST(onnx_editor, editor_api_select_output_edge_by_output_name_and_output SERIALIZED_ZOO, "onnx/model_editor/subgraph_extraction_tests.prototxt")}; const auto edge_mapper = editor.create_edge_mapper(); - const OutputEdge edge = edge_mapper.to_output_edge( - onnx_editor::Node{onnx_editor::Output{"add2"}}, onnx_editor::Output{0}); + const OutputEdge edge = + edge_mapper.to_output_edge(EditorNode{EditorOutput{"add2"}}, EditorOutput{0}); EXPECT_EQ(edge.m_node_idx, 3); EXPECT_EQ(edge.m_tensor_name, "add2"); - const OutputEdge edge2 = edge_mapper.to_output_edge( - onnx_editor::Node{onnx_editor::Output{"split1"}}, onnx_editor::Output{1}); + const OutputEdge edge2 = + edge_mapper.to_output_edge(EditorNode{EditorOutput{"split1"}}, EditorOutput{1}); EXPECT_EQ(edge2.m_node_idx, 5); EXPECT_EQ(edge2.m_tensor_name, "split2"); - const OutputEdge edge3 = edge_mapper.to_output_edge( - onnx_editor::Node{onnx_editor::Output{"split2"}}, onnx_editor::Output{0}); + const OutputEdge edge3 = + edge_mapper.to_output_edge(EditorNode{EditorOutput{"split2"}}, EditorOutput{0}); EXPECT_EQ(edge3.m_node_idx, 5); EXPECT_EQ(edge3.m_tensor_name, "split1"); } @@ -810,12 +807,12 @@ NGRAPH_TEST(onnx_editor, editor_api_select_output_edge_by_node_name_and_output_n const auto edge_mapper = editor.create_edge_mapper(); const OutputEdge edge = - edge_mapper.to_output_edge(onnx_editor::Node{"relu1_name"}, onnx_editor::Output{"relu1"}); + edge_mapper.to_output_edge(EditorNode{"relu1_name"}, EditorOutput{"relu1"}); EXPECT_EQ(edge.m_node_idx, 0); EXPECT_EQ(edge.m_tensor_name, "relu1"); const OutputEdge edge2 = - edge_mapper.to_output_edge(onnx_editor::Node{"split_name"}, onnx_editor::Output{"split2"}); + edge_mapper.to_output_edge(EditorNode{"split_name"}, EditorOutput{"split2"}); EXPECT_EQ(edge2.m_node_idx, 5); EXPECT_EQ(edge2.m_tensor_name, "split2"); } @@ -826,13 +823,11 @@ NGRAPH_TEST(onnx_editor, editor_api_select_output_edge_by_node_name_and_output_i SERIALIZED_ZOO, "onnx/model_editor/subgraph_extraction_tests.prototxt")}; const auto edge_mapper = editor.create_edge_mapper(); - const OutputEdge edge = - edge_mapper.to_output_edge(onnx_editor::Node{"relu1_name"}, onnx_editor::Output{0}); + const OutputEdge edge = edge_mapper.to_output_edge(EditorNode{"relu1_name"}, EditorOutput{0}); EXPECT_EQ(edge.m_node_idx, 0); EXPECT_EQ(edge.m_tensor_name, "relu1"); - const OutputEdge edge2 = - edge_mapper.to_output_edge(onnx_editor::Node{"split_name"}, onnx_editor::Output{1}); + const OutputEdge edge2 = edge_mapper.to_output_edge(EditorNode{"split_name"}, EditorOutput{1}); EXPECT_EQ(edge2.m_node_idx, 5); EXPECT_EQ(edge2.m_tensor_name, "split2"); } @@ -843,18 +838,16 @@ NGRAPH_TEST(onnx_editor, editor_api_select_edge_const_network) SERIALIZED_ZOO, "onnx/model_editor/subgraph_extraction_tests_2.prototxt")}; const auto edge_mapper = editor.create_edge_mapper(); - const InputEdge edge = edge_mapper.to_input_edge( - onnx_editor::Node{onnx_editor::Output{"relu4"}}, onnx_editor::Input{0}); + const InputEdge edge = + edge_mapper.to_input_edge(EditorNode{EditorOutput{"relu4"}}, EditorInput{0}); EXPECT_EQ(edge.m_node_idx, 3); EXPECT_EQ(edge.m_tensor_name, "in2"); - const OutputEdge edge2 = - edge_mapper.to_output_edge(onnx_editor::Node{"relu4_name"}, onnx_editor::Output{0}); + const OutputEdge edge2 = edge_mapper.to_output_edge(EditorNode{"relu4_name"}, EditorOutput{0}); EXPECT_EQ(edge2.m_node_idx, 3); EXPECT_EQ(edge2.m_tensor_name, "relu4"); - const OutputEdge edge3 = - edge_mapper.to_output_edge(onnx_editor::Node{"add1_name"}, onnx_editor::Output{0}); + const OutputEdge edge3 = edge_mapper.to_output_edge(EditorNode{"add1_name"}, EditorOutput{0}); EXPECT_EQ(edge3.m_node_idx, 4); EXPECT_EQ(edge3.m_tensor_name, "add1"); } @@ -868,8 +861,8 @@ NGRAPH_TEST(onnx_editor, editor_api_select_edge_error_handling) // node with given output name not found try { - const InputEdge edge = edge_mapper.to_input_edge( - onnx_editor::Node{onnx_editor::Output{"not_existed"}}, onnx_editor::Input{0}); + const InputEdge edge = + edge_mapper.to_input_edge(EditorNode{EditorOutput{"not_existed"}}, EditorInput{0}); } catch (const std::exception& e) { @@ -882,8 +875,7 @@ NGRAPH_TEST(onnx_editor, editor_api_select_edge_error_handling) // node with given name not found try { - const InputEdge edge = - edge_mapper.to_input_edge(onnx_editor::Node{"not_existed"}, onnx_editor::Input{0}); + const InputEdge edge = edge_mapper.to_input_edge(EditorNode{"not_existed"}, EditorInput{0}); } catch (const std::exception& e) { @@ -896,8 +888,7 @@ NGRAPH_TEST(onnx_editor, editor_api_select_edge_error_handling) // input index out of scope try { - const InputEdge edge = - edge_mapper.to_input_edge(onnx_editor::Node{"relu4_name"}, onnx_editor::Input{1}); + const InputEdge edge = edge_mapper.to_input_edge(EditorNode{"relu4_name"}, EditorInput{1}); } catch (const std::exception& e) { @@ -910,7 +901,7 @@ NGRAPH_TEST(onnx_editor, editor_api_select_edge_error_handling) try { const OutputEdge edge = - edge_mapper.to_output_edge(onnx_editor::Node{"relu4_name"}, onnx_editor::Output{1}); + edge_mapper.to_output_edge(EditorNode{"relu4_name"}, EditorOutput{1}); } catch (const std::exception& e) { @@ -926,13 +917,12 @@ NGRAPH_TEST(onnx_editor, editor_api_use_edge_mapper_with_graph_cutter) SERIALIZED_ZOO, "onnx/model_editor/subgraph_extraction_tests.prototxt")}; const auto mapper = editor.create_edge_mapper(); - editor.cut_graph_fragment( - {/*{InputEdge{1, "in2"}*/ mapper.to_input_edge( - onnx_editor::Node(onnx_editor::Output("add1")), onnx_editor::Input(1)), - /*InputEdge{2, "in3"}*/ mapper.to_input_edge( - onnx_editor::Node(onnx_editor::Output("conv1")), onnx_editor::Input(0))}, - {/*{OutputEdge{4, "mul2"}*/ mapper.to_output_edge( - onnx_editor::Node(onnx_editor::Output("mul2")), onnx_editor::Output(0))}); + editor.cut_graph_fragment({/*{InputEdge{1, "in2"}*/ mapper.to_input_edge( + EditorNode(EditorOutput("add1")), EditorInput(1)), + /*InputEdge{2, "in3"}*/ mapper.to_input_edge( + EditorNode(EditorOutput("conv1")), EditorInput(0))}, + {/*{OutputEdge{4, "mul2"}*/ mapper.to_output_edge( + EditorNode(EditorOutput("mul2")), EditorOutput(0))}); const auto ref_model = file_util::path_join(SERIALIZED_ZOO, From b49a576a120954ae7b5517071f6eee19e6e2be6c Mon Sep 17 00:00:00 2001 From: mbencer Date: Mon, 22 Mar 2021 17:53:10 +0100 Subject: [PATCH 065/116] Move edge mapper to separate file --- .../include/onnx_editor/edge_mapper.hpp | 55 +++++++ .../include/onnx_editor/editor.hpp | 19 +-- .../frontend/onnx_editor/src/edge_mapper.cpp | 142 ++++++++++++++++++ ngraph/frontend/onnx_editor/src/editor.cpp | 120 --------------- 4 files changed, 198 insertions(+), 138 deletions(-) create mode 100644 ngraph/frontend/onnx_editor/include/onnx_editor/edge_mapper.hpp create mode 100644 ngraph/frontend/onnx_editor/src/edge_mapper.cpp diff --git a/ngraph/frontend/onnx_editor/include/onnx_editor/edge_mapper.hpp b/ngraph/frontend/onnx_editor/include/onnx_editor/edge_mapper.hpp new file mode 100644 index 00000000000000..20596e471836da --- /dev/null +++ b/ngraph/frontend/onnx_editor/include/onnx_editor/edge_mapper.hpp @@ -0,0 +1,55 @@ +//***************************************************************************** +// Copyright 2017-2021 Intel Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//***************************************************************************** + +#pragma once + +#include +#include +#include + +#include "onnx_editor/editor_types.hpp" + +namespace ONNX_NAMESPACE +{ + // forward declaration to avoid the necessity of include paths setting in components + // that don't directly depend on the ONNX library + class GraphProto; +} // namespace ONNX_NAMESPACE + +namespace ngraph +{ + namespace onnx_editor + { + class EdgeMapper + { + public: + EdgeMapper() = delete; + EdgeMapper(const ONNX_NAMESPACE::GraphProto& graph_proto); + + InputEdge to_input_edge(Node node, Input in) const; + OutputEdge to_output_edge(Node node, Output out) const; + + private: + int find_node_index(const std::string& node_name, const std::string& output_name) const; + std::string get_node_input_name(int node_index, int input_index) const; + std::string get_node_output_name(int node_index, int output_index) const; + + std::vector> m_node_inputs; + std::vector> m_node_outputs; + std::multimap m_node_name_to_index; + }; + } +} \ No newline at end of file diff --git a/ngraph/frontend/onnx_editor/include/onnx_editor/editor.hpp b/ngraph/frontend/onnx_editor/include/onnx_editor/editor.hpp index e41ea52167d8be..a780505b89147d 100644 --- a/ngraph/frontend/onnx_editor/include/onnx_editor/editor.hpp +++ b/ngraph/frontend/onnx_editor/include/onnx_editor/editor.hpp @@ -23,6 +23,7 @@ #include "ngraph/op/constant.hpp" #include "ngraph/partial_shape.hpp" #include "ngraph/type/element_type.hpp" +#include "onnx_editor/edge_mapper.hpp" #include "onnx_editor/editor.hpp" #include "onnx_editor/editor_types.hpp" @@ -31,30 +32,12 @@ namespace ONNX_NAMESPACE // forward declaration to avoid the necessity of include paths setting in components // that don't directly depend on the ONNX library class ModelProto; - class GraphProto; } // namespace ONNX_NAMESPACE namespace ngraph { namespace onnx_editor { - class EdgeMapper - { - public: - EdgeMapper(const ONNX_NAMESPACE::GraphProto& graph_proto); - - InputEdge to_input_edge(Node node, Input in) const; - OutputEdge to_output_edge(Node node, Output out) const; - - private: - int find_node_index(const std::string& node_name, const std::string& output_name) const; - std::string get_node_input_name(int node_index, int input_index) const; - std::string get_node_output_name(int node_index, int output_index) const; - - std::vector> m_node_inputs; - std::vector> m_node_outputs; - std::multimap m_node_name_to_index; - }; /// \brief A class representing a set of utilities allowing modification of an ONNX model /// /// \note This class can be used to modify an ONNX model before it gets translated to diff --git a/ngraph/frontend/onnx_editor/src/edge_mapper.cpp b/ngraph/frontend/onnx_editor/src/edge_mapper.cpp new file mode 100644 index 00000000000000..d0d319e6722740 --- /dev/null +++ b/ngraph/frontend/onnx_editor/src/edge_mapper.cpp @@ -0,0 +1,142 @@ +//***************************************************************************** +// Copyright 2017-2021 Intel Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//***************************************************************************** + +#include + +#include "ngraph/except.hpp" +#include "onnx_editor/edge_mapper.hpp" + +using namespace ngraph; +using namespace ngraph::onnx_editor; + +onnx_editor::EdgeMapper::EdgeMapper(const ONNX_NAMESPACE::GraphProto& graph_proto) +{ + int topological_index = 0; + m_node_inputs.resize(graph_proto.node().size()); + m_node_outputs.resize(graph_proto.node().size()); + for (const auto& node_proto : graph_proto.node()) + { + for (const auto& out_name : node_proto.output()) + { + // node output name is unique + m_node_name_to_index.emplace(out_name, topological_index); + m_node_outputs[topological_index].push_back(out_name); + std::cout << "output: " << topological_index << ", " << out_name << "\n"; + } + for (const auto& in_name : node_proto.input()) + { + std::cout << "in_name: " << topological_index << ", " << in_name << "\n"; + m_node_inputs[topological_index].push_back(in_name); + } + if (!node_proto.name().empty()) + { + // node name can identify node, but it can be ambiguous + m_node_name_to_index.emplace(node_proto.name(), topological_index); + std::cout << "node_name: " << topological_index << ", " << node_proto.name() << "\n"; + } + ++topological_index; + } +} + +int onnx_editor::EdgeMapper::find_node_index(const std::string& node_name, + const std::string& output_name) const +{ + for (const auto& key : {node_name, output_name}) + { + if (key.empty()) + { + continue; + } + const auto& index_iter = m_node_name_to_index.find(key); + if (index_iter != std::end(m_node_name_to_index)) + { + return index_iter->second; + } + } + throw ngraph_error("Node with name: " + (node_name.empty() ? "not_given" : node_name) + + " and output_name: " + (output_name.empty() ? "not_given" : output_name) + + " was not found"); +}; + +std::string onnx_editor::EdgeMapper::get_node_output_name(int node_index, int output_index) const +{ + if (node_index >= m_node_outputs.size()) + { + throw ngraph_error("Node with index: " + std::to_string(node_index) + + "is out of scope outputs list"); + } + if (output_index >= m_node_outputs[node_index].size()) + { + throw ngraph_error("Node with index: " + std::to_string(node_index) + + " has not output with index: " + std::to_string(output_index)); + } + const auto output_name = m_node_outputs[node_index][output_index]; + return output_name; +} + +std::string onnx_editor::EdgeMapper::get_node_input_name(int node_index, int input_index) const +{ + if (node_index >= m_node_inputs.size()) + { + throw ngraph_error("Node with index: " + std::to_string(node_index) + + "is out of scope inputs list"); + } + if (input_index >= m_node_inputs[node_index].size()) + { + throw ngraph_error("Node with index: " + std::to_string(node_index) + + " has not input with index: " + std::to_string(input_index)); + } + const auto input_name = m_node_inputs[node_index][input_index]; + return input_name; +} + +InputEdge onnx_editor::EdgeMapper::to_input_edge(Node node, Input in) const +{ + // identification can be both based on node name and output name + const auto node_index = find_node_index(node.m_node_name, node.m_output_name); + if (!in.m_input_name.empty()) + { + return InputEdge{node_index, in.m_input_name}; + } + else if (in.m_input_index != -1) // input index is set + { + const auto& input_name = get_node_input_name(node_index, in.m_input_index); + return InputEdge{node_index, input_name}; + } + else + { + throw ngraph_error("Not enough information to determine input edge"); + } +} + +OutputEdge onnx_editor::EdgeMapper::to_output_edge(Node node, Output out) const +{ + // identification can be both based on node name and output name + const auto node_index = find_node_index(node.m_node_name, node.m_output_name); + if (!out.m_output_name.empty()) + { + return OutputEdge{node_index, out.m_output_name}; + } + else if (out.m_output_index != -1) // output index is set + { + const auto& output_name = get_node_output_name(node_index, out.m_output_index); + return OutputEdge{node_index, output_name}; + } + else + { + throw ngraph_error("Not enough information to determine output edge"); + } +} \ No newline at end of file diff --git a/ngraph/frontend/onnx_editor/src/editor.cpp b/ngraph/frontend/onnx_editor/src/editor.cpp index 62daa788085cce..530bdf0dd5de62 100644 --- a/ngraph/frontend/onnx_editor/src/editor.cpp +++ b/ngraph/frontend/onnx_editor/src/editor.cpp @@ -20,7 +20,6 @@ #include #include "detail/subgraph_extraction.hpp" -#include "ngraph/except.hpp" #include "ngraph/log.hpp" #include "onnx_common/parser.hpp" #include "onnx_common/utils.hpp" @@ -377,122 +376,3 @@ EdgeMapper onnx_editor::ONNXModelEditor::create_edge_mapper() const { return EdgeMapper{m_pimpl->m_model_proto.graph()}; } - -onnx_editor::EdgeMapper::EdgeMapper(const ONNX_NAMESPACE::GraphProto& graph_proto) -{ - int topological_index = 0; - m_node_inputs.resize(graph_proto.node().size()); - m_node_outputs.resize(graph_proto.node().size()); - for (const auto& node_proto : graph_proto.node()) - { - for (const auto& out_name : node_proto.output()) - { - // node output name is unique - m_node_name_to_index.emplace(out_name, topological_index); - m_node_outputs[topological_index].push_back(out_name); - std::cout << "output: " << topological_index << ", " << out_name << "\n"; - } - for (const auto& in_name : node_proto.input()) - { - std::cout << "in_name: " << topological_index << ", " << in_name << "\n"; - m_node_inputs[topological_index].push_back(in_name); - } - if (!node_proto.name().empty()) - { - // node name can identify node, but it can be ambiguous - m_node_name_to_index.emplace(node_proto.name(), topological_index); - std::cout << "node_name: " << topological_index << ", " << node_proto.name() << "\n"; - } - ++topological_index; - } -} - -int onnx_editor::EdgeMapper::find_node_index(const std::string& node_name, - const std::string& output_name) const -{ - for (const auto& key : {node_name, output_name}) - { - if (key.empty()) - { - continue; - } - const auto& index_iter = m_node_name_to_index.find(key); - if (index_iter != std::end(m_node_name_to_index)) - { - return index_iter->second; - } - } - throw ngraph_error("Node with name: " + (node_name.empty() ? "not_given" : node_name) + - " and output_name: " + (output_name.empty() ? "not_given" : output_name) + - " was not found"); -}; - -std::string onnx_editor::EdgeMapper::get_node_output_name(int node_index, int output_index) const -{ - if (node_index >= m_node_outputs.size()) - { - throw ngraph_error("Node with index: " + std::to_string(node_index) + - "is out of scope outputs list"); - } - if (output_index >= m_node_outputs[node_index].size()) - { - throw ngraph_error("Node with index: " + std::to_string(node_index) + - " has not output with index: " + std::to_string(output_index)); - } - const auto output_name = m_node_outputs[node_index][output_index]; - return output_name; -} - -std::string onnx_editor::EdgeMapper::get_node_input_name(int node_index, int input_index) const -{ - if (node_index >= m_node_inputs.size()) - { - throw ngraph_error("Node with index: " + std::to_string(node_index) + - "is out of scope inputs list"); - } - if (input_index >= m_node_inputs[node_index].size()) - { - throw ngraph_error("Node with index: " + std::to_string(node_index) + - " has not input with index: " + std::to_string(input_index)); - } - const auto input_name = m_node_inputs[node_index][input_index]; - return input_name; -} - -InputEdge onnx_editor::EdgeMapper::to_input_edge(Node node, Input in) const -{ - // identification can be both based on node name and output name - const auto node_index = find_node_index(node.m_node_name, node.m_output_name); - if (!in.m_input_name.empty()) - { - return InputEdge{node_index, in.m_input_name}; - } - else if (in.m_input_index != -1) // input index is set - { - const auto& input_name = get_node_input_name(node_index, in.m_input_index); - return InputEdge{node_index, input_name}; - } - else - { - throw ngraph_error("Not enough information to determine input edge"); - } -} - -OutputEdge onnx_editor::EdgeMapper::to_output_edge(Node node, Output out) const -{ - // identification can be both based on node name and output name - const auto node_index = find_node_index(node.m_node_name, node.m_output_name); - if (!out.m_output_name.empty()) - { - return OutputEdge{node_index, out.m_output_name}; - } - else if (out.m_output_index != -1) // output index is set - { - const auto& output_name = get_node_output_name(node_index, out.m_output_index); - return OutputEdge{node_index, output_name}; - } - else - { - throw ngraph_error("Not enough information to determine output edge"); - } -} From fa7e9568693e8cec097341af7747bcfd116bf65a Mon Sep 17 00:00:00 2001 From: mbencer Date: Tue, 23 Mar 2021 19:23:10 +0100 Subject: [PATCH 066/116] find dupicates with the same names --- .../include/onnx_editor/edge_mapper.hpp | 3 +- .../frontend/onnx_editor/src/edge_mapper.cpp | 34 +++++++++++++------ 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/ngraph/frontend/onnx_editor/include/onnx_editor/edge_mapper.hpp b/ngraph/frontend/onnx_editor/include/onnx_editor/edge_mapper.hpp index 20596e471836da..7878ff163e81a7 100644 --- a/ngraph/frontend/onnx_editor/include/onnx_editor/edge_mapper.hpp +++ b/ngraph/frontend/onnx_editor/include/onnx_editor/edge_mapper.hpp @@ -43,7 +43,8 @@ namespace ngraph OutputEdge to_output_edge(Node node, Output out) const; private: - int find_node_index(const std::string& node_name, const std::string& output_name) const; + std::vector find_node_indexes(const std::string& node_name, + const std::string& output_name) const; std::string get_node_input_name(int node_index, int input_index) const; std::string get_node_output_name(int node_index, int output_index) const; diff --git a/ngraph/frontend/onnx_editor/src/edge_mapper.cpp b/ngraph/frontend/onnx_editor/src/edge_mapper.cpp index d0d319e6722740..b0d73b38e8cae7 100644 --- a/ngraph/frontend/onnx_editor/src/edge_mapper.cpp +++ b/ngraph/frontend/onnx_editor/src/edge_mapper.cpp @@ -51,19 +51,31 @@ onnx_editor::EdgeMapper::EdgeMapper(const ONNX_NAMESPACE::GraphProto& graph_prot } } -int onnx_editor::EdgeMapper::find_node_index(const std::string& node_name, - const std::string& output_name) const +std::vector onnx_editor::EdgeMapper::find_node_indexes(const std::string& node_name, + const std::string& output_name) const { - for (const auto& key : {node_name, output_name}) + if (!output_name.empty()) { - if (key.empty()) + const auto& index_iter = m_node_name_to_index.find(output_name); + if (index_iter != std::end(m_node_name_to_index)) { - continue; + return std::vector{index_iter->second}; } - const auto& index_iter = m_node_name_to_index.find(key); - if (index_iter != std::end(m_node_name_to_index)) + } + // many nodes can have the same name + if (!node_name.empty()) + { + std::vector result; + auto matched_nodes_range = m_node_name_to_index.equal_range(node_name); + for (auto& index_iter = matched_nodes_range.first; index_iter != matched_nodes_range.second; + ++index_iter) + { + std::cout << "sec: " << index_iter->second << "\n"; + result.push_back(index_iter->second); + } + if (!result.empty()) { - return index_iter->second; + return result; } } throw ngraph_error("Node with name: " + (node_name.empty() ? "not_given" : node_name) + @@ -106,7 +118,8 @@ std::string onnx_editor::EdgeMapper::get_node_input_name(int node_index, int inp InputEdge onnx_editor::EdgeMapper::to_input_edge(Node node, Input in) const { // identification can be both based on node name and output name - const auto node_index = find_node_index(node.m_node_name, node.m_output_name); + const auto& node_indexes = find_node_indexes(node.m_node_name, node.m_output_name); + const auto node_index = node_indexes.at(0); if (!in.m_input_name.empty()) { return InputEdge{node_index, in.m_input_name}; @@ -125,7 +138,8 @@ InputEdge onnx_editor::EdgeMapper::to_input_edge(Node node, Input in) const OutputEdge onnx_editor::EdgeMapper::to_output_edge(Node node, Output out) const { // identification can be both based on node name and output name - const auto node_index = find_node_index(node.m_node_name, node.m_output_name); + const auto& node_indexes = find_node_indexes(node.m_node_name, node.m_output_name); + const auto node_index = node_indexes.at(0); if (!out.m_output_name.empty()) { return OutputEdge{node_index, out.m_output_name}; From 05736249e963229072433b1f51479383e695f4da Mon Sep 17 00:00:00 2001 From: mbencer Date: Wed, 24 Mar 2021 09:40:19 +0100 Subject: [PATCH 067/116] handling ambiguous node names for InputEdge + tests --- .../frontend/onnx_editor/src/edge_mapper.cpp | 39 ++++++++++- .../subgraph_extraction_tests.prototxt | 2 + ngraph/test/onnx/onnx_editor.cpp | 67 +++++++++++++++++-- 3 files changed, 102 insertions(+), 6 deletions(-) diff --git a/ngraph/frontend/onnx_editor/src/edge_mapper.cpp b/ngraph/frontend/onnx_editor/src/edge_mapper.cpp index b0d73b38e8cae7..39d9242467b58c 100644 --- a/ngraph/frontend/onnx_editor/src/edge_mapper.cpp +++ b/ngraph/frontend/onnx_editor/src/edge_mapper.cpp @@ -62,7 +62,6 @@ std::vector onnx_editor::EdgeMapper::find_node_indexes(const std::string& n return std::vector{index_iter->second}; } } - // many nodes can have the same name if (!node_name.empty()) { std::vector result; @@ -119,7 +118,43 @@ InputEdge onnx_editor::EdgeMapper::to_input_edge(Node node, Input in) const { // identification can be both based on node name and output name const auto& node_indexes = find_node_indexes(node.m_node_name, node.m_output_name); - const auto node_index = node_indexes.at(0); + int node_index = -1; + if (node_indexes.size() == 1) + { + node_index = node_indexes[0]; + } + else if (!in.m_input_name.empty()) // input indexes are not deterministic + { + // many nodes with the same name + // check if some of found index matches input name + int matched_inputs_number = 0; + for (const auto& index : node_indexes) + { + if (std::count(std::begin(m_node_inputs[index]), + std::end(m_node_inputs[index]), + in.m_input_name) > 0) + { + node_index = index; + ++matched_inputs_number; + } + } + if (matched_inputs_number == 0) + { + throw ngraph_error("Input edge described by: " + node.m_node_name + + " and input name: " + in.m_input_name + " was not found"); + } + if (matched_inputs_number > 1) + { + throw ngraph_error("Given node name: " + node.m_node_name + " and input name: " + + in.m_input_name + " are ambiguous to determine input edge"); + } + } + else + { + throw ngraph_error("Given node name: " + node.m_node_name + + " and input index: " + std::to_string(in.m_input_index) + + " are ambiguous to determine input edge"); + } if (!in.m_input_name.empty()) { return InputEdge{node_index, in.m_input_name}; diff --git a/ngraph/test/models/onnx/model_editor/subgraph_extraction_tests.prototxt b/ngraph/test/models/onnx/model_editor/subgraph_extraction_tests.prototxt index 57ceee32f8cb22..6875db701af8c1 100644 --- a/ngraph/test/models/onnx/model_editor/subgraph_extraction_tests.prototxt +++ b/ngraph/test/models/onnx/model_editor/subgraph_extraction_tests.prototxt @@ -12,6 +12,7 @@ graph { input: "in2" output: "add1" op_type: "Add" + name: "add_ambiguous_name" } node { input: "in3" @@ -24,6 +25,7 @@ graph { input: "add1" output: "add2" op_type: "Add" + name: "add_ambiguous_name" } node { input: "add1" diff --git a/ngraph/test/onnx/onnx_editor.cpp b/ngraph/test/onnx/onnx_editor.cpp index 2aa4963fa99b60..29ab3ab1dfbaff 100644 --- a/ngraph/test/onnx/onnx_editor.cpp +++ b/ngraph/test/onnx/onnx_editor.cpp @@ -911,6 +911,69 @@ NGRAPH_TEST(onnx_editor, editor_api_select_edge_error_handling) } } +// Nodes with ambiguous node names tests +NGRAPH_TEST(onnx_editor, editor_api_select_input_edge_by_ambiguous_node_name_but_matched_input) +{ + ONNXModelEditor editor{file_util::path_join( + SERIALIZED_ZOO, "onnx/model_editor/subgraph_extraction_tests.prototxt")}; + const auto edge_mapper = editor.create_edge_mapper(); + + const InputEdge edge = edge_mapper.to_input_edge(EditorNode{"add_ambiguous_name"}, EditorInput{"in2"}); + EXPECT_EQ(edge.m_node_idx, 1); + EXPECT_EQ(edge.m_tensor_name, "in2"); + + const InputEdge edge2 = edge_mapper.to_input_edge(EditorNode{"add_ambiguous_name"}, EditorInput{"add1"}); + EXPECT_EQ(edge2.m_node_idx, 3); + EXPECT_EQ(edge2.m_tensor_name, "add1"); +} + +NGRAPH_TEST(onnx_editor, editor_api_select_input_edge_by_ambiguous_node_name_and_not_matched_input) +{ + ONNXModelEditor editor{file_util::path_join( + SERIALIZED_ZOO, "onnx/model_editor/subgraph_extraction_tests.prototxt")}; + const auto edge_mapper = editor.create_edge_mapper(); + + try + { + const InputEdge edge = edge_mapper.to_input_edge(EditorNode{"add_ambiguous_name"}, EditorInput{"in3"}); + } + catch (const std::exception& e) + { + std::string msg{e.what()}; + EXPECT_TRUE(msg.find("Input edge described by: add_ambiguous_name and input name: in3 was not found") != + std::string::npos); + } + + try + { + const InputEdge edge = edge_mapper.to_input_edge(EditorNode{"add_ambiguous_name"}, EditorInput{"relu1"}); + } + catch (const std::exception& e) + { + std::string msg{e.what()}; + EXPECT_TRUE(msg.find("Given node name: add_ambiguous_name and input name: relu1 are ambiguous to determine input edge") != + std::string::npos); + } +} + +NGRAPH_TEST(onnx_editor, editor_api_select_input_edge_by_ambiguous_node_name_and_input_index) +{ + ONNXModelEditor editor{file_util::path_join( + SERIALIZED_ZOO, "onnx/model_editor/subgraph_extraction_tests.prototxt")}; + const auto edge_mapper = editor.create_edge_mapper(); + + try + { + const InputEdge edge = edge_mapper.to_input_edge(EditorNode{"add_ambiguous_name"}, EditorInput{0}); + } + catch (const std::exception& e) + { + std::string msg{e.what()}; + EXPECT_TRUE(msg.find("Given node name: add_ambiguous_name and input index: 0 are ambiguous to determine input edge") != + std::string::npos); + } +} + NGRAPH_TEST(onnx_editor, editor_api_use_edge_mapper_with_graph_cutter) { ONNXModelEditor editor{file_util::path_join( @@ -934,10 +997,6 @@ NGRAPH_TEST(onnx_editor, editor_api_use_edge_mapper_with_graph_cutter) EXPECT_TRUE(result.is_ok) << result.error_message; } -// combinations to test: -// - node names dublicates! -// mapper to separate file - using TestEngine = test::INTERPRETER_Engine; NGRAPH_TEST(onnx_editor, values__append_one_initializer) From 601d007dbb7b1580e9f1027ac9560eecdec527ac Mon Sep 17 00:00:00 2001 From: mbencer Date: Wed, 24 Mar 2021 11:14:45 +0100 Subject: [PATCH 068/116] handling ambiguous node names for OutputEdge + tests --- .../frontend/onnx_editor/src/edge_mapper.cpp | 33 +++++++++++- ngraph/test/onnx/onnx_editor.cpp | 51 +++++++++++++++++++ 2 files changed, 83 insertions(+), 1 deletion(-) diff --git a/ngraph/frontend/onnx_editor/src/edge_mapper.cpp b/ngraph/frontend/onnx_editor/src/edge_mapper.cpp index 39d9242467b58c..6bfca09284b62e 100644 --- a/ngraph/frontend/onnx_editor/src/edge_mapper.cpp +++ b/ngraph/frontend/onnx_editor/src/edge_mapper.cpp @@ -174,7 +174,38 @@ OutputEdge onnx_editor::EdgeMapper::to_output_edge(Node node, Output out) const { // identification can be both based on node name and output name const auto& node_indexes = find_node_indexes(node.m_node_name, node.m_output_name); - const auto node_index = node_indexes.at(0); + int node_index = -1; + if (node_indexes.size() == 1) + { + node_index = node_indexes[0]; + } + else if (!out.m_output_name.empty()) // output indexes are not deterministic + { + // many nodes with the same name + // check if some of found index matches output name + int matched_outputs_number = 0; + for (const auto& index : node_indexes) + { + if (std::count(std::begin(m_node_outputs[index]), + std::end(m_node_outputs[index]), + out.m_output_name) > 0) + { + node_index = index; + ++matched_outputs_number; + } + } + if (matched_outputs_number == 0) + { + throw ngraph_error("Output edge described by: " + node.m_node_name + + " and output name: " + out.m_output_name + " was not found"); + } + } + else + { + throw ngraph_error("Given node name: " + node.m_node_name + + " and output index: " + std::to_string(out.m_output_index) + + " are ambiguous to determine output edge"); + } if (!out.m_output_name.empty()) { return OutputEdge{node_index, out.m_output_name}; diff --git a/ngraph/test/onnx/onnx_editor.cpp b/ngraph/test/onnx/onnx_editor.cpp index 29ab3ab1dfbaff..2b99fd5864eb14 100644 --- a/ngraph/test/onnx/onnx_editor.cpp +++ b/ngraph/test/onnx/onnx_editor.cpp @@ -974,6 +974,57 @@ NGRAPH_TEST(onnx_editor, editor_api_select_input_edge_by_ambiguous_node_name_and } } +NGRAPH_TEST(onnx_editor, editor_api_select_output_edge_by_ambiguous_node_name_but_matched_output) +{ + ONNXModelEditor editor{file_util::path_join( + SERIALIZED_ZOO, "onnx/model_editor/subgraph_extraction_tests.prototxt")}; + const auto edge_mapper = editor.create_edge_mapper(); + + const OutputEdge edge = edge_mapper.to_output_edge(EditorNode{"add_ambiguous_name"}, EditorOutput{"add1"}); + EXPECT_EQ(edge.m_node_idx, 1); + EXPECT_EQ(edge.m_tensor_name, "add1"); + + const OutputEdge edge2 = edge_mapper.to_output_edge(EditorNode{"add_ambiguous_name"}, EditorOutput{"add2"}); + EXPECT_EQ(edge2.m_node_idx, 3); + EXPECT_EQ(edge2.m_tensor_name, "add2"); +} + +NGRAPH_TEST(onnx_editor, editor_api_select_output_edge_by_ambiguous_node_name_and_not_matched_output) +{ + ONNXModelEditor editor{file_util::path_join( + SERIALIZED_ZOO, "onnx/model_editor/subgraph_extraction_tests.prototxt")}; + const auto edge_mapper = editor.create_edge_mapper(); + + try + { + const OutputEdge edge = edge_mapper.to_output_edge(EditorNode{"add_ambiguous_name"}, EditorOutput{"split2"}); + } + catch (const std::exception& e) + { + std::string msg{e.what()}; + EXPECT_TRUE(msg.find("Output edge described by: add_ambiguous_name and output name: split2 was not found") != + std::string::npos); + } +} + +NGRAPH_TEST(onnx_editor, editor_api_select_output_edge_by_ambiguous_node_name_and_output_index) +{ + ONNXModelEditor editor{file_util::path_join( + SERIALIZED_ZOO, "onnx/model_editor/subgraph_extraction_tests.prototxt")}; + const auto edge_mapper = editor.create_edge_mapper(); + + try + { + const OutputEdge edge = edge_mapper.to_output_edge(EditorNode{"add_ambiguous_name"}, EditorOutput{0}); + } + catch (const std::exception& e) + { + std::string msg{e.what()}; + EXPECT_TRUE(msg.find("Given node name: add_ambiguous_name and output index: 0 are ambiguous to determine output edge") != + std::string::npos); + } +} + NGRAPH_TEST(onnx_editor, editor_api_use_edge_mapper_with_graph_cutter) { ONNXModelEditor editor{file_util::path_join( From 7e68613ccbee4a07ff1e14afffee5eefe8901f37 Mon Sep 17 00:00:00 2001 From: mbencer Date: Wed, 24 Mar 2021 11:23:58 +0100 Subject: [PATCH 069/116] remove diagnostic logs --- ngraph/frontend/onnx_editor/src/edge_mapper.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/ngraph/frontend/onnx_editor/src/edge_mapper.cpp b/ngraph/frontend/onnx_editor/src/edge_mapper.cpp index 6bfca09284b62e..76123c31de455e 100644 --- a/ngraph/frontend/onnx_editor/src/edge_mapper.cpp +++ b/ngraph/frontend/onnx_editor/src/edge_mapper.cpp @@ -34,18 +34,15 @@ onnx_editor::EdgeMapper::EdgeMapper(const ONNX_NAMESPACE::GraphProto& graph_prot // node output name is unique m_node_name_to_index.emplace(out_name, topological_index); m_node_outputs[topological_index].push_back(out_name); - std::cout << "output: " << topological_index << ", " << out_name << "\n"; } for (const auto& in_name : node_proto.input()) { - std::cout << "in_name: " << topological_index << ", " << in_name << "\n"; m_node_inputs[topological_index].push_back(in_name); } if (!node_proto.name().empty()) { // node name can identify node, but it can be ambiguous m_node_name_to_index.emplace(node_proto.name(), topological_index); - std::cout << "node_name: " << topological_index << ", " << node_proto.name() << "\n"; } ++topological_index; } @@ -69,7 +66,6 @@ std::vector onnx_editor::EdgeMapper::find_node_indexes(const std::string& n for (auto& index_iter = matched_nodes_range.first; index_iter != matched_nodes_range.second; ++index_iter) { - std::cout << "sec: " << index_iter->second << "\n"; result.push_back(index_iter->second); } if (!result.empty()) From 81f11b9d0c7bfc320d8d5647bd99d0523450f159 Mon Sep 17 00:00:00 2001 From: mbencer Date: Wed, 24 Mar 2021 12:01:52 +0100 Subject: [PATCH 070/116] added documentation to new structs --- .../include/onnx_editor/edge_mapper.hpp | 2 +- .../include/onnx_editor/editor.hpp | 5 ++++ .../include/onnx_editor/editor_types.hpp | 23 +++++++++++++++++++ .../frontend/onnx_editor/src/edge_mapper.cpp | 2 +- ngraph/frontend/onnx_editor/src/editor.cpp | 1 - 5 files changed, 30 insertions(+), 3 deletions(-) diff --git a/ngraph/frontend/onnx_editor/include/onnx_editor/edge_mapper.hpp b/ngraph/frontend/onnx_editor/include/onnx_editor/edge_mapper.hpp index 7878ff163e81a7..a093a6f40abcc3 100644 --- a/ngraph/frontend/onnx_editor/include/onnx_editor/edge_mapper.hpp +++ b/ngraph/frontend/onnx_editor/include/onnx_editor/edge_mapper.hpp @@ -53,4 +53,4 @@ namespace ngraph std::multimap m_node_name_to_index; }; } -} \ No newline at end of file +} diff --git a/ngraph/frontend/onnx_editor/include/onnx_editor/editor.hpp b/ngraph/frontend/onnx_editor/include/onnx_editor/editor.hpp index a780505b89147d..36cb7dd221833b 100644 --- a/ngraph/frontend/onnx_editor/include/onnx_editor/editor.hpp +++ b/ngraph/frontend/onnx_editor/include/onnx_editor/editor.hpp @@ -123,6 +123,11 @@ namespace ngraph /// \param out_file_path A path to the file where the modified model should be dumped. void serialize(const std::string& out_file_path) const; + /// \brief Create edge mapper object which allow to use node names, input/output indexes + /// istead of node indexes in order to select InputEdge/OutputEdge. + /// + /// \param out_file_path EdgeMapper object which simply using methods which operate over + /// InputEdge and OutputEdge. EdgeMapper create_edge_mapper() const; private: diff --git a/ngraph/frontend/onnx_editor/include/onnx_editor/editor_types.hpp b/ngraph/frontend/onnx_editor/include/onnx_editor/editor_types.hpp index ad9c87605da54d..cbe63dd6085c8e 100644 --- a/ngraph/frontend/onnx_editor/include/onnx_editor/editor_types.hpp +++ b/ngraph/frontend/onnx_editor/include/onnx_editor/editor_types.hpp @@ -73,6 +73,13 @@ namespace ngraph /// OutputEdge(5, "out2") using OutputEdge = Edge; + /// \brief Defines single node input by the name or the index. + /// For a node number test_node, with 3 inputs: + /// + /// ----(in_A)----> +-----------+ + /// ----(in_B)----> | test_node | ----(out)----> + /// ----(in_C)----> +-----------+ + /// You can indicate in_B as Input("in_B") and Input(1) struct Input { Input() = delete; @@ -88,6 +95,13 @@ namespace ngraph const int m_input_index = -1; }; + /// \brief Defines single node output by the name or the index. + /// For a node number test_node, with 2 outputs: + /// + /// +-----------+ ---(out1)---> + /// ----(in_A)----> | test_node | + /// +-----------+ ---(out2)---> + /// You can indicate out2 as Output("out2") and Output(1) struct Output { Output() = delete; @@ -103,6 +117,15 @@ namespace ngraph const int m_output_index = -1; }; + /// \brief Defines single node by output name which is determinitic + /// and node name which can be ambiguous. + /// For a node number test_node, with 2 outputs: + /// + /// +-----------+ ---(out1)---> + /// ----(in_A)----> | test_node | + /// +-----------+ ---(out2)---> + /// You can indicate test_node by the name as Node("test_node") + /// or by assigned output as Node(Output("out1")) or Node(Output("out2")) struct Node { Node(std::string node_name) diff --git a/ngraph/frontend/onnx_editor/src/edge_mapper.cpp b/ngraph/frontend/onnx_editor/src/edge_mapper.cpp index 76123c31de455e..8e473b61f322cd 100644 --- a/ngraph/frontend/onnx_editor/src/edge_mapper.cpp +++ b/ngraph/frontend/onnx_editor/src/edge_mapper.cpp @@ -215,4 +215,4 @@ OutputEdge onnx_editor::EdgeMapper::to_output_edge(Node node, Output out) const { throw ngraph_error("Not enough information to determine output edge"); } -} \ No newline at end of file +} diff --git a/ngraph/frontend/onnx_editor/src/editor.cpp b/ngraph/frontend/onnx_editor/src/editor.cpp index 530bdf0dd5de62..83b95cca2867ee 100644 --- a/ngraph/frontend/onnx_editor/src/editor.cpp +++ b/ngraph/frontend/onnx_editor/src/editor.cpp @@ -17,7 +17,6 @@ #include #include #include -#include #include "detail/subgraph_extraction.hpp" #include "ngraph/log.hpp" From e6a4d8bcc0d05f1f93e3ad8666b42afc649863ea Mon Sep 17 00:00:00 2001 From: mbencer Date: Wed, 24 Mar 2021 13:34:51 +0100 Subject: [PATCH 071/116] EdgeMapper documentation --- .../include/onnx_editor/edge_mapper.hpp | 43 ++++++++++++++++++- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/ngraph/frontend/onnx_editor/include/onnx_editor/edge_mapper.hpp b/ngraph/frontend/onnx_editor/include/onnx_editor/edge_mapper.hpp index a093a6f40abcc3..a145415997e10e 100644 --- a/ngraph/frontend/onnx_editor/include/onnx_editor/edge_mapper.hpp +++ b/ngraph/frontend/onnx_editor/include/onnx_editor/edge_mapper.hpp @@ -33,14 +33,53 @@ namespace ngraph { namespace onnx_editor { + /// \brief A class allows to determine InputEdge and OutputEdge by user-friendly onnx names. class EdgeMapper { public: EdgeMapper() = delete; + + /// \brief Creates an edge mapper based on graph_proto state. + /// + /// \note If state of graph_proto will be changed, the information + /// from edge mapper is outdated. + /// + /// \param graph_proto Reference to GraphProto object. EdgeMapper(const ONNX_NAMESPACE::GraphProto& graph_proto); - InputEdge to_input_edge(Node node, Input in) const; - OutputEdge to_output_edge(Node node, Output out) const; + /// \brief Returns the InputEdge based on a node (node name or output name) + /// and an input (input name or input index). + /// + /// \note The node name can be ambiguous (many nodes can have the same name). + /// In such a case the algorthim try to match the given node name + /// with the input name (given input index is not enough). + /// If after such operation a found edge is unique, it is returned. + /// If InputEdge cannot be determined based on given params the ngraph_error + /// exception is thrown. + /// + /// \param node A node helper structure created based on a node name + /// or a node output name. + /// + /// \param input A input helper structure created based on a input name + /// or a input index. + InputEdge to_input_edge(Node node, Input input) const; + + /// \brief Returns the OutputEdge based on a node (node name or output name) + /// and an output (output name or output index). + /// + /// \note The node name can be ambiguous (many nodes can have the same name). + /// In such a case the algorthim try to match the given node name + /// with the output name (given output index is not enough). + /// If after such operation a found edge is unique, it is returned. + /// If OutputEdge cannot be determined based on given params the ngraph_error + /// exception is thrown. + /// + /// \param node A node helper structure created based on a node name + /// or a node output name. + /// + /// \param output A output helper structure created based on a output name + /// or a output index. + OutputEdge to_output_edge(Node node, Output output) const; private: std::vector find_node_indexes(const std::string& node_name, From 00c02a6a9b1f8beb3de615ec1cb3c8a17eb1a2be Mon Sep 17 00:00:00 2001 From: "Lyalin, Sergey" Date: Wed, 24 Mar 2021 20:30:41 +0300 Subject: [PATCH 072/116] Complete the next step of porting of TF Bridge conversion code: successfuly converted resnet 50 v2 --- .../samples/benchmark_app/CMakeLists.txt | 2 +- .../samples/benchmark_app/main.cpp | 12 +- .../frontend/generic/src/frontend_manager.cpp | 2 +- .../tensorflow_frontend/tensorflow.hpp | 23 +- .../tensorflow/src/ngraph_builder.cpp | 285 ++++++++++++------ .../frontend/tensorflow/src/ngraph_builder.h | 36 ++- ngraph/frontend/tensorflow/src/tensorflow.cpp | 35 ++- 7 files changed, 274 insertions(+), 121 deletions(-) diff --git a/inference-engine/samples/benchmark_app/CMakeLists.txt b/inference-engine/samples/benchmark_app/CMakeLists.txt index a74294a0fbbf0d..f1fbba74dec49e 100644 --- a/inference-engine/samples/benchmark_app/CMakeLists.txt +++ b/inference-engine/samples/benchmark_app/CMakeLists.txt @@ -8,5 +8,5 @@ file (GLOB HDR ${CMAKE_CURRENT_SOURCE_DIR}/*.hpp) ie_add_sample(NAME benchmark_app SOURCES ${SRC} HEADERS ${HDR} - DEPENDENCIES format_reader + DEPENDENCIES format_reader frontend_manager OPENCV_DEPENDENCIES imgcodecs) diff --git a/inference-engine/samples/benchmark_app/main.cpp b/inference-engine/samples/benchmark_app/main.cpp index a786eef5053300..737c516b4cf2c3 100644 --- a/inference-engine/samples/benchmark_app/main.cpp +++ b/inference-engine/samples/benchmark_app/main.cpp @@ -18,6 +18,8 @@ #include #include +#include + #include "benchmark_app.hpp" #include "infer_request_wrap.hpp" #include "progress_bar.hpp" @@ -329,7 +331,15 @@ int main(int argc, char *argv[]) { slog::info << "Loading network files" << slog::endl; auto startTime = Time::now(); - CNNNetwork cnnNetwork = ie.ReadNetwork(FLAGS_m); + //CNNNetwork cnnNetwork = ie.ReadNetwork(FLAGS_m); + ngraph::frontend::FrontEndManager manager; + auto FE = manager.loadByFramework("tf"); + auto inputModel = FE->loadFromFile(FLAGS_m); + inputModel->setPartialShape(inputModel->getInputs()[0], ngraph::PartialShape({1, 224, 224, 3})); + auto ngFunc = FE->convert(inputModel); + CNNNetwork cnnNetwork(ngFunc); + cnnNetwork.serialize("benchmark_app_loaded_network.xml"); + auto duration_ms = double_to_string(get_total_ms_time(startTime)); slog::info << "Read network took " << duration_ms << " ms" << slog::endl; if (statistics) diff --git a/ngraph/frontend/generic/src/frontend_manager.cpp b/ngraph/frontend/generic/src/frontend_manager.cpp index 8e411d61fc0d85..34ac092dbef2ce 100644 --- a/ngraph/frontend/generic/src/frontend_manager.cpp +++ b/ngraph/frontend/generic/src/frontend_manager.cpp @@ -29,7 +29,7 @@ namespace ngraph #define FRONT_END_NOT_IMPLEMENTED(NAME) throw #NAME " is not implemented for this FrontEnd class"; - std::vector InputModel::InputModel::getInputs () const + std::vector InputModel::getInputs () const { FRONT_END_NOT_IMPLEMENTED(getInputs); } diff --git a/ngraph/frontend/tensorflow/include/tensorflow_frontend/tensorflow.hpp b/ngraph/frontend/tensorflow/include/tensorflow_frontend/tensorflow.hpp index 9e0b03aa7b8d23..33e7e06c32e983 100644 --- a/ngraph/frontend/tensorflow/include/tensorflow_frontend/tensorflow.hpp +++ b/ngraph/frontend/tensorflow/include/tensorflow_frontend/tensorflow.hpp @@ -20,17 +20,38 @@ //#include "../../include/frontend_manager/frontend_manager.hpp" #include "frontend_manager/frontend_manager.hpp" +namespace tensorflow { class GraphDef; } + namespace ngraph { namespace frontend { + class PlaceTensorflow : public Place + { + public: + + std::string name; + enum Kind { PORT_INPUT, PORT_OUTPUT, TENSOR, OP } kind; + size_t port; + + PlaceTensorflow (const std::string& _name, Kind _kind = OP, size_t _port = 0) : name(_name), kind(_kind), port(_port) {} + }; + class NGRAPH_API InputModelTensorflow : public InputModel { public: + std::shared_ptr graph_def; std::string path; - InputModelTensorflow (const std::string& _path) : path(_path) {} + // TODO: map from PlaceTensorflow, not from name string + std::map partialShapes; + + InputModelTensorflow (const std::string& _path); + + std::vector getInputs () const override; + + void setPartialShape (Place::Ptr place, const ngraph::PartialShape& pshape) override; }; class NGRAPH_API FrontEndTensorflow : public FrontEnd diff --git a/ngraph/frontend/tensorflow/src/ngraph_builder.cpp b/ngraph/frontend/tensorflow/src/ngraph_builder.cpp index c29e6c1768f946..a818343369f924 100644 --- a/ngraph/frontend/tensorflow/src/ngraph_builder.cpp +++ b/ngraph/frontend/tensorflow/src/ngraph_builder.cpp @@ -176,7 +176,7 @@ static Status GetInputNode(const Builder::OpMap& ng_op_map, const TFNodeDecoder* #endif - TFNodeDecoder* tf_input; + const TFNodeDecoder* tf_input; size_t src_output_idx; TF_RETURN_IF_ERROR(op->input_node(input_idx, &tf_input, &src_output_idx)); std::vector> ng_op; @@ -316,6 +316,37 @@ static Status TensorDataToVector(const TensorWrapper& tensor, std::vector* ve NGRAPH_TF_FE_NOT_IMPLEMENTED } +template +static Status GetStaticInputVector( + Builder::OpMap& ng_op_map, + const TFNodeDecoder* op, int64_t input_index, + const std::vector& static_input_map, + std::vector* vector) { + ng::Output ng_input; + GetInputNode(ng_op_map, op, input_index, ng_input); + std::cerr << "y\n"; + if(auto constant = std::dynamic_pointer_cast(ng_input.get_node_shared_ptr())) + { + std::cerr << "y\n"; + std::cerr << constant->get_output_partial_shape(0) << " " << constant->get_data_ptr() << "\n"; + std::cerr << *reinterpret_cast(constant->get_data_ptr()) << "\n"; + *vector = constant->cast_vector(); + std::cerr << "z\n"; + return Status::OK(); + } + + NGRAPH_TF_FE_NOT_IMPLEMENTED; +/* + TFNodeDecoder* input_node; + TF_RETURN_IF_ERROR(op->input_node(input_index, &input_node)); + TensorWrapper* input_tensor; + TF_RETURN_IF_ERROR( + GetStaticNodeTensor(input_node, static_input_map, &input_tensor)); + TF_RETURN_IF_ERROR(TensorDataToVector(input_tensor, vector)); + return Status::OK();*/ +} + +#if 0 template static Status GetStaticInputVector( const TFNodeDecoder* op, int64_t input_index, @@ -323,7 +354,7 @@ static Status GetStaticInputVector( std::vector* vector) { TFNodeDecoder* input_node; TF_RETURN_IF_ERROR(op->input_node(input_index, &input_node)); - TensorWrapper input_tensor; + TensorWrapper* input_tensor; TF_RETURN_IF_ERROR( GetStaticNodeTensor(input_node, static_input_map, &input_tensor)); TF_RETURN_IF_ERROR(TensorDataToVector(input_tensor, vector)); @@ -372,6 +403,7 @@ static Status GetStaticInputNode( } return Status::OK(); } +#endif // Taken from: tensorflow/core/grappler/optimizers/arithmetic_optimizer.cc // Extract values from a Const op to `values`. Returns true if succeeds. @@ -384,41 +416,57 @@ template static Status ValuesFromConstNode(const TFNodeDecoder* node, ngraph::Shape* const_tensor_shape, std::vector* values) { -#if 0 - if (node.op() != "Const") { +#if 1 + + if (node->op() != "Const") { return errors::InvalidArgument("TFNodeDecoder not a Const"); } + DataType dt; + node->getAttrValue("dtype", &dt); - if (node.attr().at("dtype").type() != DataTypeToEnum::value) { - std::stringstream ss; - ss << "Invalid data type defined for Const. Defined: " - << node.attr().at("dtype").type(); - return errors::InvalidArgument(ss.str()); - } + + /* + if (dt != DataTypeToEnum::value) { + std::stringstream ss; + ss << "Invalid data type defined for Const. Defined: " + << node.attr().at("dtype").type(); + return errors::InvalidArgument(ss.str()); + } + */ // TensorWrapper represents the content of the tensor in either _val or // tensor_content. - const TensorWrapper& tensor = node.attr().at("value").tensor(); - typename checkpoint::SaveTypeTraits::RepeatedField* tensor_values = - checkpoint::MutableTensorProtoData(const_cast(&tensor)); - - const TensorShapeProto& shape = tensor.tensor_shape(); - *const_tensor_shape = shape; - if (!tensor_values->empty() && tensor.has_tensor_shape()) { + TensorWrapper* tensor; + node->getAttrValue("value", &tensor); + //typename checkpoint::SaveTypeTraits::RepeatedField* tensor_values = + // checkpoint::MutableTensorProtoData(const_cast(&tensor)); + + const TensorShapeProto& shape = tensor->tensor_def->tensor_shape(); + ngraph::PartialShape pshape; + TFTensorShapeToNGraphShape(shape, &pshape); + *const_tensor_shape = pshape.get_shape(); + if(pshape.is_dynamic()) + NGRAPH_TF_FE_NOT_IMPLEMENTED; + auto tensor_content = tensor->tensor_def->tensor_content(); + std::vector tensor_values_plain(tensor_content.begin(), tensor_content.end()); + const T* tensor_values = reinterpret_cast(tensor_values_plain.data()); + + if (!tensor_values_plain.empty() && tensor->tensor_def->has_tensor_shape()) { // When tensor_shape is set, theoretically the representation of the data // could be compressed. So, before copying values to the returned vector, // make sure no compression happens. - if (shape.dim_size() == 1 && shape.dim(0).size() == tensor_values->size()) { - values->insert(values->end(), tensor_values->begin(), - tensor_values->end()); + //if (shape.dim_size() == 1 && shape.dim(0).size() == tensor_values_plain.size()/sizeof(T)) { + values->insert(values->end(), tensor_values, + tensor_values + tensor_values_plain.size()/sizeof(T)); return Status::OK(); - } + //} } - const auto tensor_content_size = tensor.tensor_content().size(); - CHECK_EQ(0, tensor_content_size % sizeof(VecT)) - << " tensor_content_size (" << tensor_content_size - << ") is not a multiple of " << sizeof(VecT); + const auto tensor_content_size = tensor->tensor_def->tensor_content().size(); + if(tensor_content_size % sizeof(VecT)) { + std::cerr << "[ ERROR ] tensor_content_size (" << tensor_content_size + << ") is not a multiple of " << sizeof(VecT); + } // If tensor_content_size is zero, we'll have to take the values from // int_val, float_val, etc. @@ -436,42 +484,41 @@ static Status ValuesFromConstNode(const TFNodeDecoder* node, auto val_lastsaved = (T)0; // cast for (auto i = 0; i < n_elements; i++) { - auto& tensor = node.attr().at("value").tensor(); - auto dt = node.attr().at("dtype").type(); + auto& tensor_proto = *tensor->tensor_def; int64_t val_size = 0; auto val_i = (T)0; // cast switch (dt) { // TODO(amprocte/NGRAPH-2502): there are more element types to support // here case DT_INT32: - val_size = tensor.int_val_size(); - if (val_size > 0) val_i = tensor.int_val()[i]; + val_size = tensor_proto.int_val_size(); + if (val_size > 0) val_i = tensor_proto.int_val()[i]; break; case DT_INT64: - val_size = tensor.int64_val_size(); - if (val_size > 0) val_i = tensor.int64_val()[i]; + val_size = tensor_proto.int64_val_size(); + if (val_size > 0) val_i = tensor_proto.int64_val()[i]; break; case DT_FLOAT: - val_size = tensor.float_val_size(); - if (val_size > 0) val_i = tensor.float_val()[i]; + val_size = tensor_proto.float_val_size(); + if (val_size > 0) val_i = tensor_proto.float_val()[i]; break; case DT_BOOL: - val_size = tensor.bool_val_size(); - if (val_size > 0) val_i = tensor.bool_val()[i]; + val_size = tensor_proto.bool_val_size(); + if (val_size > 0) val_i = tensor_proto.bool_val()[i]; break; case DT_DOUBLE: - val_size = tensor.double_val_size(); - if (val_size > 0) val_i = tensor.double_val()[i]; + val_size = tensor_proto.double_val_size(); + if (val_size > 0) val_i = tensor_proto.double_val()[i]; break; default: NGRAPH_VLOG(0) - << "Const node has empty tensor and we don't know how to " + << "Const node has empty tensor_proto and we don't know how to " "handle this element type"; - NGRAPH_VLOG(0) << node.DebugString(); + NGRAPH_VLOG(0) << node->DebugString(); NGRAPH_VLOG(0) << shape.DebugString(); - return errors::Unimplemented("Encountered unknown element type ", - DataType_Name(dt), - " on an empty tensor"); + return errors::Unimplemented("Encountered unknown element type " + + DataType_Name(dt) + + " on an empty tensor_proto"); } if (val_size == 0) { return errors::InvalidArgument("Empty values vector"); @@ -483,15 +530,17 @@ static Status ValuesFromConstNode(const TFNodeDecoder* node, } } } else { - values->resize(tensor_content_size / sizeof(VecT)); - port::CopyToArray(tensor.tensor_content(), - reinterpret_cast(values->data())); + + return Status::OK(); + //values->resize(tensor_content_size / sizeof(VecT)); + //port::CopyToArray(tensor.tensor_content(), + // reinterpret_cast(values->data())); } return Status::OK(); #endif - NGRAPH_TF_FE_NOT_IMPLEMENTED + } // Helper for Builder::TranslateGraph ("Const" op) @@ -673,7 +722,7 @@ static Status TranslateArgMinMax( TF_RETURN_IF_ERROR(GetInputNode(ng_op_map, op, 0, ng_input)); std::vector tf_dim; - TF_RETURN_IF_ERROR(GetStaticInputVector(op, 1, static_input_map, &tf_dim)); + TF_RETURN_IF_ERROR(GetStaticInputVector(ng_op_map, op, 1, static_input_map, &tf_dim)); ng::Shape input_shape = ng_input.get_shape(); size_t input_rank = input_shape.size(); @@ -866,7 +915,7 @@ static Status TranslateConcatV2Op( std::vector tf_concat_axis_vec; TF_RETURN_IF_ERROR(GetStaticInputVector( - op, op->num_inputs() - 1, static_input_map, &tf_concat_axis_vec)); + ng_op_map, op, op->num_inputs() - 1, static_input_map, &tf_concat_axis_vec)); int64_t concat_axis = tf_concat_axis_vec[0]; @@ -1018,7 +1067,7 @@ static Status TranslateConv2DBackpropInputOp( std::vector tf_input_sizes; TF_RETURN_IF_ERROR( - GetStaticInputVector(op, 0, static_input_map, &tf_input_sizes)); + GetStaticInputVector(ng_op_map, op, 0, static_input_map, &tf_input_sizes)); if (std::any_of(tf_input_sizes.begin(), tf_input_sizes.end(), [](int32_t size) { return size <= 0; })) { @@ -1287,7 +1336,7 @@ static Status TranslateExpandDimsOp( ng::Output ng_input; TF_RETURN_IF_ERROR(GetInputNode(ng_op_map, op, 0, ng_input)); std::vector dims; - TF_RETURN_IF_ERROR(GetStaticInputVector(op, 1, static_input_map, &dims)); + TF_RETURN_IF_ERROR(GetStaticInputVector(ng_op_map, op, 1, static_input_map, &dims)); auto ng_dims = ConstructNgNode( op->name(), ng::element::i64, ngraph::Shape{dims.size()}, dims); SaveNgOp(ng_op_map, op->name(), @@ -1440,7 +1489,7 @@ static Status TranslateGatherV2Op( GetInputNodes(ng_op_map, op, ng_input, ng_input_coords, ng_unused)); std::vector tf_axis; - TF_RETURN_IF_ERROR(GetStaticInputVector(op, 2, static_input_map, &tf_axis)); + TF_RETURN_IF_ERROR(GetStaticInputVector(ng_op_map, op, 2, static_input_map, &tf_axis)); if (tf_axis.size() > 1) { std::ostringstream buf; @@ -1871,7 +1920,7 @@ static Status TranslateNonMaxSuppressionV2Op( std::vector max_output_size; TF_RETURN_IF_ERROR( - GetStaticInputVector(op, 2, static_input_map, &max_output_size)); + GetStaticInputVector(ng_op_map, op, 2, static_input_map, &max_output_size)); // max_output_size must be scalar if (max_output_size.size() != 1) { @@ -1919,7 +1968,7 @@ static Status TranslateReduceOp( } std::vector axes; - TF_RETURN_IF_ERROR(GetStaticInputVector(op, 1, static_input_map, &axes)); + TF_RETURN_IF_ERROR(GetStaticInputVector(ng_op_map, op, 1, static_input_map, &axes)); ng::Shape input_shape = ng_input.get_shape(); size_t input_rank = input_shape.size(); @@ -1970,7 +2019,7 @@ static Status TranslateOneHotOp( auto ng_features_shape = ng_features.get_shape(); std::vector depth; - TF_RETURN_IF_ERROR(GetStaticInputVector(op, 1, static_input_map, &depth)); + TF_RETURN_IF_ERROR(GetStaticInputVector(ng_op_map, op, 1, static_input_map, &depth)); // Depth must be scalar if (depth.size() != 1) { @@ -2056,7 +2105,7 @@ static Status TranslatePadOp(const TFNodeDecoder* op, // Set pads_begin & pads_end (from the pad_val_op) std::vector paddings; - TF_RETURN_IF_ERROR(GetStaticInputVector(op, 1, static_input_map, &paddings)); + TF_RETURN_IF_ERROR(GetStaticInputVector(ng_op_map, op, 1, static_input_map, &paddings)); NGRAPH_VLOG(3) << op->name() << " pads {" << ng::join(paddings) << "}"; if (paddings.size() % 2 != 0) { return errors::InvalidArgument( @@ -2089,21 +2138,21 @@ static Status TranslateRangeOp( ng::Output ng_start, ng_stop, ng_step; TF_RETURN_IF_ERROR(GetInputNodes(ng_op_map, op, ng_start, ng_stop, ng_step)); - DataType start_type = op->input_type(0); - DataType stop_type = op->input_type(1); - DataType step_type = op->input_type(2); + //DataType start_type = op->input_type(0); + //DataType stop_type = op->input_type(1); + //DataType step_type = op->input_type(2); ng::element::Type out_type; TF_RETURN_IF_ERROR( TFDataTypeToNGraphElementType(op->output_type(0), &out_type)); - ng::Output start_node, stop_node, step_node; - TF_RETURN_IF_ERROR( - GetStaticInputNode(op, 0, static_input_map, start_type, start_node)); - TF_RETURN_IF_ERROR( - GetStaticInputNode(op, 1, static_input_map, stop_type, stop_node)); - TF_RETURN_IF_ERROR( - GetStaticInputNode(op, 2, static_input_map, step_type, step_node)); - auto ng_range = ConstructNgNode(op->name(), start_node, - stop_node, step_node, out_type); + //ng::Output start_node, stop_node, step_node; + //TF_RETURN_IF_ERROR( + // GetStaticInputNode(op, 0, static_input_map, start_type, start_node)); + //TF_RETURN_IF_ERROR( + // GetStaticInputNode(op, 1, static_input_map, stop_type, stop_node)); + //TF_RETURN_IF_ERROR( + // GetStaticInputNode(op, 2, static_input_map, step_type, step_node)); + auto ng_range = ConstructNgNode(op->name(), ng_start, + ng_stop, ng_step, out_type); SaveNgOp(ng_op_map, op->name(), ng_range); return Status::OK(); @@ -2162,7 +2211,7 @@ static Status TranslateReshapeOp( NGRAPH_VLOG(3) << "Input shape: " << ng::join(ng_input.get_shape()); std::vector shape; - TF_RETURN_IF_ERROR(GetStaticInputVector(op, 1, static_input_map, &shape)); + TF_RETURN_IF_ERROR(GetStaticInputVector(ng_op_map, op, 1, static_input_map, &shape)); NGRAPH_VLOG(3) << "Requested result shape: " << ng::join(shape); @@ -2243,8 +2292,8 @@ static Status TranslateSliceOp( std::vector begin_vec; std::vector size_vec; - TF_RETURN_IF_ERROR(GetStaticInputVector(op, 1, static_input_map, &begin_vec)); - TF_RETURN_IF_ERROR(GetStaticInputVector(op, 2, static_input_map, &size_vec)); + TF_RETURN_IF_ERROR(GetStaticInputVector(ng_op_map, op, 1, static_input_map, &begin_vec)); + TF_RETURN_IF_ERROR(GetStaticInputVector(ng_op_map, op, 2, static_input_map, &size_vec)); if (begin_vec.size() != size_vec.size()) return errors::InvalidArgument( @@ -2357,7 +2406,7 @@ static Status TranslateSplitOp( std::vector split_dim_vec; TF_RETURN_IF_ERROR( - GetStaticInputVector(op, 0, static_input_map, &split_dim_vec)); + GetStaticInputVector(ng_op_map, op, 0, static_input_map, &split_dim_vec)); int split_dim = split_dim_vec[0] + (split_dim_vec[0] < 0 ? (int64_t)rank : 0); auto ng_split_dim = ConstructNgNode( op->name(), ng::element::u64, ng::Shape{}, split_dim); @@ -2383,7 +2432,7 @@ static Status TranslateSplitVOp( std::vector split_dim_vec; TF_RETURN_IF_ERROR( - GetStaticInputVector(op, 2, static_input_map, &split_dim_vec)); + GetStaticInputVector(ng_op_map, op, 2, static_input_map, &split_dim_vec)); // there should be at least one element specified as axis and not more than // one as axis is 0-D if (split_dim_vec.size() != 1) { @@ -2398,7 +2447,7 @@ static Status TranslateSplitVOp( std::vector split_lengths_vec; TF_RETURN_IF_ERROR( - GetStaticInputVector(op, 1, static_input_map, &split_lengths_vec)); + GetStaticInputVector(ng_op_map, op, 1, static_input_map, &split_lengths_vec)); // length: Length of size_splits int length = 0; @@ -2503,12 +2552,16 @@ static Status TranslateStridedSliceOp( << " ellipsis mask: " << ellipsis_mask; std::vector begin_vec; - TF_RETURN_IF_ERROR(GetStaticInputVector(op, 1, static_input_map, &begin_vec)); + std::cerr << "x\n"; + TF_RETURN_IF_ERROR(GetStaticInputVector(ng_op_map, op, 1, static_input_map, &begin_vec)); std::vector end_vec; - TF_RETURN_IF_ERROR(GetStaticInputVector(op, 2, static_input_map, &end_vec)); + std::cerr << "x\n"; + TF_RETURN_IF_ERROR(GetStaticInputVector(ng_op_map, op, 2, static_input_map, &end_vec)); std::vector stride_vec; + std::cerr << "x\n"; TF_RETURN_IF_ERROR( - GetStaticInputVector(op, 3, static_input_map, &stride_vec)); + GetStaticInputVector(ng_op_map, op, 3, static_input_map, &stride_vec)); + std::cerr << "x\n"; auto begin = ConstructNgNode( op->name(), ng::element::i64, ng::Shape{begin_vec.size()}, begin_vec); @@ -2517,6 +2570,7 @@ static Status TranslateStridedSliceOp( auto strides = ConstructNgNode( op->name(), ng::element::i64, ng::Shape{stride_vec.size()}, stride_vec); + std::cerr << "x\n"; auto mask_to_vec = [](int32_t mask) { auto length = sizeof(mask) * CHAR_BIT; std::vector vec(length, 0); @@ -2547,7 +2601,7 @@ static Status TranslateTileOp( TF_RETURN_IF_ERROR(GetInputNodes(ng_op_map, op, ng_input, ng_multiples)); std::vector multiples; - TF_RETURN_IF_ERROR(GetStaticInputVector(op, 1, static_input_map, &multiples)); + TF_RETURN_IF_ERROR(GetStaticInputVector(ng_op_map, op, 1, static_input_map, &multiples)); auto ng_repeats = ConstructNgNode( op->name(), ng::element::i64, ng::Shape{multiples.size()}, multiples); @@ -2571,7 +2625,7 @@ static Status TranslateTopKV2Op( // scalar input tensor specifying how many max/min elts should be computed // CPU backend only supports element type i64 std::vector ng_k_vec; - TF_RETURN_IF_ERROR(GetStaticInputVector(op, 1, static_input_map, &ng_k_vec)); + TF_RETURN_IF_ERROR(GetStaticInputVector(ng_op_map, op, 1, static_input_map, &ng_k_vec)); auto ng_k = ConstructNgNode(op->name(), ng::element::i64, ng::Shape{}, ng_k_vec[0]); @@ -2840,19 +2894,30 @@ class NodeProtoWrapper : public TFNodeDecoder NodeProtoWrapper(const NodeDef* _node_def, const GraphDef* _graph_def, std::vector* _nodes) : node_def(_node_def), graph_def(_graph_def), nodes(_nodes) {} -#define GET_ATTR_VALUE(TYPE, FIELD) virtual void getAttrValue (const char* name, TYPE* x) override { *x = node_def->attr().at(name).FIELD(); } - +#define GET_ATTR_VALUE(TYPE, FIELD) virtual void getAttrValue (const char* name, TYPE* x) const override \ + { *x = node_def->attr().at(name).FIELD(); } +#define GET_ATTR_VALUE_VECTOR(TYPE, FIELD) virtual void getAttrValue (const char* name, std::vector* x) const override \ + {\ + const auto& list = node_def->attr().at(name).list();\ + x->reserve(/*node_def->attr().at(name).FIELD##_size()*/list.FIELD##_size());\ + for(size_t i = 0; i < list.FIELD##_size(); ++i)\ + {\ + x->push_back(list.FIELD(i));\ + }\ + } - virtual void getAttrValue (const char* name, std::vector* x) override { NGRAPH_TF_FE_NOT_IMPLEMENTED; } - virtual void getAttrValue (const char* name, std::vector* x) override { NGRAPH_TF_FE_NOT_IMPLEMENTED; } + GET_ATTR_VALUE_VECTOR(int32_t, i) + GET_ATTR_VALUE_VECTOR(float, f) + //virtual void getAttrValue (const char* name, std::vector* x) const override { NGRAPH_TF_FE_NOT_IMPLEMENTED; } + //virtual void getAttrValue (const char* name, std::vector* x) const override { NGRAPH_TF_FE_NOT_IMPLEMENTED; } GET_ATTR_VALUE(int32_t, i) - virtual void getAttrValue (const char* name, DataType* x) override + virtual void getAttrValue (const char* name, DataType* x) const override { *x = node_def->attr().at(name).type(); } - virtual void getAttrValue (const char* name, ngraph::PartialShape* x) override { + virtual void getAttrValue (const char* name, ngraph::PartialShape* x) const override { TFTensorShapeToNGraphShape(node_def->attr().at(name).shape(), x); } @@ -2861,10 +2926,19 @@ class NodeProtoWrapper : public TFNodeDecoder GET_ATTR_VALUE(long int, i) GET_ATTR_VALUE(float, f) - virtual void getAttrValue (const char* name, std::vector* x) override { NGRAPH_TF_FE_NOT_IMPLEMENTED; } + virtual void getAttrValue (const char* name, std::vector* x) const override { NGRAPH_TF_FE_NOT_IMPLEMENTED; } // a way to read Const value as a tensor - virtual void getAttrValue (const char* name, TensorWrapper** x) override { NGRAPH_TF_FE_NOT_IMPLEMENTED; } + virtual void getAttrValue (const char* name, TensorWrapper** x) const override + { + // TODO: use std::shared_ptr! memory is lost! + *x = new TensorWrapper(&node_def->attr().at(name).tensor()); + } + + virtual std::string op () const override + { + return node_def->op(); + } virtual unsigned int num_inputs () const override { return node_def->input_size(); } @@ -2878,9 +2952,9 @@ class NodeProtoWrapper : public TFNodeDecoder return node_def->op(); } - virtual Status input_node (size_t index, TFNodeDecoder**) const override { NGRAPH_TF_FE_NOT_IMPLEMENTED; } + virtual Status input_node (size_t index, TFNodeDecoder const * *) const override { NGRAPH_TF_FE_NOT_IMPLEMENTED; } - virtual Status input_node (size_t index, TFNodeDecoder** retnode, size_t* outputPortIndex) const override + virtual Status input_node (size_t index, TFNodeDecoder const * * retnode, size_t* outputPortIndex) const override { std::string input_name = node_def->input(index); if(input_name.find(':') != std::string::npos) { @@ -2953,7 +3027,7 @@ void PopulateNodesTopologicallySorted (const GraphDef* input_graph, std::vector< } Status Builder::TranslateGraph( - const std::vector& inputs, + const std::map& inputs, const std::vector& static_input_map, const GraphDef* input_graph, const std::string name, std::shared_ptr& ng_function) { // @@ -3028,14 +3102,17 @@ Status Builder::TranslateGraph( std::cerr << "\nX\n"; ng::PartialShape ng_shape; - try - { - GetNodeAttr(parm->attrs(), "shape", &ng_shape); - } - catch (google::protobuf::FatalException) - { - // suppose there is no shape - // TODO: do it in a good way + auto overridenInputShape = inputs.find(parm->name()); + if(overridenInputShape == inputs.end()) { + try { + GetNodeAttr(parm->attrs(), "shape", &ng_shape); + } + catch (google::protobuf::FatalException) { + // suppose there is no shape + // TODO: do it in a good way + } + } else { + ng_shape = overridenInputShape->second; } #if 0 @@ -3109,6 +3186,20 @@ Status Builder::TranslateGraph( ngraph::as_type_ptr(ng_result.get_node_shared_ptr()); } + // Find all terminal nodes in ngraph graph to complete list of results + for(auto op: tf_ops) + { + auto p = ng_op_map.find(op->name()); + if(p != ng_op_map.end()) + { + for(auto output: p->second) + { + if(output.get_target_inputs().empty()) + ng_result_list.push_back(std::make_shared(output)); + } + } + } + // // Create the nGraph function. // diff --git a/ngraph/frontend/tensorflow/src/ngraph_builder.h b/ngraph/frontend/tensorflow/src/ngraph_builder.h index 7025a00966dd9a..aea9e19eed8f5e 100644 --- a/ngraph/frontend/tensorflow/src/ngraph_builder.h +++ b/ngraph/frontend/tensorflow/src/ngraph_builder.h @@ -22,6 +22,7 @@ #include #include +// TODO: remove explicit proto dependency from this common header #include "graph.pb.h" #include "ngraph/ngraph.hpp" @@ -86,27 +87,29 @@ class TFNodeDecoder // a hack to minimize amount of code TFNodeDecoder& attrs () const { return const_cast(*this); } - virtual void getAttrValue (const char* name, std::vector* x) = 0; - virtual void getAttrValue (const char* name, std::vector* x) = 0; - virtual void getAttrValue (const char* name, int32_t* x) = 0; - virtual void getAttrValue (const char* name, DataType* x) = 0; - virtual void getAttrValue (const char* name, std::string* x) = 0; - virtual void getAttrValue (const char* name, bool* x) = 0; - virtual void getAttrValue (const char* name, long int* x) = 0; - virtual void getAttrValue (const char* name, float* x) = 0; - virtual void getAttrValue (const char* name, std::vector* x) = 0; - virtual void getAttrValue (const char* name, ngraph::PartialShape* x) = 0; + virtual void getAttrValue (const char* name, std::vector* x) const = 0; + virtual void getAttrValue (const char* name, std::vector* x) const = 0; + virtual void getAttrValue (const char* name, int32_t* x) const = 0; + virtual void getAttrValue (const char* name, DataType* x) const = 0; + virtual void getAttrValue (const char* name, std::string* x) const = 0; + virtual void getAttrValue (const char* name, bool* x) const = 0; + virtual void getAttrValue (const char* name, long int* x) const = 0; + virtual void getAttrValue (const char* name, float* x) const = 0; + virtual void getAttrValue (const char* name, std::vector* x) const = 0; + virtual void getAttrValue (const char* name, ngraph::PartialShape* x) const = 0; + + virtual std::string op () const = 0; // a way to read Const value as a tensor - virtual void getAttrValue (const char* name, TensorWrapper** x) = 0; + virtual void getAttrValue (const char* name, TensorWrapper** x) const = 0; virtual unsigned int num_inputs () const = 0; virtual std::string name () const = 0; virtual bool IsArg () const = 0; virtual std::string type_string () const = 0; - virtual Status input_node (size_t index, TFNodeDecoder**) const = 0; - virtual Status input_node (size_t index, TFNodeDecoder**, size_t* outputPortIndex) const = 0; + virtual Status input_node (size_t index, TFNodeDecoder const * *) const = 0; + virtual Status input_node (size_t index, TFNodeDecoder const * *, size_t* outputPortIndex) const = 0; virtual DataType input_type (size_t index) const = 0; virtual DataType output_type (size_t index) const = 0; @@ -117,10 +120,15 @@ class TFNodeDecoder virtual bool IsRetval () const = 0; }; +// TODO: separate interface from proto implementation; here is a proto implementation class TensorWrapper { public: + const TensorProto* tensor_def; + + TensorWrapper (const TensorProto* _tensor_def) : tensor_def(_tensor_def) {} + // a hack to minimize amount of code TensorWrapper &attrs() const { return const_cast(*this); } @@ -147,7 +155,7 @@ Status GetNodeAttr (TFNodeDecoder& attrs, const char* attr_name, T* result) class Builder { public: static Status TranslateGraph( - const std::vector& inputs, + const std::map& inputs, const std::vector& static_input_map, const GraphDef* tf_graph, const std::string name, std::shared_ptr& ng_function); diff --git a/ngraph/frontend/tensorflow/src/tensorflow.cpp b/ngraph/frontend/tensorflow/src/tensorflow.cpp index a4279355dbbead..ac4131dcbedc2c 100644 --- a/ngraph/frontend/tensorflow/src/tensorflow.cpp +++ b/ngraph/frontend/tensorflow/src/tensorflow.cpp @@ -24,16 +24,39 @@ using namespace google; +using namespace ngraph::frontend; + +InputModelTensorflow::InputModelTensorflow (const std::string& _path) : path(_path) +{ + std::ifstream pb_stream(path, std::ios::binary); + graph_def = std::make_shared(); + std::cout << "[ INFO ] Model Parsed: " << graph_def->ParseFromIstream(&pb_stream) << std::endl; + std::cout << "[ INFO ] Loaded model contains " << graph_def->node_size() << " nodes." << std::endl; +} + +std::vector InputModelTensorflow::getInputs () const { +// TODO: Cache results + std::vector result; + for (size_t i = 0; i < graph_def->node_size(); ++i) { + if (graph_def->node(i).op() == "Placeholder") + result.push_back(std::make_shared(graph_def->node(i).name())); + } + return result; +} + +void InputModelTensorflow::setPartialShape (Place::Ptr place, const ngraph::PartialShape& pshape) { + auto place_tf = std::dynamic_pointer_cast(place); + partialShapes[place_tf->name] = pshape; +} + std::shared_ptr ngraph::frontend::FrontEndTensorflow::convert (InputModel::Ptr model) const { - std::string path = std::dynamic_pointer_cast(model)->path; + auto model_tf = std::dynamic_pointer_cast(model); std::cerr << "[ INFO ] FrontEndTensorflow::convert invoked\n"; - tensorflow::GraphDef fw_model; - std::ifstream pb_stream(path, std::ios::binary); - std::cout << "[ INFO ] Model Parsed: " << fw_model.ParseFromIstream(&pb_stream) << std::endl; - std::cout << "[ INFO ] Loaded model contains " << fw_model.node_size() << " nodes." << std::endl; + std::shared_ptr f; - std::cerr << "[ STATUS ] TranslateGraph return: " << tensorflow::ngraph_bridge::Builder::TranslateGraph({}, {}, &fw_model, "here_should_be_a_graph_name", f); + std::cerr << "[ STATUS ] TranslateGraph return: " << tensorflow::ngraph_bridge::Builder::TranslateGraph( + model_tf->partialShapes, {}, model_tf->graph_def.get(), "here_should_be_a_graph_name", f); //auto f = std::make_shared(ngraph::NodeVector{}, ngraph::ParameterVector{}); std::cerr << "[ ERROR ] Convetion functionality is not implemented; an empty function will be returned."; std::cerr << "[ INFO ] Resulting nGraph function contains " << f->get_ops().size() << " nodes." << std::endl; From 1c6db0a66a4ec6a689fb492a6869e185cc9fcc45 Mon Sep 17 00:00:00 2001 From: "Lyalin, Sergey" Date: Thu, 25 Mar 2021 09:35:52 +0300 Subject: [PATCH 073/116] Disabled/removed most of the debugging output; enabled setting shape for a single input in MO --- model-optimizer/mo/front/extractor.py | 8 ++++++- model-optimizer/mo/pipeline/unified.py | 8 +++---- .../tensorflow/src/ngraph_builder.cpp | 23 +------------------ .../frontend/tensorflow/src/ngraph_builder.h | 5 ++++ .../python/src/pyngraph/frontend_manager.cpp | 1 + 5 files changed, 18 insertions(+), 27 deletions(-) diff --git a/model-optimizer/mo/front/extractor.py b/model-optimizer/mo/front/extractor.py index 56c33947583d8d..baa49faff53e2b 100644 --- a/model-optimizer/mo/front/extractor.py +++ b/model-optimizer/mo/front/extractor.py @@ -589,6 +589,7 @@ def input_user_data_repack(graph: Graph, input_user_shapes: [None, list, dict, n # New version of FrontEnd is activated print("I'm HERE") inputModel = graph.graph['input_model'] + print(input_user_shapes) if isinstance(input_user_shapes, list) or isinstance(input_user_shapes, dict): for input_name in input_user_shapes: node = decodeNameWithPort(graph, input_name) @@ -600,7 +601,12 @@ def input_user_data_repack(graph: Graph, input_user_shapes: [None, list, dict, n _input_shapes.append({'node': node, 'shape': shape, 'data_type': data_type}) else: _input_shapes.append({'node': node, 'shape': shape}) - # TODO: Implement the remaining cases + else: + # np.ndarray is a shape. User provided only --input_shape key + assert isinstance(input_user_shapes, np.ndarray) + model_inputs = inputModel.getInputs() + assert len(model_inputs) == 1 + _input_shapes.append({'node': model_inputs[0], 'shape': input_user_shapes}) return _input_shapes, dict() diff --git a/model-optimizer/mo/pipeline/unified.py b/model-optimizer/mo/pipeline/unified.py index 30ebc2fb32246f..87dd71fd6c0935 100644 --- a/model-optimizer/mo/pipeline/unified.py +++ b/model-optimizer/mo/pipeline/unified.py @@ -25,6 +25,7 @@ from mo.utils.class_registration import apply_replacements_list from ngraph import FrontEndManager from ngraph import function_to_cnn +from ngraph import PartialShape import logging as log @@ -64,11 +65,10 @@ def moc_pipeline(argv: argparse.Namespace): apply_replacements_list(graph, transforms) user_shapes = graph.graph['user_shapes'] - print(user_shapes) if user_shapes: - inputModel.extractSubgraph([us['node'] for us in user_shapes], []) -# for shape in user_shapes: -# inputModel.setPartialShape(shape['node'], ng.PartialShape([ng.Dimension(5,5), ng.Dimension(3), ng.Dimension(-1), ng.Dimension(-1)])) + assert len(inputModel.getInputs()) == 1 + assert len(user_shapes) == 1 + inputModel.setPartialShape(user_shapes[0]['node'], PartialShape(user_shapes[0]['shape'])) nGraphModel = fe.convert(inputModel) network = function_to_cnn(nGraphModel) graph.graph['network'] = network diff --git a/ngraph/frontend/tensorflow/src/ngraph_builder.cpp b/ngraph/frontend/tensorflow/src/ngraph_builder.cpp index a818343369f924..c2f70fae157570 100644 --- a/ngraph/frontend/tensorflow/src/ngraph_builder.cpp +++ b/ngraph/frontend/tensorflow/src/ngraph_builder.cpp @@ -26,13 +26,7 @@ #include "ngraph_builder.h" #include "ngraph_conversions.h" #include "default_opset.h" -#if 0 -#include "api.h" -#include "logging/ngraph_log.h" -#include "ngraph_bridge/ngraph_mark_for_clustering.h" -#include "ngraph_bridge/ngraph_utils.h" -#include "ngraph_bridge/pass/transpose_sinking.h" -#endif + using namespace std; namespace ng = ngraph; @@ -324,14 +318,9 @@ static Status GetStaticInputVector( std::vector* vector) { ng::Output ng_input; GetInputNode(ng_op_map, op, input_index, ng_input); - std::cerr << "y\n"; if(auto constant = std::dynamic_pointer_cast(ng_input.get_node_shared_ptr())) { - std::cerr << "y\n"; - std::cerr << constant->get_output_partial_shape(0) << " " << constant->get_data_ptr() << "\n"; - std::cerr << *reinterpret_cast(constant->get_data_ptr()) << "\n"; *vector = constant->cast_vector(); - std::cerr << "z\n"; return Status::OK(); } @@ -2552,16 +2541,12 @@ static Status TranslateStridedSliceOp( << " ellipsis mask: " << ellipsis_mask; std::vector begin_vec; - std::cerr << "x\n"; TF_RETURN_IF_ERROR(GetStaticInputVector(ng_op_map, op, 1, static_input_map, &begin_vec)); std::vector end_vec; - std::cerr << "x\n"; TF_RETURN_IF_ERROR(GetStaticInputVector(ng_op_map, op, 2, static_input_map, &end_vec)); std::vector stride_vec; - std::cerr << "x\n"; TF_RETURN_IF_ERROR( GetStaticInputVector(ng_op_map, op, 3, static_input_map, &stride_vec)); - std::cerr << "x\n"; auto begin = ConstructNgNode( op->name(), ng::element::i64, ng::Shape{begin_vec.size()}, begin_vec); @@ -2570,7 +2555,6 @@ static Status TranslateStridedSliceOp( auto strides = ConstructNgNode( op->name(), ng::element::i64, ng::Shape{stride_vec.size()}, stride_vec); - std::cerr << "x\n"; auto mask_to_vec = [](int32_t mask) { auto length = sizeof(mask) * CHAR_BIT; std::vector vec(length, 0); @@ -2958,7 +2942,6 @@ class NodeProtoWrapper : public TFNodeDecoder { std::string input_name = node_def->input(index); if(input_name.find(':') != std::string::npos) { - std::cerr << "input_name: " << input_name << "\n"; NGRAPH_TF_FE_NOT_IMPLEMENTED; } // TODO: don't search linearly every time!!! @@ -2986,7 +2969,6 @@ class NodeProtoWrapper : public TFNodeDecoder virtual bool IsSource () const override { // TODO: populate with other source operation types - std::cerr << "IsSource for " << node_def->op() << "\n"; return node_def->op() == "Placeholder"; } @@ -3084,7 +3066,6 @@ Status Builder::TranslateGraph( int index = 0; for (auto parm : tf_params) { - std::cerr << "processing " << parm->name() << "\n"; DataType dtype; // TODO: replace dtype by T when converting Arg if (GetNodeAttr(parm->attrs(), "dtype", &dtype) != Status::OK()) { @@ -3099,8 +3080,6 @@ Status Builder::TranslateGraph( ng::element::Type ng_et; TF_RETURN_IF_ERROR(TFDataTypeToNGraphElementType(dtype, &ng_et)); - std::cerr << "\nX\n"; - ng::PartialShape ng_shape; auto overridenInputShape = inputs.find(parm->name()); if(overridenInputShape == inputs.end()) { diff --git a/ngraph/frontend/tensorflow/src/ngraph_builder.h b/ngraph/frontend/tensorflow/src/ngraph_builder.h index aea9e19eed8f5e..a8997c07c7e329 100644 --- a/ngraph/frontend/tensorflow/src/ngraph_builder.h +++ b/ngraph/frontend/tensorflow/src/ngraph_builder.h @@ -21,6 +21,7 @@ #include #include #include +#include // TODO: remove explicit proto dependency from this common header #include "graph.pb.h" @@ -149,7 +150,11 @@ Status GetNodeAttr (TFNodeDecoder& attrs, const char* attr_name, T* result) return Status::OK(); } +#if 0 #define NGRAPH_VLOG(I) std::cerr +#else +#define NGRAPH_VLOG(I) std::ostringstream() +#endif class Builder { diff --git a/ngraph/python/src/pyngraph/frontend_manager.cpp b/ngraph/python/src/pyngraph/frontend_manager.cpp index c71a208d91cb17..412bc7857eb3bd 100644 --- a/ngraph/python/src/pyngraph/frontend_manager.cpp +++ b/ngraph/python/src/pyngraph/frontend_manager.cpp @@ -60,6 +60,7 @@ void regclass_pyngraph_InputModel(py::module m) im.def("extractSubgraph", &ngraph::frontend::InputModel::extractSubgraph); im.def("getPlaceByTensorName", &ngraph::frontend::InputModel::getPlaceByTensorName); im.def("setPartialShape", &ngraph::frontend::InputModel::setPartialShape); + im.def("getInputs", &ngraph::frontend::InputModel::getInputs); } void regclass_pyngraph_FEC(py::module m) From 7bdca9f805455019042d726b0f67a35b6fe54aa6 Mon Sep 17 00:00:00 2001 From: "Lyalin, Sergey" Date: Thu, 25 Mar 2021 10:36:53 +0300 Subject: [PATCH 074/116] Added transpose sinking and constant folding as a mandatory steps in TF FE convert method --- .../include/ngraph/pass/transpose_sinking.h | 34 ++ ngraph/core/src/pass/transpose_sinking.cpp | 501 ++++++++++++++++++ ngraph/frontend/tensorflow/src/tensorflow.cpp | 17 +- 3 files changed, 549 insertions(+), 3 deletions(-) create mode 100644 ngraph/core/include/ngraph/pass/transpose_sinking.h create mode 100644 ngraph/core/src/pass/transpose_sinking.cpp diff --git a/ngraph/core/include/ngraph/pass/transpose_sinking.h b/ngraph/core/include/ngraph/pass/transpose_sinking.h new file mode 100644 index 00000000000000..0a649bc21b0830 --- /dev/null +++ b/ngraph/core/include/ngraph/pass/transpose_sinking.h @@ -0,0 +1,34 @@ +//***************************************************************************** +// Copyright 2017-2020 Intel Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//***************************************************************************** + +#pragma once + +#include +#include + +namespace ngraph { +namespace pass { + +class NGRAPH_API TransposeSinking : public ngraph::pass::FunctionPass { + public: + TransposeSinking() { + set_property(ngraph::pass::PassProperty::REQUIRE_STATIC_SHAPE, true); + } + bool run_on_function(std::shared_ptr function) override; +}; + +} // namespace pass +} // namespace ngraph diff --git a/ngraph/core/src/pass/transpose_sinking.cpp b/ngraph/core/src/pass/transpose_sinking.cpp new file mode 100644 index 00000000000000..92c2f3d65b6659 --- /dev/null +++ b/ngraph/core/src/pass/transpose_sinking.cpp @@ -0,0 +1,501 @@ +//***************************************************************************** +// Copyright 2017-2020 Intel Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//***************************************************************************** + +#include +#include +#include +#include +#include +#include + +#include +#include + +#include + +using namespace std; + +#include "ngraph/opsets/opset5.hpp" + +#if 0 +#define NGRAPH_VLOG(LEVEL) std::cerr << "[ DEBUG ][ " << LEVEL << " ]" +#else +#define NGRAPH_VLOG(LEVEL) std::ostringstream() +#endif + +namespace ngraph { + +namespace pass { + +namespace opset = ngraph::opset5; +namespace default_opset = ngraph::opset5; + + +using TransposeMap = unordered_map>; + +static ngraph::CoordinateDiff apply_permutation(ngraph::CoordinateDiff input, + ngraph::AxisVector order) { + ngraph::CoordinateDiff output(input.size()); + for (size_t i = 0; i < order.size(); i++) { + output[i] = input.at(order.at(i)); + } + return output; +} + +static ngraph::AxisVector permutation_to_default_order( + const ngraph::AxisVector& axis_order) { + ngraph::AxisVector out(axis_order.size()); + for (size_t i = 0; i < axis_order.size(); i++) { + out.at(axis_order[i]) = i; + } + return out; +} + +template +static string describe(shared_ptr node) { + // ensure that it's either a reshape or a transpose + // TODO: use static_assert + if (!(std::is_base_of::value || + std::is_base_of::value)) { + throw runtime_error( + "describe template specialization has to be either reshape or " + "transpose"); + } + stringstream ss; + auto transpose = ngraph::as_type_ptr(node); + auto const1 = ngraph::as_type_ptr( + transpose->get_input_node_shared_ptr(1)); + ss << transpose->get_name() << " ( axis order = " + << ngraph::vector_to_string(const1->get_axis_vector_val()) + << " , shape = " << ngraph::vector_to_string(transpose->get_shape()) + << " ) " + << " , input = " << transpose->input_value(0).get_node()->get_name(); + return ss.str(); +} + +static shared_ptr make_transpose( + ngraph::Output arg, const ngraph::AxisVector& input_order) { + auto order = std::make_shared( + ngraph::element::u64, ngraph::Shape{input_order.size()}, input_order); + auto transpose = make_shared(arg, order); + NGRAPH_VLOG(4) << "Make Transpose " << describe(transpose); + return transpose; +} + +static shared_ptr make_reshape( + ngraph::Output arg, const ngraph::AxisVector& input_order) { + auto order = std::make_shared( + ngraph::element::u64, ngraph::Shape{input_order.size()}, input_order); + auto transpose = make_shared(arg, order, false); + NGRAPH_VLOG(4) << "Make Reshape " << describe(transpose); + return transpose; +} + +static void write_transposemap(TransposeMap& reorders, + ngraph::Output target, + shared_ptr transpose) { + auto name = + target.get_node()->get_name() + "." + to_string(target.get_index()); + NGRAPH_VLOG(4) << "Write TransposeMap[" << name + << "] = " << describe(transpose); + reorders[name] = transpose; +} + +static shared_ptr read_transposemap( + TransposeMap& reorders, ngraph::Output target) { + auto name = + target.get_node()->get_name() + "." + to_string(target.get_index()); + auto transpose = reorders[name]; + NGRAPH_VLOG(4) << "Read TransposeMap[" << name << "] -> " + << describe(transpose); + return transpose; +} + +static shared_ptr combine_transposes( + shared_ptr t1, shared_ptr t2) { + auto default_order = ngraph::get_default_order(t1->get_shape()); + auto t1_const = ngraph::as_type_ptr( + t1->input_value(1).get_node_shared_ptr()); + auto t2_const = ngraph::as_type_ptr( + t2->input_value(1).get_node_shared_ptr()); + auto perm_t1 = + ngraph::apply_permutation(default_order, t1_const->get_axis_vector_val()); + auto perm_t2 = + ngraph::apply_permutation(perm_t1, t2_const->get_axis_vector_val()); + auto combined = make_transpose(t2->input_value(0), perm_t2); + NGRAPH_VLOG(4) << "Combining " << describe(t1) << " and " + << describe(t2) << " into " + << describe(combined); + return combined; +} + +static void insert_transpose(shared_ptr target, + shared_ptr transpose, + size_t input_index) { + NGRAPH_VLOG(4) << "Inserting transpose at input " << target->get_name() + << " input index " << input_index; + auto arg = target->input(input_index).get_source_output(); + NGRAPH_VLOG(4) << "Arg shape: " << arg.get_shape(); + auto new_order = ngraph::as_type_ptr( + transpose->input_value(1).get_node_shared_ptr()); + auto new_transpose = make_transpose(arg.get_node_shared_ptr(), + new_order->get_axis_vector_val()); + NGRAPH_VLOG(4) << "Inserting transpose " + << describe(new_transpose) << " at input " + << target->get_name() << " input index " << input_index; + + target->input(input_index).replace_source_output(new_transpose->output(0)); +} + +static void delete_transpose(shared_ptr transpose) { + NGRAPH_VLOG(4) << "Removing transpose " << transpose->get_name(); + if (!transpose->get_users().empty()) { + ngraph::Output output = transpose->output(0); + NGRAPH_VLOG(5) << "output " << output.get_node_shared_ptr()->get_name(); + NGRAPH_VLOG(5) << "target input size " << output.get_target_inputs().size(); + for (auto input : output.get_target_inputs()) { + NGRAPH_VLOG(5) << "input " << input.get_node()->get_name(); + input.replace_source_output(transpose->input_value(0)); + } + } +} + +static void mark_transpose_for_deletion( + shared_ptr transpose, + set>& transposes_to_delete) { + NGRAPH_VLOG(4) << "Marking transpose " << transpose->get_name() + << " for deletion"; + transposes_to_delete.insert(transpose); +} + +static shared_ptr create_default_transpose( + ngraph::Output n) { + auto default_order = ngraph::get_default_order(n.get_shape()); + auto order = std::make_shared( + ngraph::element::u64, ngraph::Shape{default_order.size()}, default_order); + return make_shared(n, order); +} + +// convert_binary_to_default_order is used when one of the arguments +// of a binary op isn't in the default format (i.e. nhwc instead of nchw) +// We normalize the "left" argument to match the order of the "right" argument +// by either inserting a transpose or a reshape, depending on the shape of the +// "left" argument. +static void convert_binary_to_default_order( + shared_ptr binary, const ngraph::Input& input, + ngraph::Output right, TransposeMap& reorders, + set>& transposes_to_delete) { + auto left = input.get_source_output(); + auto right_t = read_transposemap(reorders, right); + auto right_const = ngraph::as_type_ptr( + right_t->input_value(1).get_node_shared_ptr()); + + auto perm_to_def = + permutation_to_default_order(right_const->get_axis_vector_val()); + + // if right input is being implicitly broadcasted, insert a reshape + // instead of a transpose + shared_ptr new_node; + auto left_shape = left.get_shape(); + if (left_shape.size() < perm_to_def.size()) { + left_shape.insert(left_shape.begin(), + perm_to_def.size() - left_shape.size(), 1); + auto new_shape = ngraph::apply_permutation(left_shape, perm_to_def); + new_node = make_reshape(left, new_shape); + } else if (left_shape.size() == perm_to_def.size()) { + new_node = make_transpose(left, perm_to_def); + } else { + throw runtime_error( + "case not supported when converting binary to default order"); + } + input.replace_source_output(new_node->output(0)); + + NGRAPH_VLOG(4) << "right = " << ngraph::vector_to_string(right.get_shape()) + << ", " << right.get_node_shared_ptr()->get_name(); + // this should now insert transpose on right + mark_transpose_for_deletion(right_t, transposes_to_delete); + write_transposemap(reorders, binary, right_t); +} + +static void materialize_shapes( + shared_ptr n, TransposeMap& reorders, + set>& transposes_to_delete) { + // For each node, create a default transpose for + // each of the outputs and store in the map + for (auto& it : n->outputs()) { + write_transposemap(reorders, it, create_default_transpose(it)); + } + + for (size_t i = 0; i < n->input_values().size(); i++) { + // materialize all pending transposes, flush pending transposes + auto arg = n->input_value(i); + auto arg_transpose = read_transposemap(reorders, arg); + NGRAPH_VLOG(4) << "Materializing " + << describe(arg_transpose) << " for " + << arg.get_node_shared_ptr()->get_name(); + mark_transpose_for_deletion(arg_transpose, transposes_to_delete); + auto arg_shape = arg.get_shape(); + auto arg_transpose_order = ngraph::as_type_ptr( + arg_transpose->input_value(1).get_node_shared_ptr()); + if (arg_transpose_order->get_axis_vector_val() != + get_default_order(arg.get_shape())) { + // Insert if arg needs to be transposed. + insert_transpose(n, arg_transpose, i); + } + } +} + +static void sink_transpose( + shared_ptr transpose, TransposeMap& reorders, + set>& transposes_to_delete) { + NGRAPH_VLOG(4) << "Sinking Transpose :" + << describe(transpose); + auto transpose_in = transpose->input_value(0); + auto orig_transpose = read_transposemap(reorders, transpose_in); + // combine both transposes + auto new_transpose = combine_transposes(orig_transpose, transpose); + // remove original transpose now it's combined with a new one + // should be safe to remove an already detached node + mark_transpose_for_deletion(orig_transpose, transposes_to_delete); + // replace transpose with combined one + ngraph::replace_node(transpose, new_transpose); + mark_transpose_for_deletion(new_transpose, transposes_to_delete); + write_transposemap(reorders, new_transpose, new_transpose); +} + +static void sink_unary( + shared_ptr n, TransposeMap& reorders, + set>& /* transposes_to_delete */) { + auto arg_transpose = read_transposemap(reorders, n->input_value(0)); + NGRAPH_VLOG(4) << "Propagating " << describe(arg_transpose) + << " for " << n->get_name(); + write_transposemap(reorders, n, arg_transpose); +} + +static void sink_binary(shared_ptr binary, TransposeMap& reorders, + set>& transposes_to_delete) { + auto left = binary->input_value(0); + auto right = binary->input_value(1); + auto left_t = read_transposemap(reorders, left); + auto right_t = read_transposemap(reorders, right); + auto left_const = ngraph::as_type_ptr( + left_t->input_value(1).get_node_shared_ptr()); + auto right_const = ngraph::as_type_ptr( + right_t->input_value(1).get_node_shared_ptr()); + + auto left_order = left_const->get_axis_vector_val(); + auto right_order = right_const->get_axis_vector_val(); + + auto left_mismatch = + left_order != ngraph::get_default_order(left.get_shape()); + auto right_mismatch = + right_order != ngraph::get_default_order(right.get_shape()); + + NGRAPH_VLOG(4) + << "Sink binary " << binary->get_name() + << " left transpose: " << ngraph::vector_to_string(left_order) + << " left default: " + << ngraph::vector_to_string(ngraph::get_default_order(left.get_shape())) + << " right transpose: " << ngraph::vector_to_string(right_order) + << " right default: " + << ngraph::vector_to_string(ngraph::get_default_order(right.get_shape())); + + if ((left_order.size() == right_order.size() && left_order == right_order) || + (!left_mismatch && !right_mismatch)) { + // Propagate the reshape which matches the shape of the binary node + auto new_transpose = + (binary->get_output_shape(0) == left.get_shape()) ? left_t : right_t; + NGRAPH_VLOG(4) << "Propagating " + << describe(new_transpose) << " for " + << binary->get_name(); + write_transposemap(reorders, binary, new_transpose); + // at this point, both transposes will be eventually removed + mark_transpose_for_deletion(left_t, transposes_to_delete); + mark_transpose_for_deletion(right_t, transposes_to_delete); + } else { + if (right_mismatch) { + convert_binary_to_default_order(binary, binary->input(0), right, reorders, + transposes_to_delete); + } + if (left_mismatch) { + convert_binary_to_default_order(binary, binary->input(1), left, reorders, + transposes_to_delete); + } + } +} + +static void sink_pad( + shared_ptr n, TransposeMap& reorders, + set>& /* transposes_to_delete */) { + auto n_in = n->input_value(0); + auto arg_transpose = read_transposemap(reorders, n_in); + describe(arg_transpose); + auto arg_transpose_order = ngraph::as_type_ptr( + arg_transpose->input_value(1).get_node_shared_ptr()); + auto order = arg_transpose_order->get_axis_vector_val(); + // we need the correct input shape to produce the right output shape + // we are going to create a label of the right input shape, + // so a new pad will have the right shape + auto def_order = permutation_to_default_order(order); + auto input_shape = + ngraph::apply_permutation(arg_transpose->get_shape(), def_order); + auto dummy_correct_shape = make_shared( + arg_transpose->get_element_type(), input_shape); + + auto pad_begin = apply_permutation(n->get_pads_begin(), def_order); + auto pad_end = apply_permutation(n->get_pads_end(), def_order); + auto new_begin = make_shared( + ngraph::element::i64, ngraph::Shape{pad_begin.size()}, pad_begin); + auto new_end = make_shared( + ngraph::element::i64, ngraph::Shape{pad_end.size()}, pad_end); + auto new_pad = + make_shared(dummy_correct_shape, new_begin, new_end, + n->input_value(3), n->get_pad_mode()); + ngraph::replace_node(dummy_correct_shape, + n->input_value(0).get_node_shared_ptr()); + NGRAPH_VLOG(4) << "Replacing " << n->get_name() << " with " + << new_pad->get_name(); + ngraph::replace_node(n, new_pad); + auto new_transpose = make_transpose(new_pad, order); + NGRAPH_VLOG(4) << "Propagating " << describe(new_transpose) + << " for " << n->get_name(); + write_transposemap(reorders, new_pad, new_transpose); +} + +static void sink_concat(shared_ptr n, TransposeMap& reorders, + set>& transposes_to_delete) { + auto n_in = n->input_value(0); + auto arg_transpose = read_transposemap(reorders, n_in); + auto arg_transpose_order = ngraph::as_type_ptr( + arg_transpose->input_value(1).get_node_shared_ptr()); + auto order = arg_transpose_order->get_axis_vector_val(); + // we need the correct input shape to produce the right output shape + // we are going to create a label of the right input shape, + // so a new concat will have the right shape + auto def_order = permutation_to_default_order(order); + auto input_shape = + ngraph::apply_permutation(arg_transpose->get_shape(), def_order); + auto dummy_correct_shape = make_shared( + arg_transpose->get_element_type(), input_shape); + + ngraph::NodeVector new_args; + new_args.push_back(dummy_correct_shape); + + for (size_t i = 1; i < n->get_input_size(); i++) { + auto iarg = n->input_value(i); + auto iarg_transpose = read_transposemap(reorders, iarg); + auto iarg_transpose_order = ngraph::as_type_ptr( + iarg_transpose->input_value(1).get_node_shared_ptr()); + auto iorder = iarg_transpose_order->get_axis_vector_val(); + if (iorder != order) { + NGRAPH_VLOG(4) << " input order at " << i + << "-th arg is different from first arg"; + materialize_shapes(n, reorders, transposes_to_delete); + return; + } + + auto iinput_shape = + ngraph::apply_permutation(iarg_transpose->get_shape(), def_order); + auto idummy_correct_shape = make_shared( + iarg_transpose->get_element_type(), iinput_shape); + new_args.push_back(idummy_correct_shape); + } + + auto new_axis = order.at(n->get_concatenation_axis()); + auto new_concat = make_shared(new_args, new_axis); + // put back the original arguments + for (size_t i = 0; i < new_concat->get_input_size(); i++) { + NGRAPH_VLOG(4) << "Replacing " << new_concat->get_name() << " input " << i + << " with " << n->get_name() << " input " << i; + new_concat->input(i).replace_source_output(n->input_value(i)); + } + NGRAPH_VLOG(4) << "Replacing " << n->get_name() << " with " + << new_concat->get_name(); + ngraph::replace_node(n, new_concat); + auto new_transpose = make_transpose(new_concat, order); + NGRAPH_VLOG(4) << "Propagating " << describe(new_transpose) + << " for " << n->get_name(); + write_transposemap(reorders, new_concat, new_transpose); +} + +// The goal of TransposeSinking is to remove +// round-trip transposes(i.e. nhwc->nchw(nchw-only-op)->nhwc) +// around nchw-only-op (e.g.Convolution, Batchnorm, Avg/MaxPool) +// This is achieved by both **sinking**, propagating transposes +// through ops towards ngraph::op::Results, +// or **swimming** Transposes up towards ngraph::op::Parameter +// For each op type we support we can either combine +// two transposes by replacing the existing Transpose, +// materialize pending transposes if they can't be propagated through op +bool TransposeSinking::run_on_function(shared_ptr f) { + TransposeMap reorders; + set> transposes_to_delete; + unordered_map orig_result_out_shape; + + // STEP 1 : Sink or Swim transposes away for op clusters + for (auto n : f->get_ordered_ops()) { + NGRAPH_VLOG(4) << "Processing " << n->get_name(); + // collect output shape of all Result nodes for a sanity check + if (ngraph::op::is_output(n)) { + orig_result_out_shape[n->get_name()] = n->get_output_shape(0); + } + if (auto transpose = ngraph::as_type_ptr(n)) { + sink_transpose(transpose, reorders, transposes_to_delete); + } else if (ngraph::op::is_unary_elementwise_arithmetic(n)) { + sink_unary(n, reorders, transposes_to_delete); + } else if (ngraph::op::is_binary_elementwise_arithmetic(n)) { + sink_binary(n, reorders, transposes_to_delete); + } else if (auto pad = ngraph::as_type_ptr(n)) { + sink_pad(pad, reorders, transposes_to_delete); + } else if (auto concat = ngraph::as_type_ptr(n)) { + sink_concat(concat, reorders, transposes_to_delete); + } else { + materialize_shapes(n, reorders, transposes_to_delete); + } + } + + // STEP 2: purge all the transposes we either sunk or swam. + NGRAPH_VLOG(4) << "Purging transposes "; + for (auto r : transposes_to_delete) { + delete_transpose(r); + } + + // STEP 3: fix wrong shape info wholesale + NGRAPH_VLOG(4) << "Fixing wrong shape info for the whole graph"; + for (auto n : f->get_ordered_ops()) { + n->revalidate_and_infer_types(); + } + + const ngraph::ResultVector& results = f->get_results(); + for (auto r : results) { + // make sure shapes are always materialized before results + NGRAPH_CHECK( + r->get_shape() == r->get_input_shape(0) && + r->get_element_type() == r->input_value(0).get_element_type(), + " op::Result = ", *r, ", Arg = ", r->input_value(0).get_node()); + + // make sure that after TransposeSinking pass the output_shape for Result + // does not change from the expected output_shape before the pass + NGRAPH_CHECK(r->get_output_shape(0) == orig_result_out_shape[r->get_name()], + " op::Result = ", *r, " expected output shape = ", + orig_result_out_shape[r->get_name()]); + } + + return true; +} + +} // namespace pass +} // namespace ngraph diff --git a/ngraph/frontend/tensorflow/src/tensorflow.cpp b/ngraph/frontend/tensorflow/src/tensorflow.cpp index ac4131dcbedc2c..b3280022f3e374 100644 --- a/ngraph/frontend/tensorflow/src/tensorflow.cpp +++ b/ngraph/frontend/tensorflow/src/tensorflow.cpp @@ -16,6 +16,11 @@ #include + +#include +#include +#include + #include "graph.pb.h" #include "../include/tensorflow_frontend/tensorflow.hpp" @@ -56,9 +61,15 @@ std::shared_ptr ngraph::frontend::FrontEndTensorflow::convert std::shared_ptr f; std::cerr << "[ STATUS ] TranslateGraph return: " << tensorflow::ngraph_bridge::Builder::TranslateGraph( - model_tf->partialShapes, {}, model_tf->graph_def.get(), "here_should_be_a_graph_name", f); - //auto f = std::make_shared(ngraph::NodeVector{}, ngraph::ParameterVector{}); - std::cerr << "[ ERROR ] Convetion functionality is not implemented; an empty function will be returned."; + model_tf->partialShapes, {}, model_tf->graph_def.get(), "here_should_be_a_graph_name", f) << "\n"; + std::cerr << "[ INFO ] Resulting nGraph function contains " << f->get_ops().size() << " nodes." << std::endl; + std::cerr << "[ STATUS ] Running Transpose Sinking transformation\n"; + + ngraph::pass::Manager manager; + manager.register_pass(); + manager.register_pass(); + manager.run_passes(f); + std::cerr << "[ INFO ] Resulting nGraph function contains " << f->get_ops().size() << " nodes." << std::endl; return f; } From 47f739b51aa9fa992e87b3209f0a7a06e8df4ec7 Mon Sep 17 00:00:00 2001 From: "Lyalin, Sergey" Date: Thu, 25 Mar 2021 10:49:56 +0300 Subject: [PATCH 075/116] Retarget benchmark_app to PDPD for debugging --- inference-engine/samples/benchmark_app/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/inference-engine/samples/benchmark_app/main.cpp b/inference-engine/samples/benchmark_app/main.cpp index 737c516b4cf2c3..839c4c3f1dfb2b 100644 --- a/inference-engine/samples/benchmark_app/main.cpp +++ b/inference-engine/samples/benchmark_app/main.cpp @@ -333,9 +333,9 @@ int main(int argc, char *argv[]) { auto startTime = Time::now(); //CNNNetwork cnnNetwork = ie.ReadNetwork(FLAGS_m); ngraph::frontend::FrontEndManager manager; - auto FE = manager.loadByFramework("tf"); + auto FE = manager.loadByFramework("pdpd"); auto inputModel = FE->loadFromFile(FLAGS_m); - inputModel->setPartialShape(inputModel->getInputs()[0], ngraph::PartialShape({1, 224, 224, 3})); + //inputModel->setPartialShape(inputModel->getInputs()[0], ngraph::PartialShape({1, 224, 224, 3})); auto ngFunc = FE->convert(inputModel); CNNNetwork cnnNetwork(ngFunc); cnnNetwork.serialize("benchmark_app_loaded_network.xml"); From 5a41888fc1d342246d5633a395e2e42724a1d958 Mon Sep 17 00:00:00 2001 From: "Lyalin, Sergey" Date: Thu, 25 Mar 2021 11:48:16 +0300 Subject: [PATCH 076/116] Separate pdpd frontend from generic part --- ngraph/frontend/CMakeLists.txt | 3 +- ngraph/frontend/generic/CMakeLists.txt | 18 ++--- .../frontend/generic/src/frontend_manager.cpp | 2 +- ngraph/frontend/paddlepaddle/CMakeLists.txt | 66 +++++++++++++++++++ .../include/paddlepaddle_frontend}/pdpd.hpp | 6 +- .../src/pdpd => paddlepaddle/src}/pdpd.cpp | 2 +- .../src/proto}/framework.proto | 0 7 files changed, 79 insertions(+), 18 deletions(-) create mode 100644 ngraph/frontend/paddlepaddle/CMakeLists.txt rename ngraph/frontend/{generic/src/pdpd => paddlepaddle/include/paddlepaddle_frontend}/pdpd.hpp (89%) rename ngraph/frontend/{generic/src/pdpd => paddlepaddle/src}/pdpd.cpp (99%) rename ngraph/frontend/{generic/src/pdpd => paddlepaddle/src/proto}/framework.proto (100%) diff --git a/ngraph/frontend/CMakeLists.txt b/ngraph/frontend/CMakeLists.txt index d44fb8fc61236b..6512b3f0166536 100644 --- a/ngraph/frontend/CMakeLists.txt +++ b/ngraph/frontend/CMakeLists.txt @@ -15,7 +15,8 @@ # ****************************************************************************** if (NGRAPH_ONNX_IMPORT_ENABLE) + add_subdirectory(generic) add_subdirectory(onnx_import) add_subdirectory(tensorflow) - add_subdirectory(generic) + add_subdirectory(paddlepaddle) endif() diff --git a/ngraph/frontend/generic/CMakeLists.txt b/ngraph/frontend/generic/CMakeLists.txt index e7dc34b13ddb30..8fd8f5a83dcfea 100644 --- a/ngraph/frontend/generic/CMakeLists.txt +++ b/ngraph/frontend/generic/CMakeLists.txt @@ -18,14 +18,6 @@ file(GLOB_RECURSE LIBRARY_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp ${CMAKE_CURR file(GLOB_RECURSE LIBRARY_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/src/*.hpp ${CMAKE_CURRENT_SOURCE_DIR}/src/*.h) file(GLOB_RECURSE LIBRARY_PUBLIC_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/include/*.hpp) -find_package(Protobuf REQUIRED IMPORTED) - -set(PROTOBUF_GENERATE_CPP_APPEND_PATH ON) -file(GLOB proto_files ${CMAKE_CURRENT_SOURCE_DIR}/src/pdpd/*.proto) -protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS ${proto_files}) - -include_directories(${Protobuf_INCLUDE_DIRS}) - set(FRONTEND_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include) # Create named folders for the sources within the .vcproj @@ -39,7 +31,11 @@ source_group("public include" FILES ${LIBRARY_PUBLIC_HEADERS}) add_library(frontend_manager SHARED ${LIBRARY_SRC} ${LIBRARY_HEADERS} ${LIBRARY_PUBLIC_HEADERS} ${PROTO_SRCS} ${PROTO_HDRS}) add_library(ngraph::frontend_manager ALIAS frontend_manager) -target_include_directories(frontend_manager PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../tensorflow/include ${CMAKE_CURRENT_BINARY_DIR}) +target_include_directories(frontend_manager + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/../tensorflow/include + ${CMAKE_CURRENT_SOURCE_DIR}/../paddlepaddle/include) + MESSAGE("HERE4: " ${CMAKE_CURRENT_SOURCE_DIR}) if(COMMAND ie_add_vs_version_file) @@ -49,9 +45,7 @@ endif() # TODO: Add other frontends to the list of dependencies temporary; in the produce version they should be discovered # TODO: in runtime. -target_link_libraries(frontend_manager PRIVATE onnx_importer tensorflow_frontend ${Protobuf_LIBRARIES} PUBLIC ngraph) - -message("tensorflow: " ${TENSORFLOW_FRONTEND_INCLUDE_DIR}) +target_link_libraries(frontend_manager PRIVATE onnx_importer tensorflow_frontend paddlepaddle_frontend PUBLIC ngraph) set(FRONTEND_INSTALL_INCLUDE "${NGRAPH_INSTALL_INCLUDE}/ngraph/frontend/generic") target_include_directories(frontend_manager SYSTEM PUBLIC $ diff --git a/ngraph/frontend/generic/src/frontend_manager.cpp b/ngraph/frontend/generic/src/frontend_manager.cpp index e0a9de1bdd874f..4a553c267841ef 100644 --- a/ngraph/frontend/generic/src/frontend_manager.cpp +++ b/ngraph/frontend/generic/src/frontend_manager.cpp @@ -19,7 +19,7 @@ #include "onnx_import/editor/editor.hpp" #include "tensorflow_frontend/tensorflow.hpp" #include "frontend_manager/frontend_manager.hpp" -#include "pdpd/pdpd.hpp" +#include "paddlepaddle_frontend/pdpd.hpp" namespace ngraph diff --git a/ngraph/frontend/paddlepaddle/CMakeLists.txt b/ngraph/frontend/paddlepaddle/CMakeLists.txt new file mode 100644 index 00000000000000..bcb3c0b5049bcd --- /dev/null +++ b/ngraph/frontend/paddlepaddle/CMakeLists.txt @@ -0,0 +1,66 @@ +# ****************************************************************************** +# Copyright 2017-2021 Intel Corporation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ****************************************************************************** + +file(GLOB_RECURSE LIBRARY_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cc) +file(GLOB_RECURSE LIBRARY_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/src/*.hpp ${CMAKE_CURRENT_SOURCE_DIR}/src/*.h) +file(GLOB_RECURSE LIBRARY_PUBLIC_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/include/*.hpp) + +find_package(Protobuf REQUIRED IMPORTED) +include_directories(${Protobuf_INCLUDE_DIRS}) + +set(TENSORFLOW_FRONTEND_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include) + +# Create named folders for the sources within the .vcproj +# Empty name lists them directly under the .vcproj + +source_group("src" FILES ${LIBRARY_SRC}) +source_group("include" FILES ${LIBRARY_HEADERS}) +source_group("public include" FILES ${LIBRARY_PUBLIC_HEADERS}) + +set(PROTOBUF_GENERATE_CPP_APPEND_PATH ON) +file(GLOB proto_files ${CMAKE_CURRENT_SOURCE_DIR}/src/proto/*.proto) +protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS ${proto_files}) + +include_directories(${Protobuf_INCLUDE_DIRS}) + +# Create shared library +add_library(paddlepaddle_frontend SHARED ${LIBRARY_SRC} ${LIBRARY_HEADERS} ${LIBRARY_PUBLIC_HEADERS} ${PROTO_SRCS} ${PROTO_HDRS}) +add_library(ngraph::paddlepaddle_frontend ALIAS paddlepaddle_frontend) + +target_include_directories(paddlepaddle_frontend PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../generic/include ${CMAKE_CURRENT_BINARY_DIR}) + +if(COMMAND ie_add_vs_version_file) + ie_add_vs_version_file(NAME paddlepaddle_frontend + FILEDESCRIPTION "FrontEnd to load and convert PaddlePaddle file format") +endif() + +target_link_libraries(paddlepaddle_frontend PRIVATE ${Protobuf_LIBRARIES} PUBLIC ngraph) + +# TODO: Consider to remove the following block (inherited from onnx_import just in case). +if (CMAKE_CXX_COMPILER_ID MATCHES "^(Apple)?Clang$") + target_compile_options(paddlepaddle_frontend PRIVATE -Wno-undef -Wno-reserved-id-macro -Wno-switch-enum + -Wno-invalid-offsetof -Wno-shorten-64-to-32 -Wno-unused-macros -Wno-missing-variable-declarations + -Wno-unused-private-field -Wno-shadow -Wno-deprecated PUBLIC -Wno-undefined-func-template) +endif() + +install(TARGETS paddlepaddle_frontend EXPORT ngraphTargets + RUNTIME DESTINATION ${NGRAPH_INSTALL_LIB} COMPONENT ngraph + ARCHIVE DESTINATION ${NGRAPH_INSTALL_LIB} COMPONENT ngraph + LIBRARY DESTINATION ${NGRAPH_INSTALL_LIB} COMPONENT ngraph) + +if (NGRAPH_EXPORT_TARGETS_ENABLE) + export(TARGETS paddlepaddle_frontend NAMESPACE ngraph:: APPEND FILE "${NGRAPH_TARGETS_FILE}") +endif() diff --git a/ngraph/frontend/generic/src/pdpd/pdpd.hpp b/ngraph/frontend/paddlepaddle/include/paddlepaddle_frontend/pdpd.hpp similarity index 89% rename from ngraph/frontend/generic/src/pdpd/pdpd.hpp rename to ngraph/frontend/paddlepaddle/include/paddlepaddle_frontend/pdpd.hpp index 6937e1951197e8..79058216f87442 100644 --- a/ngraph/frontend/generic/src/pdpd/pdpd.hpp +++ b/ngraph/frontend/paddlepaddle/include/paddlepaddle_frontend/pdpd.hpp @@ -17,13 +17,13 @@ #pragma once // TODO: include it by just frontend_manager.hpp without path -#include "../../include/frontend_manager/frontend_manager.hpp" +#include "frontend_manager/frontend_manager.hpp" namespace ngraph { namespace frontend { - class InputModelPDPD : public InputModel + class NGRAPH_API InputModelPDPD : public InputModel { public: @@ -32,7 +32,7 @@ namespace ngraph InputModelPDPD (const std::string& _path) : path(_path) {} }; - class FrontEndPDPD : public FrontEnd + class NGRAPH_API FrontEndPDPD : public FrontEnd { public: diff --git a/ngraph/frontend/generic/src/pdpd/pdpd.cpp b/ngraph/frontend/paddlepaddle/src/pdpd.cpp similarity index 99% rename from ngraph/frontend/generic/src/pdpd/pdpd.cpp rename to ngraph/frontend/paddlepaddle/src/pdpd.cpp index 833e1de1482ccf..a4dc7afe7d1a22 100644 --- a/ngraph/frontend/generic/src/pdpd/pdpd.cpp +++ b/ngraph/frontend/paddlepaddle/src/pdpd.cpp @@ -13,7 +13,7 @@ #include "framework.pb.h" -#include "pdpd.hpp" +#include "../include/paddlepaddle_frontend/pdpd.hpp" #include #include diff --git a/ngraph/frontend/generic/src/pdpd/framework.proto b/ngraph/frontend/paddlepaddle/src/proto/framework.proto similarity index 100% rename from ngraph/frontend/generic/src/pdpd/framework.proto rename to ngraph/frontend/paddlepaddle/src/proto/framework.proto From e213691b44161722bd6cecf4e8242ae537f1b9bf Mon Sep 17 00:00:00 2001 From: mbencer Date: Thu, 25 Mar 2021 17:06:04 +0100 Subject: [PATCH 077/116] review remarks --- .../include/onnx_editor/edge_mapper.hpp | 4 ++-- .../onnx_editor/include/onnx_editor/editor.hpp | 4 ++-- .../include/onnx_editor/editor_types.hpp | 10 +++++----- ngraph/frontend/onnx_editor/src/edge_mapper.cpp | 16 ++++++++-------- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/ngraph/frontend/onnx_editor/include/onnx_editor/edge_mapper.hpp b/ngraph/frontend/onnx_editor/include/onnx_editor/edge_mapper.hpp index a145415997e10e..579419339e5dd2 100644 --- a/ngraph/frontend/onnx_editor/include/onnx_editor/edge_mapper.hpp +++ b/ngraph/frontend/onnx_editor/include/onnx_editor/edge_mapper.hpp @@ -62,7 +62,7 @@ namespace ngraph /// /// \param input A input helper structure created based on a input name /// or a input index. - InputEdge to_input_edge(Node node, Input input) const; + InputEdge to_input_edge(const Node& node, const Input& input) const; /// \brief Returns the OutputEdge based on a node (node name or output name) /// and an output (output name or output index). @@ -79,7 +79,7 @@ namespace ngraph /// /// \param output A output helper structure created based on a output name /// or a output index. - OutputEdge to_output_edge(Node node, Output output) const; + OutputEdge to_output_edge(const Node& node, const Output& output) const; private: std::vector find_node_indexes(const std::string& node_name, diff --git a/ngraph/frontend/onnx_editor/include/onnx_editor/editor.hpp b/ngraph/frontend/onnx_editor/include/onnx_editor/editor.hpp index 26128e082a8451..fbbd55a38fff74 100644 --- a/ngraph/frontend/onnx_editor/include/onnx_editor/editor.hpp +++ b/ngraph/frontend/onnx_editor/include/onnx_editor/editor.hpp @@ -114,8 +114,8 @@ namespace ngraph /// \brief Create edge mapper object which allow to use node names, input/output indexes /// istead of node indexes in order to select InputEdge/OutputEdge. /// - /// \param out_file_path EdgeMapper object which simply using methods which operate over - /// InputEdge and OutputEdge. + /// \return EdgeMapper object which simply using methods which operate over + /// InputEdge and OutputEdge. EdgeMapper create_edge_mapper() const; private: diff --git a/ngraph/frontend/onnx_editor/include/onnx_editor/editor_types.hpp b/ngraph/frontend/onnx_editor/include/onnx_editor/editor_types.hpp index 9465dc72bea704..428d48b32f2788 100644 --- a/ngraph/frontend/onnx_editor/include/onnx_editor/editor_types.hpp +++ b/ngraph/frontend/onnx_editor/include/onnx_editor/editor_types.hpp @@ -75,8 +75,8 @@ namespace ngraph : m_input_name{std::move(input_name)} { } - Input(int input_index) - : m_input_index{std::move(input_index)} + Input(const int input_index) + : m_input_index{input_index} { } const std::string m_input_name = ""; @@ -97,8 +97,8 @@ namespace ngraph : m_output_name{std::move(output_name)} { } - Output(int output_index) - : m_output_index{std::move(output_index)} + Output(const int output_index) + : m_output_index{output_index} { } const std::string m_output_name = ""; @@ -121,7 +121,7 @@ namespace ngraph { } Node(Output output) - : m_output_name{output.m_output_name} + : m_output_name{std::move(output.m_output_name)} { } const std::string m_node_name = ""; diff --git a/ngraph/frontend/onnx_editor/src/edge_mapper.cpp b/ngraph/frontend/onnx_editor/src/edge_mapper.cpp index 8e473b61f322cd..b3e85187e3d283 100644 --- a/ngraph/frontend/onnx_editor/src/edge_mapper.cpp +++ b/ngraph/frontend/onnx_editor/src/edge_mapper.cpp @@ -14,6 +14,7 @@ // limitations under the License. //***************************************************************************** +#include #include #include "ngraph/except.hpp" @@ -61,13 +62,12 @@ std::vector onnx_editor::EdgeMapper::find_node_indexes(const std::string& n } if (!node_name.empty()) { + const auto matched_nodes_range = m_node_name_to_index.equal_range(node_name); std::vector result; - auto matched_nodes_range = m_node_name_to_index.equal_range(node_name); - for (auto& index_iter = matched_nodes_range.first; index_iter != matched_nodes_range.second; - ++index_iter) - { - result.push_back(index_iter->second); - } + std::transform(matched_nodes_range.first, + matched_nodes_range.second, + std::back_inserter(result), + [](const std::pair& iter) { return iter.second; }); if (!result.empty()) { return result; @@ -110,7 +110,7 @@ std::string onnx_editor::EdgeMapper::get_node_input_name(int node_index, int inp return input_name; } -InputEdge onnx_editor::EdgeMapper::to_input_edge(Node node, Input in) const +InputEdge onnx_editor::EdgeMapper::to_input_edge(const Node& node, const Input& in) const { // identification can be both based on node name and output name const auto& node_indexes = find_node_indexes(node.m_node_name, node.m_output_name); @@ -166,7 +166,7 @@ InputEdge onnx_editor::EdgeMapper::to_input_edge(Node node, Input in) const } } -OutputEdge onnx_editor::EdgeMapper::to_output_edge(Node node, Output out) const +OutputEdge onnx_editor::EdgeMapper::to_output_edge(const Node& node, const Output& out) const { // identification can be both based on node name and output name const auto& node_indexes = find_node_indexes(node.m_node_name, node.m_output_name); From 424fada44b6dbdbae2ff8656711ca94150fa101d Mon Sep 17 00:00:00 2001 From: "Lyalin, Sergey" Date: Thu, 25 Mar 2021 23:04:10 +0300 Subject: [PATCH 078/116] Reorganized pdpd directory structure: finer grained file structure --- .../frontend_manager/frontend_manager.hpp | 1 + .../frontend/generic/src/frontend_manager.cpp | 2 +- ngraph/frontend/paddlepaddle/CMakeLists.txt | 5 +- .../{pdpd.hpp => frontend.hpp} | 44 +-- .../include/paddlepaddle_frontend/model.hpp | 42 +++ .../include/paddlepaddle_frontend/place.hpp | 30 ++ ngraph/frontend/paddlepaddle/src/decoder.cpp | 124 +++++++ ngraph/frontend/paddlepaddle/src/decoder.hpp | 47 +++ .../src/{pdpd.cpp => frontend.cpp} | 346 ++++++------------ ngraph/frontend/paddlepaddle/src/utility.hpp | 32 ++ 10 files changed, 414 insertions(+), 259 deletions(-) rename ngraph/frontend/paddlepaddle/include/paddlepaddle_frontend/{pdpd.hpp => frontend.hpp} (50%) create mode 100644 ngraph/frontend/paddlepaddle/include/paddlepaddle_frontend/model.hpp create mode 100644 ngraph/frontend/paddlepaddle/include/paddlepaddle_frontend/place.hpp create mode 100644 ngraph/frontend/paddlepaddle/src/decoder.cpp create mode 100644 ngraph/frontend/paddlepaddle/src/decoder.hpp rename ngraph/frontend/paddlepaddle/src/{pdpd.cpp => frontend.cpp} (51%) create mode 100644 ngraph/frontend/paddlepaddle/src/utility.hpp diff --git a/ngraph/frontend/generic/include/frontend_manager/frontend_manager.hpp b/ngraph/frontend/generic/include/frontend_manager/frontend_manager.hpp index 2d5597fe414456..cedd96f00cb398 100644 --- a/ngraph/frontend/generic/include/frontend_manager/frontend_manager.hpp +++ b/ngraph/frontend/generic/include/frontend_manager/frontend_manager.hpp @@ -200,6 +200,7 @@ class NGRAPH_API InputModel virtual void setNameForOperation (Place::Ptr operation, const std::string& newName); virtual void freeNameForTensor (const std::string& name); virtual void freeNameForOperation (const std::string& name); + virtual void setNameForDimension (Place::Ptr place, size_t shapeDimIndex, const std::string& dimName); diff --git a/ngraph/frontend/generic/src/frontend_manager.cpp b/ngraph/frontend/generic/src/frontend_manager.cpp index 4a553c267841ef..488319274b19e2 100644 --- a/ngraph/frontend/generic/src/frontend_manager.cpp +++ b/ngraph/frontend/generic/src/frontend_manager.cpp @@ -19,7 +19,7 @@ #include "onnx_import/editor/editor.hpp" #include "tensorflow_frontend/tensorflow.hpp" #include "frontend_manager/frontend_manager.hpp" -#include "paddlepaddle_frontend/pdpd.hpp" +#include "paddlepaddle_frontend/frontend.hpp" namespace ngraph diff --git a/ngraph/frontend/paddlepaddle/CMakeLists.txt b/ngraph/frontend/paddlepaddle/CMakeLists.txt index bcb3c0b5049bcd..aa6b1fb3ca273a 100644 --- a/ngraph/frontend/paddlepaddle/CMakeLists.txt +++ b/ngraph/frontend/paddlepaddle/CMakeLists.txt @@ -19,9 +19,8 @@ file(GLOB_RECURSE LIBRARY_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/src/*.hpp ${CMAKE_ file(GLOB_RECURSE LIBRARY_PUBLIC_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/include/*.hpp) find_package(Protobuf REQUIRED IMPORTED) -include_directories(${Protobuf_INCLUDE_DIRS}) -set(TENSORFLOW_FRONTEND_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include) +set(PADDLEPADDLE_FRONTEND_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include) # Create named folders for the sources within the .vcproj # Empty name lists them directly under the .vcproj @@ -34,7 +33,7 @@ set(PROTOBUF_GENERATE_CPP_APPEND_PATH ON) file(GLOB proto_files ${CMAKE_CURRENT_SOURCE_DIR}/src/proto/*.proto) protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS ${proto_files}) -include_directories(${Protobuf_INCLUDE_DIRS}) +include_directories(${Protobuf_INCLUDE_DIRS} ${PADDLEPADDLE_FRONTEND_INCLUDE_DIR}) # Create shared library add_library(paddlepaddle_frontend SHARED ${LIBRARY_SRC} ${LIBRARY_HEADERS} ${LIBRARY_PUBLIC_HEADERS} ${PROTO_SRCS} ${PROTO_HDRS}) diff --git a/ngraph/frontend/paddlepaddle/include/paddlepaddle_frontend/pdpd.hpp b/ngraph/frontend/paddlepaddle/include/paddlepaddle_frontend/frontend.hpp similarity index 50% rename from ngraph/frontend/paddlepaddle/include/paddlepaddle_frontend/pdpd.hpp rename to ngraph/frontend/paddlepaddle/include/paddlepaddle_frontend/frontend.hpp index 79058216f87442..3384a41e69a181 100644 --- a/ngraph/frontend/paddlepaddle/include/paddlepaddle_frontend/pdpd.hpp +++ b/ngraph/frontend/paddlepaddle/include/paddlepaddle_frontend/frontend.hpp @@ -16,38 +16,28 @@ #pragma once -// TODO: include it by just frontend_manager.hpp without path -#include "frontend_manager/frontend_manager.hpp" +#include -namespace ngraph -{ - namespace frontend - { - class NGRAPH_API InputModelPDPD : public InputModel - { - public: - - std::string path; - - InputModelPDPD (const std::string& _path) : path(_path) {} - }; +#include "model.hpp" - class NGRAPH_API FrontEndPDPD : public FrontEnd - { - public: +namespace ngraph { +namespace frontend { - FrontEndPDPD () - { - } +class NGRAPH_API FrontEndPDPD : public FrontEnd +{ +public: - virtual InputModel::Ptr loadFromFile (const std::string& path) const override - { - return std::make_shared(path); - } + FrontEndPDPD () + { + } - virtual std::shared_ptr convert (InputModel::Ptr model) const override; - }; + virtual InputModel::Ptr loadFromFile (const std::string& path) const override + { + return std::make_shared(path); + } - } // namespace frontend + virtual std::shared_ptr convert (InputModel::Ptr model) const override; +}; +} // namespace frontend } // namespace ngraph diff --git a/ngraph/frontend/paddlepaddle/include/paddlepaddle_frontend/model.hpp b/ngraph/frontend/paddlepaddle/include/paddlepaddle_frontend/model.hpp new file mode 100644 index 00000000000000..fc74fbd243bae9 --- /dev/null +++ b/ngraph/frontend/paddlepaddle/include/paddlepaddle_frontend/model.hpp @@ -0,0 +1,42 @@ +//***************************************************************************** +// Copyright 2017-2021 Intel Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//***************************************************************************** + +#pragma once + +#include + +#include "place.hpp" + +namespace ngraph { +namespace frontend { + +class FrontEndPDPD; + +class NGRAPH_API InputModelPDPD : public InputModel +{ + // TODO: replace it by already deserialized proto hidden under some Impl class + // TODO: avoid using explicit format-dependent data stuctures here, hide it under some Impl class + std::string path; + + friend class FrontEndPDPD; + +public: + + InputModelPDPD (const std::string& _path) : path(_path) {} +}; + +} // namespace frontend +} // namespace ngraph diff --git a/ngraph/frontend/paddlepaddle/include/paddlepaddle_frontend/place.hpp b/ngraph/frontend/paddlepaddle/include/paddlepaddle_frontend/place.hpp new file mode 100644 index 00000000000000..9455488fb53c69 --- /dev/null +++ b/ngraph/frontend/paddlepaddle/include/paddlepaddle_frontend/place.hpp @@ -0,0 +1,30 @@ +//***************************************************************************** +// Copyright 2017-2021 Intel Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//***************************************************************************** + +#pragma once + +#include + +namespace ngraph { +namespace frontend { + +class PlacePDPD : public Place +{ + // TODO +}; + +} // namespace frontend +} // namespace ngraph diff --git a/ngraph/frontend/paddlepaddle/src/decoder.cpp b/ngraph/frontend/paddlepaddle/src/decoder.cpp new file mode 100644 index 00000000000000..b3559f83ff8803 --- /dev/null +++ b/ngraph/frontend/paddlepaddle/src/decoder.cpp @@ -0,0 +1,124 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "framework.pb.h" + +#include "decoder.hpp" + + +namespace ngraph { +namespace frontend { + +std::map TYPE_MAP{ + {proto::VarType_Type::VarType_Type_BOOL, ngraph::element::boolean}, + {proto::VarType_Type::VarType_Type_INT16, ngraph::element::i16}, + {proto::VarType_Type::VarType_Type_INT32, ngraph::element::i32}, + {proto::VarType_Type::VarType_Type_INT64, ngraph::element::i64}, + {proto::VarType_Type::VarType_Type_FP16, ngraph::element::f16}, + {proto::VarType_Type::VarType_Type_FP32, ngraph::element::f32}, + {proto::VarType_Type::VarType_Type_FP64, ngraph::element::f64}, + {proto::VarType_Type::VarType_Type_UINT8, ngraph::element::u8}, + {proto::VarType_Type::VarType_Type_INT8, ngraph::element::i8}, + {proto::VarType_Type::VarType_Type_BF16, ngraph::element::bf16} +}; + +std::vector DecoderPDPDProto::get_ints(const std::string& name, const std::vector& def) const +{ + std::cout << "Running get_ints" << std::endl; + std::vector attrs; + for (const auto &attr : op.attrs()) { + if (attr.name() == name) + attrs.push_back(attr); + } + if (attrs.size() == 0) { + return def; + } else if (attrs.size() > 1) { + // TODO: raise exception here + return def; + } else { + std::vector res; + std::copy(attrs[0].ints().begin(), attrs[0].ints().end(), std::back_inserter(res)); + return res; + } +} + +int DecoderPDPDProto::get_int(const std::string& name, int def) const +{ + std::vector attrs; + for (const auto &attr : op.attrs()) { + if (attr.name() == name) + attrs.push_back(attr); + } + if (attrs.size() == 0) { + return def; + } else if (attrs.size() > 1) { + // TODO: raise exception here + return def; + } else { + return attrs[0].i(); + } +} + +float DecoderPDPDProto::get_float(const std::string& name, float def) const +{ + std::vector attrs; + for (const auto &attr : op.attrs()) { + if (attr.name() == name) + attrs.push_back(attr); + } + if (attrs.size() == 0) { + return def; + } else if (attrs.size() > 1) { + // TODO: raise exception here + return def; + } else { + return attrs[0].f(); + } +} + +std::string DecoderPDPDProto::get_str(const std::string& name, const std::string& def) const +{ + std::vector attrs; + for (const auto &attr : op.attrs()) { + if (attr.name() == name) + attrs.push_back(attr); + } + if (attrs.size() == 0) { + return def; + } else if (attrs.size() > 1) { + // TODO: raise exception here + return def; + } else { + return attrs[0].s(); + } +} + +bool DecoderPDPDProto::get_bool(const std::string& name, bool def) const +{ + std::vector attrs; + for (const auto &attr : op.attrs()) { + if (attr.name() == name) + attrs.push_back(attr); + } + if (attrs.size() == 0) { + return def; + } else if (attrs.size() > 1) { + // TODO: raise exception here + return def; + } else { + return attrs[0].b(); + } +} + +} +} \ No newline at end of file diff --git a/ngraph/frontend/paddlepaddle/src/decoder.hpp b/ngraph/frontend/paddlepaddle/src/decoder.hpp new file mode 100644 index 00000000000000..802e826f0d4448 --- /dev/null +++ b/ngraph/frontend/paddlepaddle/src/decoder.hpp @@ -0,0 +1,47 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "framework.pb.h" + +#include "../include/paddlepaddle_frontend/frontend.hpp" + +#include +#include + +namespace ngraph { +namespace frontend { + +using namespace google; +using namespace paddle::framework; + +extern std::map TYPE_MAP; + +class DecoderPDPDProto +{ + proto::OpDesc op; + +public: + + DecoderPDPDProto (proto::OpDesc _op) : op(_op) {} + + std::vector get_ints(const std::string& name, const std::vector& def = {}) const; + int get_int(const std::string& name, int def = 0) const; + float get_float(const std::string& name, float def = 0.) const; + std::string get_str(const std::string& name, const std::string& def = "") const; + bool get_bool (const std::string& name, bool def = false) const; + + // TODO: Further populate get_XXX methods on demand +}; + +} +} diff --git a/ngraph/frontend/paddlepaddle/src/pdpd.cpp b/ngraph/frontend/paddlepaddle/src/frontend.cpp similarity index 51% rename from ngraph/frontend/paddlepaddle/src/pdpd.cpp rename to ngraph/frontend/paddlepaddle/src/frontend.cpp index a4dc7afe7d1a22..9dfd9b565945d5 100644 --- a/ngraph/frontend/paddlepaddle/src/pdpd.cpp +++ b/ngraph/frontend/paddlepaddle/src/frontend.cpp @@ -13,222 +13,118 @@ #include "framework.pb.h" -#include "../include/paddlepaddle_frontend/pdpd.hpp" +#include "../include/paddlepaddle_frontend/model.hpp" #include #include -using namespace google; -using namespace paddle::framework; +#include "utility.hpp" +#include "decoder.hpp" -inline void MY_ASSERT(bool ex, const std::string& msg = "Unspecified error.") { - if (!ex) throw std::runtime_error(msg); -} - -std::map TYPE_MAP{ - {proto::VarType_Type::VarType_Type_BOOL, ngraph::element::boolean}, - {proto::VarType_Type::VarType_Type_INT16, ngraph::element::i16}, - {proto::VarType_Type::VarType_Type_INT32, ngraph::element::i32}, - {proto::VarType_Type::VarType_Type_INT64, ngraph::element::i64}, - {proto::VarType_Type::VarType_Type_FP16, ngraph::element::f16}, - {proto::VarType_Type::VarType_Type_FP32, ngraph::element::f32}, - {proto::VarType_Type::VarType_Type_FP64, ngraph::element::f64}, - {proto::VarType_Type::VarType_Type_UINT8, ngraph::element::u8}, - {proto::VarType_Type::VarType_Type_INT8, ngraph::element::i8}, - {proto::VarType_Type::VarType_Type_BF16, ngraph::element::bf16} -}; -bool endsWith(const std::string& str, const std::string& suffix) { - if (str.length() >= suffix.length()) { - return (0 == str.compare(str.length() - suffix.length(), suffix.length(), suffix)); - } - return false; -} - -protobuf::RepeatedField get_ints(proto::OpDesc op, std::string name, - protobuf::RepeatedField def = protobuf::RepeatedField()) { - std::cout << "Running get_ints" << std::endl; - std::vector attrs; - for (const auto& attr : op.attrs()) { - if (attr.name() == name) - attrs.push_back(attr); - } - std::cout << "Attrs preprocessed" << std::endl; - if (attrs.size() == 0) { - return def; - } - else if (attrs.size() > 1) { - // TODO: raise exception here - return def; - } - else { - return attrs[0].ints(); - } -} - -int get_int(proto::OpDesc op, std::string name, int def = 0) { - std::vector attrs; - for (const auto& attr : op.attrs()) { - if (attr.name() == name) - attrs.push_back(attr); - } - if (attrs.size() == 0) { - return def; - } - else if (attrs.size() > 1) { - // TODO: raise exception here - return def; - } - else { - return attrs[0].i(); - } -} - -float get_float(proto::OpDesc op, std::string name, float def = 0.) { - std::vector attrs; - for (const auto& attr : op.attrs()) { - if (attr.name() == name) - attrs.push_back(attr); - } - if (attrs.size() == 0) { - return def; - } - else if (attrs.size() > 1) { - // TODO: raise exception here - return def; - } - else { - return attrs[0].f(); - } -} -std::string get_str(proto::OpDesc op, std::string name, std::string def = "") { - std::vector attrs; - for (const auto& attr : op.attrs()) { - if (attr.name() == name) - attrs.push_back(attr); - } - if (attrs.size() == 0) { - return def; - } - else if (attrs.size() > 1) { - // TODO: raise exception here - return def; - } - else { - return attrs[0].s(); - } -} +namespace ngraph { + namespace frontend { -bool get_bool(proto::OpDesc op, std::string name, bool def = false) { - std::vector attrs; - for (const auto& attr : op.attrs()) { - if (attr.name() == name) - attrs.push_back(attr); - } - if (attrs.size() == 0) { - return def; - } - else if (attrs.size() > 1) { - // TODO: raise exception here - return def; - } - else { - return attrs[0].b(); - } -} -typedef std::shared_ptr(*CreatorFunction)(std::map>>& inputs, - const proto::OpDesc& op, const proto::BlockDesc& block); +typedef std::shared_ptr(*CreatorFunction)( + std::map>> &inputs, + const DecoderPDPDProto &); -template -void print (const T& a) -{ +template +void print(const T &a) { std::cerr << "["; - for(const auto& e: a) - { + for (const auto &e: a) { std::cerr << e << ", "; } std::cerr << "]\n"; } -std::shared_ptr conv2d_creator(std::map>>& inputs, - const proto::OpDesc& op, const proto::BlockDesc& block) { +std::shared_ptr +conv2d_creator(std::map>> &inputs, + const DecoderPDPDProto &op) { std::cout << "Running conv2d creator" << std::endl; MY_ASSERT(inputs["Input"].size() == 1 && inputs["Filter"].size() == 1, "More then one input for conv2d"); - MY_ASSERT(inputs["Bias"].size() == 0 && inputs["ResidualData"].size() == 0, "Bias and residual have input for conv2d"); + MY_ASSERT(inputs["Bias"].size() == 0 && inputs["ResidualData"].size() == 0, + "Bias and residual have input for conv2d"); auto data = inputs["Input"][0]; auto filter = inputs["Filter"][0]; // TODO: resolve padding according to spec - auto strides = get_ints(op, "strides"); - auto paddings = get_ints(op, "paddings"); - auto dilations = get_ints(op, "dilations"); + auto strides = op.get_ints("strides"); + auto paddings = op.get_ints("paddings"); + auto dilations = op.get_ints("dilations"); std::cout << "Creating convolution node" << std::endl; print(strides); print(paddings); print(dilations); return std::make_shared(data, - filter, - ngraph::Strides(strides.begin(), strides.end()), - ngraph::CoordinateDiff(paddings.begin(), paddings.end()), - ngraph::CoordinateDiff(paddings.begin(), paddings.end()), - ngraph::Strides(dilations.begin(), dilations.end())); + filter, + ngraph::Strides(strides.begin(), strides.end()), + ngraph::CoordinateDiff(paddings.begin(), + paddings.end()), + ngraph::CoordinateDiff(paddings.begin(), + paddings.end()), + ngraph::Strides(dilations.begin(), dilations.end())); } -std::shared_ptr batch_norm_creator(std::map>>& inputs, - const proto::OpDesc& op, const proto::BlockDesc& block) { +std::shared_ptr +batch_norm_creator(std::map>> &inputs, + const DecoderPDPDProto &op) { MY_ASSERT(inputs["X"].size() == 1 && - inputs["Scale"].size() == 1 && - inputs["Bias"].size() == 1 && - inputs["Mean"].size() == 1 && - inputs["Variance"].size() == 1, - "More then one input for batch_norm"); + inputs["Scale"].size() == 1 && + inputs["Bias"].size() == 1 && + inputs["Mean"].size() == 1 && + inputs["Variance"].size() == 1, + "More then one input for batch_norm"); auto data = inputs["X"][0]; auto gamma = inputs["Scale"][0]; auto beta = inputs["Bias"][0]; auto mean = inputs["Mean"][0]; auto variance = inputs["Variance"][0]; - return std::make_shared(data, gamma, beta, mean, variance, get_float(op, "epsilon")); + return std::make_shared(data, gamma, beta, mean, variance, + op.get_float("epsilon")); } -std::shared_ptr relu_creator(std::map>>& inputs, - const proto::OpDesc& op, const proto::BlockDesc& block) { +std::shared_ptr +relu_creator(std::map>> &inputs, + const DecoderPDPDProto &op) { MY_ASSERT(inputs["X"].size() == 1, "More then one input for relu"); auto data = inputs["X"][0]; return std::make_shared(data); } -std::shared_ptr pool2d_creator(std::map>>& inputs, - const proto::OpDesc& op, const proto::BlockDesc& block) { +std::shared_ptr +pool2d_creator(std::map>> &inputs, + const DecoderPDPDProto &op) { MY_ASSERT(inputs["X"].size() == 1, "More then one input for pool2d"); auto data = inputs["X"][0]; // TODO : resolve padding according to spec - auto pooling_type = get_str(op, "pooling_type"); - auto global_pooling = get_bool(op, "global_pooling"); + auto pooling_type = op.get_str("pooling_type"); + auto global_pooling = op.get_bool("global_pooling"); if (pooling_type == "max" && !global_pooling) { - auto strides = get_ints(op, "strides"); - auto paddings = get_ints(op, "paddings"); - auto kernel_shape = get_ints(op, "ksize"); + auto strides = op.get_ints("strides"); + auto paddings = op.get_ints("paddings"); + auto kernel_shape = op.get_ints("ksize"); return std::make_shared(data, - ngraph::Strides(strides.begin(), strides.end()), - ngraph::Shape(paddings.begin(), paddings.end()), - ngraph::Shape(paddings.begin(), paddings.end()), - ngraph::Shape(kernel_shape.begin(), kernel_shape.end())); - } - else if (pooling_type == "avg" && global_pooling) { + ngraph::Strides(strides.begin(), strides.end()), + ngraph::Shape(paddings.begin(), paddings.end()), + ngraph::Shape(paddings.begin(), paddings.end()), + ngraph::Shape(kernel_shape.begin(), + kernel_shape.end())); + } else if (pooling_type == "avg" && global_pooling) { // TODO : resolve axes according to rank - auto axes = ngraph::opset6::Constant::create(ngraph::element::i64, { 2 }, { 2, 3 }); + auto axes = ngraph::opset6::Constant::create(ngraph::element::i64, {2}, {2, 3}); return std::make_shared(data, axes, true); - } - else { + } else { throw std::runtime_error("Unsupported pooling type"); } } -std::shared_ptr elementwise_add_creator(std::map>>& inputs, - const proto::OpDesc& op, const proto::BlockDesc& block) { +std::shared_ptr +elementwise_add_creator(std::map>> &inputs, + const DecoderPDPDProto &op) { MY_ASSERT(inputs["X"].size() == 1 && inputs["Y"].size() == 1, "More then one input for elementwise_add"); auto x = inputs["X"][0]; auto y = inputs["Y"][0]; @@ -236,70 +132,76 @@ std::shared_ptr elementwise_add_creator(std::map(x, y); } -std::shared_ptr mul_creator(std::map>>& inputs, - const proto::OpDesc& op, const proto::BlockDesc& block) { +std::shared_ptr +mul_creator(std::map>> &inputs, + const DecoderPDPDProto &op) { MY_ASSERT(inputs["X"].size() == 1 && inputs["Y"].size() == 1, "More then one input for mul"); auto x = inputs["X"][0]; auto y = inputs["Y"][0]; MY_ASSERT(x->output(0).get_partial_shape().rank().is_static()); int64_t x_rank = x->output(0).get_partial_shape().rank().get_length(); - MY_ASSERT(y->output(0).get_partial_shape().rank().is_static() && y->output(0).get_partial_shape().rank().get_length() == 2); + MY_ASSERT(y->output(0).get_partial_shape().rank().is_static() && + y->output(0).get_partial_shape().rank().get_length() == 2); if (x_rank > 2) { auto shape = std::make_shared(x); - int64_t x_num_col_dims = get_int(op, "x_num_col_dims"); - auto axis = ngraph::opset6::Constant::create(ngraph::element::i64, {}, { 0 }); - auto split_lengths = ngraph::opset6::Constant::create(ngraph::element::i64, { 2 }, { x_num_col_dims, x_rank - x_num_col_dims }); + int64_t x_num_col_dims = op.get_int("x_num_col_dims"); + auto axis = ngraph::opset6::Constant::create(ngraph::element::i64, {}, {0}); + auto split_lengths = ngraph::opset6::Constant::create(ngraph::element::i64, {2}, + {x_num_col_dims, x_rank - x_num_col_dims}); auto split = std::make_shared(shape, axis, split_lengths); - auto f_dim_red_axis = ngraph::opset6::Constant::create(ngraph::element::i64, {}, { 0 }); + auto f_dim_red_axis = ngraph::opset6::Constant::create(ngraph::element::i64, {}, {0}); auto first_dim_reduce = std::make_shared(split->output(0), f_dim_red_axis); - auto f_dim_shape = ngraph::opset6::Constant::create(ngraph::element::i64, { 1 }, { 1 }); + auto f_dim_shape = ngraph::opset6::Constant::create(ngraph::element::i64, {1}, {1}); auto first_dim = std::make_shared(first_dim_reduce, f_dim_shape, false); - auto s_dim_red_axis = ngraph::opset6::Constant::create(ngraph::element::i64, {}, { 0 }); + auto s_dim_red_axis = ngraph::opset6::Constant::create(ngraph::element::i64, {}, {0}); auto second_dim_reduce = std::make_shared(split->output(1), s_dim_red_axis); - auto s_dim_shape = ngraph::opset6::Constant::create(ngraph::element::i64, { 1 }, { 1 }); + auto s_dim_shape = ngraph::opset6::Constant::create(ngraph::element::i64, {1}, {1}); auto second_dim = std::make_shared(second_dim_reduce, s_dim_shape, false); - auto out_shape = std::make_shared(ngraph::NodeVector{ first_dim, second_dim }, 0); + auto out_shape = std::make_shared(ngraph::NodeVector{first_dim, second_dim}, 0); auto x_reshaped = std::make_shared(x, out_shape, false); return std::make_shared(x_reshaped, y); } return std::make_shared(x, y); } -std::shared_ptr scale_creator(std::map>>& inputs, - const proto::OpDesc& op, const proto::BlockDesc& block) { +std::shared_ptr +scale_creator(std::map>> &inputs, + const DecoderPDPDProto &op) { MY_ASSERT(inputs["X"].size() == 1, "More then one input for scale"); auto data = inputs["X"][0]; - auto scale = ngraph::opset6::Constant::create(ngraph::element::f32, { 1 }, { get_float(op, "scale") }); + auto scale = ngraph::opset6::Constant::create(ngraph::element::f32, {1}, {op.get_float("scale")}); return std::make_shared(data, scale); } -std::shared_ptr make_ng_node(std::map>& inputs, - std::map>& nodes, - const paddle::framework::proto::OpDesc& op, - const paddle::framework::proto::BlockDesc& block) { +std::shared_ptr +make_ng_node(std::map> &inputs, + std::map> &nodes, + const paddle::framework::proto::OpDesc &op, + const paddle::framework::proto::BlockDesc &block) { std::cout << "Making node: " << op.type() << std::endl; std::map CREATORS_MAP = { - {"conv2d", conv2d_creator}, - {"batch_norm", batch_norm_creator}, - {"relu", relu_creator}, - {"pool2d", pool2d_creator}, - {"elementwise_add", elementwise_add_creator}, - {"mul", mul_creator}, - {"scale", scale_creator} + {"conv2d", conv2d_creator}, + {"batch_norm", batch_norm_creator}, + {"relu", relu_creator}, + {"pool2d", pool2d_creator}, + {"elementwise_add", elementwise_add_creator}, + {"mul", mul_creator}, + {"scale", scale_creator} }; MY_ASSERT(CREATORS_MAP.find(op.type()) != CREATORS_MAP.end(), "No creator found"); std::map>> inputs_preproc; - for (const auto& item : inputs) { + for (const auto &item : inputs) { inputs_preproc[item.first] = std::vector>(); - for (const auto& input_name : item.second) { + for (const auto &input_name : item.second) { // TODO: refactor to not search every time inputs_preproc[item.first].push_back(nodes[input_name]); } } - return CREATORS_MAP[op.type()](inputs_preproc, op, block); + return CREATORS_MAP[op.type()](inputs_preproc, DecoderPDPDProto(op)); } -std::shared_ptr read_tensor(const paddle::framework::proto::VarDesc& var, const std::string& model_dir) { +std::shared_ptr +read_tensor(const paddle::framework::proto::VarDesc &var, const std::string &model_dir) { std::cout << "Reading tensor " << var.name() << std::endl; MY_ASSERT(var.type().type() == paddle::framework::proto::VarType::LOD_TENSOR); auto tensor = var.type().lod_tensor().tensor(); @@ -311,18 +213,26 @@ std::shared_ptr read_tensor(const paddle::framework::p // get length of file: is.seekg(0, std::ios::end); auto length = is.tellg(); - auto tensor_length = std::accumulate(tensor.dims().cbegin(), tensor.dims().cend(), 1, std::multiplies()); + auto tensor_length = std::accumulate(tensor.dims().cbegin(), tensor.dims().cend(), 1, + std::multiplies()); std::cout << "length: " << length << ", ten_len: " << tensor_length << std::endl; - is.seekg((size_t)length - tensor_length * 4, std::ios::beg); + is.seekg((size_t) length - tensor_length * 4, std::ios::beg); std::vector tensor_data(tensor_length, 0); - is.read(reinterpret_cast(&tensor_data[0]), tensor_length * 4); + is.read(reinterpret_cast(&tensor_data[0]), tensor_length * 4); is.close(); auto shape = std::vector(tensor.dims().cbegin(), tensor.dims().cend()); return ngraph::opset6::Constant::create(ngraph::element::f32, ngraph::Shape(shape), tensor_data); } -std::shared_ptr convert_model(const std::string& model_dir) { +bool endsWith(const std::string &str, const std::string &suffix) { + if (str.length() >= suffix.length()) { + return (0 == str.compare(str.length() - suffix.length(), suffix.length(), suffix)); + } + return false; +} + +std::shared_ptr convert_model(const std::string &model_dir) { std::cout << "Convert Model Start" << std::endl; paddle::framework::proto::ProgramDesc fw_model; std::ifstream pb_stream(model_dir + "/__model__", std::ios::binary); @@ -333,8 +243,8 @@ std::shared_ptr convert_model(const std::string& model_dir) { ngraph::ResultVector result_nodes; std::cout << "Blocks number: " << fw_model.blocks().size() << std::endl; - const auto& global_block = fw_model.blocks()[0]; - for (const auto& var : global_block.vars()) { + const auto &global_block = fw_model.blocks()[0]; + for (const auto &var : global_block.vars()) { if (endsWith(var.name(), "feed") || endsWith(var.name(), "fetch")) continue; if (!var.persistable()) @@ -343,22 +253,22 @@ std::shared_ptr convert_model(const std::string& model_dir) { } std::cout << "Reading consts finished" << std::endl; - for (const auto& block : fw_model.blocks()) { + for (const auto &block : fw_model.blocks()) { std::map vars_dict; - for (const auto& var : block.vars()) { + for (const auto &var : block.vars()) { vars_dict[var.name()] = var.type(); } for (int i = 0; i < block.ops_size(); i++) { std::cerr << "Observing index i = " << i << "\n"; - const auto& op = block.ops()[i]; + const auto &op = block.ops()[i]; std::cerr << "Observing " << op.type() << "\n"; std::map> outputs_dict; - for (const auto& output : op.outputs()) { + for (const auto &output : op.outputs()) { outputs_dict[output.parameter()] = output.arguments(); std::cerr << output.parameter() << "\n"; } std::map> inputs_dict; - for (const auto& input : op.inputs()) { + for (const auto &input : op.inputs()) { inputs_dict[input.parameter()] = input.arguments(); } if (op.type() == "feed") { @@ -373,8 +283,7 @@ std::shared_ptr convert_model(const std::string& model_dir) { for (auto dim : tensor_desc.dims()) { if (dim >= 0) { shape.push_back(dim); - } - else { + } else { shape.push_back(1); } } @@ -383,18 +292,16 @@ std::shared_ptr convert_model(const std::string& model_dir) { nodes_dict[layer_name] = param; parameter_nodes.push_back(param); std::cout << "Parameter created" << std::endl; - } - else if (op.type() == "fetch") { + } else if (op.type() == "fetch") { auto input_node = inputs_dict["X"][0]; MY_ASSERT(nodes_dict.find(input_node) != nodes_dict.end()); result_nodes.push_back(std::make_shared(nodes_dict[input_node])); - } - else { + } else { auto node = make_ng_node(inputs_dict, nodes_dict, op, block); std::cerr << "Node created: " << node << "\n"; node->set_friendly_name(op.outputs()[0].parameter()); std::cerr << "Named with " << node->get_friendly_name() << "\n"; - for (const auto& item : outputs_dict) { + for (const auto &item : outputs_dict) { MY_ASSERT(item.second.size() <= 1); if (item.second.size() == 1) { nodes_dict[item.second[0]] = node; @@ -406,8 +313,7 @@ std::shared_ptr convert_model(const std::string& model_dir) { return std::make_shared(result_nodes, parameter_nodes); } -std::shared_ptr ngraph::frontend::FrontEndPDPD::convert (InputModel::Ptr model) const -{ +std::shared_ptr ngraph::frontend::FrontEndPDPD::convert(InputModel::Ptr model) const { std::string path = std::dynamic_pointer_cast(model)->path; std::cerr << "[ INFO ] PFrontEndPDPD::convert invoked\n"; auto f = convert_model(path); @@ -415,21 +321,5 @@ std::shared_ptr ngraph::frontend::FrontEndPDPD::convert (Input return f; } -#if 0 -int main(int argc, char* argv[]) { - try { - std::string model_path = "/home/slyalin/.paddlehub/modules/resnet_v2_50_imagenet/model"; - auto func = convert_model(model_path); - CNNNetwork net(func); - //net.reshape({ {"@HUB_resnet_v2_50_imagenet@image"}, {1, 3, 224, 224} }); - net.serialize("PDPD_Resnet50_Function.xml", "PDPD_Resnet50_Function.bin"); - } - catch (const std::exception& ex) { - slog::err << ex.what() << slog::endl; - - return 3; - } - - return 0; } -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/ngraph/frontend/paddlepaddle/src/utility.hpp b/ngraph/frontend/paddlepaddle/src/utility.hpp new file mode 100644 index 00000000000000..11376edcf3785d --- /dev/null +++ b/ngraph/frontend/paddlepaddle/src/utility.hpp @@ -0,0 +1,32 @@ +//***************************************************************************** +// Copyright 2017-2021 Intel Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//***************************************************************************** + +#pragma once + +#include + +#include + +namespace ngraph { +namespace frontend { + +inline void MY_ASSERT(bool ex, const std::string& msg = "Unspecified error.") { + if (!ex) throw std::runtime_error(msg); +} + + +} // namespace frontend +} // namespace ngraph From 649f4f3c81d5cc5af8f75cde767a95b1e10d2e15 Mon Sep 17 00:00:00 2001 From: "Lyalin, Sergey" Date: Thu, 25 Mar 2021 23:07:20 +0300 Subject: [PATCH 079/116] Fix MO code for empty input_shape cmd line argument --- model-optimizer/mo/front/extractor.py | 7 +++---- model-optimizer/mo/pipeline/unified.py | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/model-optimizer/mo/front/extractor.py b/model-optimizer/mo/front/extractor.py index baa49faff53e2b..6f29a2a7a6b9a4 100644 --- a/model-optimizer/mo/front/extractor.py +++ b/model-optimizer/mo/front/extractor.py @@ -589,7 +589,6 @@ def input_user_data_repack(graph: Graph, input_user_shapes: [None, list, dict, n # New version of FrontEnd is activated print("I'm HERE") inputModel = graph.graph['input_model'] - print(input_user_shapes) if isinstance(input_user_shapes, list) or isinstance(input_user_shapes, dict): for input_name in input_user_shapes: node = decodeNameWithPort(graph, input_name) @@ -601,12 +600,12 @@ def input_user_data_repack(graph: Graph, input_user_shapes: [None, list, dict, n _input_shapes.append({'node': node, 'shape': shape, 'data_type': data_type}) else: _input_shapes.append({'node': node, 'shape': shape}) - else: - # np.ndarray is a shape. User provided only --input_shape key - assert isinstance(input_user_shapes, np.ndarray) + elif isinstance(input_user_shapes, np.ndarray): model_inputs = inputModel.getInputs() assert len(model_inputs) == 1 _input_shapes.append({'node': model_inputs[0], 'shape': input_user_shapes}) + else: + assert input_user_shapes is None return _input_shapes, dict() diff --git a/model-optimizer/mo/pipeline/unified.py b/model-optimizer/mo/pipeline/unified.py index 87dd71fd6c0935..e638e7d604c994 100644 --- a/model-optimizer/mo/pipeline/unified.py +++ b/model-optimizer/mo/pipeline/unified.py @@ -65,7 +65,7 @@ def moc_pipeline(argv: argparse.Namespace): apply_replacements_list(graph, transforms) user_shapes = graph.graph['user_shapes'] - if user_shapes: + if len(user_shapes) > 0: assert len(inputModel.getInputs()) == 1 assert len(user_shapes) == 1 inputModel.setPartialShape(user_shapes[0]['node'], PartialShape(user_shapes[0]['shape'])) From 3c316bb532a4fb23d5a1e6ee5f37132818224957 Mon Sep 17 00:00:00 2001 From: "Lyalin, Sergey" Date: Mon, 29 Mar 2021 01:35:17 +0300 Subject: [PATCH 080/116] Switch ONNX Importer to 'decode' mode where no real op conversion happens --- .../samples/benchmark_app/main.cpp | 1 + .../src/plugin_api/ie_ngraph_utils.hpp | 2 + .../src/transformations/serialize.cpp | 1 + .../include/onnx_import/framework_node.hpp | 33 +++++++ .../include/onnx_import/onnx_node.hpp | 90 +++++++++++++++++++ .../frontend/onnx_import/src/core/model.cpp | 4 + ngraph/frontend/onnx_import/src/onnx.cpp | 35 +++++--- ngraph/frontend/onnx_import/src/onnx_node.cpp | 39 ++++++++ 8 files changed, 194 insertions(+), 11 deletions(-) create mode 100644 ngraph/frontend/onnx_import/include/onnx_import/framework_node.hpp create mode 100644 ngraph/frontend/onnx_import/include/onnx_import/onnx_node.hpp create mode 100644 ngraph/frontend/onnx_import/src/onnx_node.cpp diff --git a/inference-engine/samples/benchmark_app/main.cpp b/inference-engine/samples/benchmark_app/main.cpp index a786eef5053300..7dd3650b13b512 100644 --- a/inference-engine/samples/benchmark_app/main.cpp +++ b/inference-engine/samples/benchmark_app/main.cpp @@ -330,6 +330,7 @@ int main(int argc, char *argv[]) { auto startTime = Time::now(); CNNNetwork cnnNetwork = ie.ReadNetwork(FLAGS_m); + cnnNetwork.serialize("model_exported_from_benchmark_app.xml"); auto duration_ms = double_to_string(get_total_ms_time(startTime)); slog::info << "Read network took " << duration_ms << " ms" << slog::endl; if (statistics) diff --git a/inference-engine/src/plugin_api/ie_ngraph_utils.hpp b/inference-engine/src/plugin_api/ie_ngraph_utils.hpp index aa3e40b08db779..023590c4d89b28 100644 --- a/inference-engine/src/plugin_api/ie_ngraph_utils.hpp +++ b/inference-engine/src/plugin_api/ie_ngraph_utils.hpp @@ -122,6 +122,8 @@ inline Precision convertPrecision(const ::ngraph::element::Type& precision) { return Precision(Precision::BIN); case ::ngraph::element::Type_t::boolean: return Precision(Precision::BOOL); + case ::ngraph::element::Type_t::dynamic: + return Precision(Precision::UNSPECIFIED); default: THROW_IE_EXCEPTION << "Incorrect precision " << precision.get_type_name() << "!"; } diff --git a/inference-engine/src/transformations/src/transformations/serialize.cpp b/inference-engine/src/transformations/src/transformations/serialize.cpp index b59f2e50ff57d4..4204ab3c09ac8f 100644 --- a/inference-engine/src/transformations/src/transformations/serialize.cpp +++ b/inference-engine/src/transformations/src/transformations/serialize.cpp @@ -423,6 +423,7 @@ std::string get_output_precision_name(ngraph::Output& o) { auto elem_type = o.get_element_type(); switch (elem_type) { case ::ngraph::element::Type_t::undefined: + case ::ngraph::element::Type_t::dynamic: return "UNSPECIFIED"; case ::ngraph::element::Type_t::f16: return "FP16"; diff --git a/ngraph/frontend/onnx_import/include/onnx_import/framework_node.hpp b/ngraph/frontend/onnx_import/include/onnx_import/framework_node.hpp new file mode 100644 index 00000000000000..9a3c47196e58f7 --- /dev/null +++ b/ngraph/frontend/onnx_import/include/onnx_import/framework_node.hpp @@ -0,0 +1,33 @@ +//***************************************************************************** +// Copyright 2017-2021 Intel Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//***************************************************************************** + +#include "ngraph/node.hpp" +#include "ngraph/visibility.hpp" + +namespace ngraph +{ +namespace frontend +{ + +class NGRAPH_API FrameworkNode : public ngraph::Node +{ +public: + + using Node::Node; +}; + +} // namespace frontend +} // namespace ngraph diff --git a/ngraph/frontend/onnx_import/include/onnx_import/onnx_node.hpp b/ngraph/frontend/onnx_import/include/onnx_import/onnx_node.hpp new file mode 100644 index 00000000000000..1702ceb34db0f6 --- /dev/null +++ b/ngraph/frontend/onnx_import/include/onnx_import/onnx_node.hpp @@ -0,0 +1,90 @@ +//***************************************************************************** +// Copyright 2017-2021 Intel Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//***************************************************************************** + +#include +#include +#include "framework_node.hpp" + +namespace ONNX_NAMESPACE +{ + // forward declaration + class ModelProto; +} + +namespace ngraph +{ + +namespace onnx_import +{ + class Model; +} + +namespace frontend +{ + +class NGRAPH_API ONNXNode : public FrameworkNode +{ + NGRAPH_RTTI_DECLARATION; + + onnx_import::Node node; + + std::shared_ptr graph; + std::shared_ptr model; + std::shared_ptr model_proto; + +public: + + ONNXNode (const onnx_import::Node& _node) : + FrameworkNode(_node.get_ng_inputs(), _node.get_outputs_size()), + node(_node) + { + } + + ONNXNode (const OutputVector& _inputs, const onnx_import::Node& _node) : + FrameworkNode(_inputs, _node.get_outputs_size()), + node(_node) + { + } + + void set_onnx_graph (std::shared_ptr _graph) { graph = _graph; } + + void set_onnx_model (std::shared_ptr _model) { model = _model; } + + void set_onnx_model_proto (std::shared_ptr _model_proto) { model_proto = _model_proto; } + + const onnx_import::Node& get_onnx_node () const { return node; } + + virtual std::shared_ptr clone_with_new_inputs(const OutputVector& inputs) const override; + + virtual bool visit_attributes(AttributeVisitor& visitor) override + { + // TODO: implement reading as well, now it work for serialization only + std::string domain = node.domain(); + std::string op_type = node.op_type(); + visitor.on_attribute("ONNX_META_domain", domain); + visitor.on_attribute("ONNX_META_type", op_type); + return true; + } +}; + +inline OutputVector framework_node_factory (const ngraph::onnx_import::Node& node) +{ + auto ng_node = std::make_shared(node); + return ng_node->outputs(); +} + +} // namespace frontend +} // namespace ngraph diff --git a/ngraph/frontend/onnx_import/src/core/model.cpp b/ngraph/frontend/onnx_import/src/core/model.cpp index 9fd122cbb6e792..5d80926e128bab 100644 --- a/ngraph/frontend/onnx_import/src/core/model.cpp +++ b/ngraph/frontend/onnx_import/src/core/model.cpp @@ -19,6 +19,7 @@ #include "core/model.hpp" #include "ngraph/log.hpp" #include "ops_bridge.hpp" +#include "onnx_import/onnx_node.hpp" namespace ngraph { @@ -66,6 +67,9 @@ namespace ngraph const Operator& Model::get_operator(const std::string& name, const std::string& domain) const { + static Operator wildcard = &frontend::framework_node_factory; + return wildcard; + const auto dm = m_opset.find(domain); if (dm == std::end(m_opset)) { diff --git a/ngraph/frontend/onnx_import/src/onnx.cpp b/ngraph/frontend/onnx_import/src/onnx.cpp index be6c35a6301c0f..772b07919998f7 100644 --- a/ngraph/frontend/onnx_import/src/onnx.cpp +++ b/ngraph/frontend/onnx_import/src/onnx.cpp @@ -16,6 +16,7 @@ #include #include +#include #include "core/graph.hpp" #include "core/model.hpp" @@ -32,26 +33,37 @@ namespace ngraph namespace detail { std::shared_ptr - convert_to_ng_function(const ONNX_NAMESPACE::ModelProto& model_proto) + convert_to_ng_function(std::shared_ptr model_proto) { - Model model{model_proto}; - Graph graph{model_proto.graph(), model}; + auto model = std::make_shared(*model_proto); + auto graph = std::make_shared(model_proto->graph(), *model); auto function = std::make_shared( - graph.get_ng_outputs(), graph.get_ng_parameters(), graph.get_name()); + graph->get_ng_outputs(), graph->get_ng_parameters(), graph->get_name()); + + for(auto node: function->get_ops()) + { + if(auto raw_node = std::dynamic_pointer_cast(node)) + { + raw_node->set_onnx_graph(graph); + raw_node->set_onnx_model(model); + raw_node->set_onnx_model_proto(model_proto); + } + } + for (std::size_t i{0}; i < function->get_output_size(); ++i) { function->get_output_op(i)->set_friendly_name( - graph.get_outputs().at(i).get_name()); + graph->get_outputs().at(i).get_name()); } return function; } - std::shared_ptr import_onnx_model(ONNX_NAMESPACE::ModelProto& model_proto, + std::shared_ptr import_onnx_model(std::shared_ptr model_proto, const std::string& model_path) { - transform::expand_onnx_functions(model_proto); - transform::fixup_legacy_operators(model_proto); - transform::update_external_data_paths(model_proto, model_path); + transform::expand_onnx_functions(*model_proto); + transform::fixup_legacy_operators(*model_proto); + transform::update_external_data_paths(*model_proto, model_path); return detail::convert_to_ng_function(model_proto); } @@ -60,7 +72,7 @@ namespace ngraph std::shared_ptr import_onnx_model(std::istream& stream, const std::string& model_path) { - ONNX_NAMESPACE::ModelProto model_proto{parse_from_istream(stream)}; + auto model_proto = std::make_shared(parse_from_istream(stream)); return detail::import_onnx_model(model_proto, model_path); } @@ -80,7 +92,8 @@ namespace ngraph std::shared_ptr import_onnx_model(const ONNXModelEditor& model_editor) { - return detail::import_onnx_model(model_editor.model(), model_editor.model_path()); + //throw false; // TODO: Migrate ONNX Model Editor to shared_ptr's to keep model + return detail::import_onnx_model(std::make_shared(model_editor.model()), model_editor.model_path()); } std::set get_supported_operators(std::int64_t version, diff --git a/ngraph/frontend/onnx_import/src/onnx_node.cpp b/ngraph/frontend/onnx_import/src/onnx_node.cpp new file mode 100644 index 00000000000000..ef26e0d9e62b04 --- /dev/null +++ b/ngraph/frontend/onnx_import/src/onnx_node.cpp @@ -0,0 +1,39 @@ +//***************************************************************************** +// Copyright 2017-2021 Intel Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//***************************************************************************** + +#include + +namespace ngraph +{ +namespace frontend +{ + +NGRAPH_RTTI_DEFINITION(ONNXNode, "__ONNXNode", 1); + +std::shared_ptr ONNXNode::clone_with_new_inputs(const OutputVector& inputs) const +{ + return std::make_shared(inputs, node); +} +/* + OutputVector framework_node_factory (const ngraph::onnx_import::Node& node) +{ + auto ng_node = std::make_shared(node.get_ng_inputs(), node.get_outputs_size()); + return ng_node->outputs(); +} + */ + +} // namespace frontend +} // namespace ngraph From 0d6b4365e09679b43731a70cafc9ef25b19cba03 Mon Sep 17 00:00:00 2001 From: "Lyalin, Sergey" Date: Mon, 29 Mar 2021 14:26:07 +0300 Subject: [PATCH 081/116] Implement the second round of conversion from ONNXNode --- .../samples/benchmark_app/CMakeLists.txt | 2 +- .../samples/benchmark_app/main.cpp | 7 +- .../include/onnx_import/core/node.hpp | 2 + .../onnx_import/include/onnx_import/onnx.hpp | 9 ++- .../include/onnx_import/onnx_node.hpp | 6 +- .../onnx_import/src/core/attribute.cpp | 2 +- .../frontend/onnx_import/src/core/graph.cpp | 32 +++++++-- .../frontend/onnx_import/src/core/graph.hpp | 9 ++- .../frontend/onnx_import/src/core/model.cpp | 3 - ngraph/frontend/onnx_import/src/core/node.cpp | 9 +++ ngraph/frontend/onnx_import/src/onnx.cpp | 69 ++++++++++++++++--- 11 files changed, 121 insertions(+), 29 deletions(-) diff --git a/inference-engine/samples/benchmark_app/CMakeLists.txt b/inference-engine/samples/benchmark_app/CMakeLists.txt index a74294a0fbbf0d..bd0ed87b75f97d 100644 --- a/inference-engine/samples/benchmark_app/CMakeLists.txt +++ b/inference-engine/samples/benchmark_app/CMakeLists.txt @@ -8,5 +8,5 @@ file (GLOB HDR ${CMAKE_CURRENT_SOURCE_DIR}/*.hpp) ie_add_sample(NAME benchmark_app SOURCES ${SRC} HEADERS ${HDR} - DEPENDENCIES format_reader + DEPENDENCIES format_reader frontend_manager onnx_importer OPENCV_DEPENDENCIES imgcodecs) diff --git a/inference-engine/samples/benchmark_app/main.cpp b/inference-engine/samples/benchmark_app/main.cpp index 7dd3650b13b512..eb11c90178bd78 100644 --- a/inference-engine/samples/benchmark_app/main.cpp +++ b/inference-engine/samples/benchmark_app/main.cpp @@ -18,6 +18,8 @@ #include #include +#include + #include "benchmark_app.hpp" #include "infer_request_wrap.hpp" #include "progress_bar.hpp" @@ -329,7 +331,10 @@ int main(int argc, char *argv[]) { slog::info << "Loading network files" << slog::endl; auto startTime = Time::now(); - CNNNetwork cnnNetwork = ie.ReadNetwork(FLAGS_m); + //CNNNetwork cnnNetwork = ie.ReadNetwork(FLAGS_m); + auto func = ngraph::onnx_import::import_onnx_model(FLAGS_m, true); + ngraph::onnx_import::convert_onnx_nodes(func); + CNNNetwork cnnNetwork(func); cnnNetwork.serialize("model_exported_from_benchmark_app.xml"); auto duration_ms = double_to_string(get_total_ms_time(startTime)); slog::info << "Read network took " << duration_ms << " ms" << slog::endl; diff --git a/ngraph/frontend/onnx_import/include/onnx_import/core/node.hpp b/ngraph/frontend/onnx_import/include/onnx_import/core/node.hpp index 8f832699216b95..84c8ee1d2b283b 100644 --- a/ngraph/frontend/onnx_import/include/onnx_import/core/node.hpp +++ b/ngraph/frontend/onnx_import/include/onnx_import/core/node.hpp @@ -72,6 +72,8 @@ namespace ngraph const std::string& op_type() const; const std::string& get_name() const; + std::vector get_input_names() const; + /// \brief Describe the ONNX Node to make debugging graphs easier /// Function will return the Node's name if it has one, or the names of its outputs. /// \return Description of Node diff --git a/ngraph/frontend/onnx_import/include/onnx_import/onnx.hpp b/ngraph/frontend/onnx_import/include/onnx_import/onnx.hpp index 0ab60ff37bc4a1..0dd557af861da6 100644 --- a/ngraph/frontend/onnx_import/include/onnx_import/onnx.hpp +++ b/ngraph/frontend/onnx_import/include/onnx_import/onnx.hpp @@ -71,7 +71,7 @@ namespace ngraph /// \return An nGraph function that represents a single output from the created graph. ONNX_IMPORTER_API std::shared_ptr import_onnx_model(std::istream& stream, - const std::string& model_path = ""); + const std::string& model_path = "", bool decode_only = false); /// \brief Imports and converts an ONNX model from the input file /// to an nGraph Function representation. @@ -84,7 +84,7 @@ namespace ngraph /// /// \return An nGraph function that represents a single output from the created graph. ONNX_IMPORTER_API - std::shared_ptr import_onnx_model(const std::string& file_path); + std::shared_ptr import_onnx_model(const std::string& file_path, bool decode_only = false); /// \brief Imports an ONNX model modified by the ONNXModelEditor wrapper. /// @@ -94,7 +94,10 @@ namespace ngraph /// /// \return An nGraph function representing the previously modified ONNX model. ONNX_IMPORTER_API - std::shared_ptr import_onnx_model(const ONNXModelEditor& model_editor); + std::shared_ptr import_onnx_model(const ONNXModelEditor& model_editor, bool decode_only = false); + + ONNX_IMPORTER_API + void convert_onnx_nodes (std::shared_ptr f); } // namespace onnx_import } // namespace ngraph diff --git a/ngraph/frontend/onnx_import/include/onnx_import/onnx_node.hpp b/ngraph/frontend/onnx_import/include/onnx_import/onnx_node.hpp index 1702ceb34db0f6..11b8fcfb049b47 100644 --- a/ngraph/frontend/onnx_import/include/onnx_import/onnx_node.hpp +++ b/ngraph/frontend/onnx_import/include/onnx_import/onnx_node.hpp @@ -60,11 +60,13 @@ class NGRAPH_API ONNXNode : public FrameworkNode } void set_onnx_graph (std::shared_ptr _graph) { graph = _graph; } - void set_onnx_model (std::shared_ptr _model) { model = _model; } - void set_onnx_model_proto (std::shared_ptr _model_proto) { model_proto = _model_proto; } + std::shared_ptr get_onnx_graph () const { return graph; } + //void get_onnx_model (std::shared_ptr _model) { model = _model; } + //void get_onnx_model_proto (std::shared_ptr _model_proto) { model_proto = _model_proto; } + const onnx_import::Node& get_onnx_node () const { return node; } virtual std::shared_ptr clone_with_new_inputs(const OutputVector& inputs) const override; diff --git a/ngraph/frontend/onnx_import/src/core/attribute.cpp b/ngraph/frontend/onnx_import/src/core/attribute.cpp index 13635826c1c8c5..d8ee336f18cee0 100644 --- a/ngraph/frontend/onnx_import/src/core/attribute.cpp +++ b/ngraph/frontend/onnx_import/src/core/attribute.cpp @@ -27,7 +27,7 @@ namespace ngraph std::vector result; for (const auto& graph : m_attribute_proto->graphs()) { - result.emplace_back(graph, model); + result.emplace_back(graph, model, false); // TODO: decode_only is false -- not supported here, should be properly propagated } return result; } diff --git a/ngraph/frontend/onnx_import/src/core/graph.cpp b/ngraph/frontend/onnx_import/src/core/graph.cpp index 2d2f1e77ade374..124c7612b7f690 100644 --- a/ngraph/frontend/onnx_import/src/core/graph.cpp +++ b/ngraph/frontend/onnx_import/src/core/graph.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include "core/graph.hpp" #include "core/null_node.hpp" @@ -28,6 +29,7 @@ #include "onnx_import/core/node.hpp" #include "utils/common.hpp" #include "utils/provenance_tag.hpp" +#include "onnx_import/onnx_node.hpp" namespace ngraph { @@ -64,8 +66,8 @@ namespace ngraph } } // namespace detail - Graph::Graph(const ONNX_NAMESPACE::GraphProto& graph_proto, Model& model) - : Graph(graph_proto, model, std::unique_ptr(new GraphCache())) + Graph::Graph(const ONNX_NAMESPACE::GraphProto& graph_proto, Model& model, bool decode_only) + : Graph(graph_proto, model, std::unique_ptr(new GraphCache()), decode_only) { // Remove dangling Parameters for (auto param_it = m_parameters.begin(); param_it != m_parameters.end();) @@ -90,10 +92,12 @@ namespace ngraph Graph::Graph(const ONNX_NAMESPACE::GraphProto& graph_proto, Model& model, - std::unique_ptr&& cache) + std::unique_ptr&& cache, + bool decode_only) : m_graph_proto{&graph_proto} , m_model{&model} , m_cache{std::move(cache)} + , m_decode_only(decode_only) { std::map initializers; // Process all initializers in the graph @@ -208,6 +212,10 @@ namespace ngraph } const GraphCache& Graph::get_graph_cache() const { return *m_cache.get(); } + void Graph::update_node_input_cache (const std::string& name, Output&& output) + { + m_cache->emplace_node(name, std::move(output)); + } bool Graph::is_node_in_cache(const std::string& name) const { return m_cache->contains(name); @@ -234,8 +242,19 @@ namespace ngraph OutputVector Graph::make_ng_nodes(const Node& onnx_node) const { - const auto ng_node_factory = - m_model->get_operator(onnx_node.op_type(), onnx_node.domain()); + //if m_decode_only + Operator ng_node_factory; + + //const auto& name = onnx_node.op_type(); + if(m_decode_only /*&& !(name == "Add")*/) + { + ng_node_factory = frontend::framework_node_factory; + } + else + { + ng_node_factory = m_model->get_operator(onnx_node.op_type(), onnx_node.domain()); + } + OutputVector ng_node_vector; try { @@ -351,7 +370,8 @@ namespace ngraph : Graph( proto, model, - std::unique_ptr(new SubgraphCache(parent_graph.get_graph_cache()))) + std::unique_ptr(new SubgraphCache(parent_graph.get_graph_cache())), + false) // TODO: Subgraph is not supported { // find all nodes on edge parent graph-subgraph // (it means input of node from parent graph, output from subgraph) diff --git a/ngraph/frontend/onnx_import/src/core/graph.hpp b/ngraph/frontend/onnx_import/src/core/graph.hpp index 599ba342ea1e63..a09159239e1773 100644 --- a/ngraph/frontend/onnx_import/src/core/graph.hpp +++ b/ngraph/frontend/onnx_import/src/core/graph.hpp @@ -35,7 +35,7 @@ namespace ngraph class Graph { public: - Graph(const ONNX_NAMESPACE::GraphProto& proto, Model& model); + Graph(const ONNX_NAMESPACE::GraphProto& proto, Model& model, bool decode_only); const std::vector& get_nodes() const { return m_nodes; } const std::vector& get_inputs() const { return m_inputs; } const std::vector& get_outputs() const { return m_outputs; } @@ -46,12 +46,16 @@ namespace ngraph const std::string& get_name() const { return m_graph_proto->name(); } OutputVector make_ng_nodes(const Node& onnx_node) const; const GraphCache& get_graph_cache() const; + void update_node_input_cache (const std::string& name, Output&& output); const OpsetImports& get_opset_imports() const; + void set_decode_only (bool decode_only) { m_decode_only = decode_only; } + protected: Graph(const ONNX_NAMESPACE::GraphProto& proto, Model& model, - std::unique_ptr&& cache); + std::unique_ptr&& cache, + bool decode_only); void set_friendly_names(const Node& onnx_node, const OutputVector& ng_node_vector) const; @@ -75,6 +79,7 @@ namespace ngraph std::vector m_inputs; std::vector m_outputs; Model* m_model; + bool m_decode_only = false; }; /// \brief Representation of ONNX subgraph. It is used for example by ONNX Loop op. diff --git a/ngraph/frontend/onnx_import/src/core/model.cpp b/ngraph/frontend/onnx_import/src/core/model.cpp index 5d80926e128bab..fe9a96aeda4a24 100644 --- a/ngraph/frontend/onnx_import/src/core/model.cpp +++ b/ngraph/frontend/onnx_import/src/core/model.cpp @@ -67,9 +67,6 @@ namespace ngraph const Operator& Model::get_operator(const std::string& name, const std::string& domain) const { - static Operator wildcard = &frontend::framework_node_factory; - return wildcard; - const auto dm = m_opset.find(domain); if (dm == std::end(m_opset)) { diff --git a/ngraph/frontend/onnx_import/src/core/node.cpp b/ngraph/frontend/onnx_import/src/core/node.cpp index 6b8b33979e6d0b..3885623ee71213 100644 --- a/ngraph/frontend/onnx_import/src/core/node.cpp +++ b/ngraph/frontend/onnx_import/src/core/node.cpp @@ -51,6 +51,10 @@ namespace ngraph const std::string& description() const; const std::vector>& get_output_names() const; + std::vector get_input_names() const + { + return std::vector(m_node_proto->input().begin(), m_node_proto->input().end()); + } const std::string& output(int index) const; std::size_t get_outputs_size() const; @@ -212,6 +216,11 @@ namespace ngraph return m_pimpl->get_output_names(); } + std::vector Node::get_input_names() const + { + return m_pimpl->get_input_names(); + } + const std::string& Node::output(int index) const { return m_pimpl->output(index); } std::size_t Node::get_outputs_size() const { return m_pimpl->get_outputs_size(); } bool Node::has_attribute(const std::string& name) const diff --git a/ngraph/frontend/onnx_import/src/onnx.cpp b/ngraph/frontend/onnx_import/src/onnx.cpp index 772b07919998f7..9bba89f7f73ca8 100644 --- a/ngraph/frontend/onnx_import/src/onnx.cpp +++ b/ngraph/frontend/onnx_import/src/onnx.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include "core/graph.hpp" #include "core/model.hpp" @@ -33,10 +34,10 @@ namespace ngraph namespace detail { std::shared_ptr - convert_to_ng_function(std::shared_ptr model_proto) + convert_to_ng_function(std::shared_ptr model_proto, bool decode_only) { auto model = std::make_shared(*model_proto); - auto graph = std::make_shared(model_proto->graph(), *model); + auto graph = std::make_shared(model_proto->graph(), *model, decode_only); auto function = std::make_shared( graph->get_ng_outputs(), graph->get_ng_parameters(), graph->get_name()); @@ -59,25 +60,25 @@ namespace ngraph } std::shared_ptr import_onnx_model(std::shared_ptr model_proto, - const std::string& model_path) + const std::string& model_path, bool decode_only) { transform::expand_onnx_functions(*model_proto); transform::fixup_legacy_operators(*model_proto); transform::update_external_data_paths(*model_proto, model_path); - return detail::convert_to_ng_function(model_proto); + return detail::convert_to_ng_function(model_proto, decode_only); } } // namespace detail std::shared_ptr import_onnx_model(std::istream& stream, - const std::string& model_path) + const std::string& model_path, bool decode_only) { auto model_proto = std::make_shared(parse_from_istream(stream)); - return detail::import_onnx_model(model_proto, model_path); + return detail::import_onnx_model(model_proto, model_path, decode_only); } - std::shared_ptr import_onnx_model(const std::string& file_path) + std::shared_ptr import_onnx_model(const std::string& file_path, bool decode_only) { std::ifstream model_stream{file_path, std::ios::in | std::ios::binary}; @@ -87,13 +88,16 @@ namespace ngraph file_path + ". Could not open the file."); }; - return import_onnx_model(model_stream, file_path); + return import_onnx_model(model_stream, file_path, decode_only); } - std::shared_ptr import_onnx_model(const ONNXModelEditor& model_editor) + std::shared_ptr import_onnx_model(const ONNXModelEditor& model_editor, bool decode_only) { //throw false; // TODO: Migrate ONNX Model Editor to shared_ptr's to keep model - return detail::import_onnx_model(std::make_shared(model_editor.model()), model_editor.model_path()); + return detail::import_onnx_model( + std::make_shared(model_editor.model()), + model_editor.model_path(), + decode_only); } std::set get_supported_operators(std::int64_t version, @@ -117,6 +121,51 @@ namespace ngraph op_name, version, domain == "ai.onnx" ? "" : domain); } + + /// Convert nGraph function with ONNXNode inclusions finally to regular opset + void convert_onnx_nodes (std::shared_ptr f) + { + auto ops = f->get_ordered_ops(); + for(auto node: ops) + { + if(auto raw_node = std::dynamic_pointer_cast(node)) + { + // Update cache to make sure that all inputs are properly registered + // based on proto names + + const auto& onnx_node = raw_node->get_onnx_node(); + auto input_names = onnx_node.get_input_names(); + assert(raw_node->get_input_size() == input_names.size()); + for(size_t i = 0; i < input_names.size(); ++i) + { + raw_node->get_onnx_graph()->update_node_input_cache(input_names[i], raw_node->get_input_source_output(i)); + } + // TODO: Configure it in a proper way -- don't modify graph properties (don't even keep decode_only as a graph property) + raw_node->get_onnx_graph()->set_decode_only(false); + OutputVector ng_nodes{onnx_node.get_ng_nodes()}; + // Filter out null outputs + while(!ng_nodes.empty()) + { + if(dynamic_cast(ng_nodes.back().get_node())) + { + ng_nodes.pop_back(); + } + else break; + } + std::cerr << "[ INFO ] Translating " << raw_node->get_onnx_node().op_type() << "\n"; + for(const auto& output: ng_nodes) + { + std::cerr << " output: " << output.get_partial_shape() << "\n"; + } + replace_node(raw_node, ng_nodes); + } + else + { + // Have to revalidate node because new intpus can affect shape/type propagation for already translated nodes + node->revalidate_and_infer_types(); + } + } + } } // namespace onnx_import } // namespace ngraph From 9fa8922b50a6d7848333d689063ce2c7718177b2 Mon Sep 17 00:00:00 2001 From: Mateusz Bencer Date: Mon, 29 Mar 2021 13:54:47 +0200 Subject: [PATCH 082/116] Code documentation improvement after code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Michał Karzyński <4430709+postrational@users.noreply.github.com> --- .../include/onnx_editor/edge_mapper.hpp | 28 +++++++++---------- .../include/onnx_editor/editor.hpp | 6 ++-- .../include/onnx_editor/editor_types.hpp | 18 ++++++------ 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/ngraph/frontend/onnx_editor/include/onnx_editor/edge_mapper.hpp b/ngraph/frontend/onnx_editor/include/onnx_editor/edge_mapper.hpp index 579419339e5dd2..42981455cbaea3 100644 --- a/ngraph/frontend/onnx_editor/include/onnx_editor/edge_mapper.hpp +++ b/ngraph/frontend/onnx_editor/include/onnx_editor/edge_mapper.hpp @@ -24,7 +24,7 @@ namespace ONNX_NAMESPACE { - // forward declaration to avoid the necessity of include paths setting in components + // Forward declaration to avoid the necessity of including paths in components // that don't directly depend on the ONNX library class GraphProto; } // namespace ONNX_NAMESPACE @@ -33,13 +33,13 @@ namespace ngraph { namespace onnx_editor { - /// \brief A class allows to determine InputEdge and OutputEdge by user-friendly onnx names. + /// \brief A class which allows specifying InputEdge and OutputEdge by user-friendly ONNX names. class EdgeMapper { public: EdgeMapper() = delete; - /// \brief Creates an edge mapper based on graph_proto state. + /// \brief Creates an edge mapper based on a GraphProto object. /// /// \note If state of graph_proto will be changed, the information /// from edge mapper is outdated. @@ -50,26 +50,26 @@ namespace ngraph /// \brief Returns the InputEdge based on a node (node name or output name) /// and an input (input name or input index). /// - /// \note The node name can be ambiguous (many nodes can have the same name). - /// In such a case the algorthim try to match the given node name - /// with the input name (given input index is not enough). - /// If after such operation a found edge is unique, it is returned. - /// If InputEdge cannot be determined based on given params the ngraph_error - /// exception is thrown. + /// \note The node name can be ambiguous (many ONNX nodes can have the same name). + /// In such a case the algorthim tries to match the given node name + /// with the input name (providing an input index is not enough). + /// If a unique edge is found, it will be returned. + /// If InputEdge cannot be determined based on parameter values an ngraph_error + /// exception will be thrown. /// /// \param node A node helper structure created based on a node name /// or a node output name. /// - /// \param input A input helper structure created based on a input name + /// \param input An input helper structure created based on a input name /// or a input index. InputEdge to_input_edge(const Node& node, const Input& input) const; - /// \brief Returns the OutputEdge based on a node (node name or output name) + /// \brief Returns an OutputEdge based on a node (node name or output name) /// and an output (output name or output index). /// - /// \note The node name can be ambiguous (many nodes can have the same name). - /// In such a case the algorthim try to match the given node name - /// with the output name (given output index is not enough). + /// \note The node name can be ambiguous (many ONNX nodes can have the same name). + /// In such a case the algorthim will try to match the given node name + /// with the output name (providing an output index is not enough). /// If after such operation a found edge is unique, it is returned. /// If OutputEdge cannot be determined based on given params the ngraph_error /// exception is thrown. diff --git a/ngraph/frontend/onnx_editor/include/onnx_editor/editor.hpp b/ngraph/frontend/onnx_editor/include/onnx_editor/editor.hpp index fbbd55a38fff74..b883b6a8806be3 100644 --- a/ngraph/frontend/onnx_editor/include/onnx_editor/editor.hpp +++ b/ngraph/frontend/onnx_editor/include/onnx_editor/editor.hpp @@ -111,10 +111,10 @@ namespace ngraph /// \param out_file_path A path to the file where the modified model should be dumped. void serialize(const std::string& out_file_path) const; - /// \brief Create edge mapper object which allow to use node names, input/output indexes - /// istead of node indexes in order to select InputEdge/OutputEdge. + /// \brief Create an EdgeMapper object which allows the use of node names + /// instead of node indexes when specifying input and output edges. /// - /// \return EdgeMapper object which simply using methods which operate over + /// \return EdgeMapper object which simplifies using methods which operate over /// InputEdge and OutputEdge. EdgeMapper create_edge_mapper() const; diff --git a/ngraph/frontend/onnx_editor/include/onnx_editor/editor_types.hpp b/ngraph/frontend/onnx_editor/include/onnx_editor/editor_types.hpp index 428d48b32f2788..b14e73a2a55e37 100644 --- a/ngraph/frontend/onnx_editor/include/onnx_editor/editor_types.hpp +++ b/ngraph/frontend/onnx_editor/include/onnx_editor/editor_types.hpp @@ -61,13 +61,13 @@ namespace ngraph /// OutputEdge(5, "out2") using OutputEdge = Edge; - /// \brief Defines single node input by the name or the index. - /// For a node number test_node, with 3 inputs: + /// \brief Specifies a single node input by the name or index. + /// For a node test_node, with 3 inputs: /// /// ----(in_A)----> +-----------+ /// ----(in_B)----> | test_node | ----(out)----> /// ----(in_C)----> +-----------+ - /// You can indicate in_B as Input("in_B") and Input(1) + /// You can indicate in_B as Input("in_B") or Input(1) struct Input { Input() = delete; @@ -83,13 +83,13 @@ namespace ngraph const int m_input_index = -1; }; - /// \brief Defines single node output by the name or the index. - /// For a node number test_node, with 2 outputs: + /// \brief Specifies a single node output by the name or index. + /// For a node test_node, with 2 outputs: /// /// +-----------+ ---(out1)---> /// ----(in_A)----> | test_node | /// +-----------+ ---(out2)---> - /// You can indicate out2 as Output("out2") and Output(1) + /// You can indicate out2 as Output("out2") or Output(1) struct Output { Output() = delete; @@ -105,14 +105,14 @@ namespace ngraph const int m_output_index = -1; }; - /// \brief Defines single node by output name which is determinitic + /// \brief Specifies a single node by output name which is determinitic /// and node name which can be ambiguous. - /// For a node number test_node, with 2 outputs: + /// For a node test_node, with 2 outputs: /// /// +-----------+ ---(out1)---> /// ----(in_A)----> | test_node | /// +-----------+ ---(out2)---> - /// You can indicate test_node by the name as Node("test_node") + /// You can indicate test_node by name as Node("test_node") /// or by assigned output as Node(Output("out1")) or Node(Output("out2")) struct Node { From 8b2bc1e84fc084f7fb1e21b9255d8e78da4cffdb Mon Sep 17 00:00:00 2001 From: mbencer Date: Mon, 29 Mar 2021 13:58:43 +0200 Subject: [PATCH 083/116] style fix --- .../frontend/onnx_editor/include/onnx_editor/edge_mapper.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ngraph/frontend/onnx_editor/include/onnx_editor/edge_mapper.hpp b/ngraph/frontend/onnx_editor/include/onnx_editor/edge_mapper.hpp index 42981455cbaea3..e2e631be2773b0 100644 --- a/ngraph/frontend/onnx_editor/include/onnx_editor/edge_mapper.hpp +++ b/ngraph/frontend/onnx_editor/include/onnx_editor/edge_mapper.hpp @@ -33,7 +33,8 @@ namespace ngraph { namespace onnx_editor { - /// \brief A class which allows specifying InputEdge and OutputEdge by user-friendly ONNX names. + /// \brief A class which allows specifying InputEdge and OutputEdge by user-friendly ONNX + /// names. class EdgeMapper { public: From 9527f42cdfdc1554b46cd25b7befc6518c3ccbd0 Mon Sep 17 00:00:00 2001 From: mbencer Date: Mon, 29 Mar 2021 14:01:31 +0200 Subject: [PATCH 084/116] changed edge mapper names convention --- .../include/onnx_editor/edge_mapper.hpp | 4 +- .../frontend/onnx_editor/src/edge_mapper.cpp | 4 +- ngraph/test/onnx/onnx_editor.cpp | 74 +++++++++---------- 3 files changed, 41 insertions(+), 41 deletions(-) diff --git a/ngraph/frontend/onnx_editor/include/onnx_editor/edge_mapper.hpp b/ngraph/frontend/onnx_editor/include/onnx_editor/edge_mapper.hpp index e2e631be2773b0..83efbfffa2d26b 100644 --- a/ngraph/frontend/onnx_editor/include/onnx_editor/edge_mapper.hpp +++ b/ngraph/frontend/onnx_editor/include/onnx_editor/edge_mapper.hpp @@ -63,7 +63,7 @@ namespace ngraph /// /// \param input An input helper structure created based on a input name /// or a input index. - InputEdge to_input_edge(const Node& node, const Input& input) const; + InputEdge find_input_edge(const Node& node, const Input& input) const; /// \brief Returns an OutputEdge based on a node (node name or output name) /// and an output (output name or output index). @@ -80,7 +80,7 @@ namespace ngraph /// /// \param output A output helper structure created based on a output name /// or a output index. - OutputEdge to_output_edge(const Node& node, const Output& output) const; + OutputEdge find_output_edge(const Node& node, const Output& output) const; private: std::vector find_node_indexes(const std::string& node_name, diff --git a/ngraph/frontend/onnx_editor/src/edge_mapper.cpp b/ngraph/frontend/onnx_editor/src/edge_mapper.cpp index b3e85187e3d283..90341f47dc5dbb 100644 --- a/ngraph/frontend/onnx_editor/src/edge_mapper.cpp +++ b/ngraph/frontend/onnx_editor/src/edge_mapper.cpp @@ -110,7 +110,7 @@ std::string onnx_editor::EdgeMapper::get_node_input_name(int node_index, int inp return input_name; } -InputEdge onnx_editor::EdgeMapper::to_input_edge(const Node& node, const Input& in) const +InputEdge onnx_editor::EdgeMapper::find_input_edge(const Node& node, const Input& in) const { // identification can be both based on node name and output name const auto& node_indexes = find_node_indexes(node.m_node_name, node.m_output_name); @@ -166,7 +166,7 @@ InputEdge onnx_editor::EdgeMapper::to_input_edge(const Node& node, const Input& } } -OutputEdge onnx_editor::EdgeMapper::to_output_edge(const Node& node, const Output& out) const +OutputEdge onnx_editor::EdgeMapper::find_output_edge(const Node& node, const Output& out) const { // identification can be both based on node name and output name const auto& node_indexes = find_node_indexes(node.m_node_name, node.m_output_name); diff --git a/ngraph/test/onnx/onnx_editor.cpp b/ngraph/test/onnx/onnx_editor.cpp index d0783bc04f120e..7f38ed589d1d7b 100644 --- a/ngraph/test/onnx/onnx_editor.cpp +++ b/ngraph/test/onnx/onnx_editor.cpp @@ -683,12 +683,12 @@ NGRAPH_TEST(onnx_editor, editor_api_select_input_edge_by_output_name_and_input_n SERIALIZED_ZOO, "onnx/model_editor/subgraph__inception_head.prototxt")}; const auto edge_mapper = editor.create_edge_mapper(); - const InputEdge edge = edge_mapper.to_input_edge(EditorNode{EditorOutput{"conv1/7x7_s2_2"}}, + const InputEdge edge = edge_mapper.find_input_edge(EditorNode{EditorOutput{"conv1/7x7_s2_2"}}, EditorInput{"conv1/7x7_s2_1"}); EXPECT_EQ(edge.m_node_idx, 1); EXPECT_EQ(edge.m_tensor_name, "conv1/7x7_s2_1"); - const InputEdge edge2 = edge_mapper.to_input_edge(EditorNode{EditorOutput{"conv1/7x7_s2_1"}}, + const InputEdge edge2 = edge_mapper.find_input_edge(EditorNode{EditorOutput{"conv1/7x7_s2_1"}}, EditorInput{"data_0"}); EXPECT_EQ(edge2.m_node_idx, 0); EXPECT_EQ(edge2.m_tensor_name, "data_0"); @@ -701,17 +701,17 @@ NGRAPH_TEST(onnx_editor, editor_api_select_input_edge_by_output_name_and_input_i const auto edge_mapper = editor.create_edge_mapper(); const InputEdge edge = - edge_mapper.to_input_edge(EditorNode{EditorOutput{"conv1/7x7_s2_2"}}, EditorInput{0}); + edge_mapper.find_input_edge(EditorNode{EditorOutput{"conv1/7x7_s2_2"}}, EditorInput{0}); EXPECT_EQ(edge.m_node_idx, 1); EXPECT_EQ(edge.m_tensor_name, "conv1/7x7_s2_1"); const InputEdge edge2 = - edge_mapper.to_input_edge(EditorNode{EditorOutput{"conv1/7x7_s2_1"}}, EditorInput{1}); + edge_mapper.find_input_edge(EditorNode{EditorOutput{"conv1/7x7_s2_1"}}, EditorInput{1}); EXPECT_EQ(edge2.m_node_idx, 0); EXPECT_EQ(edge2.m_tensor_name, "conv1/7x7_s2_w_0"); const InputEdge edge3 = - edge_mapper.to_input_edge(EditorNode{EditorOutput{"conv1/7x7_s2_1"}}, EditorInput{2}); + edge_mapper.find_input_edge(EditorNode{EditorOutput{"conv1/7x7_s2_1"}}, EditorInput{2}); EXPECT_EQ(edge3.m_node_idx, 0); EXPECT_EQ(edge3.m_tensor_name, "conv1/7x7_s2_b_0"); } @@ -723,12 +723,12 @@ NGRAPH_TEST(onnx_editor, editor_api_select_input_edge_by_node_name_and_input_nam const auto edge_mapper = editor.create_edge_mapper(); const InputEdge edge = - edge_mapper.to_input_edge(EditorNode{"relu1"}, EditorInput{"conv1/7x7_s2_1"}); + edge_mapper.find_input_edge(EditorNode{"relu1"}, EditorInput{"conv1/7x7_s2_1"}); EXPECT_EQ(edge.m_node_idx, 1); EXPECT_EQ(edge.m_tensor_name, "conv1/7x7_s2_1"); const InputEdge edge2 = - edge_mapper.to_input_edge(EditorNode{"conv1"}, EditorInput{"conv1/7x7_s2_w_0"}); + edge_mapper.find_input_edge(EditorNode{"conv1"}, EditorInput{"conv1/7x7_s2_w_0"}); EXPECT_EQ(edge2.m_node_idx, 0); EXPECT_EQ(edge2.m_tensor_name, "conv1/7x7_s2_w_0"); } @@ -739,11 +739,11 @@ NGRAPH_TEST(onnx_editor, editor_api_select_input_edge_by_node_name_and_input_ind SERIALIZED_ZOO, "onnx/model_editor/subgraph_extraction_tests.prototxt")}; const auto edge_mapper = editor.create_edge_mapper(); - const InputEdge edge = edge_mapper.to_input_edge(EditorNode{"relu1_name"}, EditorInput{0}); + const InputEdge edge = edge_mapper.find_input_edge(EditorNode{"relu1_name"}, EditorInput{0}); EXPECT_EQ(edge.m_node_idx, 0); EXPECT_EQ(edge.m_tensor_name, "in1"); - const InputEdge edge2 = edge_mapper.to_input_edge(EditorNode{"split_name"}, EditorInput{0}); + const InputEdge edge2 = edge_mapper.find_input_edge(EditorNode{"split_name"}, EditorInput{0}); EXPECT_EQ(edge2.m_node_idx, 5); EXPECT_EQ(edge2.m_tensor_name, "add2"); } @@ -756,12 +756,12 @@ NGRAPH_TEST(onnx_editor, editor_api_select_output_edge_by_output_name_and_input_ const auto edge_mapper = editor.create_edge_mapper(); const OutputEdge edge = - edge_mapper.to_output_edge(EditorNode{EditorOutput{"mul2"}}, EditorOutput{"mul2"}); + edge_mapper.find_output_edge(EditorNode{EditorOutput{"mul2"}}, EditorOutput{"mul2"}); EXPECT_EQ(edge.m_node_idx, 4); EXPECT_EQ(edge.m_tensor_name, "mul2"); const OutputEdge edge2 = - edge_mapper.to_output_edge(EditorNode{EditorOutput{"split1"}}, EditorOutput{"split2"}); + edge_mapper.find_output_edge(EditorNode{EditorOutput{"split1"}}, EditorOutput{"split2"}); EXPECT_EQ(edge2.m_node_idx, 5); EXPECT_EQ(edge2.m_tensor_name, "split2"); } @@ -773,17 +773,17 @@ NGRAPH_TEST(onnx_editor, editor_api_select_output_edge_by_output_name_and_output const auto edge_mapper = editor.create_edge_mapper(); const OutputEdge edge = - edge_mapper.to_output_edge(EditorNode{EditorOutput{"add2"}}, EditorOutput{0}); + edge_mapper.find_output_edge(EditorNode{EditorOutput{"add2"}}, EditorOutput{0}); EXPECT_EQ(edge.m_node_idx, 3); EXPECT_EQ(edge.m_tensor_name, "add2"); const OutputEdge edge2 = - edge_mapper.to_output_edge(EditorNode{EditorOutput{"split1"}}, EditorOutput{1}); + edge_mapper.find_output_edge(EditorNode{EditorOutput{"split1"}}, EditorOutput{1}); EXPECT_EQ(edge2.m_node_idx, 5); EXPECT_EQ(edge2.m_tensor_name, "split2"); const OutputEdge edge3 = - edge_mapper.to_output_edge(EditorNode{EditorOutput{"split2"}}, EditorOutput{0}); + edge_mapper.find_output_edge(EditorNode{EditorOutput{"split2"}}, EditorOutput{0}); EXPECT_EQ(edge3.m_node_idx, 5); EXPECT_EQ(edge3.m_tensor_name, "split1"); } @@ -795,12 +795,12 @@ NGRAPH_TEST(onnx_editor, editor_api_select_output_edge_by_node_name_and_output_n const auto edge_mapper = editor.create_edge_mapper(); const OutputEdge edge = - edge_mapper.to_output_edge(EditorNode{"relu1_name"}, EditorOutput{"relu1"}); + edge_mapper.find_output_edge(EditorNode{"relu1_name"}, EditorOutput{"relu1"}); EXPECT_EQ(edge.m_node_idx, 0); EXPECT_EQ(edge.m_tensor_name, "relu1"); const OutputEdge edge2 = - edge_mapper.to_output_edge(EditorNode{"split_name"}, EditorOutput{"split2"}); + edge_mapper.find_output_edge(EditorNode{"split_name"}, EditorOutput{"split2"}); EXPECT_EQ(edge2.m_node_idx, 5); EXPECT_EQ(edge2.m_tensor_name, "split2"); } @@ -811,11 +811,11 @@ NGRAPH_TEST(onnx_editor, editor_api_select_output_edge_by_node_name_and_output_i SERIALIZED_ZOO, "onnx/model_editor/subgraph_extraction_tests.prototxt")}; const auto edge_mapper = editor.create_edge_mapper(); - const OutputEdge edge = edge_mapper.to_output_edge(EditorNode{"relu1_name"}, EditorOutput{0}); + const OutputEdge edge = edge_mapper.find_output_edge(EditorNode{"relu1_name"}, EditorOutput{0}); EXPECT_EQ(edge.m_node_idx, 0); EXPECT_EQ(edge.m_tensor_name, "relu1"); - const OutputEdge edge2 = edge_mapper.to_output_edge(EditorNode{"split_name"}, EditorOutput{1}); + const OutputEdge edge2 = edge_mapper.find_output_edge(EditorNode{"split_name"}, EditorOutput{1}); EXPECT_EQ(edge2.m_node_idx, 5); EXPECT_EQ(edge2.m_tensor_name, "split2"); } @@ -827,15 +827,15 @@ NGRAPH_TEST(onnx_editor, editor_api_select_edge_const_network) const auto edge_mapper = editor.create_edge_mapper(); const InputEdge edge = - edge_mapper.to_input_edge(EditorNode{EditorOutput{"relu4"}}, EditorInput{0}); + edge_mapper.find_input_edge(EditorNode{EditorOutput{"relu4"}}, EditorInput{0}); EXPECT_EQ(edge.m_node_idx, 3); EXPECT_EQ(edge.m_tensor_name, "in2"); - const OutputEdge edge2 = edge_mapper.to_output_edge(EditorNode{"relu4_name"}, EditorOutput{0}); + const OutputEdge edge2 = edge_mapper.find_output_edge(EditorNode{"relu4_name"}, EditorOutput{0}); EXPECT_EQ(edge2.m_node_idx, 3); EXPECT_EQ(edge2.m_tensor_name, "relu4"); - const OutputEdge edge3 = edge_mapper.to_output_edge(EditorNode{"add1_name"}, EditorOutput{0}); + const OutputEdge edge3 = edge_mapper.find_output_edge(EditorNode{"add1_name"}, EditorOutput{0}); EXPECT_EQ(edge3.m_node_idx, 4); EXPECT_EQ(edge3.m_tensor_name, "add1"); } @@ -850,7 +850,7 @@ NGRAPH_TEST(onnx_editor, editor_api_select_edge_error_handling) try { const InputEdge edge = - edge_mapper.to_input_edge(EditorNode{EditorOutput{"not_existed"}}, EditorInput{0}); + edge_mapper.find_input_edge(EditorNode{EditorOutput{"not_existed"}}, EditorInput{0}); } catch (const std::exception& e) { @@ -863,7 +863,7 @@ NGRAPH_TEST(onnx_editor, editor_api_select_edge_error_handling) // node with given name not found try { - const InputEdge edge = edge_mapper.to_input_edge(EditorNode{"not_existed"}, EditorInput{0}); + const InputEdge edge = edge_mapper.find_input_edge(EditorNode{"not_existed"}, EditorInput{0}); } catch (const std::exception& e) { @@ -876,7 +876,7 @@ NGRAPH_TEST(onnx_editor, editor_api_select_edge_error_handling) // input index out of scope try { - const InputEdge edge = edge_mapper.to_input_edge(EditorNode{"relu4_name"}, EditorInput{1}); + const InputEdge edge = edge_mapper.find_input_edge(EditorNode{"relu4_name"}, EditorInput{1}); } catch (const std::exception& e) { @@ -889,7 +889,7 @@ NGRAPH_TEST(onnx_editor, editor_api_select_edge_error_handling) try { const OutputEdge edge = - edge_mapper.to_output_edge(EditorNode{"relu4_name"}, EditorOutput{1}); + edge_mapper.find_output_edge(EditorNode{"relu4_name"}, EditorOutput{1}); } catch (const std::exception& e) { @@ -906,11 +906,11 @@ NGRAPH_TEST(onnx_editor, editor_api_select_input_edge_by_ambiguous_node_name_but SERIALIZED_ZOO, "onnx/model_editor/subgraph_extraction_tests.prototxt")}; const auto edge_mapper = editor.create_edge_mapper(); - const InputEdge edge = edge_mapper.to_input_edge(EditorNode{"add_ambiguous_name"}, EditorInput{"in2"}); + const InputEdge edge = edge_mapper.find_input_edge(EditorNode{"add_ambiguous_name"}, EditorInput{"in2"}); EXPECT_EQ(edge.m_node_idx, 1); EXPECT_EQ(edge.m_tensor_name, "in2"); - const InputEdge edge2 = edge_mapper.to_input_edge(EditorNode{"add_ambiguous_name"}, EditorInput{"add1"}); + const InputEdge edge2 = edge_mapper.find_input_edge(EditorNode{"add_ambiguous_name"}, EditorInput{"add1"}); EXPECT_EQ(edge2.m_node_idx, 3); EXPECT_EQ(edge2.m_tensor_name, "add1"); } @@ -923,7 +923,7 @@ NGRAPH_TEST(onnx_editor, editor_api_select_input_edge_by_ambiguous_node_name_and try { - const InputEdge edge = edge_mapper.to_input_edge(EditorNode{"add_ambiguous_name"}, EditorInput{"in3"}); + const InputEdge edge = edge_mapper.find_input_edge(EditorNode{"add_ambiguous_name"}, EditorInput{"in3"}); } catch (const std::exception& e) { @@ -934,7 +934,7 @@ NGRAPH_TEST(onnx_editor, editor_api_select_input_edge_by_ambiguous_node_name_and try { - const InputEdge edge = edge_mapper.to_input_edge(EditorNode{"add_ambiguous_name"}, EditorInput{"relu1"}); + const InputEdge edge = edge_mapper.find_input_edge(EditorNode{"add_ambiguous_name"}, EditorInput{"relu1"}); } catch (const std::exception& e) { @@ -952,7 +952,7 @@ NGRAPH_TEST(onnx_editor, editor_api_select_input_edge_by_ambiguous_node_name_and try { - const InputEdge edge = edge_mapper.to_input_edge(EditorNode{"add_ambiguous_name"}, EditorInput{0}); + const InputEdge edge = edge_mapper.find_input_edge(EditorNode{"add_ambiguous_name"}, EditorInput{0}); } catch (const std::exception& e) { @@ -968,11 +968,11 @@ NGRAPH_TEST(onnx_editor, editor_api_select_output_edge_by_ambiguous_node_name_bu SERIALIZED_ZOO, "onnx/model_editor/subgraph_extraction_tests.prototxt")}; const auto edge_mapper = editor.create_edge_mapper(); - const OutputEdge edge = edge_mapper.to_output_edge(EditorNode{"add_ambiguous_name"}, EditorOutput{"add1"}); + const OutputEdge edge = edge_mapper.find_output_edge(EditorNode{"add_ambiguous_name"}, EditorOutput{"add1"}); EXPECT_EQ(edge.m_node_idx, 1); EXPECT_EQ(edge.m_tensor_name, "add1"); - const OutputEdge edge2 = edge_mapper.to_output_edge(EditorNode{"add_ambiguous_name"}, EditorOutput{"add2"}); + const OutputEdge edge2 = edge_mapper.find_output_edge(EditorNode{"add_ambiguous_name"}, EditorOutput{"add2"}); EXPECT_EQ(edge2.m_node_idx, 3); EXPECT_EQ(edge2.m_tensor_name, "add2"); } @@ -985,7 +985,7 @@ NGRAPH_TEST(onnx_editor, editor_api_select_output_edge_by_ambiguous_node_name_an try { - const OutputEdge edge = edge_mapper.to_output_edge(EditorNode{"add_ambiguous_name"}, EditorOutput{"split2"}); + const OutputEdge edge = edge_mapper.find_output_edge(EditorNode{"add_ambiguous_name"}, EditorOutput{"split2"}); } catch (const std::exception& e) { @@ -1003,7 +1003,7 @@ NGRAPH_TEST(onnx_editor, editor_api_select_output_edge_by_ambiguous_node_name_an try { - const OutputEdge edge = edge_mapper.to_output_edge(EditorNode{"add_ambiguous_name"}, EditorOutput{0}); + const OutputEdge edge = edge_mapper.find_output_edge(EditorNode{"add_ambiguous_name"}, EditorOutput{0}); } catch (const std::exception& e) { @@ -1019,11 +1019,11 @@ NGRAPH_TEST(onnx_editor, editor_api_use_edge_mapper_with_graph_cutter) SERIALIZED_ZOO, "onnx/model_editor/subgraph_extraction_tests.prototxt")}; const auto mapper = editor.create_edge_mapper(); - editor.cut_graph_fragment({/*{InputEdge{1, "in2"}*/ mapper.to_input_edge( + editor.cut_graph_fragment({/*{InputEdge{1, "in2"}*/ mapper.find_input_edge( EditorNode(EditorOutput("add1")), EditorInput(1)), - /*InputEdge{2, "in3"}*/ mapper.to_input_edge( + /*InputEdge{2, "in3"}*/ mapper.find_input_edge( EditorNode(EditorOutput("conv1")), EditorInput(0))}, - {/*{OutputEdge{4, "mul2"}*/ mapper.to_output_edge( + {/*{OutputEdge{4, "mul2"}*/ mapper.find_output_edge( EditorNode(EditorOutput("mul2")), EditorOutput(0))}); const auto ref_model = From 7a3c669b757316274d0225f157edab48006cdb3e Mon Sep 17 00:00:00 2001 From: mbencer Date: Mon, 29 Mar 2021 15:15:21 +0200 Subject: [PATCH 085/116] review remarks --- .../frontend/onnx_editor/src/edge_mapper.cpp | 6 +++-- .../subgraph_extraction_tests.prototxt | 1 + ngraph/test/onnx/onnx_editor.cpp | 22 ++++++++++++++++++- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/ngraph/frontend/onnx_editor/src/edge_mapper.cpp b/ngraph/frontend/onnx_editor/src/edge_mapper.cpp index 90341f47dc5dbb..e0d27c3a754f99 100644 --- a/ngraph/frontend/onnx_editor/src/edge_mapper.cpp +++ b/ngraph/frontend/onnx_editor/src/edge_mapper.cpp @@ -119,7 +119,8 @@ InputEdge onnx_editor::EdgeMapper::find_input_edge(const Node& node, const Input { node_index = node_indexes[0]; } - else if (!in.m_input_name.empty()) // input indexes are not deterministic + else if (!in.m_input_name + .empty()) // input indexes are not deterministic if a node name is ambiguous { // many nodes with the same name // check if some of found index matches input name @@ -175,7 +176,8 @@ OutputEdge onnx_editor::EdgeMapper::find_output_edge(const Node& node, const Out { node_index = node_indexes[0]; } - else if (!out.m_output_name.empty()) // output indexes are not deterministic + else if (!out.m_output_name + .empty()) // output indexes are not deterministic if a node name is ambiguous { // many nodes with the same name // check if some of found index matches output name diff --git a/ngraph/test/models/onnx/model_editor/subgraph_extraction_tests.prototxt b/ngraph/test/models/onnx/model_editor/subgraph_extraction_tests.prototxt index 6875db701af8c1..fe8972df10c98d 100644 --- a/ngraph/test/models/onnx/model_editor/subgraph_extraction_tests.prototxt +++ b/ngraph/test/models/onnx/model_editor/subgraph_extraction_tests.prototxt @@ -32,6 +32,7 @@ graph { input: "conv1" output: "mul2" op_type: "Mul" + name: "" } node { input: "add2" diff --git a/ngraph/test/onnx/onnx_editor.cpp b/ngraph/test/onnx/onnx_editor.cpp index 7f38ed589d1d7b..000648a9126eae 100644 --- a/ngraph/test/onnx/onnx_editor.cpp +++ b/ngraph/test/onnx/onnx_editor.cpp @@ -748,8 +748,28 @@ NGRAPH_TEST(onnx_editor, editor_api_select_input_edge_by_node_name_and_input_ind EXPECT_EQ(edge2.m_tensor_name, "add2"); } +NGRAPH_TEST(onnx_editor, editor_api_select_input_edge_empty_node_name) +{ + ONNXModelEditor editor{file_util::path_join( + SERIALIZED_ZOO, "onnx/model_editor/subgraph_extraction_tests.prototxt")}; + const auto edge_mapper = editor.create_edge_mapper(); + + try + { + const InputEdge edge = + edge_mapper.find_input_edge(EditorNode{""}, EditorInput{"conv1/7x7_s2_1"}); + } + catch (const std::exception& e) + { + std::string msg{e.what()}; + EXPECT_TRUE( + msg.find("Node with name: not_given and output_name: not_given was not found") != + std::string::npos); + } +} + // OUTPUT EDGES TEST -NGRAPH_TEST(onnx_editor, editor_api_select_output_edge_by_output_name_and_input_name) +NGRAPH_TEST(onnx_editor, editor_api_select_output_edge_by_output_name_and_output_name) { ONNXModelEditor editor{file_util::path_join( SERIALIZED_ZOO, "onnx/model_editor/subgraph_extraction_tests.prototxt")}; From 9ca76f0763ef1aaabfbcc5fa191e109a54aa3009 Mon Sep 17 00:00:00 2001 From: mbencer Date: Mon, 29 Mar 2021 15:18:00 +0200 Subject: [PATCH 086/116] new style of copyright applied to edge mapper --- .../include/onnx_editor/edge_mapper.hpp | 16 ++-------------- ngraph/frontend/onnx_editor/src/edge_mapper.cpp | 16 ++-------------- 2 files changed, 4 insertions(+), 28 deletions(-) diff --git a/ngraph/frontend/onnx_editor/include/onnx_editor/edge_mapper.hpp b/ngraph/frontend/onnx_editor/include/onnx_editor/edge_mapper.hpp index 83efbfffa2d26b..b50f5f6fa5e517 100644 --- a/ngraph/frontend/onnx_editor/include/onnx_editor/edge_mapper.hpp +++ b/ngraph/frontend/onnx_editor/include/onnx_editor/edge_mapper.hpp @@ -1,18 +1,6 @@ -//***************************************************************************** -// Copyright 2017-2021 Intel Corporation +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -//***************************************************************************** #pragma once diff --git a/ngraph/frontend/onnx_editor/src/edge_mapper.cpp b/ngraph/frontend/onnx_editor/src/edge_mapper.cpp index e0d27c3a754f99..be45b93a6a7e8e 100644 --- a/ngraph/frontend/onnx_editor/src/edge_mapper.cpp +++ b/ngraph/frontend/onnx_editor/src/edge_mapper.cpp @@ -1,18 +1,6 @@ -//***************************************************************************** -// Copyright 2017-2021 Intel Corporation +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -//***************************************************************************** #include #include From 0b02c2e4efd8eff92f32a1e018893b40eef89b8c Mon Sep 17 00:00:00 2001 From: mbencer Date: Mon, 29 Mar 2021 15:59:32 +0200 Subject: [PATCH 087/116] Introduce new find_output_edge overload. --- .../onnx_editor/include/onnx_editor/edge_mapper.hpp | 8 ++++++++ ngraph/frontend/onnx_editor/src/edge_mapper.cpp | 5 +++++ ngraph/test/onnx/onnx_editor.cpp | 13 ++++++++++++- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/ngraph/frontend/onnx_editor/include/onnx_editor/edge_mapper.hpp b/ngraph/frontend/onnx_editor/include/onnx_editor/edge_mapper.hpp index b50f5f6fa5e517..45596425869e29 100644 --- a/ngraph/frontend/onnx_editor/include/onnx_editor/edge_mapper.hpp +++ b/ngraph/frontend/onnx_editor/include/onnx_editor/edge_mapper.hpp @@ -70,6 +70,14 @@ namespace ngraph /// or a output index. OutputEdge find_output_edge(const Node& node, const Output& output) const; + /// \brief Returns an OutputEdge based on a output name. + /// + /// \note The output name guarantees the uniqueness of the edge. + /// + /// \param output_name A node output name. + /// + OutputEdge find_output_edge(const std::string& output_name) const; + private: std::vector find_node_indexes(const std::string& node_name, const std::string& output_name) const; diff --git a/ngraph/frontend/onnx_editor/src/edge_mapper.cpp b/ngraph/frontend/onnx_editor/src/edge_mapper.cpp index be45b93a6a7e8e..a9de69d00dd1e6 100644 --- a/ngraph/frontend/onnx_editor/src/edge_mapper.cpp +++ b/ngraph/frontend/onnx_editor/src/edge_mapper.cpp @@ -206,3 +206,8 @@ OutputEdge onnx_editor::EdgeMapper::find_output_edge(const Node& node, const Out throw ngraph_error("Not enough information to determine output edge"); } } + +OutputEdge onnx_editor::EdgeMapper::find_output_edge(const std::string& output_name) const +{ + return find_output_edge(Node{Output{output_name}}, Output{output_name}); +} diff --git a/ngraph/test/onnx/onnx_editor.cpp b/ngraph/test/onnx/onnx_editor.cpp index 000648a9126eae..a0897dcd96a034 100644 --- a/ngraph/test/onnx/onnx_editor.cpp +++ b/ngraph/test/onnx/onnx_editor.cpp @@ -769,7 +769,7 @@ NGRAPH_TEST(onnx_editor, editor_api_select_input_edge_empty_node_name) } // OUTPUT EDGES TEST -NGRAPH_TEST(onnx_editor, editor_api_select_output_edge_by_output_name_and_output_name) +NGRAPH_TEST(onnx_editor, editor_api_select_output_edge_by_output_name) { ONNXModelEditor editor{file_util::path_join( SERIALIZED_ZOO, "onnx/model_editor/subgraph_extraction_tests.prototxt")}; @@ -784,6 +784,17 @@ NGRAPH_TEST(onnx_editor, editor_api_select_output_edge_by_output_name_and_output edge_mapper.find_output_edge(EditorNode{EditorOutput{"split1"}}, EditorOutput{"split2"}); EXPECT_EQ(edge2.m_node_idx, 5); EXPECT_EQ(edge2.m_tensor_name, "split2"); + + // simplified overload + const OutputEdge edge3 = + edge_mapper.find_output_edge("mul2"); + EXPECT_EQ(edge3.m_node_idx, 4); + EXPECT_EQ(edge3.m_tensor_name, "mul2"); + + const OutputEdge edge4 = + edge_mapper.find_output_edge("split2"); + EXPECT_EQ(edge4.m_node_idx, 5); + EXPECT_EQ(edge4.m_tensor_name, "split2"); } NGRAPH_TEST(onnx_editor, editor_api_select_output_edge_by_output_name_and_output_index) From 19e86171280bebb6090a6bf5325b18ea4b1a7722 Mon Sep 17 00:00:00 2001 From: Mateusz Bencer Date: Tue, 30 Mar 2021 19:32:25 +0200 Subject: [PATCH 088/116] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Michał Karzyński <4430709+postrational@users.noreply.github.com> --- .../frontend/onnx_editor/include/onnx_editor/editor_types.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ngraph/frontend/onnx_editor/include/onnx_editor/editor_types.hpp b/ngraph/frontend/onnx_editor/include/onnx_editor/editor_types.hpp index b14e73a2a55e37..84aa4944251b07 100644 --- a/ngraph/frontend/onnx_editor/include/onnx_editor/editor_types.hpp +++ b/ngraph/frontend/onnx_editor/include/onnx_editor/editor_types.hpp @@ -62,6 +62,7 @@ namespace ngraph using OutputEdge = Edge; /// \brief Specifies a single node input by the name or index. + /// /// For a node test_node, with 3 inputs: /// /// ----(in_A)----> +-----------+ @@ -106,7 +107,7 @@ namespace ngraph }; /// \brief Specifies a single node by output name which is determinitic - /// and node name which can be ambiguous. + /// or node name which can be ambiguous. /// For a node test_node, with 2 outputs: /// /// +-----------+ ---(out1)---> From 43fffe277114675968ade4d30ff670c52edaf5b7 Mon Sep 17 00:00:00 2001 From: "Lyalin, Sergey" Date: Wed, 31 Mar 2021 00:20:41 +0300 Subject: [PATCH 089/116] Reorganized PDPD FE to unlock independent ops enabling --- ngraph/frontend/paddlepaddle/CMakeLists.txt | 7 +- ngraph/frontend/paddlepaddle/src/decoder.hpp | 23 +- ngraph/frontend/paddlepaddle/src/frontend.cpp | 214 ++++-------------- .../paddlepaddle/src/node_context.hpp | 79 +++++++ .../paddlepaddle/src/op/batch_norm.cpp | 35 +++ .../paddlepaddle/src/op/batch_norm.hpp | 27 +++ .../frontend/paddlepaddle/src/op/conv2d.cpp | 41 ++++ .../frontend/paddlepaddle/src/op/conv2d.hpp | 27 +++ .../paddlepaddle/src/op/elementwise_add.cpp | 32 +++ .../paddlepaddle/src/op/elementwise_add.hpp | 27 +++ ngraph/frontend/paddlepaddle/src/op/mul.cpp | 59 +++++ ngraph/frontend/paddlepaddle/src/op/mul.hpp | 27 +++ .../frontend/paddlepaddle/src/op/pool2d.cpp | 49 ++++ .../frontend/paddlepaddle/src/op/pool2d.hpp | 27 +++ ngraph/frontend/paddlepaddle/src/op/relu.cpp | 29 +++ ngraph/frontend/paddlepaddle/src/op/relu.hpp | 27 +++ ngraph/frontend/paddlepaddle/src/op/scale.cpp | 31 +++ ngraph/frontend/paddlepaddle/src/op/scale.hpp | 27 +++ ngraph/frontend/paddlepaddle/src/op_table.cpp | 45 ++++ ngraph/frontend/paddlepaddle/src/op_table.hpp | 36 +++ 20 files changed, 702 insertions(+), 167 deletions(-) create mode 100644 ngraph/frontend/paddlepaddle/src/node_context.hpp create mode 100644 ngraph/frontend/paddlepaddle/src/op/batch_norm.cpp create mode 100644 ngraph/frontend/paddlepaddle/src/op/batch_norm.hpp create mode 100644 ngraph/frontend/paddlepaddle/src/op/conv2d.cpp create mode 100644 ngraph/frontend/paddlepaddle/src/op/conv2d.hpp create mode 100644 ngraph/frontend/paddlepaddle/src/op/elementwise_add.cpp create mode 100644 ngraph/frontend/paddlepaddle/src/op/elementwise_add.hpp create mode 100644 ngraph/frontend/paddlepaddle/src/op/mul.cpp create mode 100644 ngraph/frontend/paddlepaddle/src/op/mul.hpp create mode 100644 ngraph/frontend/paddlepaddle/src/op/pool2d.cpp create mode 100644 ngraph/frontend/paddlepaddle/src/op/pool2d.hpp create mode 100644 ngraph/frontend/paddlepaddle/src/op/relu.cpp create mode 100644 ngraph/frontend/paddlepaddle/src/op/relu.hpp create mode 100644 ngraph/frontend/paddlepaddle/src/op/scale.cpp create mode 100644 ngraph/frontend/paddlepaddle/src/op/scale.hpp create mode 100644 ngraph/frontend/paddlepaddle/src/op_table.cpp create mode 100644 ngraph/frontend/paddlepaddle/src/op_table.hpp diff --git a/ngraph/frontend/paddlepaddle/CMakeLists.txt b/ngraph/frontend/paddlepaddle/CMakeLists.txt index aa6b1fb3ca273a..f41ccf36babffa 100644 --- a/ngraph/frontend/paddlepaddle/CMakeLists.txt +++ b/ngraph/frontend/paddlepaddle/CMakeLists.txt @@ -39,7 +39,12 @@ include_directories(${Protobuf_INCLUDE_DIRS} ${PADDLEPADDLE_FRONTEND_INCLUDE_DIR add_library(paddlepaddle_frontend SHARED ${LIBRARY_SRC} ${LIBRARY_HEADERS} ${LIBRARY_PUBLIC_HEADERS} ${PROTO_SRCS} ${PROTO_HDRS}) add_library(ngraph::paddlepaddle_frontend ALIAS paddlepaddle_frontend) -target_include_directories(paddlepaddle_frontend PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../generic/include ${CMAKE_CURRENT_BINARY_DIR}) +# TODO: fix relative include directory by moving +target_include_directories(paddlepaddle_frontend + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/src + ${CMAKE_CURRENT_SOURCE_DIR}/../generic/include + ${CMAKE_CURRENT_BINARY_DIR}) if(COMMAND ie_add_vs_version_file) ie_add_vs_version_file(NAME paddlepaddle_frontend diff --git a/ngraph/frontend/paddlepaddle/src/decoder.hpp b/ngraph/frontend/paddlepaddle/src/decoder.hpp index 802e826f0d4448..f4075b586fd4df 100644 --- a/ngraph/frontend/paddlepaddle/src/decoder.hpp +++ b/ngraph/frontend/paddlepaddle/src/decoder.hpp @@ -1,6 +1,21 @@ -// Copyright (C) 2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 +//***************************************************************************** +// Copyright 2017-2021 Intel Corporation // +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//***************************************************************************** + + +#pragma once #include #include @@ -26,6 +41,10 @@ using namespace paddle::framework; extern std::map TYPE_MAP; +// TODO: Inherit from one of the ngraph classes +class AttributeNotFound : public std::exception +{}; + class DecoderPDPDProto { proto::OpDesc op; diff --git a/ngraph/frontend/paddlepaddle/src/frontend.cpp b/ngraph/frontend/paddlepaddle/src/frontend.cpp index 9dfd9b565945d5..d77590d10b67dd 100644 --- a/ngraph/frontend/paddlepaddle/src/frontend.cpp +++ b/ngraph/frontend/paddlepaddle/src/frontend.cpp @@ -1,6 +1,19 @@ -// Copyright (C) 2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 +//***************************************************************************** +// Copyright 2017-2021 Intel Corporation // +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//***************************************************************************** + #include #include @@ -20,174 +33,24 @@ #include "utility.hpp" #include "decoder.hpp" +#include "node_context.hpp" +#include "op_table.hpp" +#include namespace ngraph { - namespace frontend { - - -typedef std::shared_ptr(*CreatorFunction)( - std::map>> &inputs, - const DecoderPDPDProto &); - -template -void print(const T &a) { - std::cerr << "["; - for (const auto &e: a) { - std::cerr << e << ", "; - } - std::cerr << "]\n"; -} - -std::shared_ptr -conv2d_creator(std::map>> &inputs, - const DecoderPDPDProto &op) { - std::cout << "Running conv2d creator" << std::endl; - MY_ASSERT(inputs["Input"].size() == 1 && inputs["Filter"].size() == 1, "More then one input for conv2d"); - MY_ASSERT(inputs["Bias"].size() == 0 && inputs["ResidualData"].size() == 0, - "Bias and residual have input for conv2d"); - auto data = inputs["Input"][0]; - auto filter = inputs["Filter"][0]; - // TODO: resolve padding according to spec - auto strides = op.get_ints("strides"); - auto paddings = op.get_ints("paddings"); - auto dilations = op.get_ints("dilations"); - std::cout << "Creating convolution node" << std::endl; - print(strides); - print(paddings); - print(dilations); - return std::make_shared(data, - filter, - ngraph::Strides(strides.begin(), strides.end()), - ngraph::CoordinateDiff(paddings.begin(), - paddings.end()), - ngraph::CoordinateDiff(paddings.begin(), - paddings.end()), - ngraph::Strides(dilations.begin(), dilations.end())); -} - - -std::shared_ptr -batch_norm_creator(std::map>> &inputs, - const DecoderPDPDProto &op) { - MY_ASSERT(inputs["X"].size() == 1 && - inputs["Scale"].size() == 1 && - inputs["Bias"].size() == 1 && - inputs["Mean"].size() == 1 && - inputs["Variance"].size() == 1, - "More then one input for batch_norm"); - auto data = inputs["X"][0]; - auto gamma = inputs["Scale"][0]; - auto beta = inputs["Bias"][0]; - auto mean = inputs["Mean"][0]; - auto variance = inputs["Variance"][0]; - return std::make_shared(data, gamma, beta, mean, variance, - op.get_float("epsilon")); -} - - -std::shared_ptr -relu_creator(std::map>> &inputs, - const DecoderPDPDProto &op) { - MY_ASSERT(inputs["X"].size() == 1, "More then one input for relu"); - auto data = inputs["X"][0]; - return std::make_shared(data); -} - -std::shared_ptr -pool2d_creator(std::map>> &inputs, - const DecoderPDPDProto &op) { - MY_ASSERT(inputs["X"].size() == 1, "More then one input for pool2d"); - auto data = inputs["X"][0]; - // TODO : resolve padding according to spec - auto pooling_type = op.get_str("pooling_type"); - auto global_pooling = op.get_bool("global_pooling"); - if (pooling_type == "max" && !global_pooling) { - auto strides = op.get_ints("strides"); - auto paddings = op.get_ints("paddings"); - auto kernel_shape = op.get_ints("ksize"); - return std::make_shared(data, - ngraph::Strides(strides.begin(), strides.end()), - ngraph::Shape(paddings.begin(), paddings.end()), - ngraph::Shape(paddings.begin(), paddings.end()), - ngraph::Shape(kernel_shape.begin(), - kernel_shape.end())); - } else if (pooling_type == "avg" && global_pooling) { - // TODO : resolve axes according to rank - auto axes = ngraph::opset6::Constant::create(ngraph::element::i64, {2}, {2, 3}); - return std::make_shared(data, axes, true); - } else { - throw std::runtime_error("Unsupported pooling type"); - } -} - -std::shared_ptr -elementwise_add_creator(std::map>> &inputs, - const DecoderPDPDProto &op) { - MY_ASSERT(inputs["X"].size() == 1 && inputs["Y"].size() == 1, "More then one input for elementwise_add"); - auto x = inputs["X"][0]; - auto y = inputs["Y"][0]; - // TODO : resolve broadcast - return std::make_shared(x, y); -} - -std::shared_ptr -mul_creator(std::map>> &inputs, - const DecoderPDPDProto &op) { - MY_ASSERT(inputs["X"].size() == 1 && inputs["Y"].size() == 1, "More then one input for mul"); - auto x = inputs["X"][0]; - auto y = inputs["Y"][0]; - MY_ASSERT(x->output(0).get_partial_shape().rank().is_static()); - int64_t x_rank = x->output(0).get_partial_shape().rank().get_length(); - MY_ASSERT(y->output(0).get_partial_shape().rank().is_static() && - y->output(0).get_partial_shape().rank().get_length() == 2); - if (x_rank > 2) { - auto shape = std::make_shared(x); - int64_t x_num_col_dims = op.get_int("x_num_col_dims"); - auto axis = ngraph::opset6::Constant::create(ngraph::element::i64, {}, {0}); - auto split_lengths = ngraph::opset6::Constant::create(ngraph::element::i64, {2}, - {x_num_col_dims, x_rank - x_num_col_dims}); - auto split = std::make_shared(shape, axis, split_lengths); - auto f_dim_red_axis = ngraph::opset6::Constant::create(ngraph::element::i64, {}, {0}); - auto first_dim_reduce = std::make_shared(split->output(0), f_dim_red_axis); - auto f_dim_shape = ngraph::opset6::Constant::create(ngraph::element::i64, {1}, {1}); - auto first_dim = std::make_shared(first_dim_reduce, f_dim_shape, false); - auto s_dim_red_axis = ngraph::opset6::Constant::create(ngraph::element::i64, {}, {0}); - auto second_dim_reduce = std::make_shared(split->output(1), s_dim_red_axis); - auto s_dim_shape = ngraph::opset6::Constant::create(ngraph::element::i64, {1}, {1}); - auto second_dim = std::make_shared(second_dim_reduce, s_dim_shape, false); - auto out_shape = std::make_shared(ngraph::NodeVector{first_dim, second_dim}, 0); - auto x_reshaped = std::make_shared(x, out_shape, false); - return std::make_shared(x_reshaped, y); - } - return std::make_shared(x, y); -} - -std::shared_ptr -scale_creator(std::map>> &inputs, - const DecoderPDPDProto &op) { - MY_ASSERT(inputs["X"].size() == 1, "More then one input for scale"); - auto data = inputs["X"][0]; - auto scale = ngraph::opset6::Constant::create(ngraph::element::f32, {1}, {op.get_float("scale")}); - return std::make_shared(data, scale); -} +namespace frontend { +namespace pdpd { std::shared_ptr make_ng_node(std::map> &inputs, std::map> &nodes, const paddle::framework::proto::OpDesc &op, - const paddle::framework::proto::BlockDesc &block) { + const paddle::framework::proto::BlockDesc &block, + const std::map& CREATORS_MAP) { std::cout << "Making node: " << op.type() << std::endl; - std::map CREATORS_MAP = { - {"conv2d", conv2d_creator}, - {"batch_norm", batch_norm_creator}, - {"relu", relu_creator}, - {"pool2d", pool2d_creator}, - {"elementwise_add", elementwise_add_creator}, - {"mul", mul_creator}, - {"scale", scale_creator} - }; + MY_ASSERT(CREATORS_MAP.find(op.type()) != CREATORS_MAP.end(), "No creator found"); std::map>> inputs_preproc; for (const auto &item : inputs) { @@ -197,7 +60,25 @@ make_ng_node(std::map @@ -253,6 +134,8 @@ std::shared_ptr convert_model(const std::string &model_dir) { } std::cout << "Reading consts finished" << std::endl; + std::map CREATORS_MAP = get_supported_ops(); + for (const auto &block : fw_model.blocks()) { std::map vars_dict; for (const auto &var : block.vars()) { @@ -287,7 +170,8 @@ std::shared_ptr convert_model(const std::string &model_dir) { shape.push_back(1); } } - auto param = std::make_shared(TYPE_MAP[dtype], ngraph::Shape(shape)); + auto param = std::make_shared(TYPE_MAP[dtype], + ngraph::Shape(shape)); param->set_friendly_name(layer_name); nodes_dict[layer_name] = param; parameter_nodes.push_back(param); @@ -297,7 +181,7 @@ std::shared_ptr convert_model(const std::string &model_dir) { MY_ASSERT(nodes_dict.find(input_node) != nodes_dict.end()); result_nodes.push_back(std::make_shared(nodes_dict[input_node])); } else { - auto node = make_ng_node(inputs_dict, nodes_dict, op, block); + auto node = make_ng_node(inputs_dict, nodes_dict, op, block, CREATORS_MAP); std::cerr << "Node created: " << node << "\n"; node->set_friendly_name(op.outputs()[0].parameter()); std::cerr << "Named with " << node->get_friendly_name() << "\n"; @@ -313,10 +197,12 @@ std::shared_ptr convert_model(const std::string &model_dir) { return std::make_shared(result_nodes, parameter_nodes); } +} + std::shared_ptr ngraph::frontend::FrontEndPDPD::convert(InputModel::Ptr model) const { std::string path = std::dynamic_pointer_cast(model)->path; std::cerr << "[ INFO ] PFrontEndPDPD::convert invoked\n"; - auto f = convert_model(path); + auto f = pdpd::convert_model(path); std::cerr << "[ INFO ] Resulting nGraph function contains " << f->get_ops().size() << "\n"; return f; } diff --git a/ngraph/frontend/paddlepaddle/src/node_context.hpp b/ngraph/frontend/paddlepaddle/src/node_context.hpp new file mode 100644 index 00000000000000..44f44885cf1fab --- /dev/null +++ b/ngraph/frontend/paddlepaddle/src/node_context.hpp @@ -0,0 +1,79 @@ +//***************************************************************************** +// Copyright 2017-2021 Intel Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//***************************************************************************** + +#pragma once +#include "decoder.hpp" + +namespace ngraph { +namespace frontend { +namespace pdpd { + +typedef std::map> NamedInputs; + +/// Keep necessary data for a single node in the original FW graph to facilitate conversion process in the rules code. +class NodeContext +{ + const DecoderPDPDProto& node; + NamedInputs& name_map; + +public: + + NodeContext (const DecoderPDPDProto& _node, NamedInputs& _name_map) : node(_node), name_map(_name_map) {} + + bool has_ng_input (const std::string& name) const { return name_map.find(name) != name_map.end(); } + Output get_ng_input (const std::string& name) const { return name_map[name]; } + + template + T get_attribute (const std::string& name, const T& def = T()) const; + + template + bool has_attribute (const std::string& name) const + { + // TODO: Rework this hack + try { + get_attribute(name); + return true; + } + catch(const AttributeNotFound&) { + return false; + } + } +}; + +template <> +inline int32_t NodeContext::get_attribute (const std::string& name, const int32_t& def) const +{ return node.get_int(name, def); } + +template <> +inline float NodeContext::get_attribute (const std::string& name, const float& def) const +{ return node.get_float(name, def); } + +template <> +inline std::string NodeContext::get_attribute (const std::string& name, const std::string& def) const +{ return node.get_str(name, def); } + +template <> +inline std::vector NodeContext::get_attribute (const std::string& name, const std::vector& def) const +{ return node.get_ints(name, def); } + +template <> +inline bool NodeContext::get_attribute (const std::string& name, const bool& def) const +{ return node.get_bool(name, def); } + + +} +} +} diff --git a/ngraph/frontend/paddlepaddle/src/op/batch_norm.cpp b/ngraph/frontend/paddlepaddle/src/op/batch_norm.cpp new file mode 100644 index 00000000000000..33a5e356f8f2c2 --- /dev/null +++ b/ngraph/frontend/paddlepaddle/src/op/batch_norm.cpp @@ -0,0 +1,35 @@ +//***************************************************************************** +// Copyright 2017-2021 Intel Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//***************************************************************************** + +#include +#include "batch_norm.hpp" + +namespace ngraph { +namespace frontend { +namespace pdpd { +namespace op { + +OutputVector batch_norm (const NodeContext& node) { + auto data = node.get_ng_input("X"); + auto gamma = node.get_ng_input("Scale"); + auto beta = node.get_ng_input("Bias"); + auto mean = node.get_ng_input("Mean"); + auto variance = node.get_ng_input("Variance"); + return {std::make_shared( + data, gamma, beta, mean, variance, node.get_attribute("epsilon"))}; +} + +}}}} \ No newline at end of file diff --git a/ngraph/frontend/paddlepaddle/src/op/batch_norm.hpp b/ngraph/frontend/paddlepaddle/src/op/batch_norm.hpp new file mode 100644 index 00000000000000..fbdf9aaa83f2f0 --- /dev/null +++ b/ngraph/frontend/paddlepaddle/src/op/batch_norm.hpp @@ -0,0 +1,27 @@ +//***************************************************************************** +// Copyright 2017-2021 Intel Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//***************************************************************************** + +#pragma once +#include "node_context.hpp" + +namespace ngraph { +namespace frontend { +namespace pdpd { +namespace op { + +OutputVector batch_norm (const NodeContext& node); + +}}}} \ No newline at end of file diff --git a/ngraph/frontend/paddlepaddle/src/op/conv2d.cpp b/ngraph/frontend/paddlepaddle/src/op/conv2d.cpp new file mode 100644 index 00000000000000..d3dd4bd898a6a9 --- /dev/null +++ b/ngraph/frontend/paddlepaddle/src/op/conv2d.cpp @@ -0,0 +1,41 @@ +//***************************************************************************** +// Copyright 2017-2021 Intel Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//***************************************************************************** + +#include +#include "conv2d.hpp" + +namespace ngraph { +namespace frontend { +namespace pdpd { +namespace op { + +OutputVector conv2d (const NodeContext& node) { + auto data = node.get_ng_input("Input"); + auto filter = node.get_ng_input("Filter"); + // TODO: resolve padding according to spec + auto strides = node.get_attribute>("strides"); + auto paddings = node.get_attribute>("paddings"); + auto dilations = node.get_attribute>("dilations"); + return {std::make_shared( + data, + filter, + ngraph::Strides(strides.begin(), strides.end()), + ngraph::CoordinateDiff(paddings.begin(), paddings.end()), + ngraph::CoordinateDiff(paddings.begin(), paddings.end()), + ngraph::Strides(dilations.begin(), dilations.end()))}; +} + +}}}} \ No newline at end of file diff --git a/ngraph/frontend/paddlepaddle/src/op/conv2d.hpp b/ngraph/frontend/paddlepaddle/src/op/conv2d.hpp new file mode 100644 index 00000000000000..331c57248e36c0 --- /dev/null +++ b/ngraph/frontend/paddlepaddle/src/op/conv2d.hpp @@ -0,0 +1,27 @@ +//***************************************************************************** +// Copyright 2017-2021 Intel Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//***************************************************************************** + +#pragma once +#include "node_context.hpp" + +namespace ngraph { +namespace frontend { +namespace pdpd { +namespace op { + +OutputVector conv2d (const NodeContext& node_context); + +}}}} diff --git a/ngraph/frontend/paddlepaddle/src/op/elementwise_add.cpp b/ngraph/frontend/paddlepaddle/src/op/elementwise_add.cpp new file mode 100644 index 00000000000000..4bf230f4914ed1 --- /dev/null +++ b/ngraph/frontend/paddlepaddle/src/op/elementwise_add.cpp @@ -0,0 +1,32 @@ +//***************************************************************************** +// Copyright 2017-2021 Intel Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//***************************************************************************** + +#include +#include "elementwise_add.hpp" + +namespace ngraph { +namespace frontend { +namespace pdpd { +namespace op { + +OutputVector elementwise_add (const NodeContext& node) { + auto x = node.get_ng_input("X"); + auto y = node.get_ng_input("Y"); + // TODO : resolve broadcast + return {std::make_shared(x, y)}; +} + +}}}} \ No newline at end of file diff --git a/ngraph/frontend/paddlepaddle/src/op/elementwise_add.hpp b/ngraph/frontend/paddlepaddle/src/op/elementwise_add.hpp new file mode 100644 index 00000000000000..7c5a919942ced0 --- /dev/null +++ b/ngraph/frontend/paddlepaddle/src/op/elementwise_add.hpp @@ -0,0 +1,27 @@ +//***************************************************************************** +// Copyright 2017-2021 Intel Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//***************************************************************************** + +#pragma once +#include "node_context.hpp" + +namespace ngraph { +namespace frontend { +namespace pdpd { +namespace op { + +OutputVector elementwise_add (const NodeContext& node_context); + +}}}} diff --git a/ngraph/frontend/paddlepaddle/src/op/mul.cpp b/ngraph/frontend/paddlepaddle/src/op/mul.cpp new file mode 100644 index 00000000000000..1efc7bf103cf22 --- /dev/null +++ b/ngraph/frontend/paddlepaddle/src/op/mul.cpp @@ -0,0 +1,59 @@ +//***************************************************************************** +// Copyright 2017-2021 Intel Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//***************************************************************************** + +#include +#include "utility.hpp" +#include "mul.hpp" + +namespace ngraph { +namespace frontend { +namespace pdpd { +namespace op { + +OutputVector mul (const NodeContext& node) { + auto x = node.get_ng_input("X"); + auto y = node.get_ng_input("Y"); + MY_ASSERT(x.get_partial_shape().rank().is_static()); + int64_t x_rank = x.get_partial_shape().rank().get_length(); + MY_ASSERT(y.get_partial_shape().rank().is_static() && + y.get_partial_shape().rank().get_length() == 2); + if (x_rank > 2) { + auto shape = std::make_shared(x); + int64_t x_num_col_dims = node.get_attribute("x_num_col_dims"); + auto axis = ngraph::opset6::Constant::create(ngraph::element::i64, {}, {0}); + auto split_lengths = ngraph::opset6::Constant::create(ngraph::element::i64, {2}, + {x_num_col_dims, x_rank - x_num_col_dims}); + auto split = std::make_shared(shape, axis, split_lengths); + auto f_dim_red_axis = ngraph::opset6::Constant::create(ngraph::element::i64, {}, {0}); + auto first_dim_reduce = std::make_shared(split->output(0), + f_dim_red_axis); + auto f_dim_shape = ngraph::opset6::Constant::create(ngraph::element::i64, {1}, {1}); + auto first_dim = std::make_shared(first_dim_reduce, f_dim_shape, false); + auto s_dim_red_axis = ngraph::opset6::Constant::create(ngraph::element::i64, {}, {0}); + auto second_dim_reduce = std::make_shared(split->output(1), + s_dim_red_axis); + auto s_dim_shape = ngraph::opset6::Constant::create(ngraph::element::i64, {1}, {1}); + auto second_dim = std::make_shared(second_dim_reduce, s_dim_shape, false); + auto out_shape = std::make_shared(ngraph::NodeVector{first_dim, second_dim}, + 0); + auto x_reshaped = std::make_shared(x, out_shape, false); + return {std::make_shared(x_reshaped, y)}; + } + return {std::make_shared(x, y)}; + +} + +}}}} \ No newline at end of file diff --git a/ngraph/frontend/paddlepaddle/src/op/mul.hpp b/ngraph/frontend/paddlepaddle/src/op/mul.hpp new file mode 100644 index 00000000000000..2c93cf07ea76b1 --- /dev/null +++ b/ngraph/frontend/paddlepaddle/src/op/mul.hpp @@ -0,0 +1,27 @@ +//***************************************************************************** +// Copyright 2017-2021 Intel Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//***************************************************************************** + +#pragma once +#include "node_context.hpp" + +namespace ngraph { +namespace frontend { +namespace pdpd { +namespace op { + +OutputVector mul (const NodeContext& node); + +}}}} \ No newline at end of file diff --git a/ngraph/frontend/paddlepaddle/src/op/pool2d.cpp b/ngraph/frontend/paddlepaddle/src/op/pool2d.cpp new file mode 100644 index 00000000000000..7f75dca51a90bc --- /dev/null +++ b/ngraph/frontend/paddlepaddle/src/op/pool2d.cpp @@ -0,0 +1,49 @@ +//***************************************************************************** +// Copyright 2017-2021 Intel Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//***************************************************************************** + +#include +#include "pool2d.hpp" + +namespace ngraph { +namespace frontend { +namespace pdpd { +namespace op { + +OutputVector pool2d (const NodeContext& node) { + // TODO : resolve padding according to spec + auto data = node.get_ng_input("X"); + auto pooling_type = node.get_attribute("pooling_type"); + auto global_pooling = node.get_attribute("global_pooling"); + if (pooling_type == "max" && !global_pooling) { + auto strides = node.get_attribute>("strides"); + auto paddings = node.get_attribute>("paddings"); + auto kernel_shape = node.get_attribute>("ksize"); + return {std::make_shared( + data, + ngraph::Strides(strides.begin(), strides.end()), + ngraph::Shape(paddings.begin(), paddings.end()), + ngraph::Shape(paddings.begin(), paddings.end()), + ngraph::Shape(kernel_shape.begin(), kernel_shape.end()))}; + } else if (pooling_type == "avg" && global_pooling) { + // TODO : resolve axes according to rank + auto axes = ngraph::opset6::Constant::create(ngraph::element::i64, {2}, {2, 3}); + return {std::make_shared(data, axes, true)}; + } else { + throw std::runtime_error("Unsupported pooling type"); + } +} + +}}}} \ No newline at end of file diff --git a/ngraph/frontend/paddlepaddle/src/op/pool2d.hpp b/ngraph/frontend/paddlepaddle/src/op/pool2d.hpp new file mode 100644 index 00000000000000..935d29479ba51c --- /dev/null +++ b/ngraph/frontend/paddlepaddle/src/op/pool2d.hpp @@ -0,0 +1,27 @@ +//***************************************************************************** +// Copyright 2017-2021 Intel Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//***************************************************************************** + +#pragma once +#include "node_context.hpp" + +namespace ngraph { +namespace frontend { +namespace pdpd { +namespace op { + +OutputVector pool2d (const NodeContext& node); + +}}}} \ No newline at end of file diff --git a/ngraph/frontend/paddlepaddle/src/op/relu.cpp b/ngraph/frontend/paddlepaddle/src/op/relu.cpp new file mode 100644 index 00000000000000..aa838dd3d9aa65 --- /dev/null +++ b/ngraph/frontend/paddlepaddle/src/op/relu.cpp @@ -0,0 +1,29 @@ +//***************************************************************************** +// Copyright 2017-2021 Intel Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//***************************************************************************** + +#include +#include "relu.hpp" + +namespace ngraph { +namespace frontend { +namespace pdpd { +namespace op { + +OutputVector relu (const NodeContext& node) { + return {std::make_shared(node.get_ng_input("X"))}; +} + +}}}} \ No newline at end of file diff --git a/ngraph/frontend/paddlepaddle/src/op/relu.hpp b/ngraph/frontend/paddlepaddle/src/op/relu.hpp new file mode 100644 index 00000000000000..012e13de529b6e --- /dev/null +++ b/ngraph/frontend/paddlepaddle/src/op/relu.hpp @@ -0,0 +1,27 @@ +//***************************************************************************** +// Copyright 2017-2021 Intel Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//***************************************************************************** + +#pragma once +#include "node_context.hpp" + +namespace ngraph { +namespace frontend { +namespace pdpd { +namespace op { + +OutputVector relu (const NodeContext& node); + +}}}} \ No newline at end of file diff --git a/ngraph/frontend/paddlepaddle/src/op/scale.cpp b/ngraph/frontend/paddlepaddle/src/op/scale.cpp new file mode 100644 index 00000000000000..24a2c7c8bc90ed --- /dev/null +++ b/ngraph/frontend/paddlepaddle/src/op/scale.cpp @@ -0,0 +1,31 @@ +//***************************************************************************** +// Copyright 2017-2021 Intel Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//***************************************************************************** + +#include +#include "scale.hpp" + +namespace ngraph { +namespace frontend { +namespace pdpd { +namespace op { + +OutputVector scale (const NodeContext& node) { + auto data = node.get_ng_input("X"); + auto scale = ngraph::opset6::Constant::create(ngraph::element::f32, {1}, {node.get_attribute("scale")}); + return {std::make_shared(data, scale)}; +} + +}}}} \ No newline at end of file diff --git a/ngraph/frontend/paddlepaddle/src/op/scale.hpp b/ngraph/frontend/paddlepaddle/src/op/scale.hpp new file mode 100644 index 00000000000000..9c9c1c3b4332e9 --- /dev/null +++ b/ngraph/frontend/paddlepaddle/src/op/scale.hpp @@ -0,0 +1,27 @@ +//***************************************************************************** +// Copyright 2017-2021 Intel Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//***************************************************************************** + +#pragma once +#include "node_context.hpp" + +namespace ngraph { +namespace frontend { +namespace pdpd { +namespace op { + +OutputVector scale (const NodeContext& node); + +}}}} \ No newline at end of file diff --git a/ngraph/frontend/paddlepaddle/src/op_table.cpp b/ngraph/frontend/paddlepaddle/src/op_table.cpp new file mode 100644 index 00000000000000..eca7f0d5dec7cb --- /dev/null +++ b/ngraph/frontend/paddlepaddle/src/op_table.cpp @@ -0,0 +1,45 @@ +//***************************************************************************** +// Copyright 2017-2021 Intel Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//***************************************************************************** + +#include "op/conv2d.hpp" +#include "op/conv2d.hpp" +#include "op/batch_norm.hpp" +#include "op/relu.hpp" +#include "op/pool2d.hpp" +#include "op/elementwise_add.hpp" +#include "op/mul.hpp" +#include "op/scale.hpp" + +#include "op_table.hpp" + + +namespace ngraph { +namespace frontend { +namespace pdpd { + +std::map get_supported_ops() { + return { + {"conv2d", op::conv2d}, + {"batch_norm", op::batch_norm}, + {"relu", op::relu}, + {"pool2d", op::pool2d}, + {"elementwise_add", op::elementwise_add}, + {"mul", op::mul}, + {"scale", op::scale}, + }; +}; + +}}} diff --git a/ngraph/frontend/paddlepaddle/src/op_table.hpp b/ngraph/frontend/paddlepaddle/src/op_table.hpp new file mode 100644 index 00000000000000..94101d33676075 --- /dev/null +++ b/ngraph/frontend/paddlepaddle/src/op_table.hpp @@ -0,0 +1,36 @@ +//***************************************************************************** +// Copyright 2017-2021 Intel Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//***************************************************************************** + +#pragma once + +#include +#include +#include + +#include + +#include "node_context.hpp" + + +namespace ngraph { +namespace frontend { +namespace pdpd { + +using CreatorFunction = std::function; + +std::map get_supported_ops(); + +}}} From 703aec57882fb34037919efc2efff860cfe7d7ba Mon Sep 17 00:00:00 2001 From: mbencer Date: Wed, 31 Mar 2021 15:25:03 +0200 Subject: [PATCH 090/116] make EdgeMapper a proxy object --- .../include/onnx_editor/edge_mapper.hpp | 12 +- .../include/onnx_editor/editor.hpp | 46 ++++++- .../frontend/onnx_editor/src/edge_mapper.cpp | 5 + ngraph/frontend/onnx_editor/src/editor.cpp | 17 ++- ngraph/test/onnx/onnx_editor.cpp | 116 ++++++++---------- 5 files changed, 122 insertions(+), 74 deletions(-) diff --git a/ngraph/frontend/onnx_editor/include/onnx_editor/edge_mapper.hpp b/ngraph/frontend/onnx_editor/include/onnx_editor/edge_mapper.hpp index 45596425869e29..599ac3f97bb4f6 100644 --- a/ngraph/frontend/onnx_editor/include/onnx_editor/edge_mapper.hpp +++ b/ngraph/frontend/onnx_editor/include/onnx_editor/edge_mapper.hpp @@ -30,10 +30,10 @@ namespace ngraph /// \brief Creates an edge mapper based on a GraphProto object. /// - /// \note If state of graph_proto will be changed, the information - /// from edge mapper is outdated. + /// \note If state of graph_proto will be changed, the information from edge mapper + /// is outdated. In such a case the update method should be called. /// - /// \param graph_proto Reference to GraphProto object. + /// \param graph_proto Reference to a GraphProto object. EdgeMapper(const ONNX_NAMESPACE::GraphProto& graph_proto); /// \brief Returns the InputEdge based on a node (node name or output name) @@ -78,6 +78,12 @@ namespace ngraph /// OutputEdge find_output_edge(const std::string& output_name) const; + /// \brief Updates state of a EdgeMapper instance if a model was changed. + /// + /// \param graph_proto Reference to a GraphProto object. + /// + void update(const ONNX_NAMESPACE::GraphProto& graph_proto); + private: std::vector find_node_indexes(const std::string& node_name, const std::string& output_name) const; diff --git a/ngraph/frontend/onnx_editor/include/onnx_editor/editor.hpp b/ngraph/frontend/onnx_editor/include/onnx_editor/editor.hpp index b883b6a8806be3..27003e1047acbf 100644 --- a/ngraph/frontend/onnx_editor/include/onnx_editor/editor.hpp +++ b/ngraph/frontend/onnx_editor/include/onnx_editor/editor.hpp @@ -111,18 +111,54 @@ namespace ngraph /// \param out_file_path A path to the file where the modified model should be dumped. void serialize(const std::string& out_file_path) const; - /// \brief Create an EdgeMapper object which allows the use of node names - /// instead of node indexes when specifying input and output edges. + /// \brief Returns the InputEdge based on a node (node name or output name) + /// and an input (input name or input index). /// - /// \return EdgeMapper object which simplifies using methods which operate over - /// InputEdge and OutputEdge. - EdgeMapper create_edge_mapper() const; + /// \note The node name can be ambiguous (many ONNX nodes can have the same name). + /// In such a case the algorthim tries to match the given node name + /// with the input name (providing an input index is not enough). + /// If a unique edge is found, it will be returned. + /// If InputEdge cannot be determined based on parameter values an ngraph_error + /// exception will be thrown. + /// + /// \param node A node helper structure created based on a node name + /// or a node output name. + /// + /// \param input An input helper structure created based on a input name + /// or a input index. + InputEdge find_input_edge(const EditorNode& node, const EditorInput& input) const; + + /// \brief Returns an OutputEdge based on a node (node name or output name) + /// and an output (output name or output index). + /// + /// \note The node name can be ambiguous (many ONNX nodes can have the same name). + /// In such a case the algorthim will try to match the given node name + /// with the output name (providing an output index is not enough). + /// If after such operation a found edge is unique, it is returned. + /// If OutputEdge cannot be determined based on given params the ngraph_error + /// exception is thrown. + /// + /// \param node A node helper structure created based on a node name + /// or a node output name. + /// + /// \param output A output helper structure created based on a output name + /// or a output index. + OutputEdge find_output_edge(const EditorNode& node, const EditorOutput& output) const; + + /// \brief Returns an OutputEdge based on a output name. + /// + /// \note The output name guarantees the uniqueness of the edge. + /// + /// \param output_name A node output name. + /// + OutputEdge find_output_edge(const std::string& output_name) const; private: const std::string m_model_path; struct Impl; std::unique_ptr m_pimpl; + EdgeMapper m_edge_mapper; }; } // namespace onnx_editor } // namespace ngraph diff --git a/ngraph/frontend/onnx_editor/src/edge_mapper.cpp b/ngraph/frontend/onnx_editor/src/edge_mapper.cpp index a9de69d00dd1e6..e534f4fefc8eaa 100644 --- a/ngraph/frontend/onnx_editor/src/edge_mapper.cpp +++ b/ngraph/frontend/onnx_editor/src/edge_mapper.cpp @@ -12,6 +12,11 @@ using namespace ngraph; using namespace ngraph::onnx_editor; onnx_editor::EdgeMapper::EdgeMapper(const ONNX_NAMESPACE::GraphProto& graph_proto) +{ + update(graph_proto); +} + +void onnx_editor::EdgeMapper::update(const ONNX_NAMESPACE::GraphProto& graph_proto) { int topological_index = 0; m_node_inputs.resize(graph_proto.node().size()); diff --git a/ngraph/frontend/onnx_editor/src/editor.cpp b/ngraph/frontend/onnx_editor/src/editor.cpp index a9937277b40ad2..c98292d71eeb51 100644 --- a/ngraph/frontend/onnx_editor/src/editor.cpp +++ b/ngraph/frontend/onnx_editor/src/editor.cpp @@ -214,6 +214,7 @@ struct onnx_editor::ONNXModelEditor::Impl onnx_editor::ONNXModelEditor::ONNXModelEditor(const std::string& model_path) : m_pimpl{new ONNXModelEditor::Impl{model_path}, [](Impl* impl) { delete impl; }} + , m_edge_mapper{m_pimpl->m_model_proto.graph()} , m_model_path{model_path} { } @@ -359,7 +360,19 @@ void onnx_editor::ONNXModelEditor::set_input_values( } } -EdgeMapper onnx_editor::ONNXModelEditor::create_edge_mapper() const +InputEdge onnx_editor::ONNXModelEditor::find_input_edge(const EditorNode& node, + const EditorInput& input) const { - return EdgeMapper{m_pimpl->m_model_proto.graph()}; + return m_edge_mapper.find_input_edge(node, input); +} + +OutputEdge onnx_editor::ONNXModelEditor::find_output_edge(const EditorNode& node, + const EditorOutput& input) const +{ + return m_edge_mapper.find_output_edge(node, input); +} + +OutputEdge onnx_editor::ONNXModelEditor::find_output_edge(const std::string& output_name) const +{ + return m_edge_mapper.find_output_edge(output_name); } diff --git a/ngraph/test/onnx/onnx_editor.cpp b/ngraph/test/onnx/onnx_editor.cpp index a0897dcd96a034..f4149786fb03af 100644 --- a/ngraph/test/onnx/onnx_editor.cpp +++ b/ngraph/test/onnx/onnx_editor.cpp @@ -681,14 +681,13 @@ NGRAPH_TEST(onnx_editor, editor_api_select_input_edge_by_output_name_and_input_n { ONNXModelEditor editor{file_util::path_join( SERIALIZED_ZOO, "onnx/model_editor/subgraph__inception_head.prototxt")}; - const auto edge_mapper = editor.create_edge_mapper(); - const InputEdge edge = edge_mapper.find_input_edge(EditorNode{EditorOutput{"conv1/7x7_s2_2"}}, + const InputEdge edge = editor.find_input_edge(EditorNode{EditorOutput{"conv1/7x7_s2_2"}}, EditorInput{"conv1/7x7_s2_1"}); EXPECT_EQ(edge.m_node_idx, 1); EXPECT_EQ(edge.m_tensor_name, "conv1/7x7_s2_1"); - const InputEdge edge2 = edge_mapper.find_input_edge(EditorNode{EditorOutput{"conv1/7x7_s2_1"}}, + const InputEdge edge2 = editor.find_input_edge(EditorNode{EditorOutput{"conv1/7x7_s2_1"}}, EditorInput{"data_0"}); EXPECT_EQ(edge2.m_node_idx, 0); EXPECT_EQ(edge2.m_tensor_name, "data_0"); @@ -698,20 +697,19 @@ NGRAPH_TEST(onnx_editor, editor_api_select_input_edge_by_output_name_and_input_i { ONNXModelEditor editor{file_util::path_join( SERIALIZED_ZOO, "onnx/model_editor/subgraph__inception_head.prototxt")}; - const auto edge_mapper = editor.create_edge_mapper(); const InputEdge edge = - edge_mapper.find_input_edge(EditorNode{EditorOutput{"conv1/7x7_s2_2"}}, EditorInput{0}); + editor.find_input_edge(EditorNode{EditorOutput{"conv1/7x7_s2_2"}}, EditorInput{0}); EXPECT_EQ(edge.m_node_idx, 1); EXPECT_EQ(edge.m_tensor_name, "conv1/7x7_s2_1"); const InputEdge edge2 = - edge_mapper.find_input_edge(EditorNode{EditorOutput{"conv1/7x7_s2_1"}}, EditorInput{1}); + editor.find_input_edge(EditorNode{EditorOutput{"conv1/7x7_s2_1"}}, EditorInput{1}); EXPECT_EQ(edge2.m_node_idx, 0); EXPECT_EQ(edge2.m_tensor_name, "conv1/7x7_s2_w_0"); const InputEdge edge3 = - edge_mapper.find_input_edge(EditorNode{EditorOutput{"conv1/7x7_s2_1"}}, EditorInput{2}); + editor.find_input_edge(EditorNode{EditorOutput{"conv1/7x7_s2_1"}}, EditorInput{2}); EXPECT_EQ(edge3.m_node_idx, 0); EXPECT_EQ(edge3.m_tensor_name, "conv1/7x7_s2_b_0"); } @@ -720,15 +718,14 @@ NGRAPH_TEST(onnx_editor, editor_api_select_input_edge_by_node_name_and_input_nam { ONNXModelEditor editor{file_util::path_join( SERIALIZED_ZOO, "onnx/model_editor/subgraph__inception_head.prototxt")}; - const auto edge_mapper = editor.create_edge_mapper(); const InputEdge edge = - edge_mapper.find_input_edge(EditorNode{"relu1"}, EditorInput{"conv1/7x7_s2_1"}); + editor.find_input_edge(EditorNode{"relu1"}, EditorInput{"conv1/7x7_s2_1"}); EXPECT_EQ(edge.m_node_idx, 1); EXPECT_EQ(edge.m_tensor_name, "conv1/7x7_s2_1"); const InputEdge edge2 = - edge_mapper.find_input_edge(EditorNode{"conv1"}, EditorInput{"conv1/7x7_s2_w_0"}); + editor.find_input_edge(EditorNode{"conv1"}, EditorInput{"conv1/7x7_s2_w_0"}); EXPECT_EQ(edge2.m_node_idx, 0); EXPECT_EQ(edge2.m_tensor_name, "conv1/7x7_s2_w_0"); } @@ -737,13 +734,12 @@ NGRAPH_TEST(onnx_editor, editor_api_select_input_edge_by_node_name_and_input_ind { ONNXModelEditor editor{file_util::path_join( SERIALIZED_ZOO, "onnx/model_editor/subgraph_extraction_tests.prototxt")}; - const auto edge_mapper = editor.create_edge_mapper(); - const InputEdge edge = edge_mapper.find_input_edge(EditorNode{"relu1_name"}, EditorInput{0}); + const InputEdge edge = editor.find_input_edge(EditorNode{"relu1_name"}, EditorInput{0}); EXPECT_EQ(edge.m_node_idx, 0); EXPECT_EQ(edge.m_tensor_name, "in1"); - const InputEdge edge2 = edge_mapper.find_input_edge(EditorNode{"split_name"}, EditorInput{0}); + const InputEdge edge2 = editor.find_input_edge(EditorNode{"split_name"}, EditorInput{0}); EXPECT_EQ(edge2.m_node_idx, 5); EXPECT_EQ(edge2.m_tensor_name, "add2"); } @@ -752,12 +748,11 @@ NGRAPH_TEST(onnx_editor, editor_api_select_input_edge_empty_node_name) { ONNXModelEditor editor{file_util::path_join( SERIALIZED_ZOO, "onnx/model_editor/subgraph_extraction_tests.prototxt")}; - const auto edge_mapper = editor.create_edge_mapper(); try { const InputEdge edge = - edge_mapper.find_input_edge(EditorNode{""}, EditorInput{"conv1/7x7_s2_1"}); + editor.find_input_edge(EditorNode{""}, EditorInput{"conv1/7x7_s2_1"}); } catch (const std::exception& e) { @@ -773,26 +768,25 @@ NGRAPH_TEST(onnx_editor, editor_api_select_output_edge_by_output_name) { ONNXModelEditor editor{file_util::path_join( SERIALIZED_ZOO, "onnx/model_editor/subgraph_extraction_tests.prototxt")}; - const auto edge_mapper = editor.create_edge_mapper(); const OutputEdge edge = - edge_mapper.find_output_edge(EditorNode{EditorOutput{"mul2"}}, EditorOutput{"mul2"}); + editor.find_output_edge(EditorNode{EditorOutput{"mul2"}}, EditorOutput{"mul2"}); EXPECT_EQ(edge.m_node_idx, 4); EXPECT_EQ(edge.m_tensor_name, "mul2"); const OutputEdge edge2 = - edge_mapper.find_output_edge(EditorNode{EditorOutput{"split1"}}, EditorOutput{"split2"}); + editor.find_output_edge(EditorNode{EditorOutput{"split1"}}, EditorOutput{"split2"}); EXPECT_EQ(edge2.m_node_idx, 5); EXPECT_EQ(edge2.m_tensor_name, "split2"); // simplified overload const OutputEdge edge3 = - edge_mapper.find_output_edge("mul2"); + editor.find_output_edge("mul2"); EXPECT_EQ(edge3.m_node_idx, 4); EXPECT_EQ(edge3.m_tensor_name, "mul2"); const OutputEdge edge4 = - edge_mapper.find_output_edge("split2"); + editor.find_output_edge("split2"); EXPECT_EQ(edge4.m_node_idx, 5); EXPECT_EQ(edge4.m_tensor_name, "split2"); } @@ -801,20 +795,19 @@ NGRAPH_TEST(onnx_editor, editor_api_select_output_edge_by_output_name_and_output { ONNXModelEditor editor{file_util::path_join( SERIALIZED_ZOO, "onnx/model_editor/subgraph_extraction_tests.prototxt")}; - const auto edge_mapper = editor.create_edge_mapper(); const OutputEdge edge = - edge_mapper.find_output_edge(EditorNode{EditorOutput{"add2"}}, EditorOutput{0}); + editor.find_output_edge(EditorNode{EditorOutput{"add2"}}, EditorOutput{0}); EXPECT_EQ(edge.m_node_idx, 3); EXPECT_EQ(edge.m_tensor_name, "add2"); const OutputEdge edge2 = - edge_mapper.find_output_edge(EditorNode{EditorOutput{"split1"}}, EditorOutput{1}); + editor.find_output_edge(EditorNode{EditorOutput{"split1"}}, EditorOutput{1}); EXPECT_EQ(edge2.m_node_idx, 5); EXPECT_EQ(edge2.m_tensor_name, "split2"); const OutputEdge edge3 = - edge_mapper.find_output_edge(EditorNode{EditorOutput{"split2"}}, EditorOutput{0}); + editor.find_output_edge(EditorNode{EditorOutput{"split2"}}, EditorOutput{0}); EXPECT_EQ(edge3.m_node_idx, 5); EXPECT_EQ(edge3.m_tensor_name, "split1"); } @@ -823,15 +816,14 @@ NGRAPH_TEST(onnx_editor, editor_api_select_output_edge_by_node_name_and_output_n { ONNXModelEditor editor{file_util::path_join( SERIALIZED_ZOO, "onnx/model_editor/subgraph_extraction_tests.prototxt")}; - const auto edge_mapper = editor.create_edge_mapper(); const OutputEdge edge = - edge_mapper.find_output_edge(EditorNode{"relu1_name"}, EditorOutput{"relu1"}); + editor.find_output_edge(EditorNode{"relu1_name"}, EditorOutput{"relu1"}); EXPECT_EQ(edge.m_node_idx, 0); EXPECT_EQ(edge.m_tensor_name, "relu1"); const OutputEdge edge2 = - edge_mapper.find_output_edge(EditorNode{"split_name"}, EditorOutput{"split2"}); + editor.find_output_edge(EditorNode{"split_name"}, EditorOutput{"split2"}); EXPECT_EQ(edge2.m_node_idx, 5); EXPECT_EQ(edge2.m_tensor_name, "split2"); } @@ -840,13 +832,12 @@ NGRAPH_TEST(onnx_editor, editor_api_select_output_edge_by_node_name_and_output_i { ONNXModelEditor editor{file_util::path_join( SERIALIZED_ZOO, "onnx/model_editor/subgraph_extraction_tests.prototxt")}; - const auto edge_mapper = editor.create_edge_mapper(); - const OutputEdge edge = edge_mapper.find_output_edge(EditorNode{"relu1_name"}, EditorOutput{0}); + const OutputEdge edge = editor.find_output_edge(EditorNode{"relu1_name"}, EditorOutput{0}); EXPECT_EQ(edge.m_node_idx, 0); EXPECT_EQ(edge.m_tensor_name, "relu1"); - const OutputEdge edge2 = edge_mapper.find_output_edge(EditorNode{"split_name"}, EditorOutput{1}); + const OutputEdge edge2 = editor.find_output_edge(EditorNode{"split_name"}, EditorOutput{1}); EXPECT_EQ(edge2.m_node_idx, 5); EXPECT_EQ(edge2.m_tensor_name, "split2"); } @@ -855,18 +846,17 @@ NGRAPH_TEST(onnx_editor, editor_api_select_edge_const_network) { ONNXModelEditor editor{file_util::path_join( SERIALIZED_ZOO, "onnx/model_editor/subgraph_extraction_tests_2.prototxt")}; - const auto edge_mapper = editor.create_edge_mapper(); const InputEdge edge = - edge_mapper.find_input_edge(EditorNode{EditorOutput{"relu4"}}, EditorInput{0}); + editor.find_input_edge(EditorNode{EditorOutput{"relu4"}}, EditorInput{0}); EXPECT_EQ(edge.m_node_idx, 3); EXPECT_EQ(edge.m_tensor_name, "in2"); - const OutputEdge edge2 = edge_mapper.find_output_edge(EditorNode{"relu4_name"}, EditorOutput{0}); + const OutputEdge edge2 = editor.find_output_edge(EditorNode{"relu4_name"}, EditorOutput{0}); EXPECT_EQ(edge2.m_node_idx, 3); EXPECT_EQ(edge2.m_tensor_name, "relu4"); - const OutputEdge edge3 = edge_mapper.find_output_edge(EditorNode{"add1_name"}, EditorOutput{0}); + const OutputEdge edge3 = editor.find_output_edge(EditorNode{"add1_name"}, EditorOutput{0}); EXPECT_EQ(edge3.m_node_idx, 4); EXPECT_EQ(edge3.m_tensor_name, "add1"); } @@ -875,13 +865,12 @@ NGRAPH_TEST(onnx_editor, editor_api_select_edge_error_handling) { ONNXModelEditor editor{file_util::path_join( SERIALIZED_ZOO, "onnx/model_editor/subgraph_extraction_tests_2.prototxt")}; - const auto edge_mapper = editor.create_edge_mapper(); // node with given output name not found try { const InputEdge edge = - edge_mapper.find_input_edge(EditorNode{EditorOutput{"not_existed"}}, EditorInput{0}); + editor.find_input_edge(EditorNode{EditorOutput{"not_existed"}}, EditorInput{0}); } catch (const std::exception& e) { @@ -894,7 +883,7 @@ NGRAPH_TEST(onnx_editor, editor_api_select_edge_error_handling) // node with given name not found try { - const InputEdge edge = edge_mapper.find_input_edge(EditorNode{"not_existed"}, EditorInput{0}); + const InputEdge edge = editor.find_input_edge(EditorNode{"not_existed"}, EditorInput{0}); } catch (const std::exception& e) { @@ -907,7 +896,7 @@ NGRAPH_TEST(onnx_editor, editor_api_select_edge_error_handling) // input index out of scope try { - const InputEdge edge = edge_mapper.find_input_edge(EditorNode{"relu4_name"}, EditorInput{1}); + const InputEdge edge = editor.find_input_edge(EditorNode{"relu4_name"}, EditorInput{1}); } catch (const std::exception& e) { @@ -920,7 +909,7 @@ NGRAPH_TEST(onnx_editor, editor_api_select_edge_error_handling) try { const OutputEdge edge = - edge_mapper.find_output_edge(EditorNode{"relu4_name"}, EditorOutput{1}); + editor.find_output_edge(EditorNode{"relu4_name"}, EditorOutput{1}); } catch (const std::exception& e) { @@ -933,15 +922,14 @@ NGRAPH_TEST(onnx_editor, editor_api_select_edge_error_handling) // Nodes with ambiguous node names tests NGRAPH_TEST(onnx_editor, editor_api_select_input_edge_by_ambiguous_node_name_but_matched_input) { - ONNXModelEditor editor{file_util::path_join( + const ONNXModelEditor editor{file_util::path_join( SERIALIZED_ZOO, "onnx/model_editor/subgraph_extraction_tests.prototxt")}; - const auto edge_mapper = editor.create_edge_mapper(); - const InputEdge edge = edge_mapper.find_input_edge(EditorNode{"add_ambiguous_name"}, EditorInput{"in2"}); + InputEdge edge = editor.find_input_edge(EditorNode{"add_ambiguous_name"}, EditorInput{"in2"}); EXPECT_EQ(edge.m_node_idx, 1); EXPECT_EQ(edge.m_tensor_name, "in2"); - const InputEdge edge2 = edge_mapper.find_input_edge(EditorNode{"add_ambiguous_name"}, EditorInput{"add1"}); + const InputEdge edge2 = editor.find_input_edge(EditorNode{"add_ambiguous_name"}, EditorInput{"add1"}); EXPECT_EQ(edge2.m_node_idx, 3); EXPECT_EQ(edge2.m_tensor_name, "add1"); } @@ -950,11 +938,10 @@ NGRAPH_TEST(onnx_editor, editor_api_select_input_edge_by_ambiguous_node_name_and { ONNXModelEditor editor{file_util::path_join( SERIALIZED_ZOO, "onnx/model_editor/subgraph_extraction_tests.prototxt")}; - const auto edge_mapper = editor.create_edge_mapper(); try { - const InputEdge edge = edge_mapper.find_input_edge(EditorNode{"add_ambiguous_name"}, EditorInput{"in3"}); + const InputEdge edge = editor.find_input_edge(EditorNode{"add_ambiguous_name"}, EditorInput{"in3"}); } catch (const std::exception& e) { @@ -965,7 +952,7 @@ NGRAPH_TEST(onnx_editor, editor_api_select_input_edge_by_ambiguous_node_name_and try { - const InputEdge edge = edge_mapper.find_input_edge(EditorNode{"add_ambiguous_name"}, EditorInput{"relu1"}); + const InputEdge edge = editor.find_input_edge(EditorNode{"add_ambiguous_name"}, EditorInput{"relu1"}); } catch (const std::exception& e) { @@ -979,11 +966,10 @@ NGRAPH_TEST(onnx_editor, editor_api_select_input_edge_by_ambiguous_node_name_and { ONNXModelEditor editor{file_util::path_join( SERIALIZED_ZOO, "onnx/model_editor/subgraph_extraction_tests.prototxt")}; - const auto edge_mapper = editor.create_edge_mapper(); try { - const InputEdge edge = edge_mapper.find_input_edge(EditorNode{"add_ambiguous_name"}, EditorInput{0}); + const InputEdge edge = editor.find_input_edge(EditorNode{"add_ambiguous_name"}, EditorInput{0}); } catch (const std::exception& e) { @@ -997,13 +983,12 @@ NGRAPH_TEST(onnx_editor, editor_api_select_output_edge_by_ambiguous_node_name_bu { ONNXModelEditor editor{file_util::path_join( SERIALIZED_ZOO, "onnx/model_editor/subgraph_extraction_tests.prototxt")}; - const auto edge_mapper = editor.create_edge_mapper(); - const OutputEdge edge = edge_mapper.find_output_edge(EditorNode{"add_ambiguous_name"}, EditorOutput{"add1"}); + const OutputEdge edge = editor.find_output_edge(EditorNode{"add_ambiguous_name"}, EditorOutput{"add1"}); EXPECT_EQ(edge.m_node_idx, 1); EXPECT_EQ(edge.m_tensor_name, "add1"); - const OutputEdge edge2 = edge_mapper.find_output_edge(EditorNode{"add_ambiguous_name"}, EditorOutput{"add2"}); + const OutputEdge edge2 = editor.find_output_edge(EditorNode{"add_ambiguous_name"}, EditorOutput{"add2"}); EXPECT_EQ(edge2.m_node_idx, 3); EXPECT_EQ(edge2.m_tensor_name, "add2"); } @@ -1012,11 +997,10 @@ NGRAPH_TEST(onnx_editor, editor_api_select_output_edge_by_ambiguous_node_name_an { ONNXModelEditor editor{file_util::path_join( SERIALIZED_ZOO, "onnx/model_editor/subgraph_extraction_tests.prototxt")}; - const auto edge_mapper = editor.create_edge_mapper(); try { - const OutputEdge edge = edge_mapper.find_output_edge(EditorNode{"add_ambiguous_name"}, EditorOutput{"split2"}); + const OutputEdge edge = editor.find_output_edge(EditorNode{"add_ambiguous_name"}, EditorOutput{"split2"}); } catch (const std::exception& e) { @@ -1030,11 +1014,10 @@ NGRAPH_TEST(onnx_editor, editor_api_select_output_edge_by_ambiguous_node_name_an { ONNXModelEditor editor{file_util::path_join( SERIALIZED_ZOO, "onnx/model_editor/subgraph_extraction_tests.prototxt")}; - const auto edge_mapper = editor.create_edge_mapper(); try { - const OutputEdge edge = edge_mapper.find_output_edge(EditorNode{"add_ambiguous_name"}, EditorOutput{0}); + const OutputEdge edge = editor.find_output_edge(EditorNode{"add_ambiguous_name"}, EditorOutput{0}); } catch (const std::exception& e) { @@ -1044,18 +1027,23 @@ NGRAPH_TEST(onnx_editor, editor_api_select_output_edge_by_ambiguous_node_name_an } } -NGRAPH_TEST(onnx_editor, editor_api_use_edge_mapper_with_graph_cutter) +NGRAPH_TEST(onnx_editor, editor_api_use_editor_with_graph_cutter) { ONNXModelEditor editor{file_util::path_join( SERIALIZED_ZOO, "onnx/model_editor/subgraph_extraction_tests.prototxt")}; - const auto mapper = editor.create_edge_mapper(); - - editor.cut_graph_fragment({/*{InputEdge{1, "in2"}*/ mapper.find_input_edge( - EditorNode(EditorOutput("add1")), EditorInput(1)), - /*InputEdge{2, "in3"}*/ mapper.find_input_edge( - EditorNode(EditorOutput("conv1")), EditorInput(0))}, - {/*{OutputEdge{4, "mul2"}*/ mapper.find_output_edge( - EditorNode(EditorOutput("mul2")), EditorOutput(0))}); + + // InputEdge{1, "in2"} + const auto input_edge_1 = editor.find_input_edge( + EditorNode(EditorOutput("add1")), EditorInput(1)); + //InputEdge{2, "in3"} + const auto input_edge_2 = editor.find_input_edge( + EditorNode(EditorOutput("conv1")), EditorInput(0)); + + + const auto output_edge = editor.find_output_edge( + EditorNode(EditorOutput("mul2")), EditorOutput(0)); + // OutputEdge{4, "mul2"} + editor.cut_graph_fragment({input_edge_1, input_edge_2}, {output_edge}); const auto ref_model = file_util::path_join(SERIALIZED_ZOO, From 151b1dc5337b24a2a25072ea8dc7aed4415b6348 Mon Sep 17 00:00:00 2001 From: mbencer Date: Wed, 31 Mar 2021 15:33:42 +0200 Subject: [PATCH 091/116] Removed Input, Output, Node aliases --- .../include/onnx_editor/edge_mapper.hpp | 12 +++---- .../include/onnx_editor/editor_types.hpp | 36 +++++++++---------- .../frontend/onnx_editor/src/edge_mapper.cpp | 8 +++-- 3 files changed, 27 insertions(+), 29 deletions(-) diff --git a/ngraph/frontend/onnx_editor/include/onnx_editor/edge_mapper.hpp b/ngraph/frontend/onnx_editor/include/onnx_editor/edge_mapper.hpp index 599ac3f97bb4f6..573a4a257d6703 100644 --- a/ngraph/frontend/onnx_editor/include/onnx_editor/edge_mapper.hpp +++ b/ngraph/frontend/onnx_editor/include/onnx_editor/edge_mapper.hpp @@ -46,12 +46,12 @@ namespace ngraph /// If InputEdge cannot be determined based on parameter values an ngraph_error /// exception will be thrown. /// - /// \param node A node helper structure created based on a node name + /// \param node An EditorNode helper structure created based on a node name /// or a node output name. /// - /// \param input An input helper structure created based on a input name + /// \param input An EditorInput helper structure created based on a input name /// or a input index. - InputEdge find_input_edge(const Node& node, const Input& input) const; + InputEdge find_input_edge(const EditorNode& node, const EditorInput& input) const; /// \brief Returns an OutputEdge based on a node (node name or output name) /// and an output (output name or output index). @@ -63,12 +63,12 @@ namespace ngraph /// If OutputEdge cannot be determined based on given params the ngraph_error /// exception is thrown. /// - /// \param node A node helper structure created based on a node name + /// \param node An EditorNode helper structure created based on a node name /// or a node output name. /// - /// \param output A output helper structure created based on a output name + /// \param output An EditorOutput helper structure created based on a output name /// or a output index. - OutputEdge find_output_edge(const Node& node, const Output& output) const; + OutputEdge find_output_edge(const EditorNode& node, const EditorOutput& output) const; /// \brief Returns an OutputEdge based on a output name. /// diff --git a/ngraph/frontend/onnx_editor/include/onnx_editor/editor_types.hpp b/ngraph/frontend/onnx_editor/include/onnx_editor/editor_types.hpp index 84aa4944251b07..2ac484e46b53de 100644 --- a/ngraph/frontend/onnx_editor/include/onnx_editor/editor_types.hpp +++ b/ngraph/frontend/onnx_editor/include/onnx_editor/editor_types.hpp @@ -68,15 +68,15 @@ namespace ngraph /// ----(in_A)----> +-----------+ /// ----(in_B)----> | test_node | ----(out)----> /// ----(in_C)----> +-----------+ - /// You can indicate in_B as Input("in_B") or Input(1) - struct Input + /// You can indicate in_B as EditorInput("in_B") or EditorInput(1) + struct EditorInput { - Input() = delete; - Input(std::string input_name) + EditorInput() = delete; + EditorInput(std::string input_name) : m_input_name{std::move(input_name)} { } - Input(const int input_index) + EditorInput(const int input_index) : m_input_index{input_index} { } @@ -90,15 +90,15 @@ namespace ngraph /// +-----------+ ---(out1)---> /// ----(in_A)----> | test_node | /// +-----------+ ---(out2)---> - /// You can indicate out2 as Output("out2") or Output(1) - struct Output + /// You can indicate out2 as EditorOutput("out2") or EditorOutput(1) + struct EditorOutput { - Output() = delete; - Output(std::string output_name) + EditorOutput() = delete; + EditorOutput(std::string output_name) : m_output_name{std::move(output_name)} { } - Output(const int output_index) + EditorOutput(const int output_index) : m_output_index{output_index} { } @@ -113,25 +113,21 @@ namespace ngraph /// +-----------+ ---(out1)---> /// ----(in_A)----> | test_node | /// +-----------+ ---(out2)---> - /// You can indicate test_node by name as Node("test_node") - /// or by assigned output as Node(Output("out1")) or Node(Output("out2")) - struct Node + /// You can indicate test_node by name as EditorNode("test_node") + /// or by assigned output as EditorNode(EditorOutput("out1")) + /// or EditorNode(EditorOutput("out2")) + struct EditorNode { - Node(std::string node_name) + EditorNode(std::string node_name) : m_node_name{std::move(node_name)} { } - Node(Output output) + EditorNode(EditorOutput output) : m_output_name{std::move(output.m_output_name)} { } const std::string m_node_name = ""; const std::string m_output_name = ""; }; - - // Aliases to avoid name conflicts with classes from ngraph namespace - using EditorInput = Input; - using EditorOutput = Output; - using EditorNode = Node; } } diff --git a/ngraph/frontend/onnx_editor/src/edge_mapper.cpp b/ngraph/frontend/onnx_editor/src/edge_mapper.cpp index e534f4fefc8eaa..3bb8ca91edfcae 100644 --- a/ngraph/frontend/onnx_editor/src/edge_mapper.cpp +++ b/ngraph/frontend/onnx_editor/src/edge_mapper.cpp @@ -103,7 +103,8 @@ std::string onnx_editor::EdgeMapper::get_node_input_name(int node_index, int inp return input_name; } -InputEdge onnx_editor::EdgeMapper::find_input_edge(const Node& node, const Input& in) const +InputEdge onnx_editor::EdgeMapper::find_input_edge(const EditorNode& node, + const EditorInput& in) const { // identification can be both based on node name and output name const auto& node_indexes = find_node_indexes(node.m_node_name, node.m_output_name); @@ -160,7 +161,8 @@ InputEdge onnx_editor::EdgeMapper::find_input_edge(const Node& node, const Input } } -OutputEdge onnx_editor::EdgeMapper::find_output_edge(const Node& node, const Output& out) const +OutputEdge onnx_editor::EdgeMapper::find_output_edge(const EditorNode& node, + const EditorOutput& out) const { // identification can be both based on node name and output name const auto& node_indexes = find_node_indexes(node.m_node_name, node.m_output_name); @@ -214,5 +216,5 @@ OutputEdge onnx_editor::EdgeMapper::find_output_edge(const Node& node, const Out OutputEdge onnx_editor::EdgeMapper::find_output_edge(const std::string& output_name) const { - return find_output_edge(Node{Output{output_name}}, Output{output_name}); + return find_output_edge(EditorNode{EditorOutput{output_name}}, EditorOutput{output_name}); } From 95988ef70715024b7258f218c5e1b084066936c0 Mon Sep 17 00:00:00 2001 From: Michael Nosov Date: Wed, 31 Mar 2021 21:09:13 +0300 Subject: [PATCH 092/116] FronEndManager - private implementation --- .../frontend_manager/frontend_manager.hpp | 16 +++-- .../frontend/generic/src/frontend_manager.cpp | 62 +++++++++++++++++-- ngraph/frontend/paddlepaddle/src/frontend.cpp | 3 +- .../tensorflow/src/ngraph_builder.cpp | 1 + 4 files changed, 72 insertions(+), 10 deletions(-) diff --git a/ngraph/frontend/generic/include/frontend_manager/frontend_manager.hpp b/ngraph/frontend/generic/include/frontend_manager/frontend_manager.hpp index cedd96f00cb398..aecc9f4f7e8b61 100644 --- a/ngraph/frontend/generic/include/frontend_manager/frontend_manager.hpp +++ b/ngraph/frontend/generic/include/frontend_manager/frontend_manager.hpp @@ -312,11 +312,19 @@ enum FrontEndCapabilities { class NGRAPH_API FrontEndManager { public: - FrontEndManager () {} - FrontEnd::Ptr loadByFramework (const std::string& framework, FrontEndCapabilities fec = FEC_DEFAULT); - FrontEnd::Ptr loadByModel (const std::string& path, FrontEndCapabilities fec = FEC_DEFAULT); - std::vector availableFrontEnds () const; + FrontEndManager(); + ~FrontEndManager(); + FrontEnd::Ptr loadByFramework(const std::string& framework, FrontEndCapabilities fec = FEC_DEFAULT); + FrontEnd::Ptr loadByModel(const std::string& path, FrontEndCapabilities fec = FEC_DEFAULT); + std::vector availableFrontEnds() const; + + using FrontEndFactory = std::function; + void registerFrontEnd(const std::string& name, FrontEndFactory creator); +private: + class Impl; + std::unique_ptr m_impl; }; + } // namespace frontend } // namespace ngraph diff --git a/ngraph/frontend/generic/src/frontend_manager.cpp b/ngraph/frontend/generic/src/frontend_manager.cpp index 488319274b19e2..406f3964a9665e 100644 --- a/ngraph/frontend/generic/src/frontend_manager.cpp +++ b/ngraph/frontend/generic/src/frontend_manager.cpp @@ -28,6 +28,8 @@ namespace ngraph { #define FRONT_END_NOT_IMPLEMENTED(NAME) throw #NAME " is not implemented for this FrontEnd class"; + #define FRONT_END_ASSERT(EXPRESSION) \ + { if (!(EXPRESSION)) throw "AssertionFailed"; } std::vector InputModel::getInputs () const { @@ -429,8 +431,55 @@ namespace ngraph FRONT_END_NOT_IMPLEMENTED(normalize); } - FrontEnd::Ptr FrontEndManager::loadByFramework (const std::string& framework, FrontEndCapabilities fec) + ////////////////////////////////////////////////////////////// + class FrontEndManager::Impl { + std::map m_factories; + + void registerDefault() { + registerFrontEnd("onnx", [](FrontEndCapabilities){return std::make_shared();}); + registerFrontEnd("pdpd", [](FrontEndCapabilities){return std::make_shared();}); + registerFrontEnd("tf", [](FrontEndCapabilities){return std::make_shared();}); + } + public: + Impl() { + registerDefault(); + } + ~Impl() = default; + FrontEnd::Ptr loadByFramework(const std::string& framework, FrontEndCapabilities fec) { + FRONT_END_ASSERT(m_factories.count(framework)) + return m_factories[framework](fec); + } + + std::vector availableFrontEnds() const { + std::vector keys; + + std::transform(m_factories.begin(), m_factories.end(), + std::back_inserter(keys), + [](const std::pair& item) { + return item.first; + }); + return keys; + } + + FrontEnd::Ptr loadByModel (const std::string& path, FrontEndCapabilities fec) + { + FRONT_END_NOT_IMPLEMENTED(loadByModel); + } + + void registerFrontEnd(const std::string& name, FrontEndFactory creator) { + m_factories.insert({name, creator}); + } + }; + + FrontEndManager::FrontEndManager(): m_impl(new Impl()) { + std::cout << "Create maanger:\n"; + } + FrontEndManager::~FrontEndManager() = default; + + FrontEnd::Ptr FrontEndManager::loadByFramework(const std::string& framework, FrontEndCapabilities fec) + { + m_impl->loadByFramework(framework, fec); if (framework == "onnx") return std::make_shared(); else if (framework == "pdpd") @@ -441,14 +490,17 @@ namespace ngraph throw "Framework " + framework + " is unknown for FrontEnd manager; cannot load it."; } - FrontEnd::Ptr FrontEndManager::loadByModel (const std::string& path, FrontEndCapabilities fec) + FrontEnd::Ptr FrontEndManager::loadByModel(const std::string& path, FrontEndCapabilities fec) { - FRONT_END_NOT_IMPLEMENTED(loadByModel); + return m_impl->loadByModel(path, fec); } - std::vector FrontEndManager::availableFrontEnds () const + std::vector FrontEndManager::availableFrontEnds() const { - return {"onnx", "pdpd", "tf"}; + if (m_impl) { + std::cout << "No impl"; + } + return m_impl->availableFrontEnds(); } } // namespace frontend diff --git a/ngraph/frontend/paddlepaddle/src/frontend.cpp b/ngraph/frontend/paddlepaddle/src/frontend.cpp index d77590d10b67dd..96b413e481e091 100644 --- a/ngraph/frontend/paddlepaddle/src/frontend.cpp +++ b/ngraph/frontend/paddlepaddle/src/frontend.cpp @@ -16,6 +16,7 @@ #include +#include #include #include #include @@ -208,4 +209,4 @@ std::shared_ptr ngraph::frontend::FrontEndPDPD::convert(InputM } } -} \ No newline at end of file +} diff --git a/ngraph/frontend/tensorflow/src/ngraph_builder.cpp b/ngraph/frontend/tensorflow/src/ngraph_builder.cpp index c2f70fae157570..57c4e49223822c 100644 --- a/ngraph/frontend/tensorflow/src/ngraph_builder.cpp +++ b/ngraph/frontend/tensorflow/src/ngraph_builder.cpp @@ -14,6 +14,7 @@ * limitations under the License. *******************************************************************************/ +#include #include "graph.pb.h" #include "tensor.pb.h" From 3e3e9e3c780c5bd63729a0665e5a463201bdee53 Mon Sep 17 00:00:00 2001 From: "Lyalin, Sergey" Date: Wed, 31 Mar 2021 21:52:14 +0300 Subject: [PATCH 093/116] Extended NodeContext with get_ng_input_size and get_ng_inputs for multiple inputs with the same name --- ngraph/frontend/paddlepaddle/src/frontend.cpp | 9 ++----- .../paddlepaddle/src/node_context.hpp | 24 ++++++++++++++++--- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/ngraph/frontend/paddlepaddle/src/frontend.cpp b/ngraph/frontend/paddlepaddle/src/frontend.cpp index d77590d10b67dd..19047ef1785a30 100644 --- a/ngraph/frontend/paddlepaddle/src/frontend.cpp +++ b/ngraph/frontend/paddlepaddle/src/frontend.cpp @@ -67,13 +67,8 @@ make_ng_node(std::map> NamedInputs; +typedef std::map NamedInputs; /// Keep necessary data for a single node in the original FW graph to facilitate conversion process in the rules code. class NodeContext @@ -33,8 +34,25 @@ class NodeContext NodeContext (const DecoderPDPDProto& _node, NamedInputs& _name_map) : node(_node), name_map(_name_map) {} - bool has_ng_input (const std::string& name) const { return name_map.find(name) != name_map.end(); } - Output get_ng_input (const std::string& name) const { return name_map[name]; } + /// Detects if there is at least one input attached with a given name + bool has_ng_input (const std::string& name) const + { + auto found = name_map.find(name); + if(found != name_map.end()) + return !found->second.empty(); + } + + size_t get_ng_input_size (const std::string& name) const { return name_map.at(name).size(); } + + /// Returns exactly one input with a given name; throws if there is no inputs or there are more than one input + Output get_ng_input (const std::string& name) const + { + MY_ASSERT(name_map.at(name).size() == 1); + return name_map.at(name).at(0); + } + + /// Returns all inputs with a given name + OutputVector get_ng_inputs (const std::string& name) const { return name_map.at(name); } template T get_attribute (const std::string& name, const T& def = T()) const; From e4dffcc9924f122251bce5c7dbc32c18f623b668 Mon Sep 17 00:00:00 2001 From: mbencer Date: Thu, 1 Apr 2021 09:11:57 +0200 Subject: [PATCH 094/116] added updating mapper --- .../include/onnx_editor/edge_mapper.hpp | 2 +- .../include/onnx_editor/editor.hpp | 9 +++++--- .../frontend/onnx_editor/src/edge_mapper.cpp | 5 +++++ ngraph/frontend/onnx_editor/src/editor.cpp | 21 +++++++++++++++---- ngraph/test/onnx/onnx_editor.cpp | 21 ++++++++++++++++--- 5 files changed, 47 insertions(+), 11 deletions(-) diff --git a/ngraph/frontend/onnx_editor/include/onnx_editor/edge_mapper.hpp b/ngraph/frontend/onnx_editor/include/onnx_editor/edge_mapper.hpp index 573a4a257d6703..a4dbb9378998e7 100644 --- a/ngraph/frontend/onnx_editor/include/onnx_editor/edge_mapper.hpp +++ b/ngraph/frontend/onnx_editor/include/onnx_editor/edge_mapper.hpp @@ -26,7 +26,7 @@ namespace ngraph class EdgeMapper { public: - EdgeMapper() = delete; + EdgeMapper() = default; /// \brief Creates an edge mapper based on a GraphProto object. /// diff --git a/ngraph/frontend/onnx_editor/include/onnx_editor/editor.hpp b/ngraph/frontend/onnx_editor/include/onnx_editor/editor.hpp index 27003e1047acbf..3f8cd2b6d1154b 100644 --- a/ngraph/frontend/onnx_editor/include/onnx_editor/editor.hpp +++ b/ngraph/frontend/onnx_editor/include/onnx_editor/editor.hpp @@ -126,7 +126,7 @@ namespace ngraph /// /// \param input An input helper structure created based on a input name /// or a input index. - InputEdge find_input_edge(const EditorNode& node, const EditorInput& input) const; + InputEdge find_input_edge(const EditorNode& node, const EditorInput& input); /// \brief Returns an OutputEdge based on a node (node name or output name) /// and an output (output name or output index). @@ -143,7 +143,7 @@ namespace ngraph /// /// \param output A output helper structure created based on a output name /// or a output index. - OutputEdge find_output_edge(const EditorNode& node, const EditorOutput& output) const; + OutputEdge find_output_edge(const EditorNode& node, const EditorOutput& output); /// \brief Returns an OutputEdge based on a output name. /// @@ -151,10 +151,13 @@ namespace ngraph /// /// \param output_name A node output name. /// - OutputEdge find_output_edge(const std::string& output_name) const; + OutputEdge find_output_edge(const std::string& output_name); private: + void update_mapper_if_needed(); + const std::string m_model_path; + bool m_is_mapper_updated; struct Impl; std::unique_ptr m_pimpl; diff --git a/ngraph/frontend/onnx_editor/src/edge_mapper.cpp b/ngraph/frontend/onnx_editor/src/edge_mapper.cpp index 3bb8ca91edfcae..b3e89e05fbd583 100644 --- a/ngraph/frontend/onnx_editor/src/edge_mapper.cpp +++ b/ngraph/frontend/onnx_editor/src/edge_mapper.cpp @@ -18,6 +18,11 @@ onnx_editor::EdgeMapper::EdgeMapper(const ONNX_NAMESPACE::GraphProto& graph_prot void onnx_editor::EdgeMapper::update(const ONNX_NAMESPACE::GraphProto& graph_proto) { + // reset state + m_node_inputs.clear(); + m_node_outputs.clear(); + m_node_name_to_index.clear(); + int topological_index = 0; m_node_inputs.resize(graph_proto.node().size()); m_node_outputs.resize(graph_proto.node().size()); diff --git a/ngraph/frontend/onnx_editor/src/editor.cpp b/ngraph/frontend/onnx_editor/src/editor.cpp index c98292d71eeb51..bf1b156da4353d 100644 --- a/ngraph/frontend/onnx_editor/src/editor.cpp +++ b/ngraph/frontend/onnx_editor/src/editor.cpp @@ -214,7 +214,7 @@ struct onnx_editor::ONNXModelEditor::Impl onnx_editor::ONNXModelEditor::ONNXModelEditor(const std::string& model_path) : m_pimpl{new ONNXModelEditor::Impl{model_path}, [](Impl* impl) { delete impl; }} - , m_edge_mapper{m_pimpl->m_model_proto.graph()} + , m_is_mapper_updated{false} , m_model_path{model_path} { } @@ -305,6 +305,7 @@ void onnx_editor::ONNXModelEditor::cut_graph_fragment(const std::vectorremove_shape_inference_info(); + m_is_mapper_updated = false; } std::vector onnx_editor::ONNXModelEditor::model_inputs() const @@ -360,19 +361,31 @@ void onnx_editor::ONNXModelEditor::set_input_values( } } +void onnx_editor::ONNXModelEditor::update_mapper_if_needed() +{ + if (!m_is_mapper_updated) + { + m_edge_mapper.update(m_pimpl->m_model_proto.graph()); + } + m_is_mapper_updated = true; +} + InputEdge onnx_editor::ONNXModelEditor::find_input_edge(const EditorNode& node, - const EditorInput& input) const + const EditorInput& input) { + update_mapper_if_needed(); return m_edge_mapper.find_input_edge(node, input); } OutputEdge onnx_editor::ONNXModelEditor::find_output_edge(const EditorNode& node, - const EditorOutput& input) const + const EditorOutput& input) { + update_mapper_if_needed(); return m_edge_mapper.find_output_edge(node, input); } -OutputEdge onnx_editor::ONNXModelEditor::find_output_edge(const std::string& output_name) const +OutputEdge onnx_editor::ONNXModelEditor::find_output_edge(const std::string& output_name) { + update_mapper_if_needed(); return m_edge_mapper.find_output_edge(output_name); } diff --git a/ngraph/test/onnx/onnx_editor.cpp b/ngraph/test/onnx/onnx_editor.cpp index f4149786fb03af..008ec4540cbe5c 100644 --- a/ngraph/test/onnx/onnx_editor.cpp +++ b/ngraph/test/onnx/onnx_editor.cpp @@ -922,7 +922,7 @@ NGRAPH_TEST(onnx_editor, editor_api_select_edge_error_handling) // Nodes with ambiguous node names tests NGRAPH_TEST(onnx_editor, editor_api_select_input_edge_by_ambiguous_node_name_but_matched_input) { - const ONNXModelEditor editor{file_util::path_join( + ONNXModelEditor editor{file_util::path_join( SERIALIZED_ZOO, "onnx/model_editor/subgraph_extraction_tests.prototxt")}; InputEdge edge = editor.find_input_edge(EditorNode{"add_ambiguous_name"}, EditorInput{"in2"}); @@ -1027,7 +1027,7 @@ NGRAPH_TEST(onnx_editor, editor_api_select_output_edge_by_ambiguous_node_name_an } } -NGRAPH_TEST(onnx_editor, editor_api_use_editor_with_graph_cutter) +NGRAPH_TEST(onnx_editor, editor_api_use_edge_mapper_with_graph_cutter) { ONNXModelEditor editor{file_util::path_join( SERIALIZED_ZOO, "onnx/model_editor/subgraph_extraction_tests.prototxt")}; @@ -1035,7 +1035,7 @@ NGRAPH_TEST(onnx_editor, editor_api_use_editor_with_graph_cutter) // InputEdge{1, "in2"} const auto input_edge_1 = editor.find_input_edge( EditorNode(EditorOutput("add1")), EditorInput(1)); - //InputEdge{2, "in3"} + // InputEdge{2, "in3"} const auto input_edge_2 = editor.find_input_edge( EditorNode(EditorOutput("conv1")), EditorInput(0)); @@ -1053,6 +1053,21 @@ NGRAPH_TEST(onnx_editor, editor_api_use_editor_with_graph_cutter) const auto result = compare_onnx_models(editor.model_string(), ref_model); EXPECT_TRUE(result.is_ok) << result.error_message; + + // check if mapper was updated after the model changed + const auto input_edge_4 = editor.find_input_edge( + EditorNode(EditorOutput("relu1")), EditorInput(0)); + EXPECT_EQ(input_edge_4.m_node_idx, 0); + EXPECT_EQ(input_edge_4.m_tensor_name, "in1"); + + const auto input_edge_5 = editor.find_input_edge( + EditorNode(EditorOutput("add1")), EditorInput(1)); + EXPECT_EQ(input_edge_5.m_node_idx, 1); + EXPECT_EQ(input_edge_5.m_tensor_name, "in2"); + + const auto output_edge_3 = editor.find_output_edge("mul2"); + EXPECT_EQ(output_edge_3.m_node_idx, 3); + EXPECT_EQ(output_edge_3.m_tensor_name, "mul2"); } using TestEngine = test::INTERPRETER_Engine; From bf6324f98d808b2bd5d763beb500beba889fd168 Mon Sep 17 00:00:00 2001 From: Michael Nosov Date: Thu, 1 Apr 2021 13:40:06 +0300 Subject: [PATCH 095/116] Code cleanup --- ngraph/frontend/generic/src/frontend_manager.cpp | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/ngraph/frontend/generic/src/frontend_manager.cpp b/ngraph/frontend/generic/src/frontend_manager.cpp index 406f3964a9665e..a97cab597a6c7c 100644 --- a/ngraph/frontend/generic/src/frontend_manager.cpp +++ b/ngraph/frontend/generic/src/frontend_manager.cpp @@ -473,21 +473,12 @@ namespace ngraph }; FrontEndManager::FrontEndManager(): m_impl(new Impl()) { - std::cout << "Create maanger:\n"; } FrontEndManager::~FrontEndManager() = default; FrontEnd::Ptr FrontEndManager::loadByFramework(const std::string& framework, FrontEndCapabilities fec) { - m_impl->loadByFramework(framework, fec); - if (framework == "onnx") - return std::make_shared(); - else if (framework == "pdpd") - return std::make_shared(); - else if (framework == "tf") - return std::make_shared(); - else - throw "Framework " + framework + " is unknown for FrontEnd manager; cannot load it."; + return m_impl->loadByFramework(framework, fec); } FrontEnd::Ptr FrontEndManager::loadByModel(const std::string& path, FrontEndCapabilities fec) @@ -497,9 +488,6 @@ namespace ngraph std::vector FrontEndManager::availableFrontEnds() const { - if (m_impl) { - std::cout << "No impl"; - } return m_impl->availableFrontEnds(); } } // namespace frontend From 758f6271ef7aae8875052e5243f0b0487e53edf0 Mon Sep 17 00:00:00 2001 From: "Vafin, Maxim" Date: Thu, 1 Apr 2021 12:23:54 +0300 Subject: [PATCH 096/116] Read composed weights model --- .../include/paddlepaddle_frontend/model.hpp | 8 +- ngraph/frontend/paddlepaddle/src/frontend.cpp | 99 +++++++++++++------ .../paddlepaddle/src/node_context.hpp | 1 + .../frontend/paddlepaddle/src/op/matmul.cpp | 40 ++++++++ .../frontend/paddlepaddle/src/op/matmul.hpp | 30 ++++++ .../frontend/paddlepaddle/src/op/pool2d.cpp | 16 ++- .../frontend/paddlepaddle/src/op/reshape2.cpp | 41 ++++++++ .../frontend/paddlepaddle/src/op/reshape2.hpp | 30 ++++++ .../frontend/paddlepaddle/src/op/softmax.cpp | 39 ++++++++ .../frontend/paddlepaddle/src/op/softmax.hpp | 30 ++++++ ngraph/frontend/paddlepaddle/src/op_table.cpp | 19 ++-- ngraph/frontend/paddlepaddle/src/utility.hpp | 4 + 12 files changed, 317 insertions(+), 40 deletions(-) create mode 100644 ngraph/frontend/paddlepaddle/src/op/matmul.cpp create mode 100644 ngraph/frontend/paddlepaddle/src/op/matmul.hpp create mode 100644 ngraph/frontend/paddlepaddle/src/op/reshape2.cpp create mode 100644 ngraph/frontend/paddlepaddle/src/op/reshape2.hpp create mode 100644 ngraph/frontend/paddlepaddle/src/op/softmax.cpp create mode 100644 ngraph/frontend/paddlepaddle/src/op/softmax.hpp diff --git a/ngraph/frontend/paddlepaddle/include/paddlepaddle_frontend/model.hpp b/ngraph/frontend/paddlepaddle/include/paddlepaddle_frontend/model.hpp index fc74fbd243bae9..535888c5b6033e 100644 --- a/ngraph/frontend/paddlepaddle/include/paddlepaddle_frontend/model.hpp +++ b/ngraph/frontend/paddlepaddle/include/paddlepaddle_frontend/model.hpp @@ -17,6 +17,7 @@ #pragma once #include +#include #include "place.hpp" @@ -29,11 +30,14 @@ class NGRAPH_API InputModelPDPD : public InputModel { // TODO: replace it by already deserialized proto hidden under some Impl class // TODO: avoid using explicit format-dependent data stuctures here, hide it under some Impl class - std::string path; - + friend class FrontEndPDPD; public: + std::string path; + std::string model_file; + std::ifstream weights_stream; + bool weights_composed = false; InputModelPDPD (const std::string& _path) : path(_path) {} }; diff --git a/ngraph/frontend/paddlepaddle/src/frontend.cpp b/ngraph/frontend/paddlepaddle/src/frontend.cpp index 19047ef1785a30..b92ed7bc49aa2c 100644 --- a/ngraph/frontend/paddlepaddle/src/frontend.cpp +++ b/ngraph/frontend/paddlepaddle/src/frontend.cpp @@ -76,29 +76,41 @@ make_ng_node(std::map -read_tensor(const paddle::framework::proto::VarDesc &var, const std::string &model_dir) { +std::shared_ptr read_tensor(const paddle::framework::proto::VarDesc& var, + std::shared_ptr model) +{ std::cout << "Reading tensor " << var.name() << std::endl; MY_ASSERT(var.type().type() == paddle::framework::proto::VarType::LOD_TENSOR); auto tensor = var.type().lod_tensor().tensor(); + auto tensor_length = std::accumulate( + tensor.dims().cbegin(), tensor.dims().cend(), 1, std::multiplies()); + std::vector tensor_data(tensor_length, 0); - std::ifstream is(model_dir + "/" + var.name(), std::ios::in | std::ifstream::binary); - if (!is || !is.is_open()) { - std::cout << "File not opened" << std::endl; - } - // get length of file: - is.seekg(0, std::ios::end); - auto length = is.tellg(); - auto tensor_length = std::accumulate(tensor.dims().cbegin(), tensor.dims().cend(), 1, - std::multiplies()); - std::cout << "length: " << length << ", ten_len: " << tensor_length << std::endl; - is.seekg((size_t) length - tensor_length * 4, std::ios::beg); + if (model->weights_composed) { + std::vector leading_zeros(16, 0); + model->weights_stream.read(&leading_zeros[0], 16); + uint32_t dims_len = 0; + model->weights_stream.read(reinterpret_cast(&dims_len), 4); + std::vector dims_struct(dims_len, 0); + model->weights_stream.read(&dims_struct[0], dims_len); + model->weights_stream.read(reinterpret_cast(&tensor_data[0]), tensor_length * 4); + } else { + std::ifstream is(model->path + "/" + var.name(), std::ios::in | std::ifstream::binary); + if (!is || !is.is_open()) + { + std::cout << "File not opened" << std::endl; + } + // get length of file: + is.seekg(0, std::ios::end); + auto length = is.tellg(); + std::cout << "length: " << length << ", ten_len: " << tensor_length << std::endl; + is.seekg((size_t)length - tensor_length * 4, std::ios::beg); - std::vector tensor_data(tensor_length, 0); - is.read(reinterpret_cast(&tensor_data[0]), tensor_length * 4); - is.close(); + is.read(reinterpret_cast(&tensor_data[0]), tensor_length * 4); + } auto shape = std::vector(tensor.dims().cbegin(), tensor.dims().cend()); - return ngraph::opset6::Constant::create(ngraph::element::f32, ngraph::Shape(shape), tensor_data); + return ngraph::opset6::Constant::create( + ngraph::element::f32, ngraph::Shape(shape), tensor_data); } bool endsWith(const std::string &str, const std::string &suffix) { @@ -108,10 +120,13 @@ bool endsWith(const std::string &str, const std::string &suffix) { return false; } -std::shared_ptr convert_model(const std::string &model_dir) { - std::cout << "Convert Model Start" << std::endl; +std::shared_ptr + convert_model(std::shared_ptr model) +{ + std::cout << "Convert Model Start" << std::endl; + paddle::framework::proto::ProgramDesc fw_model; - std::ifstream pb_stream(model_dir + "/__model__", std::ios::binary); + std::ifstream pb_stream(model->model_file, std::ios::binary); std::cout << "Model Parsed: " << fw_model.ParseFromIstream(&pb_stream) << std::endl; std::map> nodes_dict; @@ -119,19 +134,26 @@ std::shared_ptr convert_model(const std::string &model_dir) { ngraph::ResultVector result_nodes; std::cout << "Blocks number: " << fw_model.blocks().size() << std::endl; - const auto &global_block = fw_model.blocks()[0]; - for (const auto &var : global_block.vars()) { - if (endsWith(var.name(), "feed") || endsWith(var.name(), "fetch")) + const auto& global_block = fw_model.blocks()[0]; + // We need to read variables in sorted by name order. This is the order variables written in composed file. + std::map sorted_vars; + for (auto& var : global_block.vars()) + { + sorted_vars[var.name()] = var; + } + for (const auto& name_var : sorted_vars) + { + if (endsWith(name_var.first, "feed") || endsWith(name_var.first, "fetch")) continue; - if (!var.persistable()) + if (!name_var.second.persistable()) continue; - nodes_dict[var.name()] = read_tensor(var, model_dir); + nodes_dict[name_var.first] = read_tensor(name_var.second, model); } std::cout << "Reading consts finished" << std::endl; std::map CREATORS_MAP = get_supported_ops(); - for (const auto &block : fw_model.blocks()) { + for (const auto& block : fw_model.blocks()) { std::map vars_dict; for (const auto &var : block.vars()) { vars_dict[var.name()] = var.type(); @@ -158,6 +180,7 @@ std::shared_ptr convert_model(const std::string &model_dir) { auto dtype = tensor_desc.data_type(); std::vector shape; // set all -1 dims to 1 + // TODO: remove when input shape can be specified for (auto dim : tensor_desc.dims()) { if (dim >= 0) { shape.push_back(dim); @@ -195,9 +218,29 @@ std::shared_ptr convert_model(const std::string &model_dir) { } std::shared_ptr ngraph::frontend::FrontEndPDPD::convert(InputModel::Ptr model) const { - std::string path = std::dynamic_pointer_cast(model)->path; std::cerr << "[ INFO ] PFrontEndPDPD::convert invoked\n"; - auto f = pdpd::convert_model(path); + auto pdpd_model = std::dynamic_pointer_cast(model); + std::string ext = ".pdmodel"; + if (pdpd_model->path.length() >= ext.length() && + (0 == + pdpd_model->path.compare(pdpd_model->path.length() - ext.length(), ext.length(), ext))) + { + pdpd_model->weights_composed = true; + pdpd_model->model_file = pdpd_model->path; + auto weights_file = + pdpd_model->path.replace(pdpd_model->path.size() - ext.size(), ext.size(), ".pdiparams"); + pdpd_model->weights_stream = std::ifstream(weights_file, std::ios::binary); + if (!pdpd_model->weights_stream || !pdpd_model->weights_stream.is_open()) + { + std::cout << "File not opened" << std::endl; + } + } + else + { + pdpd_model->weights_composed = false; + pdpd_model->model_file = pdpd_model->path + "/__model__"; + } + auto f = pdpd::convert_model(pdpd_model); std::cerr << "[ INFO ] Resulting nGraph function contains " << f->get_ops().size() << "\n"; return f; } diff --git a/ngraph/frontend/paddlepaddle/src/node_context.hpp b/ngraph/frontend/paddlepaddle/src/node_context.hpp index 496dbbe2a2cc5b..539b16049cb7d2 100644 --- a/ngraph/frontend/paddlepaddle/src/node_context.hpp +++ b/ngraph/frontend/paddlepaddle/src/node_context.hpp @@ -40,6 +40,7 @@ class NodeContext auto found = name_map.find(name); if(found != name_map.end()) return !found->second.empty(); + return false; } size_t get_ng_input_size (const std::string& name) const { return name_map.at(name).size(); } diff --git a/ngraph/frontend/paddlepaddle/src/op/matmul.cpp b/ngraph/frontend/paddlepaddle/src/op/matmul.cpp new file mode 100644 index 00000000000000..dd32d4310882c8 --- /dev/null +++ b/ngraph/frontend/paddlepaddle/src/op/matmul.cpp @@ -0,0 +1,40 @@ +//***************************************************************************** +// Copyright 2017-2021 Intel Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//***************************************************************************** + +#include +#include "matmul.hpp" +#include "utility.hpp" + +namespace ngraph { +namespace frontend { +namespace pdpd { +namespace op { + + OutputVector matmul(const NodeContext& node) { + auto x = node.get_ng_input("X"); + auto y = node.get_ng_input("Y"); + auto alpha = node.get_attribute("alpha"); + auto transpose_a = node.get_attribute("transpose_a"); + auto transpose_b = node.get_attribute("transpose_b"); + auto mm = std::make_shared(x, y, transpose_a, transpose_b); + auto alpha_node = ngraph::opset6::Constant::create(ngraph::element::f32, {1}, {alpha}); + return {std::make_shared(mm, alpha_node)}; + } + +} // namespace op +} // namespace pdpd +} // namespace frontend +} // namespace ngraph \ No newline at end of file diff --git a/ngraph/frontend/paddlepaddle/src/op/matmul.hpp b/ngraph/frontend/paddlepaddle/src/op/matmul.hpp new file mode 100644 index 00000000000000..4b6c6737cfe8f0 --- /dev/null +++ b/ngraph/frontend/paddlepaddle/src/op/matmul.hpp @@ -0,0 +1,30 @@ +//***************************************************************************** +// Copyright 2017-2021 Intel Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//***************************************************************************** + +#pragma once +#include "node_context.hpp" + +namespace ngraph { +namespace frontend { +namespace pdpd { +namespace op { + +OutputVector matmul(const NodeContext& node); + +} // namespace op +} // namespace pdpd +} // namespace frontend +} // namespace ngraph \ No newline at end of file diff --git a/ngraph/frontend/paddlepaddle/src/op/pool2d.cpp b/ngraph/frontend/paddlepaddle/src/op/pool2d.cpp index 7f75dca51a90bc..ca2c82d895ef9c 100644 --- a/ngraph/frontend/paddlepaddle/src/op/pool2d.cpp +++ b/ngraph/frontend/paddlepaddle/src/op/pool2d.cpp @@ -27,17 +27,27 @@ OutputVector pool2d (const NodeContext& node) { auto data = node.get_ng_input("X"); auto pooling_type = node.get_attribute("pooling_type"); auto global_pooling = node.get_attribute("global_pooling"); + auto adaptive = node.get_attribute("adaptive"); + auto kernel_shape = node.get_attribute>("ksize"); if (pooling_type == "max" && !global_pooling) { auto strides = node.get_attribute>("strides"); auto paddings = node.get_attribute>("paddings"); - auto kernel_shape = node.get_attribute>("ksize"); + auto rounding_type = node.get_attribute("ceil_mode") + ? ngraph::op::RoundingType::CEIL + : ngraph::op::RoundingType::FLOOR; return {std::make_shared( data, ngraph::Strides(strides.begin(), strides.end()), ngraph::Shape(paddings.begin(), paddings.end()), ngraph::Shape(paddings.begin(), paddings.end()), - ngraph::Shape(kernel_shape.begin(), kernel_shape.end()))}; - } else if (pooling_type == "avg" && global_pooling) { + ngraph::Shape(kernel_shape.begin(), kernel_shape.end()), + rounding_type)}; + } + else if (pooling_type == "avg" && + (global_pooling || adaptive && all_of(kernel_shape.begin(), + kernel_shape.end(), + [](int32_t s) { return s == 1; }))) + { // TODO : resolve axes according to rank auto axes = ngraph::opset6::Constant::create(ngraph::element::i64, {2}, {2, 3}); return {std::make_shared(data, axes, true)}; diff --git a/ngraph/frontend/paddlepaddle/src/op/reshape2.cpp b/ngraph/frontend/paddlepaddle/src/op/reshape2.cpp new file mode 100644 index 00000000000000..92b7bc891f4506 --- /dev/null +++ b/ngraph/frontend/paddlepaddle/src/op/reshape2.cpp @@ -0,0 +1,41 @@ +//***************************************************************************** +// Copyright 2017-2021 Intel Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//***************************************************************************** + +#include +#include "reshape2.hpp" +#include "utility.hpp" + +namespace ngraph { +namespace frontend { +namespace pdpd { +namespace op { + +OutputVector reshape2(const NodeContext& node) { + auto data = node.get_ng_input("X"); + if (!node.has_ng_input("Shape") && !node.has_ng_input("ShapeTensor")) + { + auto shape_attr = node.get_attribute>("shape"); + auto shape_node = ngraph::opset6::Constant::create(ngraph::element::i32, {shape_attr.size()}, shape_attr); + return {std::make_shared(data, shape_node, true)}; + } else { + NOT_IMPLEMENTED("reshape2 with shape as input"); + } +} + +} // namespace op +} // namespace pdpd +} // namespace frontend +} // namespace ngraph \ No newline at end of file diff --git a/ngraph/frontend/paddlepaddle/src/op/reshape2.hpp b/ngraph/frontend/paddlepaddle/src/op/reshape2.hpp new file mode 100644 index 00000000000000..2c8f0c49580d55 --- /dev/null +++ b/ngraph/frontend/paddlepaddle/src/op/reshape2.hpp @@ -0,0 +1,30 @@ +//***************************************************************************** +// Copyright 2017-2021 Intel Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//***************************************************************************** + +#pragma once +#include "node_context.hpp" + +namespace ngraph { +namespace frontend { +namespace pdpd { +namespace op { + +OutputVector reshape2(const NodeContext& node); + +} // namespace op +} // namespace pdpd +} // namespace frontend +} // namespace ngraph \ No newline at end of file diff --git a/ngraph/frontend/paddlepaddle/src/op/softmax.cpp b/ngraph/frontend/paddlepaddle/src/op/softmax.cpp new file mode 100644 index 00000000000000..a11cc13a750c1e --- /dev/null +++ b/ngraph/frontend/paddlepaddle/src/op/softmax.cpp @@ -0,0 +1,39 @@ +//***************************************************************************** +// Copyright 2017-2021 Intel Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//***************************************************************************** + +#include +#include "softmax.hpp" +#include "utility.hpp" + +namespace ngraph { +namespace frontend { +namespace pdpd { +namespace op { + OutputVector softmax(const NodeContext& node) { + auto data = node.get_ng_input("X"); + auto axis = node.get_attribute("axis"); + if (axis < 0) + { + MY_ASSERT(data.get_partial_shape().rank().is_static(), "Softmax rank must be static"); + auto data_rank = data.get_partial_shape().rank().get_length(); + axis = data_rank + axis; + } + return {std::make_shared(data, axis)}; + } +} // namespace op +} // namespace pdpd +} // namespace frontend +} // namespace ngraph \ No newline at end of file diff --git a/ngraph/frontend/paddlepaddle/src/op/softmax.hpp b/ngraph/frontend/paddlepaddle/src/op/softmax.hpp new file mode 100644 index 00000000000000..d6732ba5cf7a3c --- /dev/null +++ b/ngraph/frontend/paddlepaddle/src/op/softmax.hpp @@ -0,0 +1,30 @@ +//***************************************************************************** +// Copyright 2017-2021 Intel Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//***************************************************************************** + +#pragma once +#include "node_context.hpp" + +namespace ngraph { +namespace frontend { +namespace pdpd { +namespace op { + +OutputVector softmax(const NodeContext& node); + +} // namespace op +} // namespace pdpd +} // namespace frontend +} // namespace ngraph \ No newline at end of file diff --git a/ngraph/frontend/paddlepaddle/src/op_table.cpp b/ngraph/frontend/paddlepaddle/src/op_table.cpp index eca7f0d5dec7cb..4b52d487909644 100644 --- a/ngraph/frontend/paddlepaddle/src/op_table.cpp +++ b/ngraph/frontend/paddlepaddle/src/op_table.cpp @@ -14,14 +14,16 @@ // limitations under the License. //***************************************************************************** -#include "op/conv2d.hpp" -#include "op/conv2d.hpp" #include "op/batch_norm.hpp" -#include "op/relu.hpp" -#include "op/pool2d.hpp" +#include "op/conv2d.hpp" #include "op/elementwise_add.hpp" +#include "op/matmul.hpp" #include "op/mul.hpp" +#include "op/pool2d.hpp" +#include "op/relu.hpp" +#include "op/reshape2.hpp" #include "op/scale.hpp" +#include "op/softmax.hpp" #include "op_table.hpp" @@ -32,13 +34,16 @@ namespace pdpd { std::map get_supported_ops() { return { - {"conv2d", op::conv2d}, {"batch_norm", op::batch_norm}, - {"relu", op::relu}, - {"pool2d", op::pool2d}, + {"conv2d", op::conv2d}, {"elementwise_add", op::elementwise_add}, + {"matmul", op::matmul}, {"mul", op::mul}, + {"pool2d", op::pool2d}, + {"relu", op::relu}, + {"reshape2", op::reshape2}, {"scale", op::scale}, + {"softmax", op::softmax} }; }; diff --git a/ngraph/frontend/paddlepaddle/src/utility.hpp b/ngraph/frontend/paddlepaddle/src/utility.hpp index 11376edcf3785d..8c16273a7d3c80 100644 --- a/ngraph/frontend/paddlepaddle/src/utility.hpp +++ b/ngraph/frontend/paddlepaddle/src/utility.hpp @@ -27,6 +27,10 @@ inline void MY_ASSERT(bool ex, const std::string& msg = "Unspecified error.") { if (!ex) throw std::runtime_error(msg); } +inline void NOT_IMPLEMENTED(const std::string& name = "Unspecified") +{ + throw std::runtime_error(name + " is not implemented"); +} } // namespace frontend } // namespace ngraph From d9412812988d05ffef5f1ad619352152bd2d464c Mon Sep 17 00:00:00 2001 From: Michael Nosov Date: Thu, 1 Apr 2021 17:15:26 +0300 Subject: [PATCH 097/116] fix build issues after rebase --- ngraph/frontend/generic/CMakeLists.txt | 5 +- .../frontend/generic/src/frontend_manager.cpp | 14 +- .../include/onnx_editor/editor.hpp | 22 +- ngraph/frontend/onnx_editor/src/editor.cpp | 55 +-- .../editor/detail/subgraph_extraction.hpp | 173 ------- .../src/editor/detail/subgraph_extraction.cpp | 454 ------------------ .../onnx_import/src/utils/onnx_test_util.cpp | 275 ----------- .../onnx_import/src/utils/onnx_test_util.hpp | 54 --- ngraph/test/onnx/onnx_editor.cpp | 385 --------------- 9 files changed, 21 insertions(+), 1416 deletions(-) delete mode 100644 ngraph/frontend/onnx_import/include/onnx_import/editor/detail/subgraph_extraction.hpp delete mode 100644 ngraph/frontend/onnx_import/src/editor/detail/subgraph_extraction.cpp delete mode 100644 ngraph/frontend/onnx_import/src/utils/onnx_test_util.cpp delete mode 100644 ngraph/frontend/onnx_import/src/utils/onnx_test_util.hpp diff --git a/ngraph/frontend/generic/CMakeLists.txt b/ngraph/frontend/generic/CMakeLists.txt index 8fd8f5a83dcfea..7b52245afaee8d 100644 --- a/ngraph/frontend/generic/CMakeLists.txt +++ b/ngraph/frontend/generic/CMakeLists.txt @@ -34,6 +34,9 @@ add_library(ngraph::frontend_manager ALIAS frontend_manager) target_include_directories(frontend_manager PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../tensorflow/include + ${CMAKE_CURRENT_SOURCE_DIR}/../onnx_editor/include + ${CMAKE_CURRENT_SOURCE_DIR}/../onnx_import/include + ${CMAKE_CURRENT_SOURCE_DIR}/../onnx_common/include ${CMAKE_CURRENT_SOURCE_DIR}/../paddlepaddle/include) MESSAGE("HERE4: " ${CMAKE_CURRENT_SOURCE_DIR}) @@ -45,7 +48,7 @@ endif() # TODO: Add other frontends to the list of dependencies temporary; in the produce version they should be discovered # TODO: in runtime. -target_link_libraries(frontend_manager PRIVATE onnx_importer tensorflow_frontend paddlepaddle_frontend PUBLIC ngraph) +target_link_libraries(frontend_manager PRIVATE onnx_importer onnx_editor onnx_common tensorflow_frontend paddlepaddle_frontend PUBLIC ngraph) set(FRONTEND_INSTALL_INCLUDE "${NGRAPH_INSTALL_INCLUDE}/ngraph/frontend/generic") target_include_directories(frontend_manager SYSTEM PUBLIC $ diff --git a/ngraph/frontend/generic/src/frontend_manager.cpp b/ngraph/frontend/generic/src/frontend_manager.cpp index a97cab597a6c7c..ab819b55968a4c 100644 --- a/ngraph/frontend/generic/src/frontend_manager.cpp +++ b/ngraph/frontend/generic/src/frontend_manager.cpp @@ -16,7 +16,7 @@ #include #include "onnx_import/onnx.hpp" -#include "onnx_import/editor/editor.hpp" +#include "onnx_editor/editor.hpp" #include "tensorflow_frontend/tensorflow.hpp" #include "frontend_manager/frontend_manager.hpp" #include "paddlepaddle_frontend/frontend.hpp" @@ -226,7 +226,7 @@ namespace ngraph { public: - onnx_import::InputEdge edge; + onnx_editor::InputEdge edge; PlaceInputEdgeONNX (const std::string& _sourceTensorName, int _operationNodeIndex) : edge(_operationNodeIndex, _sourceTensorName) @@ -237,7 +237,7 @@ namespace ngraph { public: - onnx_import::OutputEdge edge; + onnx_editor::OutputEdge edge; PlaceOutputEdgeONNX (int _operationNodeIndex, const std::string& _targetTensorName) : edge(_operationNodeIndex, _targetTensorName) @@ -271,7 +271,7 @@ namespace ngraph public: // TODO: Move to private - onnx_import::ONNXModelEditor editor; + onnx_editor::ONNXModelEditor editor; InputModelONNX (const std::string& model_path) : editor(model_path) {} @@ -308,7 +308,7 @@ namespace ngraph std::cerr << "inputs.size() = " << inputs.size() << "\n"; // Current implementation is limited by tensor places only, each input tensor should be consumed by a single op only // TODO Extend to non tensor inputs/outputs and remove other limitations - std::vector onnx_inputs; + std::vector onnx_inputs; onnx_inputs.reserve(inputs.size()); for(const auto& input: inputs) { @@ -326,7 +326,7 @@ namespace ngraph } std::cerr << "{4}\n"; - std::vector onnx_outputs; + std::vector onnx_outputs; onnx_outputs.reserve(outputs.size()); for(const auto& output: outputs) { @@ -372,7 +372,7 @@ namespace ngraph virtual std::shared_ptr convert (InputModel::Ptr model) const override { - return import_onnx_model(std::dynamic_pointer_cast(model)->editor); + return onnx_import::import_onnx_model(std::dynamic_pointer_cast(model)->editor.model_path()); } }; diff --git a/ngraph/frontend/onnx_editor/include/onnx_editor/editor.hpp b/ngraph/frontend/onnx_editor/include/onnx_editor/editor.hpp index 5deaeaa3569ad4..54f4ab025bd658 100644 --- a/ngraph/frontend/onnx_editor/include/onnx_editor/editor.hpp +++ b/ngraph/frontend/onnx_editor/include/onnx_editor/editor.hpp @@ -11,11 +11,16 @@ #include "ngraph/op/constant.hpp" #include "ngraph/partial_shape.hpp" #include "ngraph/type/element_type.hpp" -#include "onnx_editor/detail/subgraph_extraction.hpp" -#include "onnx_import/utils/onnx_importer_visibility.hpp" #include "onnx_editor/editor.hpp" #include "onnx_editor/editor_types.hpp" +namespace ONNX_NAMESPACE +{ + // forward declaration to avoid the necessity of include paths setting in components + // that don't directly depend on the ONNX library + class ModelProto; +} // namespace ONNX_NAMESPACE + namespace ngraph { namespace onnx_editor @@ -80,19 +85,6 @@ namespace ngraph /// overwritten. void set_input_values( const std::map>& input_values); - - /// \brief Extracts a subgraph constrained by input edges and output edges. In the end - /// the underlying ModelProto is modified - obsolete inputs, initializers, nodes - /// and outputs are removed from the in-memory model. - /// - /// \node Please look at the declaration of InputEdge and OutputEdge for explanation - /// how those objects can be created. If the outputs parameter is empty - /// this method keeps all of the original outputs of the model. - /// - /// \param inputs A collection of input edges which become new inputs to the graph - /// \param outputs A collection of output edges which become new outputs of the graph - void cut_graph_fragment(const std::vector& inputs, - const std::vector& outputs); /// \brief Returns a non-const reference to the underlying ModelProto object, possibly /// modified by the editor's API calls diff --git a/ngraph/frontend/onnx_editor/src/editor.cpp b/ngraph/frontend/onnx_editor/src/editor.cpp index 4cdf1f17df4431..a1dd02c9e9e625 100644 --- a/ngraph/frontend/onnx_editor/src/editor.cpp +++ b/ngraph/frontend/onnx_editor/src/editor.cpp @@ -193,12 +193,6 @@ namespace tensor_type->set_elem_type(initializer.data_type()); } } - - template - std::string extract_name(const T& input_or_initializer) - { - return input_or_initializer.name(); - }; } // namespace /// \brief A helper class used to hold the ModelProto object as its field @@ -364,55 +358,12 @@ void onnx_editor::ONNXModelEditor::set_input_values( } } -void onnx_import::ONNXModelEditor::cut_graph_fragment(const std::vector& inputs, - const std::vector& outputs) -{ - if (inputs.empty() && outputs.empty()) - { - return; - } - - m_pimpl->infer_shapes(); - - SubgraphExtractor editor{*(m_pimpl->m_model_proto.mutable_graph())}; - editor.add_new_inputs(inputs); - editor.add_new_outputs(outputs); - editor.extract_subgraph(outputs); - - m_pimpl->remove_shape_inference_info(); -} - -std::vector onnx_import::ONNXModelEditor::model_inputs() const -{ - const auto& graph = m_pimpl->m_model_proto.graph(); - - std::vector inputs_and_initializers; - inputs_and_initializers.reserve(graph.input_size() + graph.initializer_size()); - - std::transform(graph.input().begin(), - graph.input().end(), - std::back_inserter(inputs_and_initializers), - extract_name); - - std::transform(graph.initializer().begin(), - graph.initializer().end(), - std::back_inserter(inputs_and_initializers), - extract_name); - - return inputs_and_initializers; -} - -std::string onnx_import::ONNXModelEditor::model_string() const -{ - return m_pimpl->m_model_proto.SerializeAsString(); -} - namespace { const auto is_equal_to = +[](const std::string& other) { return [&](const std::string& s) { return s == other; }; }; } -int onnx_import::ONNXModelEditor::find_producing_node_idx(const std::string& tensorName) const +int onnx_editor::ONNXModelEditor::find_producing_node_idx(const std::string& tensorName) const { const auto& graph = m_pimpl->m_model_proto.graph(); @@ -433,7 +384,7 @@ int onnx_import::ONNXModelEditor::find_producing_node_idx(const std::string& ten } -std::vector onnx_import::ONNXModelEditor::find_consumeing_node_idxs(const std::string& tensorName) const { +std::vector onnx_editor::ONNXModelEditor::find_consumeing_node_idxs(const std::string& tensorName) const { const auto &graph = m_pimpl->m_model_proto.graph(); std::vector result; for (int i = 0; i < graph.node_size(); ++i) { @@ -448,7 +399,7 @@ std::vector onnx_import::ONNXModelEditor::find_consumeing_node_idxs(const s return result; } -bool onnx_import::ONNXModelEditor::validate_tensor_name(const std::string& tensorName) const { +bool onnx_editor::ONNXModelEditor::validate_tensor_name(const std::string& tensorName) const { const auto &graph = m_pimpl->m_model_proto.graph(); for (int i = 0; i < graph.node_size(); ++i) { const auto &outputs = graph.node(i).output(); diff --git a/ngraph/frontend/onnx_import/include/onnx_import/editor/detail/subgraph_extraction.hpp b/ngraph/frontend/onnx_import/include/onnx_import/editor/detail/subgraph_extraction.hpp deleted file mode 100644 index c0ffae1dfe42c2..00000000000000 --- a/ngraph/frontend/onnx_import/include/onnx_import/editor/detail/subgraph_extraction.hpp +++ /dev/null @@ -1,173 +0,0 @@ -//***************************************************************************** -// Copyright 2017-2021 Intel Corporation -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -//***************************************************************************** - -#pragma once - -#include -#include -#include -#include -#include -#include "../../utils/onnx_importer_visibility.hpp" - -namespace ONNX_NAMESPACE -{ - // forward declaration to avoid the necessity of include paths setting in components - // that don't directly depend on the ONNX library - class GraphProto; - class NodeProto; - class ValueInfoProto; - class ModelProto; -} // namespace ONNX_NAMESPACE - -namespace ngraph -{ - enum class EdgeType - { - INPUT, - OUTPUT - }; - - template - struct Edge - { - Edge() = delete; - Edge(const int node_idx, std::string tensor_name) - : m_node_idx{node_idx} - , m_tensor_name{std::move(tensor_name)} - { - } - - const int m_node_idx; - const std::string m_tensor_name; - }; - namespace onnx_import - { - - ONNX_IMPORTER_API - int find_producing_node_idx(const ONNX_NAMESPACE::ModelProto& model, - const std::string& tensorName); - - /// \brief Defines an edge connected to an input of any node in the graph. - /// It consists of a node index in the processed ONNX model and the input name. - /// The index should point to a node in the topological sort of the underlying graph - /// which means it has to be in range: 0 <= node_idx < graph.node_size() - /// - /// For a node number 5, with 3 inputs: - /// - /// ----(in_A)----> +--------+ - /// ----(in_B)----> | node 5 | ----(out)----> - /// ----(in_C)----> +--------+ - /// - /// there are 3 possible valid instances of this struct: - /// InputEdge(5, "in_A") - /// InputEdge(5, "in_B") - /// InputEdge(5, "in_C") - using InputEdge = Edge; - - /// \brief Defines an edge connected to an output of any node in the graph. - /// It consists of a node index in the processed ONNX model and the output name. - /// - /// For a node number 5, with 2 outputs: - /// - /// +--------+ ----(out1)----> - /// ----(in_A)----> | node 5 | - /// +--------+ ----(out2)----> - /// - /// there are 2 possible valid instances of this struct: - /// OutputEdge(5, "out1") - /// OutputEdge(5, "out2") - using OutputEdge = Edge; - - /// \brief Subgraph extraction helper structure - struct SubgraphExtractor - { - SubgraphExtractor(ONNX_NAMESPACE::GraphProto& graph); - - /// \brief Adds new inputs to the graph and connects them to the nodes indicated by - /// the provided input edges. - void add_new_inputs(const std::vector& new_inputs); - - /// \brief Adds new outputs to the graph with the same name as the nodes pointed to - /// by the input edges "new_outputs". - void add_new_outputs(const std::vector& new_outputs); - - /// \brief Extracts the final subgraph by traversing the original model bottom-up - /// starting at each of the provided output edges. The extracted subgraph - /// contains all previously added inputs and potentially a subset of original - /// model's inputs that contribute to the value calculated in the output tensors. - /// In the end the underlying GraphProto is modified and obsolete elements - /// are discarded after this method call has finished. - /// - /// \param subgraph_outputs A list of expected outputs of the extracted subgraph. - void extract_subgraph(std::vector subgraph_outputs); - - /// \brief Represents a subgraph of an ONNX model by holding a subset of nodes, inputs, - /// outputs and initializers of the original graph. Objects of this struct can be - /// merged into other instances using the += operator to build a subgraph from - /// smaller clusters. - struct SubgraphComponents - { - SubgraphComponents() = default; - SubgraphComponents(const SubgraphComponents&) = delete; - SubgraphComponents(SubgraphComponents&&) = default; - SubgraphComponents& operator=(const SubgraphComponents&) = delete; - SubgraphComponents& operator=(SubgraphComponents&&) = default; - - std::set nodes; - std::set inputs; - std::set initializers; - std::set outputs; - - SubgraphComponents& operator+=(SubgraphComponents&& other) - { - nodes.insert(other.nodes.begin(), other.nodes.end()); - inputs.insert(other.inputs.begin(), other.inputs.end()); - initializers.insert(other.initializers.begin(), other.initializers.end()); - outputs.insert(other.outputs.begin(), other.outputs.end()); - return *this; - } - }; - - private: - ONNX_NAMESPACE::GraphProto& m_onnx_graph; - - // Graph traversal helper: node index -> node inputs (one-to-many) - std::unordered_multimap m_node_inputs; - // Number of consumers of all tensors in the graph - std::map m_tensor_consumers; - - /// \brief Replaces the old input edge with a new one in the helper struct. - /// This is used by the output contributors discovery. - void replace_input_edge(const InputEdge& old_edge, const InputEdge& new_edge); - - /// \brief Returns a list of edges of each outputs of the graph "m_onnx_graph" - std::vector all_output_edges() const; - - /// \brief Traverses the graph bottom-up and collects all nodes, inputs and initializers - /// that contribute to an output designated by the provided output edge. - /// A sum of such SubgraphComponents objects forms a target extracted subgraph. - SubgraphComponents - discover_output_contributors(const OutputEdge& output_edge, - const SubgraphComponents& already_collected) const; - - /// \brief Modifies the underlying GraphProto object and discards all obsolete elements. - /// - /// \param subgraph An object describing the subgraph to be extracted (elems to be kept) - void extract_subgraph_from_onnx_model(const SubgraphComponents& subgraph); - }; - } // namespace onnx_import -} // namespace ngraph diff --git a/ngraph/frontend/onnx_import/src/editor/detail/subgraph_extraction.cpp b/ngraph/frontend/onnx_import/src/editor/detail/subgraph_extraction.cpp deleted file mode 100644 index 66df579486e5eb..00000000000000 --- a/ngraph/frontend/onnx_import/src/editor/detail/subgraph_extraction.cpp +++ /dev/null @@ -1,454 +0,0 @@ -//***************************************************************************** -// Copyright 2017-2021 Intel Corporation -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -//***************************************************************************** - -#include -#include -#include - -#include "ngraph/check.hpp" -#include "onnx_import/editor/detail/subgraph_extraction.hpp" - -using namespace ngraph::onnx_import; - -namespace -{ - void validate_node_index(const ONNX_NAMESPACE::GraphProto& graph, const int node_idx) - { - NGRAPH_CHECK( - node_idx >= 0 && node_idx < graph.node_size(), - "The specified node index is out of range of nodes in the original model(idx: ", - std::to_string(node_idx), - "; nodes count in the model: ", - std::to_string(graph.node_size()), - ")"); - } - - template - std::function name_equals(const std::string& name) - { - return [&name](const T& onnx_object) -> bool { return onnx_object.name() == name; }; - } - - const auto is_equal_to = - +[](const std::string& other) { return [&](const std::string& s) { return s == other; }; }; - - template - bool already_exists(const Container& items, const std::string& name) - { - using std::begin; - using std::end; - return std::any_of( - begin(items), end(items), name_equals(name)); - } - - bool is_graph_input(const ONNX_NAMESPACE::GraphProto& graph, const std::string& name) - { - return already_exists(graph.input(), name); - } - - bool is_graph_initializer(const ONNX_NAMESPACE::GraphProto& graph, const std::string& name) - { - return already_exists(graph.initializer(), name); - } - - int find_source_node_idx(const ONNX_NAMESPACE::GraphProto& graph, - const int current_node_idx, - const std::string& input_name) - { - for (int i = current_node_idx - 1; i >= 0; --i) - { - const auto& outputs = graph.node(i).output(); - const auto output_found = - std::any_of(std::begin(outputs), std::end(outputs), is_equal_to(input_name)); - - if (output_found) - { - return i; - } - } - - throw ngraph::ngraph_error{"Source node not found in the graph for node: " + - std::to_string(current_node_idx) + " and input name: " + - input_name}; - } - - /// \brief Looks up a descriptor for a given tensor name. This descriptor contains inferred - /// shape information which is required to create new inputs and outputs in the graph. - const ONNX_NAMESPACE::ValueInfoProto& - find_tensor_descriptor(const ONNX_NAMESPACE::GraphProto& graph, - const std::string& tensor_name) - { - const auto it = std::find_if(std::begin(graph.value_info()), - std::end(graph.value_info()), - name_equals(tensor_name)); - - NGRAPH_CHECK(it != std::end(graph.value_info()), - "Could not find a tensor descriptor for tensor '", - tensor_name, - "'. It's not possible to add a new input to the graph without the type and " - "shape information of the intermediate tensor."); - - return *it; - } - - void replace_initializer_with_new_input(ONNX_NAMESPACE::GraphProto& graph, - const InputEdge& edge) - { - const auto it = std::find_if(std::begin(graph.initializer()), - std::end(graph.initializer()), - name_equals(edge.m_tensor_name)); - - NGRAPH_CHECK(it != std::end(graph.initializer()), - "Could not find an initializer in the graph: '", - edge.m_tensor_name); - - if (!already_exists(graph.input(), edge.m_tensor_name)) - { - const auto& initializer = *it; - auto& new_input = *(graph.add_input()); - - auto& new_input_tensor_type = *(new_input.mutable_type()->mutable_tensor_type()); - new_input_tensor_type.set_elem_type(initializer.data_type()); - - auto& new_input_shape = *(new_input_tensor_type.mutable_shape()); - for (const auto initializer_dim : initializer.dims()) - { - auto& new_dim = *(new_input_shape.add_dim()); - new_dim.set_dim_value(initializer_dim); - } - - *(new_input.mutable_name()) = edge.m_tensor_name; - } - - graph.mutable_initializer()->erase(it); - } - - std::pair append_new_graph_input(ONNX_NAMESPACE::GraphProto& graph, - const InputEdge& edge) - { - if (already_exists(graph.input(), edge.m_tensor_name) && - !is_graph_initializer(graph, edge.m_tensor_name)) - { - // no need to append a new input if an edge points to an existing one in the model - return {false, edge}; - } - - auto& target_node = *(graph.mutable_node(edge.m_node_idx)); - auto& node_inputs = *(target_node.mutable_input()); - auto target_input = - std::find(std::begin(node_inputs), std::end(node_inputs), edge.m_tensor_name); - - NGRAPH_CHECK(target_input != std::end(node_inputs), - "Input '", - edge.m_tensor_name, - "' not found in the inputs of node ", - edge.m_node_idx, - ". Cannot append a new graph input to this node."); - - const std::string new_input_name = target_node.output(0) + ":" + edge.m_tensor_name; - - if (is_graph_initializer(graph, edge.m_tensor_name)) - { - replace_initializer_with_new_input(graph, edge); - return {false, edge}; - } - else - { - auto& new_input = *(graph.add_input()); - // copy the intermediate tensor properties to the newly created input - new_input.MergeFrom(find_tensor_descriptor(graph, edge.m_tensor_name)); - *(new_input.mutable_name()) = new_input_name; - // attach the new graph input to the target node's input - *target_input = new_input_name; - return {true, InputEdge{edge.m_node_idx, new_input_name}}; - } - } - - /// \brief Replaces a node or initializer (consumed by multiple nodes) with a new input - int replace_source_with_new_input(ONNX_NAMESPACE::GraphProto& graph, const InputEdge& edge) - { - if (already_exists(graph.input(), edge.m_tensor_name) && - !is_graph_initializer(graph, edge.m_tensor_name)) - { - // happens when a user specifies multiple input edges pointing to the same tensor name - return -1; - } - - if (is_graph_initializer(graph, edge.m_tensor_name)) - { - replace_initializer_with_new_input(graph, edge); - } - else - { - auto& new_input = *(graph.add_input()); - // copy the intermediate tensor properties to the newly created input - new_input.MergeFrom(find_tensor_descriptor(graph, edge.m_tensor_name)); - - const auto source_node_idx = - find_source_node_idx(graph, edge.m_node_idx, edge.m_tensor_name); - auto& source_node = *(graph.mutable_node(source_node_idx)); - auto& node_outputs = *source_node.mutable_output(); - auto target_output = - std::find(std::begin(node_outputs), std::end(node_outputs), edge.m_tensor_name); - - NGRAPH_CHECK(target_output != std::end(node_outputs), - "Output '", - edge.m_tensor_name, - "' not found in the outputs of node ", - source_node_idx, - ". Cannot remove the output from this node."); - - // stop produsing tensor "edge.m_tensor_name" by the source node of the processed edge - *target_output = ""; - - return source_node_idx; - } - - return -1; - } - - void append_new_graph_output(ONNX_NAMESPACE::GraphProto& graph, const OutputEdge& edge) - { - if (already_exists(graph.output(), edge.m_tensor_name)) - { - return; - } - - auto& target_node = *(graph.mutable_node(edge.m_node_idx)); - const auto& node_outputs = target_node.output(); - const auto target_output = - std::find(std::begin(node_outputs), std::end(node_outputs), edge.m_tensor_name); - - NGRAPH_CHECK(target_output != std::end(node_outputs), - "Output '", - edge.m_tensor_name, - "' not found in the outputs of node ", - edge.m_node_idx, - ". Cannot append a new graph output to this node."); - - auto& new_output = *(graph.add_output()); - // copy the intermediate tensor's properties to the newly created - new_output.MergeFrom(find_tensor_descriptor(graph, edge.m_tensor_name)); - *(new_output.mutable_name()) = edge.m_tensor_name; - } - - /// \brief Removes all items from a container except the ones whose names are in items_to_keep - /// It's intended to work with ONNX graph inputs, outputs and initializers only. - template - void discard_by_name(Container& all_items, const std::set& items_to_keep) - { - static_assert( - std::is_same::value || - std::is_same::value, - "Unsupported value type of the container"); - - // The tested item can be discarded if its name is not found in the items_to_keep set - const auto can_be_discarded = [&items_to_keep](const typename Container::value_type& item) { - return items_to_keep.count(item.name()) == 0; - }; - - using std::begin; - using std::end; - - // move the elements-to-discard to the end of the container - const auto new_end = std::remove_if(begin(all_items), end(all_items), can_be_discarded); - // erase all of the discarded elements past the new end of the container - all_items.erase(new_end, end(all_items)); - } - - /// \brief Removes all nodes from a container keeping the ones whose index is in nodes_to_keep - template - void discard_nodes(Container& all_nodes, const std::set& nodes_to_keep) - { - static_assert( - std::is_same::value, - "Unsupported value type of the container"); - - int idx = 0; - const auto discard_node = [&idx, &nodes_to_keep](const typename Container::value_type&) { - return nodes_to_keep.count(idx++) == 0; - }; - - using std::begin; - using std::end; - - const auto new_end = std::remove_if(begin(all_nodes), end(all_nodes), discard_node); - all_nodes.erase(new_end, end(all_nodes)); - } -} // namespace - -/* -----------------------------------------------------------------------------------------------*/ - - - - -SubgraphExtractor::SubgraphExtractor(ONNX_NAMESPACE::GraphProto& graph) - : m_onnx_graph(graph) -{ - for (int i = 0; i < graph.node_size(); ++i) - { - for (const auto& node_input : graph.node(i).input()) - { - m_node_inputs.insert({i, node_input}); - m_tensor_consumers[node_input] += 1; - } - } -} - -void SubgraphExtractor::add_new_inputs(const std::vector& new_inputs) -{ - for (const auto& edge_to_replace : new_inputs) - { - validate_node_index(m_onnx_graph, edge_to_replace.m_node_idx); - - if (m_tensor_consumers[edge_to_replace.m_tensor_name] > 1) - { - int idx = replace_source_with_new_input(m_onnx_graph, edge_to_replace); - if (idx != -1) - { - // if a node was replaced with an input, remove input edges from a helper multimap - // for this node because it won't end up in the target subgraph - m_node_inputs.erase(idx); - } - } - else - { - const auto& new_edge = append_new_graph_input(m_onnx_graph, edge_to_replace); - if (new_edge.first) - { - replace_input_edge(edge_to_replace, new_edge.second); - } - } - } -} - -void SubgraphExtractor::add_new_outputs(const std::vector& new_outputs) -{ - for (const auto& new_output : new_outputs) - { - validate_node_index(m_onnx_graph, new_output.m_node_idx); - - append_new_graph_output(m_onnx_graph, new_output); - } -} - -void SubgraphExtractor::replace_input_edge(const InputEdge& old_edge, const InputEdge& new_edge) -{ - const auto node_inputs = m_node_inputs.equal_range(old_edge.m_node_idx); - auto old_input_name = node_inputs.first; - - while (old_input_name->second != old_edge.m_tensor_name && old_input_name != node_inputs.second) - { - ++old_input_name; - } - - m_node_inputs.erase(old_input_name); - m_node_inputs.insert({new_edge.m_node_idx, new_edge.m_tensor_name}); -} - -void SubgraphExtractor::extract_subgraph(std::vector subgraph_outputs) -{ - if (subgraph_outputs.empty()) - { - subgraph_outputs = all_output_edges(); - } - - SubgraphComponents subgraph; - - for (const auto& output_edge : subgraph_outputs) - { - subgraph += discover_output_contributors(output_edge, subgraph); - } - - extract_subgraph_from_onnx_model(subgraph); -} - -SubgraphExtractor::SubgraphComponents SubgraphExtractor::discover_output_contributors( - const OutputEdge& output_edge, const SubgraphComponents& already_collected) const -{ - const auto already_visited = [&already_collected](const int node_index) { - return already_collected.nodes.count(node_index) > 0; - }; - - SubgraphComponents output_contributors; - output_contributors.outputs.insert(output_edge.m_tensor_name); - - // reverse DFS graph traversal - std::stack nodes_to_visit; - nodes_to_visit.push(output_edge.m_node_idx); - - while (!nodes_to_visit.empty()) - { - const auto n = nodes_to_visit.top(); - nodes_to_visit.pop(); - - if (already_visited(n)) - { - continue; - } - - output_contributors.nodes.insert(n); - - // check if the visitor reached any of the graph inputs - // and/or keep looking for more contributors further up in the graph - const auto n_inputs = m_node_inputs.equal_range(n); - for (auto input_name = n_inputs.first; input_name != n_inputs.second; ++input_name) - { - if (is_graph_input(m_onnx_graph, input_name->second)) - { - output_contributors.inputs.insert(input_name->second); - // when an initializer has a matching graph input - if (is_graph_initializer(m_onnx_graph, input_name->second)) - { - output_contributors.initializers.insert(input_name->second); - } - } - else if (is_graph_initializer(m_onnx_graph, input_name->second)) - { - // when an initializer doesn't have a corresponding input - output_contributors.initializers.insert(input_name->second); - } - else - { - nodes_to_visit.push(find_source_node_idx(m_onnx_graph, n, input_name->second)); - } - } - } - - return output_contributors; -} - -void SubgraphExtractor::extract_subgraph_from_onnx_model(const SubgraphComponents& subgraph) -{ - discard_by_name(*(m_onnx_graph.mutable_input()), subgraph.inputs); - discard_by_name(*(m_onnx_graph.mutable_initializer()), subgraph.initializers); - discard_by_name(*(m_onnx_graph.mutable_output()), subgraph.outputs); - discard_nodes(*(m_onnx_graph.mutable_node()), subgraph.nodes); -} - -std::vector SubgraphExtractor::all_output_edges() const -{ - std::vector all_outputs; - - for (const auto& graph_output : m_onnx_graph.output()) - { - all_outputs.emplace_back( - find_source_node_idx(m_onnx_graph, m_onnx_graph.node_size(), graph_output.name()), - graph_output.name()); - } - - return all_outputs; -} diff --git a/ngraph/frontend/onnx_import/src/utils/onnx_test_util.cpp b/ngraph/frontend/onnx_import/src/utils/onnx_test_util.cpp deleted file mode 100644 index b396c27b80cb28..00000000000000 --- a/ngraph/frontend/onnx_import/src/utils/onnx_test_util.cpp +++ /dev/null @@ -1,275 +0,0 @@ -//***************************************************************************** -// Copyright 2017-2021 Intel Corporation -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -//***************************************************************************** - -#include -#include -#include -#include - -#include "onnx_test_util.hpp" -#include "parser.hpp" - -using namespace ngraph::onnx_import; - -namespace -{ - ComparisonResult compare_nodes(const ONNX_NAMESPACE::GraphProto& graph, - const ONNX_NAMESPACE::GraphProto& ref_graph) - { - if (graph.node_size() != ref_graph.node_size()) - { - return ComparisonResult::fail("The number of nodes in compared models doesn't match"); - } - else - { - for (int i = 0; i < graph.node_size(); ++i) - { - const auto& lhs = graph.node(i); - const auto& rhs = ref_graph.node(i); - - if (lhs.op_type() != rhs.op_type()) - { - return ComparisonResult::fail("Operation types are different at index " + - std::to_string(i) + ": " + lhs.op_type() + - " vs " + rhs.op_type()); - } - - for (int j = 0; j < lhs.input_size(); ++j) - { - if (lhs.input(j) != rhs.input(j)) - { - return ComparisonResult::fail( - "Input names don't match for nodes at index " + std::to_string(i) + - ": " + lhs.input(j) + " vs " + rhs.input(j)); - } - } - - for (int j = 0; j < lhs.output_size(); ++j) - { - if (lhs.output(j) != rhs.output(j)) - { - return ComparisonResult::fail( - "Output names don't match for nodes at index " + std::to_string(i) + - ": " + lhs.output(j) + " vs " + rhs.output(j)); - } - } - } - } - - return ComparisonResult::pass(); - } - - ComparisonResult compare_value_info(const ONNX_NAMESPACE::ValueInfoProto& lhs, - const ONNX_NAMESPACE::ValueInfoProto& rhs, - const std::string& item_type) - { - if (lhs.name() != rhs.name()) - { - return ComparisonResult::fail(item_type + " names in the graph don't match: " + - lhs.name() + " vs " + rhs.name()); - } - - const auto& lhs_tensor = lhs.type().tensor_type(); - const auto& rhs_tensor = rhs.type().tensor_type(); - if (lhs_tensor.elem_type() != rhs_tensor.elem_type()) - { - return ComparisonResult::fail("Element types don't match for " + item_type + " " + - lhs.name() + ": " + - std::to_string(lhs_tensor.elem_type()) + " vs " + - std::to_string(rhs_tensor.elem_type())); - } - - const auto& lhs_shape = lhs_tensor.shape(); - const auto& rhs_shape = rhs_tensor.shape(); - if (lhs_shape.dim_size() != rhs_shape.dim_size()) - { - return ComparisonResult::fail("Tensor ranks don't match for " + item_type + " " + - lhs.name() + ": " + std::to_string(lhs_shape.dim_size()) + - " vs " + std::to_string(rhs_shape.dim_size())); - } - else - { - for (int j = 0; j < lhs_shape.dim_size(); ++j) - { - const auto& lhs_dim = lhs_shape.dim(j); - const auto& rhs_dim = rhs_shape.dim(j); - if ((lhs_dim.has_dim_value() && rhs_dim.has_dim_param()) || - (rhs_dim.has_dim_value() && lhs_dim.has_dim_param())) - { - return ComparisonResult::fail("Dynamic vs static dimension mismatch for " + - item_type + " " + lhs.name() + " at index: " + - std::to_string(j)); - } - else if (lhs_dim.has_dim_value() && lhs_dim.dim_value() != rhs_dim.dim_value()) - { - return ComparisonResult::fail("Shape dimensions don't match for " + item_type + - " " + lhs.name() + " at index: " + - std::to_string(j) + ". " + - std::to_string(lhs_dim.dim_value()) + " vs " + - std::to_string(rhs_dim.dim_value())); - } - } - } - - return ComparisonResult::pass(); - } - - ComparisonResult compare_inputs(const ONNX_NAMESPACE::GraphProto& graph, - const ONNX_NAMESPACE::GraphProto& ref_graph) - { - if (graph.input_size() != ref_graph.input_size()) - { - return ComparisonResult::fail( - "The number of inputs in compared models doesn't match: " + - std::to_string(graph.input_size()) + " vs " + - std::to_string(ref_graph.input_size())); - } - else - { - for (int i = 0; i < graph.input_size(); ++i) - { - const auto& lhs = graph.input(i); - const auto& rhs = ref_graph.input(i); - - const auto res = compare_value_info(lhs, rhs, "input"); - if (!res.is_ok) - { - return res; - } - } - - return ComparisonResult::pass(); - } - } - - ComparisonResult compare_outputs(const ONNX_NAMESPACE::GraphProto& graph, - const ONNX_NAMESPACE::GraphProto& ref_graph) - { - if (graph.output_size() != ref_graph.output_size()) - { - return ComparisonResult::fail("The number of outputs in compared models doesn't match" + - std::to_string(graph.output_size()) + " vs " + - std::to_string(ref_graph.output_size())); - } - else - { - for (int i = 0; i < graph.output_size(); ++i) - { - const auto& lhs = graph.output(i); - const auto& rhs = ref_graph.output(i); - - const auto res = compare_value_info(lhs, rhs, "output"); - if (!res.is_ok) - { - return res; - } - } - - return ComparisonResult::pass(); - } - } - - ComparisonResult compare_initializers(const ONNX_NAMESPACE::GraphProto& graph, - const ONNX_NAMESPACE::GraphProto& ref_graph) - { - if (graph.initializer_size() != ref_graph.initializer_size()) - { - return ComparisonResult::fail( - "The number of initializers in compared models doesn't match" + - std::to_string(graph.initializer_size()) + " vs " + - std::to_string(ref_graph.initializer_size())); - } - else - { - for (int i = 0; i < graph.initializer_size(); ++i) - { - const auto& lhs = graph.initializer(i); - const auto& rhs = ref_graph.initializer(i); - - if (lhs.name() != rhs.name()) - { - return ComparisonResult::fail("Initializer names in the graph don't match: " + - lhs.name() + " vs " + rhs.name()); - } - else if (lhs.data_type() != rhs.data_type()) - { - return ComparisonResult::fail( - "Initializer data types in the graph don't match: " + - std::to_string(lhs.data_type()) + " vs " + std::to_string(rhs.data_type())); - } - else if (lhs.dims_size() != rhs.dims_size()) - { - return ComparisonResult::fail("Initializer ranks in the graph don't match: " + - std::to_string(lhs.dims_size()) + " vs " + - std::to_string(rhs.dims_size())); - } - else - { - for (int j = 0; j < lhs.dims_size(); ++j) - { - if (lhs.dims(j) != rhs.dims(j)) - { - return ComparisonResult::fail( - "Shape dimensions don't match for initializer " + lhs.name() + - " at index: " + std::to_string(j) + ". " + - std::to_string(lhs.dims(j)) + " vs " + std::to_string(rhs.dims(j))); - } - } - } - } - - return ComparisonResult::pass(); - } - } - - ComparisonResult compare_onnx_graphs(const ONNX_NAMESPACE::GraphProto& graph, - const ONNX_NAMESPACE::GraphProto& ref_graph) - { - ComparisonResult comparison = compare_inputs(graph, ref_graph); - if (!comparison.is_ok) - { - return comparison; - } - - comparison = compare_outputs(graph, ref_graph); - if (!comparison.is_ok) - { - return comparison; - } - - comparison = compare_initializers(graph, ref_graph); - if (!comparison.is_ok) - { - return comparison; - } - - return compare_nodes(graph, ref_graph); - } -} // namespace -namespace ngraph -{ - namespace onnx_import - { - ComparisonResult compare_onnx_models(const std::string& model, - const std::string& reference_model_path) - { - std::stringstream model_stream{model}; - const auto model_proto = onnx_import::parse_from_istream(model_stream); - const auto ref_model = onnx_import::parse_from_file(reference_model_path); - return compare_onnx_graphs(model_proto.graph(), ref_model.graph()); - } - } // namespace onnx_import -} // namespace ngraph diff --git a/ngraph/frontend/onnx_import/src/utils/onnx_test_util.hpp b/ngraph/frontend/onnx_import/src/utils/onnx_test_util.hpp deleted file mode 100644 index 6c97bd1c1fee5b..00000000000000 --- a/ngraph/frontend/onnx_import/src/utils/onnx_test_util.hpp +++ /dev/null @@ -1,54 +0,0 @@ -//***************************************************************************** -// Copyright 2017-2021 Intel Corporation -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -//***************************************************************************** - -#pragma once - -#include - -#include "onnx_import/utils/onnx_importer_visibility.hpp" - -namespace ngraph -{ - namespace onnx_import - { - struct ONNX_IMPORTER_API ComparisonResult - { - ComparisonResult() = default; - ComparisonResult(std::string error) - : is_ok{false} - , error_message{std::move(error)} - { - } - ComparisonResult(ComparisonResult&&) = default; - ComparisonResult(const ComparisonResult&) = default; - ComparisonResult& operator=(ComparisonResult&&) = default; - ComparisonResult& operator=(const ComparisonResult&) = default; - - bool is_ok = true; - std::string error_message; - - static ComparisonResult pass() { return {}; } - static ComparisonResult fail(std::string error) - { - return ComparisonResult{std::move(error)}; - } - }; - - ONNX_IMPORTER_API ComparisonResult - compare_onnx_models(const std::string& model, const std::string& reference_model_path); - - } // namespace onnx_import -} // namespace ngraph diff --git a/ngraph/test/onnx/onnx_editor.cpp b/ngraph/test/onnx/onnx_editor.cpp index 168a9bb8bb7037..898d5e449b1509 100644 --- a/ngraph/test/onnx/onnx_editor.cpp +++ b/ngraph/test/onnx/onnx_editor.cpp @@ -17,7 +17,6 @@ #include "util/onnx_test_util.hpp" #include "util/test_case.hpp" #include "util/test_control.hpp" -#include "utils/onnx_test_util.hpp" NGRAPH_SUPPRESS_DEPRECATED_START @@ -797,387 +796,3 @@ NGRAPH_TEST(onnx_editor, values__append_two_initializers_mixed_types) test_case.add_expected_output(Shape{2, 2, 1}, {1, 4, 5, 8}); test_case.run(); } - -NGRAPH_TEST(onnx_editor, subgraph__linear_model_head_cut) -{ - onnx_import::ONNXModelEditor editor{file_util::path_join( - SERIALIZED_ZOO, "onnx/model_editor/subgraph__inception_head.prototxt")}; - - editor.cut_graph_fragment({{InputEdge(1, "conv1/7x7_s2_1")}}, {}); - - const auto ref_model = file_util::path_join( - SERIALIZED_ZOO, "onnx/model_editor/reference/subgraph__linear_model_head_cut.prototxt"); - - const auto result = compare_onnx_models(editor.model_string(), ref_model); - - EXPECT_TRUE(result.is_ok) << result.error_message; -} - -NGRAPH_TEST(onnx_editor, subgraph__linear_model_head_cut_ins_and_outs) -{ - onnx_import::ONNXModelEditor editor{file_util::path_join( - SERIALIZED_ZOO, "onnx/model_editor/subgraph__inception_head.prototxt")}; - - editor.cut_graph_fragment({{InputEdge(1, "conv1/7x7_s2_1")}}, - {{OutputEdge(2, "pool1/3x3_s2_1")}}); - - // expected to behave the same way as subgraph__linear_model_head_cut - const auto ref_model = file_util::path_join( - SERIALIZED_ZOO, "onnx/model_editor/reference/subgraph__linear_model_head_cut.prototxt"); - - const auto result = compare_onnx_models(editor.model_string(), ref_model); - - EXPECT_TRUE(result.is_ok) << result.error_message; -} - -NGRAPH_TEST(onnx_editor, subgraph__linear_model_deeper_head_cut) -{ - onnx_import::ONNXModelEditor editor{file_util::path_join( - SERIALIZED_ZOO, "onnx/model_editor/subgraph__inception_head.prototxt")}; - - editor.cut_graph_fragment({{InputEdge(2, "conv1/7x7_s2_2")}}, {}); - - const auto ref_model = file_util::path_join( - SERIALIZED_ZOO, - "onnx/model_editor/reference/subgraph__linear_model_deeper_head_cut.prototxt"); - - const auto result = compare_onnx_models(editor.model_string(), ref_model); - - EXPECT_TRUE(result.is_ok) << result.error_message; -} - -NGRAPH_TEST(onnx_editor, subgraph__linear_model_tail_cut) -{ - onnx_import::ONNXModelEditor editor{file_util::path_join( - SERIALIZED_ZOO, "onnx/model_editor/subgraph__inception_head.prototxt")}; - - editor.cut_graph_fragment({}, {{OutputEdge{1, "conv1/7x7_s2_2"}}}); - - const auto ref_model = file_util::path_join( - SERIALIZED_ZOO, "onnx/model_editor/reference/subgraph__linear_model_tail_cut.prototxt"); - - const auto result = compare_onnx_models(editor.model_string(), ref_model); - - EXPECT_TRUE(result.is_ok) << result.error_message; -} - -NGRAPH_TEST(onnx_editor, subgraph__linear_model_tail_cut_ins_and_outs) -{ - onnx_import::ONNXModelEditor editor{file_util::path_join( - SERIALIZED_ZOO, "onnx/model_editor/subgraph__inception_head.prototxt")}; - - editor.cut_graph_fragment({{InputEdge{0, "data_0"}}}, {{OutputEdge{1, "conv1/7x7_s2_2"}}}); - - // expected to behave the same way as subgraph__linear_model_tail_cut - const auto ref_model = file_util::path_join( - SERIALIZED_ZOO, "onnx/model_editor/reference/subgraph__linear_model_tail_cut.prototxt"); - - const auto result = compare_onnx_models(editor.model_string(), ref_model); - - EXPECT_TRUE(result.is_ok) << result.error_message; -} - -NGRAPH_TEST(onnx_editor, subgraph__linear_model_with_initializer_tail_cut) -{ - onnx_import::ONNXModelEditor editor{file_util::path_join( - SERIALIZED_ZOO, "onnx/model_editor/subgraph__inception_head_with_initializer.prototxt")}; - - editor.cut_graph_fragment({}, {{OutputEdge{1, "conv1/7x7_s2_2"}}}); - - const auto ref_model = file_util::path_join( - SERIALIZED_ZOO, - "onnx/model_editor/reference/subgraph__linear_model_with_initializer_tail_cut.prototxt"); - - const auto result = compare_onnx_models(editor.model_string(), ref_model); - - EXPECT_TRUE(result.is_ok) << result.error_message; -} - -NGRAPH_TEST(onnx_editor, subgraph__initializer_without_matching_input_tail_cut) -{ - onnx_import::ONNXModelEditor editor{file_util::path_join( - SERIALIZED_ZOO, "onnx/model_editor/subgraph__initializer_without_matching_input.prototxt")}; - - editor.cut_graph_fragment({}, {{OutputEdge{1, "conv1/7x7_s2_2"}}}); - - const auto ref_model = - file_util::path_join(SERIALIZED_ZOO, - "onnx/model_editor/reference/" - "subgraph__initializer_without_matching_input_tail_cut.prototxt"); - - const auto result = compare_onnx_models(editor.model_string(), ref_model); - - EXPECT_TRUE(result.is_ok) << result.error_message; -} - -NGRAPH_TEST(onnx_editor, subgraph__linear_model_deeper_tail_cut) -{ - onnx_import::ONNXModelEditor editor{file_util::path_join( - SERIALIZED_ZOO, "onnx/model_editor/subgraph__inception_head.prototxt")}; - - editor.cut_graph_fragment({}, {{OutputEdge{0, "conv1/7x7_s2_1"}}}); - - const auto ref_model = file_util::path_join( - SERIALIZED_ZOO, - "onnx/model_editor/reference/subgraph__linear_model_deeper_tail_cut.prototxt"); - - const auto result = compare_onnx_models(editor.model_string(), ref_model); - - EXPECT_TRUE(result.is_ok) << result.error_message; -} - -NGRAPH_TEST(onnx_editor, subgraph__no_input_params) -{ - const auto model_path = - file_util::path_join(SERIALIZED_ZOO, "onnx/model_editor/subgraph__inception_head.prototxt"); - - onnx_import::ONNXModelEditor editor{model_path}; - - editor.cut_graph_fragment({}, {}); - - const auto result = compare_onnx_models(editor.model_string(), model_path); - - EXPECT_TRUE(result.is_ok) << result.error_message; -} - -NGRAPH_TEST(onnx_editor, subgraph__initializer_to_input_replacement) -{ - onnx_import::ONNXModelEditor editor{file_util::path_join( - SERIALIZED_ZOO, "onnx/model_editor/subgraph__inception_head_with_initializer.prototxt")}; - - editor.cut_graph_fragment({{InputEdge{0, "conv1/7x7_s2_b_0"}}}, - {{OutputEdge{0, "conv1/7x7_s2_1"}}}); - - const auto ref_model = file_util::path_join( - SERIALIZED_ZOO, - "onnx/model_editor/reference/subgraph__initializer_to_input_replacement.prototxt"); - - const auto result = compare_onnx_models(editor.model_string(), ref_model); - - EXPECT_TRUE(result.is_ok) << result.error_message; -} - -NGRAPH_TEST(onnx_editor, subgraph__initializer_to_input_replacement_2) -{ - onnx_import::ONNXModelEditor editor{file_util::path_join( - SERIALIZED_ZOO, "onnx/model_editor/subgraph__initializer_without_matching_input.prototxt")}; - - editor.cut_graph_fragment({{InputEdge{0, "conv1/7x7_s2_b_0"}}}, - {{OutputEdge{0, "conv1/7x7_s2_1"}}}); - - const auto ref_model = file_util::path_join( - SERIALIZED_ZOO, - "onnx/model_editor/reference/subgraph__initializer_to_input_replacement.prototxt"); - - const auto result = compare_onnx_models(editor.model_string(), ref_model); - - EXPECT_TRUE(result.is_ok) << result.error_message; -} - -NGRAPH_TEST(onnx_editor, subgraph__multiout_op_output_edge) -{ - onnx_import::ONNXModelEditor editor{file_util::path_join( - SERIALIZED_ZOO, "onnx/model_editor/subgraph_extraction_tests.prototxt")}; - - editor.cut_graph_fragment({}, {{OutputEdge{5, "split2"}}}); - - const auto ref_model = file_util::path_join( - SERIALIZED_ZOO, "onnx/model_editor/reference/subgraph__multiout_op_output_edge.prototxt"); - - const auto result = compare_onnx_models(editor.model_string(), ref_model); - - EXPECT_TRUE(result.is_ok) << result.error_message; -} - -NGRAPH_TEST(onnx_editor, subgraph__existing_inputs_and_outputs_based_extraction) -{ - onnx_import::ONNXModelEditor editor{file_util::path_join( - SERIALIZED_ZOO, "onnx/model_editor/subgraph_extraction_tests.prototxt")}; - - editor.cut_graph_fragment({{InputEdge{1, "in2"}, InputEdge{2, "in3"}}}, - {{OutputEdge{4, "mul2"}}}); - - const auto ref_model = - file_util::path_join(SERIALIZED_ZOO, - "onnx/model_editor/reference/" - "subgraph__existing_inputs_and_outputs_based_extraction.prototxt"); - - const auto result = compare_onnx_models(editor.model_string(), ref_model); - - EXPECT_TRUE(result.is_ok) << result.error_message; -} - -NGRAPH_TEST(onnx_editor, subgraph__input_edge_from_tensor_with_multiple_consumers) -{ - onnx_import::ONNXModelEditor editor{file_util::path_join( - SERIALIZED_ZOO, "onnx/model_editor/subgraph_extraction_tests.prototxt")}; - - editor.cut_graph_fragment({{InputEdge{1, "relu1"}, InputEdge{6, "relu1"}}}, - {{OutputEdge{6, "mul1"}, OutputEdge{4, "mul2"}}}); - - const auto ref_model = - file_util::path_join(SERIALIZED_ZOO, - "onnx/model_editor/reference/" - "subgraph__input_edge_from_tensor_with_multiple_consumers.prototxt"); - - const auto result = compare_onnx_models(editor.model_string(), ref_model); - - EXPECT_TRUE(result.is_ok) << result.error_message; -} - -NGRAPH_TEST(onnx_editor, subgraph__input_edge_from_tensor_with_multiple_consumers_2) -{ - onnx_import::ONNXModelEditor editor{file_util::path_join( - SERIALIZED_ZOO, "onnx/model_editor/subgraph_extraction_tests.prototxt")}; - - editor.cut_graph_fragment({{InputEdge{3, "relu1"}, InputEdge{3, "add1"}}}, - {{OutputEdge{3, "add2"}, OutputEdge{4, "mul2"}}}); - - const auto ref_model = - file_util::path_join(SERIALIZED_ZOO, - "onnx/model_editor/reference/" - "subgraph__input_edge_from_tensor_with_multiple_consumers_2.prototxt"); - - const auto result = compare_onnx_models(editor.model_string(), ref_model); - - EXPECT_TRUE(result.is_ok) << result.error_message; -} - -NGRAPH_TEST(onnx_editor, subgraph__input_edge_from_tensor_with_multiple_consumers_3) -{ - onnx_import::ONNXModelEditor editor{file_util::path_join( - SERIALIZED_ZOO, "onnx/model_editor/subgraph_extraction_tests.prototxt")}; - - editor.cut_graph_fragment({{InputEdge{3, "relu1"}, InputEdge{6, "relu1"}}}, - {{OutputEdge{6, "mul1"}, OutputEdge{5, "split2"}}}); - - const auto ref_model = - file_util::path_join(SERIALIZED_ZOO, - "onnx/model_editor/reference/" - "subgraph__input_edge_from_tensor_with_multiple_consumers_3.prototxt"); - - const auto result = compare_onnx_models(editor.model_string(), ref_model); - - EXPECT_TRUE(result.is_ok) << result.error_message; -} - -NGRAPH_TEST(onnx_editor, subgraph__input_edge_from_tensor_with_multiple_consumers_4) -{ - onnx_import::ONNXModelEditor editor{file_util::path_join( - SERIALIZED_ZOO, "onnx/model_editor/subgraph_extraction_tests.prototxt")}; - - editor.cut_graph_fragment({{InputEdge{3, "relu1"}}}, - {{OutputEdge{6, "mul1"}, OutputEdge{5, "split2"}}}); - - // expected to behave the same way as the test above - const auto ref_model = - file_util::path_join(SERIALIZED_ZOO, - "onnx/model_editor/reference/" - "subgraph__input_edge_from_tensor_with_multiple_consumers_3.prototxt"); - - const auto result = compare_onnx_models(editor.model_string(), ref_model); - - EXPECT_TRUE(result.is_ok) << result.error_message; -} - -NGRAPH_TEST(onnx_editor, subgraph__multiple_consumers_of_graph_input_relu2) -{ - onnx_import::ONNXModelEditor editor{file_util::path_join( - SERIALIZED_ZOO, "onnx/model_editor/subgraph_extraction_tests_2.prototxt")}; - - editor.cut_graph_fragment({{InputEdge{4, "relu2"}}}, {}); - - const auto ref_model = - file_util::path_join(SERIALIZED_ZOO, - "onnx/model_editor/reference/" - "subgraph__multiple_consumers_of_graph_input_relu2.prototxt"); - - const auto result = compare_onnx_models(editor.model_string(), ref_model); - - EXPECT_TRUE(result.is_ok) << result.error_message; -} - -NGRAPH_TEST(onnx_editor, subgraph__multiple_consumers_of_graph_initializer) -{ - onnx_import::ONNXModelEditor editor{file_util::path_join( - SERIALIZED_ZOO, "onnx/model_editor/subgraph_extraction_tests_2.prototxt")}; - - editor.cut_graph_fragment({{InputEdge{2, "in2"}}}, {}); - - const auto ref_model = - file_util::path_join(SERIALIZED_ZOO, - "onnx/model_editor/reference/" - "subgraph__multiple_consumers_of_graph_initializer.prototxt"); - - const auto result = compare_onnx_models(editor.model_string(), ref_model); - - EXPECT_TRUE(result.is_ok) << result.error_message; -} - -NGRAPH_TEST(onnx_editor, subgraph__multiple_consumers_of_graph_initializer_2) -{ - onnx_import::ONNXModelEditor editor{file_util::path_join( - SERIALIZED_ZOO, "onnx/model_editor/subgraph_extraction_tests_2.prototxt")}; - - editor.cut_graph_fragment({{InputEdge{2, "in2"}, InputEdge{3, "in2"}}}, {}); - - // same as above - const auto ref_model = - file_util::path_join(SERIALIZED_ZOO, - "onnx/model_editor/reference/" - "subgraph__multiple_consumers_of_graph_initializer.prototxt"); - - const auto result = compare_onnx_models(editor.model_string(), ref_model); - - EXPECT_TRUE(result.is_ok) << result.error_message; -} - -NGRAPH_TEST(onnx_editor, subgraph__multiple_consumers_of_graph_initializer_relu2_and_init) -{ - onnx_import::ONNXModelEditor editor{file_util::path_join( - SERIALIZED_ZOO, "onnx/model_editor/subgraph_extraction_tests_2.prototxt")}; - - editor.cut_graph_fragment({{InputEdge{5, "relu2"}, InputEdge{3, "in2"}}}, {}); - - const auto ref_model = file_util::path_join( - SERIALIZED_ZOO, - "onnx/model_editor/reference/" - "subgraph__multiple_consumers_of_graph_initializer_relu2_and_init.prototxt"); - - const auto result = compare_onnx_models(editor.model_string(), ref_model); - - EXPECT_TRUE(result.is_ok) << result.error_message; -} - -NGRAPH_TEST(onnx_editor, subgraph__invalid_edge_idx) -{ - const auto model_path = - file_util::path_join(SERIALIZED_ZOO, "onnx/model_editor/subgraph__inception_head.prototxt"); - - onnx_import::ONNXModelEditor editor{model_path}; - - EXPECT_THROW(editor.cut_graph_fragment({{InputEdge{15, "x"}}}, {}), ngraph::ngraph_error); -} - -NGRAPH_TEST(onnx_editor, subgraph__invalid_edge_name) -{ - const auto model_path = - file_util::path_join(SERIALIZED_ZOO, "onnx/model_editor/subgraph__inception_head.prototxt"); - - onnx_import::ONNXModelEditor editor{model_path}; - - EXPECT_THROW(editor.cut_graph_fragment({{InputEdge{0, "x"}}}, {}), ngraph::ngraph_error); -} - -NGRAPH_TEST(onnx_editor, subgraph__inputs_getter) -{ - onnx_import::ONNXModelEditor editor{file_util::path_join( - SERIALIZED_ZOO, "onnx/model_editor/subgraph__inception_head.prototxt")}; - - EXPECT_EQ(editor.model_inputs(), - (std::vector{"data_0", "conv1/7x7_s2_w_0", "conv1/7x7_s2_b_0"})); - - editor.cut_graph_fragment({{InputEdge(1, "conv1/7x7_s2_1")}}, {}); - - EXPECT_EQ(editor.model_inputs(), (std::vector{"conv1/7x7_s2_2:conv1/7x7_s2_1"})); -} From 9bcdf797b0739884ace9a226c998f3c0bb4daec4 Mon Sep 17 00:00:00 2001 From: "Vafin, Maxim" Date: Fri, 2 Apr 2021 13:34:10 +0300 Subject: [PATCH 098/116] Unify reading --- ngraph/frontend/paddlepaddle/src/frontend.cpp | 28 +++++++++---------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/ngraph/frontend/paddlepaddle/src/frontend.cpp b/ngraph/frontend/paddlepaddle/src/frontend.cpp index b92ed7bc49aa2c..772c9aef24d5c9 100644 --- a/ngraph/frontend/paddlepaddle/src/frontend.cpp +++ b/ngraph/frontend/paddlepaddle/src/frontend.cpp @@ -86,28 +86,26 @@ std::shared_ptr read_tensor(const paddle::framework::p tensor.dims().cbegin(), tensor.dims().cend(), 1, std::multiplies()); std::vector tensor_data(tensor_length, 0); + std::ifstream is; + std::ifstream* stream_ptr; if (model->weights_composed) { - std::vector leading_zeros(16, 0); - model->weights_stream.read(&leading_zeros[0], 16); - uint32_t dims_len = 0; - model->weights_stream.read(reinterpret_cast(&dims_len), 4); - std::vector dims_struct(dims_len, 0); - model->weights_stream.read(&dims_struct[0], dims_len); - model->weights_stream.read(reinterpret_cast(&tensor_data[0]), tensor_length * 4); + stream_ptr = &model->weights_stream; } else { - std::ifstream is(model->path + "/" + var.name(), std::ios::in | std::ifstream::binary); + is = std::ifstream(model->path + "/" + var.name(), std::ios::in | std::ifstream::binary); if (!is || !is.is_open()) { std::cout << "File not opened" << std::endl; } - // get length of file: - is.seekg(0, std::ios::end); - auto length = is.tellg(); - std::cout << "length: " << length << ", ten_len: " << tensor_length << std::endl; - is.seekg((size_t)length - tensor_length * 4, std::ios::beg); - - is.read(reinterpret_cast(&tensor_data[0]), tensor_length * 4); + stream_ptr = &is; } + std::vector leading_zeros(16, 0); + stream_ptr->read(&leading_zeros[0], 16); + uint32_t dims_len = 0; + stream_ptr->read(reinterpret_cast(&dims_len), 4); + std::vector dims_struct(dims_len, 0); + stream_ptr->read(&dims_struct[0], dims_len); + stream_ptr->read(reinterpret_cast(&tensor_data[0]), tensor_length * 4); + auto shape = std::vector(tensor.dims().cbegin(), tensor.dims().cend()); return ngraph::opset6::Constant::create( ngraph::element::f32, ngraph::Shape(shape), tensor_data); From 45a45cf45e20a425333ca2a470c32bf027de5788 Mon Sep 17 00:00:00 2001 From: Michael Nosov Date: Fri, 2 Apr 2021 19:40:14 +0300 Subject: [PATCH 099/116] Make benchmark app working again Added few CMake modifications to make FronEndManager includable in IECore The problem was that all nodes had a name "Out". In this case results map inserted result["Out"], then result["Out"] again Having friendly names unique helped with this --- CMakeLists.txt | 1 + inference-engine/src/CMakeLists.txt | 2 +- .../src/inference_engine/CMakeLists.txt | 3 ++- inference-engine/src/inference_engine/ie_core.cpp | 2 ++ ngraph/frontend/paddlepaddle/src/frontend.cpp | 14 +++++++++++--- 5 files changed, 17 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6c3797d10ca59d..a37eaf10782469 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -107,6 +107,7 @@ function(build_ngraph) set(SDL_cmake_included ON) add_subdirectory(ngraph) set(NGRAPH_LIBRARIES ngraph PARENT_SCOPE) + set(FRONTEND_LIBRARIES frontend_manager PARENT_SCOPE) set(NGRAPH_REF_LIBRARIES ngraph_reference PARENT_SCOPE) endfunction() diff --git a/inference-engine/src/CMakeLists.txt b/inference-engine/src/CMakeLists.txt index db8d27ada7a23d..bfd718f556042d 100644 --- a/inference-engine/src/CMakeLists.txt +++ b/inference-engine/src/CMakeLists.txt @@ -51,5 +51,5 @@ add_custom_target(ie_libraries ALL inference_engine_lp_transformations inference_engine_snippets) if(NGRAPH_ONNX_IMPORT_ENABLE) - add_dependencies(ie_libraries inference_engine_onnx_reader) + add_dependencies(ie_libraries inference_engine_onnx_reader frontend_manager) endif() diff --git a/inference-engine/src/inference_engine/CMakeLists.txt b/inference-engine/src/inference_engine/CMakeLists.txt index 338100ee5a6aa1..b1a31f09529e81 100644 --- a/inference-engine/src/inference_engine/CMakeLists.txt +++ b/inference-engine/src/inference_engine/CMakeLists.txt @@ -108,6 +108,7 @@ target_compile_definitions(${TARGET_NAME}_obj PRIVATE IMPLEMENT_INFERENCE_ENGINE $) target_include_directories(${TARGET_NAME}_obj SYSTEM PRIVATE $ + $ $ $) @@ -137,7 +138,7 @@ ie_add_vs_version_file(NAME ${TARGET_NAME} set_ie_threading_interface_for(${TARGET_NAME}) target_link_libraries(${TARGET_NAME} PRIVATE pugixml openvino::itt ${CMAKE_DL_LIBS} Threads::Threads - ${NGRAPH_LIBRARIES} inference_engine_transformations) + ${NGRAPH_LIBRARIES} ${FRONTEND_LIBRARIES} inference_engine_transformations) target_include_directories(${TARGET_NAME} INTERFACE ${PUBLIC_HEADERS_DIR} PRIVATE $ diff --git a/inference-engine/src/inference_engine/ie_core.cpp b/inference-engine/src/inference_engine/ie_core.cpp index 35cb82a3ddb15d..2118e6aaca8d63 100644 --- a/inference-engine/src/inference_engine/ie_core.cpp +++ b/inference-engine/src/inference_engine/ie_core.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include #include "compilation_context.hpp" @@ -205,6 +206,7 @@ class Core::Impl : public ICore { std::unordered_set opsetNames; std::vector extensions; + ngraph::frontend::FrontEndManager frontEndManager; std::map pluginRegistry; mutable std::mutex pluginsMutex; // to lock parallel access to pluginRegistry and plugins diff --git a/ngraph/frontend/paddlepaddle/src/frontend.cpp b/ngraph/frontend/paddlepaddle/src/frontend.cpp index d22d08a461739b..e51440b97b8aef 100644 --- a/ngraph/frontend/paddlepaddle/src/frontend.cpp +++ b/ngraph/frontend/paddlepaddle/src/frontend.cpp @@ -175,11 +175,19 @@ std::shared_ptr convert_model(const std::string &model_dir) { } else if (op.type() == "fetch") { auto input_node = inputs_dict["X"][0]; MY_ASSERT(nodes_dict.find(input_node) != nodes_dict.end()); - result_nodes.push_back(std::make_shared(nodes_dict[input_node])); + auto result = std::make_shared(nodes_dict[input_node]); + result->set_friendly_name(input_node); + result_nodes.push_back(result); } else { auto node = make_ng_node(inputs_dict, nodes_dict, op, block, CREATORS_MAP); - std::cerr << "Node created: " << node << "\n"; - node->set_friendly_name(op.outputs()[0].parameter()); + std::string layer_name; + for (const auto& outs : outputs_dict) { + for (const auto& fieldName : outs.second) { + layer_name += fieldName; + } + } + node->set_friendly_name(layer_name); + std::cerr << "Named with " << node->get_friendly_name() << "\n"; for (const auto &item : outputs_dict) { MY_ASSERT(item.second.size() <= 1); From 616a933d663ed1375d62eff11e229697c5164d48 Mon Sep 17 00:00:00 2001 From: Michael Nosov Date: Sat, 3 Apr 2021 00:05:08 +0300 Subject: [PATCH 100/116] hello_classification - add example of pdpd --- .../hello_classification/CMakeLists.txt | 2 +- .../samples/hello_classification/main.cpp | 31 ++++++++++++++----- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/inference-engine/samples/hello_classification/CMakeLists.txt b/inference-engine/samples/hello_classification/CMakeLists.txt index 9b0509bab82c23..bf6b0389a1eb46 100644 --- a/inference-engine/samples/hello_classification/CMakeLists.txt +++ b/inference-engine/samples/hello_classification/CMakeLists.txt @@ -4,6 +4,6 @@ ie_add_sample(NAME hello_classification SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/main.cpp" - DEPENDENCIES ie_samples_utils + DEPENDENCIES ie_samples_utils frontend_manager OPENCV_DEPENDENCIES core imgcodecs) diff --git a/inference-engine/samples/hello_classification/main.cpp b/inference-engine/samples/hello_classification/main.cpp index 84998fada4fa76..74cfd1e58489e5 100644 --- a/inference-engine/samples/hello_classification/main.cpp +++ b/inference-engine/samples/hello_classification/main.cpp @@ -11,6 +11,8 @@ #include #include #include +#include + using namespace InferenceEngine; @@ -88,7 +90,14 @@ int main(int argc, char *argv[]) { // 2. Read a model in OpenVINO Intermediate Representation (.xml and .bin files) or ONNX (.onnx file) format CNNNetwork network = ie.ReadNetwork(input_model); - if (network.getOutputsInfo().size() != 1) throw std::logic_error("Sample supports topologies with 1 output only"); +// ngraph::frontend::FrontEndManager manager; +// auto FE = manager.loadByFramework("pdpd"); +// auto inputModel = FE->loadFromFile(input_model); +// //inputModel->setPartialShape(inputModel->getInputs()[0], ngraph::PartialShape({1, 224, 224, 3})); +// auto ngFunc = FE->convert(inputModel); +// CNNNetwork network(ngFunc); + + //if (network.getOutputsInfo().size() != 1) throw std::logic_error("Sample supports topologies with 1 output only"); if (network.getInputsInfo().size() != 1) throw std::logic_error("Sample supports topologies with 1 input only"); // ----------------------------------------------------------------------------------------------------- @@ -105,10 +114,14 @@ int main(int argc, char *argv[]) { input_info->setPrecision(Precision::U8); // --------------------------- Prepare output blobs ---------------------------------------------------- - DataPtr output_info = network.getOutputsInfo().begin()->second; - std::string output_name = network.getOutputsInfo().begin()->first; + std::vector output_info; + std::vector output_name; + for (auto &out : network.getOutputsInfo()) { + out.second->setPrecision(Precision::FP32); + output_info.push_back(out.second); + output_name.push_back(out.first); + } - output_info->setPrecision(Precision::FP32); // ----------------------------------------------------------------------------------------------------- // --------------------------- 4. Loading model to the device ------------------------------------------ @@ -132,10 +145,12 @@ int main(int argc, char *argv[]) { // ----------------------------------------------------------------------------------------------------- // --------------------------- 8. Process output ------------------------------------------------------ - Blob::Ptr output = infer_request.GetBlob(output_name); - // Print classification results - ClassificationResult_t classificationResult(output, {input_image_path}); - classificationResult.print(); + for (auto name : output_name) { + Blob::Ptr output = infer_request.GetBlob(name); + // Print classification results + ClassificationResult_t classificationResult(output, {input_image_path}); + classificationResult.print(); + } // ----------------------------------------------------------------------------------------------------- } catch (const std::exception & ex) { std::cerr << ex.what() << std::endl; From 53dabc6b603fd4f78edec31806e53de38814a29e Mon Sep 17 00:00:00 2001 From: mbencer Date: Wed, 7 Apr 2021 09:26:10 +0200 Subject: [PATCH 101/116] Introduced find_output_consumers --- .../include/onnx_editor/edge_mapper.hpp | 10 ++++++ .../include/onnx_editor/editor.hpp | 9 +++++ .../frontend/onnx_editor/src/edge_mapper.cpp | 16 +++++++++ ngraph/frontend/onnx_editor/src/editor.cpp | 7 ++++ ngraph/test/onnx/onnx_editor.cpp | 36 +++++++++++++++++++ 5 files changed, 78 insertions(+) diff --git a/ngraph/frontend/onnx_editor/include/onnx_editor/edge_mapper.hpp b/ngraph/frontend/onnx_editor/include/onnx_editor/edge_mapper.hpp index a4dbb9378998e7..ba585f18d632be 100644 --- a/ngraph/frontend/onnx_editor/include/onnx_editor/edge_mapper.hpp +++ b/ngraph/frontend/onnx_editor/include/onnx_editor/edge_mapper.hpp @@ -84,6 +84,15 @@ namespace ngraph /// void update(const ONNX_NAMESPACE::GraphProto& graph_proto); + /// \brief Returns a vector of InputEdges which consume an output of a node + /// determined by provided output name. + /// + /// \note The output name is deterministic in the ONNX standard. + /// + /// \param output_name A node output name. + /// + std::vector find_output_consumers(const std::string& output_name) const; + private: std::vector find_node_indexes(const std::string& node_name, const std::string& output_name) const; @@ -93,6 +102,7 @@ namespace ngraph std::vector> m_node_inputs; std::vector> m_node_outputs; std::multimap m_node_name_to_index; + std::multimap m_output_consumers_index; }; } } diff --git a/ngraph/frontend/onnx_editor/include/onnx_editor/editor.hpp b/ngraph/frontend/onnx_editor/include/onnx_editor/editor.hpp index 3f8cd2b6d1154b..e1d786bf98564c 100644 --- a/ngraph/frontend/onnx_editor/include/onnx_editor/editor.hpp +++ b/ngraph/frontend/onnx_editor/include/onnx_editor/editor.hpp @@ -153,6 +153,15 @@ namespace ngraph /// OutputEdge find_output_edge(const std::string& output_name); + /// \brief Returns a vector of InputEdges which consume an output of a node + /// determined by provided output name. + /// + /// \note The output name is deterministic in the ONNX standard. + /// + /// \param output_name A node output name. + /// + std::vector find_output_consumers(const std::string& output_name); + private: void update_mapper_if_needed(); diff --git a/ngraph/frontend/onnx_editor/src/edge_mapper.cpp b/ngraph/frontend/onnx_editor/src/edge_mapper.cpp index b3e89e05fbd583..7058ed6f4b0a53 100644 --- a/ngraph/frontend/onnx_editor/src/edge_mapper.cpp +++ b/ngraph/frontend/onnx_editor/src/edge_mapper.cpp @@ -32,11 +32,13 @@ void onnx_editor::EdgeMapper::update(const ONNX_NAMESPACE::GraphProto& graph_pro { // node output name is unique m_node_name_to_index.emplace(out_name, topological_index); + std::cout << out_name << " -- " << topological_index << "\n"; m_node_outputs[topological_index].push_back(out_name); } for (const auto& in_name : node_proto.input()) { m_node_inputs[topological_index].push_back(in_name); + m_output_consumers_index.emplace(in_name, topological_index); } if (!node_proto.name().empty()) { @@ -223,3 +225,17 @@ OutputEdge onnx_editor::EdgeMapper::find_output_edge(const std::string& output_n { return find_output_edge(EditorNode{EditorOutput{output_name}}, EditorOutput{output_name}); } + +std::vector + onnx_editor::EdgeMapper::find_output_consumers(const std::string& output_name) const +{ + const auto matched_nodes_range = m_output_consumers_index.equal_range(output_name); + std::vector input_edges; + std::transform(matched_nodes_range.first, + matched_nodes_range.second, + std::back_inserter(input_edges), + [&output_name](const std::pair& iter) { + return InputEdge{iter.second, output_name}; + }); + return input_edges; +} diff --git a/ngraph/frontend/onnx_editor/src/editor.cpp b/ngraph/frontend/onnx_editor/src/editor.cpp index bf1b156da4353d..b01f977d07abae 100644 --- a/ngraph/frontend/onnx_editor/src/editor.cpp +++ b/ngraph/frontend/onnx_editor/src/editor.cpp @@ -389,3 +389,10 @@ OutputEdge onnx_editor::ONNXModelEditor::find_output_edge(const std::string& out update_mapper_if_needed(); return m_edge_mapper.find_output_edge(output_name); } + +std::vector + onnx_editor::ONNXModelEditor::find_output_consumers(const std::string& output_name) +{ + update_mapper_if_needed(); + return m_edge_mapper.find_output_consumers(output_name); +} diff --git a/ngraph/test/onnx/onnx_editor.cpp b/ngraph/test/onnx/onnx_editor.cpp index 008ec4540cbe5c..dc3a81e228d1f9 100644 --- a/ngraph/test/onnx/onnx_editor.cpp +++ b/ngraph/test/onnx/onnx_editor.cpp @@ -1070,6 +1070,42 @@ NGRAPH_TEST(onnx_editor, editor_api_use_edge_mapper_with_graph_cutter) EXPECT_EQ(output_edge_3.m_tensor_name, "mul2"); } +NGRAPH_TEST(onnx_editor, editor_api_find_output_consumers) +{ + ONNXModelEditor editor{file_util::path_join( + SERIALIZED_ZOO, "onnx/model_editor/subgraph_extraction_tests.prototxt")}; + + std::vector output_consumers = editor.find_output_consumers("relu1"); + EXPECT_EQ(output_consumers.size(), 3); + EXPECT_EQ(output_consumers[0].m_node_idx, 1); + EXPECT_EQ(output_consumers[0].m_tensor_name, "relu1"); + EXPECT_EQ(output_consumers[1].m_node_idx, 3); + EXPECT_EQ(output_consumers[1].m_tensor_name, "relu1"); + EXPECT_EQ(output_consumers[2].m_node_idx, 6); + EXPECT_EQ(output_consumers[2].m_tensor_name, "relu1"); + + output_consumers = editor.find_output_consumers("add1"); + EXPECT_EQ(output_consumers.size(), 2); + EXPECT_EQ(output_consumers[0].m_node_idx, 3); + EXPECT_EQ(output_consumers[0].m_tensor_name, "add1"); + EXPECT_EQ(output_consumers[1].m_node_idx, 4); + EXPECT_EQ(output_consumers[1].m_tensor_name, "add1"); + + output_consumers = editor.find_output_consumers("in3"); + EXPECT_EQ(output_consumers.size(), 1); + EXPECT_EQ(output_consumers[0].m_node_idx, 2); + EXPECT_EQ(output_consumers[0].m_tensor_name, "in3"); +} + +NGRAPH_TEST(onnx_editor, editor_api_find_output_consumers_empty_result) +{ + ONNXModelEditor editor{file_util::path_join( + SERIALIZED_ZOO, "onnx/model_editor/subgraph_extraction_tests.prototxt")}; + + const std::vector output_consumers = editor.find_output_consumers("not_existed"); + EXPECT_EQ(output_consumers.size(), 0); +} + using TestEngine = test::INTERPRETER_Engine; NGRAPH_TEST(onnx_editor, values__append_one_initializer) From d990628617c47632843fe593422d58a250bff905 Mon Sep 17 00:00:00 2001 From: mbencer Date: Wed, 7 Apr 2021 09:41:58 +0200 Subject: [PATCH 102/116] hide m_edge_mapper using pimpl --- .../onnx_editor/include/onnx_editor/editor.hpp | 2 -- ngraph/frontend/onnx_editor/src/editor.cpp | 12 +++++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ngraph/frontend/onnx_editor/include/onnx_editor/editor.hpp b/ngraph/frontend/onnx_editor/include/onnx_editor/editor.hpp index e1d786bf98564c..fab830b230daca 100644 --- a/ngraph/frontend/onnx_editor/include/onnx_editor/editor.hpp +++ b/ngraph/frontend/onnx_editor/include/onnx_editor/editor.hpp @@ -11,7 +11,6 @@ #include "ngraph/op/constant.hpp" #include "ngraph/partial_shape.hpp" #include "ngraph/type/element_type.hpp" -#include "onnx_editor/edge_mapper.hpp" #include "onnx_editor/editor.hpp" #include "onnx_editor/editor_types.hpp" @@ -170,7 +169,6 @@ namespace ngraph struct Impl; std::unique_ptr m_pimpl; - EdgeMapper m_edge_mapper; }; } // namespace onnx_editor } // namespace ngraph diff --git a/ngraph/frontend/onnx_editor/src/editor.cpp b/ngraph/frontend/onnx_editor/src/editor.cpp index b01f977d07abae..feeddbefd50a80 100644 --- a/ngraph/frontend/onnx_editor/src/editor.cpp +++ b/ngraph/frontend/onnx_editor/src/editor.cpp @@ -10,6 +10,7 @@ #include "ngraph/log.hpp" #include "onnx_common/parser.hpp" #include "onnx_common/utils.hpp" +#include "onnx_editor/edge_mapper.hpp" #include "onnx_editor/editor.hpp" using namespace ngraph; @@ -200,6 +201,7 @@ namespace struct onnx_editor::ONNXModelEditor::Impl { ONNX_NAMESPACE::ModelProto m_model_proto; + EdgeMapper m_edge_mapper; Impl() = delete; @@ -365,7 +367,7 @@ void onnx_editor::ONNXModelEditor::update_mapper_if_needed() { if (!m_is_mapper_updated) { - m_edge_mapper.update(m_pimpl->m_model_proto.graph()); + m_pimpl->m_edge_mapper.update(m_pimpl->m_model_proto.graph()); } m_is_mapper_updated = true; } @@ -374,25 +376,25 @@ InputEdge onnx_editor::ONNXModelEditor::find_input_edge(const EditorNode& node, const EditorInput& input) { update_mapper_if_needed(); - return m_edge_mapper.find_input_edge(node, input); + return m_pimpl->m_edge_mapper.find_input_edge(node, input); } OutputEdge onnx_editor::ONNXModelEditor::find_output_edge(const EditorNode& node, const EditorOutput& input) { update_mapper_if_needed(); - return m_edge_mapper.find_output_edge(node, input); + return m_pimpl->m_edge_mapper.find_output_edge(node, input); } OutputEdge onnx_editor::ONNXModelEditor::find_output_edge(const std::string& output_name) { update_mapper_if_needed(); - return m_edge_mapper.find_output_edge(output_name); + return m_pimpl->m_edge_mapper.find_output_edge(output_name); } std::vector onnx_editor::ONNXModelEditor::find_output_consumers(const std::string& output_name) { update_mapper_if_needed(); - return m_edge_mapper.find_output_consumers(output_name); + return m_pimpl->m_edge_mapper.find_output_consumers(output_name); } From 186be2ec67b8be338aa4d90928d4b1553a504714 Mon Sep 17 00:00:00 2001 From: mbencer Date: Wed, 7 Apr 2021 10:26:36 +0200 Subject: [PATCH 103/116] make find_* methods const --- .../include/onnx_editor/edge_mapper.hpp | 6 ------ .../include/onnx_editor/editor.hpp | 11 +++++----- .../frontend/onnx_editor/src/edge_mapper.cpp | 15 ++------------ ngraph/frontend/onnx_editor/src/editor.cpp | 20 +++++++++---------- 4 files changed, 17 insertions(+), 35 deletions(-) diff --git a/ngraph/frontend/onnx_editor/include/onnx_editor/edge_mapper.hpp b/ngraph/frontend/onnx_editor/include/onnx_editor/edge_mapper.hpp index ba585f18d632be..87cd67be0c96dc 100644 --- a/ngraph/frontend/onnx_editor/include/onnx_editor/edge_mapper.hpp +++ b/ngraph/frontend/onnx_editor/include/onnx_editor/edge_mapper.hpp @@ -78,12 +78,6 @@ namespace ngraph /// OutputEdge find_output_edge(const std::string& output_name) const; - /// \brief Updates state of a EdgeMapper instance if a model was changed. - /// - /// \param graph_proto Reference to a GraphProto object. - /// - void update(const ONNX_NAMESPACE::GraphProto& graph_proto); - /// \brief Returns a vector of InputEdges which consume an output of a node /// determined by provided output name. /// diff --git a/ngraph/frontend/onnx_editor/include/onnx_editor/editor.hpp b/ngraph/frontend/onnx_editor/include/onnx_editor/editor.hpp index fab830b230daca..a1a98c071b8e51 100644 --- a/ngraph/frontend/onnx_editor/include/onnx_editor/editor.hpp +++ b/ngraph/frontend/onnx_editor/include/onnx_editor/editor.hpp @@ -125,7 +125,7 @@ namespace ngraph /// /// \param input An input helper structure created based on a input name /// or a input index. - InputEdge find_input_edge(const EditorNode& node, const EditorInput& input); + InputEdge find_input_edge(const EditorNode& node, const EditorInput& input) const; /// \brief Returns an OutputEdge based on a node (node name or output name) /// and an output (output name or output index). @@ -142,7 +142,7 @@ namespace ngraph /// /// \param output A output helper structure created based on a output name /// or a output index. - OutputEdge find_output_edge(const EditorNode& node, const EditorOutput& output); + OutputEdge find_output_edge(const EditorNode& node, const EditorOutput& output) const; /// \brief Returns an OutputEdge based on a output name. /// @@ -150,7 +150,7 @@ namespace ngraph /// /// \param output_name A node output name. /// - OutputEdge find_output_edge(const std::string& output_name); + OutputEdge find_output_edge(const std::string& output_name) const; /// \brief Returns a vector of InputEdges which consume an output of a node /// determined by provided output name. @@ -159,13 +159,12 @@ namespace ngraph /// /// \param output_name A node output name. /// - std::vector find_output_consumers(const std::string& output_name); + std::vector find_output_consumers(const std::string& output_name) const; private: - void update_mapper_if_needed(); + void update_mapper_if_needed() const; const std::string m_model_path; - bool m_is_mapper_updated; struct Impl; std::unique_ptr m_pimpl; diff --git a/ngraph/frontend/onnx_editor/src/edge_mapper.cpp b/ngraph/frontend/onnx_editor/src/edge_mapper.cpp index 7058ed6f4b0a53..a75a38d34d0d2c 100644 --- a/ngraph/frontend/onnx_editor/src/edge_mapper.cpp +++ b/ngraph/frontend/onnx_editor/src/edge_mapper.cpp @@ -12,27 +12,16 @@ using namespace ngraph; using namespace ngraph::onnx_editor; onnx_editor::EdgeMapper::EdgeMapper(const ONNX_NAMESPACE::GraphProto& graph_proto) + : m_node_inputs(graph_proto.node().size()) + , m_node_outputs(graph_proto.node().size()) { - update(graph_proto); -} - -void onnx_editor::EdgeMapper::update(const ONNX_NAMESPACE::GraphProto& graph_proto) -{ - // reset state - m_node_inputs.clear(); - m_node_outputs.clear(); - m_node_name_to_index.clear(); - int topological_index = 0; - m_node_inputs.resize(graph_proto.node().size()); - m_node_outputs.resize(graph_proto.node().size()); for (const auto& node_proto : graph_proto.node()) { for (const auto& out_name : node_proto.output()) { // node output name is unique m_node_name_to_index.emplace(out_name, topological_index); - std::cout << out_name << " -- " << topological_index << "\n"; m_node_outputs[topological_index].push_back(out_name); } for (const auto& in_name : node_proto.input()) diff --git a/ngraph/frontend/onnx_editor/src/editor.cpp b/ngraph/frontend/onnx_editor/src/editor.cpp index feeddbefd50a80..ac856eeb26b69f 100644 --- a/ngraph/frontend/onnx_editor/src/editor.cpp +++ b/ngraph/frontend/onnx_editor/src/editor.cpp @@ -202,6 +202,7 @@ struct onnx_editor::ONNXModelEditor::Impl { ONNX_NAMESPACE::ModelProto m_model_proto; EdgeMapper m_edge_mapper; + bool m_is_mapper_updated = false; Impl() = delete; @@ -216,7 +217,6 @@ struct onnx_editor::ONNXModelEditor::Impl onnx_editor::ONNXModelEditor::ONNXModelEditor(const std::string& model_path) : m_pimpl{new ONNXModelEditor::Impl{model_path}, [](Impl* impl) { delete impl; }} - , m_is_mapper_updated{false} , m_model_path{model_path} { } @@ -307,7 +307,7 @@ void onnx_editor::ONNXModelEditor::cut_graph_fragment(const std::vectorremove_shape_inference_info(); - m_is_mapper_updated = false; + m_pimpl->m_is_mapper_updated = false; } std::vector onnx_editor::ONNXModelEditor::model_inputs() const @@ -363,37 +363,37 @@ void onnx_editor::ONNXModelEditor::set_input_values( } } -void onnx_editor::ONNXModelEditor::update_mapper_if_needed() +void onnx_editor::ONNXModelEditor::update_mapper_if_needed() const { - if (!m_is_mapper_updated) + if (!m_pimpl->m_is_mapper_updated) { - m_pimpl->m_edge_mapper.update(m_pimpl->m_model_proto.graph()); + m_pimpl->m_edge_mapper = EdgeMapper(m_pimpl->m_model_proto.graph()); } - m_is_mapper_updated = true; + m_pimpl->m_is_mapper_updated = true; } InputEdge onnx_editor::ONNXModelEditor::find_input_edge(const EditorNode& node, - const EditorInput& input) + const EditorInput& input) const { update_mapper_if_needed(); return m_pimpl->m_edge_mapper.find_input_edge(node, input); } OutputEdge onnx_editor::ONNXModelEditor::find_output_edge(const EditorNode& node, - const EditorOutput& input) + const EditorOutput& input) const { update_mapper_if_needed(); return m_pimpl->m_edge_mapper.find_output_edge(node, input); } -OutputEdge onnx_editor::ONNXModelEditor::find_output_edge(const std::string& output_name) +OutputEdge onnx_editor::ONNXModelEditor::find_output_edge(const std::string& output_name) const { update_mapper_if_needed(); return m_pimpl->m_edge_mapper.find_output_edge(output_name); } std::vector - onnx_editor::ONNXModelEditor::find_output_consumers(const std::string& output_name) + onnx_editor::ONNXModelEditor::find_output_consumers(const std::string& output_name) const { update_mapper_if_needed(); return m_pimpl->m_edge_mapper.find_output_consumers(output_name); From 3ffdb48edb87a78c70359b44b60e39eef1018de9 Mon Sep 17 00:00:00 2001 From: mbencer Date: Wed, 7 Apr 2021 14:00:54 +0200 Subject: [PATCH 104/116] introduced is_correct_and_unambiguous_node method --- .../include/onnx_editor/edge_mapper.hpp | 9 ++++++ .../include/onnx_editor/editor.hpp | 9 ++++++ .../frontend/onnx_editor/src/edge_mapper.cpp | 29 ++++++++++++++----- ngraph/frontend/onnx_editor/src/editor.cpp | 6 ++++ ngraph/test/onnx/onnx_editor.cpp | 27 +++++++++++++++++ 5 files changed, 72 insertions(+), 8 deletions(-) diff --git a/ngraph/frontend/onnx_editor/include/onnx_editor/edge_mapper.hpp b/ngraph/frontend/onnx_editor/include/onnx_editor/edge_mapper.hpp index 87cd67be0c96dc..70d19be65a4b51 100644 --- a/ngraph/frontend/onnx_editor/include/onnx_editor/edge_mapper.hpp +++ b/ngraph/frontend/onnx_editor/include/onnx_editor/edge_mapper.hpp @@ -87,6 +87,15 @@ namespace ngraph /// std::vector find_output_consumers(const std::string& output_name) const; + /// \brief Returns true if a provided node is correct (exists in a graph) + /// and is not ambiguous (identification of an ONNX node can be ambiguous + /// if an only tensor name is provided). + /// + /// \param node An EditorNode helper structure created based on a node name + /// or a node output name. + /// + bool is_correct_and_unambiguous_node(const EditorNode& node) const; + private: std::vector find_node_indexes(const std::string& node_name, const std::string& output_name) const; diff --git a/ngraph/frontend/onnx_editor/include/onnx_editor/editor.hpp b/ngraph/frontend/onnx_editor/include/onnx_editor/editor.hpp index f9cf8c69e24e5c..b93b568141e287 100644 --- a/ngraph/frontend/onnx_editor/include/onnx_editor/editor.hpp +++ b/ngraph/frontend/onnx_editor/include/onnx_editor/editor.hpp @@ -159,6 +159,15 @@ namespace ngraph /// std::vector find_output_consumers(const std::string& output_name) const; + /// \brief Returns a vector of InputEdges which consume an output of a node + /// determined by provided output name. + /// + /// \note The output name is deterministic in the ONNX standard. + /// + /// \param output_name A node output name. + /// + bool is_correct_and_unambiguous_node(const EditorNode& node) const; + private: void update_mapper_if_needed() const; diff --git a/ngraph/frontend/onnx_editor/src/edge_mapper.cpp b/ngraph/frontend/onnx_editor/src/edge_mapper.cpp index a75a38d34d0d2c..73cf26746c1f6e 100644 --- a/ngraph/frontend/onnx_editor/src/edge_mapper.cpp +++ b/ngraph/frontend/onnx_editor/src/edge_mapper.cpp @@ -49,22 +49,16 @@ std::vector onnx_editor::EdgeMapper::find_node_indexes(const std::string& n return std::vector{index_iter->second}; } } + std::vector result; if (!node_name.empty()) { const auto matched_nodes_range = m_node_name_to_index.equal_range(node_name); - std::vector result; std::transform(matched_nodes_range.first, matched_nodes_range.second, std::back_inserter(result), [](const std::pair& iter) { return iter.second; }); - if (!result.empty()) - { - return result; - } } - throw ngraph_error("Node with name: " + (node_name.empty() ? "not_given" : node_name) + - " and output_name: " + (output_name.empty() ? "not_given" : output_name) + - " was not found"); + return result; }; std::string onnx_editor::EdgeMapper::get_node_output_name(int node_index, int output_index) const @@ -109,6 +103,13 @@ InputEdge onnx_editor::EdgeMapper::find_input_edge(const EditorNode& node, { node_index = node_indexes[0]; } + else if (node_indexes.empty()) + { + throw ngraph_error( + "Node with name: " + (node.m_node_name.empty() ? "not_given" : node.m_node_name) + + " and output_name: " + (node.m_output_name.empty() ? "not_given" : node.m_output_name) + + " was not found"); + } else if (!in.m_input_name .empty()) // input indexes are not deterministic if a node name is ambiguous { @@ -167,6 +168,13 @@ OutputEdge onnx_editor::EdgeMapper::find_output_edge(const EditorNode& node, { node_index = node_indexes[0]; } + else if (node_indexes.empty()) + { + throw ngraph_error( + "Node with name: " + (node.m_node_name.empty() ? "not_given" : node.m_node_name) + + " and output_name: " + (node.m_output_name.empty() ? "not_given" : node.m_output_name) + + " was not found"); + } else if (!out.m_output_name .empty()) // output indexes are not deterministic if a node name is ambiguous { @@ -228,3 +236,8 @@ std::vector }); return input_edges; } + +bool onnx_editor::EdgeMapper::is_correct_and_unambiguous_node(const EditorNode& node) const +{ + return find_node_indexes(node.m_node_name, node.m_output_name).size() == 1; +} diff --git a/ngraph/frontend/onnx_editor/src/editor.cpp b/ngraph/frontend/onnx_editor/src/editor.cpp index 30f03b18d43278..abdc891b56437f 100644 --- a/ngraph/frontend/onnx_editor/src/editor.cpp +++ b/ngraph/frontend/onnx_editor/src/editor.cpp @@ -399,3 +399,9 @@ std::vector update_mapper_if_needed(); return m_pimpl->m_edge_mapper.find_output_consumers(output_name); } + +bool onnx_editor::ONNXModelEditor::is_correct_and_unambiguous_node(const EditorNode& node) const +{ + update_mapper_if_needed(); + return m_pimpl->m_edge_mapper.is_correct_and_unambiguous_node(node); +} diff --git a/ngraph/test/onnx/onnx_editor.cpp b/ngraph/test/onnx/onnx_editor.cpp index 372b2a15320bdd..8e9789218bad9a 100644 --- a/ngraph/test/onnx/onnx_editor.cpp +++ b/ngraph/test/onnx/onnx_editor.cpp @@ -1088,6 +1088,33 @@ NGRAPH_TEST(onnx_editor, editor_api_find_output_consumers_empty_result) EXPECT_EQ(output_consumers.size(), 0); } +NGRAPH_TEST(onnx_editor, editor_api_is_correct_and_unambiguous_node) +{ + ONNXModelEditor editor{file_util::path_join( + SERIALIZED_ZOO, "onnx/model_editor/subgraph_extraction_tests.prototxt")}; + + bool is_correct_node = editor.is_correct_and_unambiguous_node(EditorNode{EditorOutput{"relu1"}}); + EXPECT_EQ(is_correct_node, true); + + is_correct_node = editor.is_correct_and_unambiguous_node(EditorNode{EditorOutput{"mul2"}}); + EXPECT_EQ(is_correct_node, true); + + is_correct_node = editor.is_correct_and_unambiguous_node(EditorNode{EditorOutput{"split2"}}); + EXPECT_EQ(is_correct_node, true); + + is_correct_node = editor.is_correct_and_unambiguous_node(EditorNode{"relu1_name"}); + EXPECT_EQ(is_correct_node, true); + + is_correct_node = editor.is_correct_and_unambiguous_node(EditorNode{EditorOutput{"in3"}}); + EXPECT_EQ(is_correct_node, false); + + is_correct_node = editor.is_correct_and_unambiguous_node(EditorNode{"add_ambiguous_name"}); + EXPECT_EQ(is_correct_node, false); + + is_correct_node = editor.is_correct_and_unambiguous_node(EditorNode{"not_exist"}); + EXPECT_EQ(is_correct_node, false); +} + using TestEngine = test::INTERPRETER_Engine; NGRAPH_TEST(onnx_editor, values__append_one_initializer) From 2ff3c6d80f3be91e5f159b782d18e6fe9c1ebcfd Mon Sep 17 00:00:00 2001 From: "Lyalin, Sergey" Date: Wed, 7 Apr 2021 19:38:43 +0300 Subject: [PATCH 105/116] Small test scenariou update in benchmark_app for subgraph extracting for onnx model (doesn't work) --- inference-engine/samples/benchmark_app/main.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/inference-engine/samples/benchmark_app/main.cpp b/inference-engine/samples/benchmark_app/main.cpp index 478d3a664a3d2d..b2f1ea9ba30382 100644 --- a/inference-engine/samples/benchmark_app/main.cpp +++ b/inference-engine/samples/benchmark_app/main.cpp @@ -348,6 +348,9 @@ int main(int argc, char *argv[]) { auto FE = manager.loadByFramework("onnx"); auto inputModel = FE->loadFromFile(FLAGS_m); //inputModel->setPartialShape(inputModel->getInputs()[0], ngraph::PartialShape({1, 224, 224, 3})); + auto new_input = inputModel->getPlaceByTensorName("resnetv17_conv0_fwd"); + inputModel->extractSubgraph({inputModel->getPlaceByTensorName("resnetv17_conv0_fwd")}, {}); + inputModel->setPartialShape(new_input, ngraph::PartialShape({1, 64, 112, 112})); #if 0 auto ngFunc = FE->convert(inputModel); #else From 641d6a9d0bb9d7ebb5dad79d8119f4145a6ef162 Mon Sep 17 00:00:00 2001 From: mbencer Date: Thu, 8 Apr 2021 11:52:35 +0200 Subject: [PATCH 106/116] separate node names and node output names --- .../include/onnx_editor/edge_mapper.hpp | 1 + ngraph/frontend/onnx_editor/src/edge_mapper.cpp | 6 +++--- .../subgraph_extraction_tests_2.prototxt | 1 + ngraph/test/onnx/onnx_editor.cpp | 14 ++++++++++++++ 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/ngraph/frontend/onnx_editor/include/onnx_editor/edge_mapper.hpp b/ngraph/frontend/onnx_editor/include/onnx_editor/edge_mapper.hpp index 70d19be65a4b51..95e612807021db 100644 --- a/ngraph/frontend/onnx_editor/include/onnx_editor/edge_mapper.hpp +++ b/ngraph/frontend/onnx_editor/include/onnx_editor/edge_mapper.hpp @@ -105,6 +105,7 @@ namespace ngraph std::vector> m_node_inputs; std::vector> m_node_outputs; std::multimap m_node_name_to_index; + std::map m_node_output_name_to_index; std::multimap m_output_consumers_index; }; } diff --git a/ngraph/frontend/onnx_editor/src/edge_mapper.cpp b/ngraph/frontend/onnx_editor/src/edge_mapper.cpp index 73cf26746c1f6e..50c02740393c50 100644 --- a/ngraph/frontend/onnx_editor/src/edge_mapper.cpp +++ b/ngraph/frontend/onnx_editor/src/edge_mapper.cpp @@ -21,7 +21,7 @@ onnx_editor::EdgeMapper::EdgeMapper(const ONNX_NAMESPACE::GraphProto& graph_prot for (const auto& out_name : node_proto.output()) { // node output name is unique - m_node_name_to_index.emplace(out_name, topological_index); + m_node_output_name_to_index.emplace(out_name, topological_index); m_node_outputs[topological_index].push_back(out_name); } for (const auto& in_name : node_proto.input()) @@ -43,8 +43,8 @@ std::vector onnx_editor::EdgeMapper::find_node_indexes(const std::string& n { if (!output_name.empty()) { - const auto& index_iter = m_node_name_to_index.find(output_name); - if (index_iter != std::end(m_node_name_to_index)) + const auto& index_iter = m_node_output_name_to_index.find(output_name); + if (index_iter != std::end(m_node_output_name_to_index)) { return std::vector{index_iter->second}; } diff --git a/ngraph/test/models/onnx/model_editor/subgraph_extraction_tests_2.prototxt b/ngraph/test/models/onnx/model_editor/subgraph_extraction_tests_2.prototxt index 7982b52d1bc78a..a5fbee597db549 100644 --- a/ngraph/test/models/onnx/model_editor/subgraph_extraction_tests_2.prototxt +++ b/ngraph/test/models/onnx/model_editor/subgraph_extraction_tests_2.prototxt @@ -5,6 +5,7 @@ graph { input: "in1" output: "relu1" op_type: "Relu" + name: "add1" } node { input: "in1" diff --git a/ngraph/test/onnx/onnx_editor.cpp b/ngraph/test/onnx/onnx_editor.cpp index 8e9789218bad9a..f31d8ec6d7c0d7 100644 --- a/ngraph/test/onnx/onnx_editor.cpp +++ b/ngraph/test/onnx/onnx_editor.cpp @@ -975,6 +975,20 @@ NGRAPH_TEST(onnx_editor, editor_api_select_output_edge_by_ambiguous_node_name_bu EXPECT_EQ(edge2.m_tensor_name, "add2"); } +NGRAPH_TEST(onnx_editor, editor_api_select_output_edge_by_the_same_node_name_and_output_name) +{ + ONNXModelEditor editor{file_util::path_join( + SERIALIZED_ZOO, "onnx/model_editor/subgraph_extraction_tests_2.prototxt")}; + + const OutputEdge edge = editor.find_output_edge(EditorNode{"add1"}, EditorOutput{0}); + EXPECT_EQ(edge.m_node_idx, 0); + EXPECT_EQ(edge.m_tensor_name, "relu1"); + + const OutputEdge edge2 = editor.find_output_edge(EditorNode{EditorOutput{"add1"}}, EditorOutput{0}); + EXPECT_EQ(edge2.m_node_idx, 4); + EXPECT_EQ(edge2.m_tensor_name, "add1"); +} + NGRAPH_TEST(onnx_editor, editor_api_select_output_edge_by_ambiguous_node_name_and_not_matched_output) { ONNXModelEditor editor{file_util::path_join( From 23d840aef1312f687e094e2ddb71d7acdccbb173 Mon Sep 17 00:00:00 2001 From: "Lyalin, Sergey" Date: Thu, 8 Apr 2021 13:18:36 +0300 Subject: [PATCH 107/116] Fixed stupid error that prevented benchmark_app from correct build --- ngraph/frontend/onnx_import/include/onnx_import/onnx.hpp | 6 ------ .../onnx_import/include/onnx_import/utils/onnx_internal.hpp | 4 ++++ ngraph/frontend/onnx_import/src/utils/onnx_internal.cpp | 2 +- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/ngraph/frontend/onnx_import/include/onnx_import/onnx.hpp b/ngraph/frontend/onnx_import/include/onnx_import/onnx.hpp index 1d9722c3e21404..d98338046404d1 100644 --- a/ngraph/frontend/onnx_import/include/onnx_import/onnx.hpp +++ b/ngraph/frontend/onnx_import/include/onnx_import/onnx.hpp @@ -79,12 +79,6 @@ namespace ngraph ONNX_IMPORTER_API std::shared_ptr import_onnx_model(const std::string& file_path, bool decode_only = false); - // TODO: Hide behind an appropriate API; Exposes ONNX_NAMESPACE; provide correct importer -> editor dependency - namespace detail { - ONNX_IMPORTER_API - std::shared_ptr - convert_to_ng_function(std::shared_ptr model_proto, bool decode_only); - } ONNX_IMPORTER_API void convert_onnx_nodes (std::shared_ptr f); diff --git a/ngraph/frontend/onnx_import/include/onnx_import/utils/onnx_internal.hpp b/ngraph/frontend/onnx_import/include/onnx_import/utils/onnx_internal.hpp index 263e257daac36f..eb54502d11e234 100644 --- a/ngraph/frontend/onnx_import/include/onnx_import/utils/onnx_internal.hpp +++ b/ngraph/frontend/onnx_import/include/onnx_import/utils/onnx_internal.hpp @@ -21,6 +21,10 @@ namespace ngraph { namespace detail { + ONNX_IMPORTER_API + std::shared_ptr + convert_to_ng_function(std::shared_ptr model_proto, bool decode_only); + /// \brief Imports and converts an serialized ONNX model from a ModelProto /// to an nGraph Function representation. /// diff --git a/ngraph/frontend/onnx_import/src/utils/onnx_internal.cpp b/ngraph/frontend/onnx_import/src/utils/onnx_internal.cpp index aeade53f1a8fb5..66348fafc015d7 100644 --- a/ngraph/frontend/onnx_import/src/utils/onnx_internal.cpp +++ b/ngraph/frontend/onnx_import/src/utils/onnx_internal.cpp @@ -49,7 +49,7 @@ namespace ngraph transform::fixup_legacy_operators(*model_proto); transform::update_external_data_paths(*model_proto, model_path); - return detail::convert_to_ng_function(model_proto, decode_only); + return convert_to_ng_function(model_proto, decode_only); } } // namespace detail } // namespace onnx_import From 844a8d517bb466cee19c4dfa69718608df4fc6ba Mon Sep 17 00:00:00 2001 From: "Lyalin, Sergey" Date: Thu, 8 Apr 2021 20:41:48 +0300 Subject: [PATCH 108/116] Added test cases for overriding input and outputs --- .../samples/benchmark_app/main.cpp | 61 +++++++++++++++++-- 1 file changed, 55 insertions(+), 6 deletions(-) diff --git a/inference-engine/samples/benchmark_app/main.cpp b/inference-engine/samples/benchmark_app/main.cpp index 53a03ac04dee07..c70820a0e8bc12 100644 --- a/inference-engine/samples/benchmark_app/main.cpp +++ b/inference-engine/samples/benchmark_app/main.cpp @@ -347,14 +347,63 @@ int main(int argc, char *argv[]) { ngraph::frontend::FrontEndManager manager; auto FE = manager.loadByFramework("onnx"); auto inputModel = FE->loadFromFile(FLAGS_m); - //inputModel->setPartialShape(inputModel->getInputs()[0], ngraph::PartialShape({1, 224, 224, 3})); - auto new_input = inputModel->getPlaceByTensorName("resnetv17_conv0_fwd"); - inputModel->extractSubgraph({inputModel->getPlaceByTensorName("resnetv17_conv0_fwd")}, {}); - inputModel->setPartialShape(new_input, ngraph::PartialShape({1, 64, 112, 112})); -#if 0 + int test_scenario = 0; + + // The next test cases are applicable for resnet50-v1-7.onnx model from the official repository + + switch (test_scenario) { + case 0: { + inputModel->setPartialShape(inputModel->getInputs()[0], ngraph::PartialShape({10, 3, 224, 224})); + break; + } + case 1: { + auto new_input = inputModel->getPlaceByTensorName("resnetv17_conv0_fwd"); + inputModel->overrideAllInputs({inputModel->getPlaceByTensorName("resnetv17_conv0_fwd")}); + break; + } + case 2: { + auto new_input = inputModel->getPlaceByTensorName("resnetv17_conv0_fwd"); + inputModel->overrideAllInputs({new_input}); + inputModel->setPartialShape(new_input, ngraph::PartialShape({2, 64, 112, 112})); + break; + } + case 3: { + auto new_input = inputModel->getPlaceByTensorName("resnetv17_conv0_fwd"); + inputModel->setPartialShape(new_input, ngraph::PartialShape({2, 64, 112, 112})); + inputModel->overrideAllInputs({new_input}); + break; + } + case 4: { + auto new_input = inputModel->getPlaceByTensorName("resnetv17_conv0_fwd"); + inputModel->setPartialShape(new_input, ngraph::PartialShape({2, 64, 112, 112})); + inputModel->overrideAllInputs({new_input}); + break; + } + case 5: { + // Multiple consumers for a tensor, should be converted to a single Parameter + auto new_input = inputModel->getPlaceByTensorName("resnetv17_pool0_fwd"); + inputModel->overrideAllInputs({new_input}); + break; + } + case 6: { + // Split usages of a tensor to two Parameters; using ports instead of tensors + auto new_input = inputModel->getPlaceByTensorName("resnetv17_pool0_fwd"); + auto ports = new_input->getConsumingPorts(); + inputModel->overrideAllInputs({ports[0], ports[1]}); // it is known there are two ports + break; + } + case 7: { + auto new_output_1 = inputModel->getPlaceByTensorName("resnetv17_stage1_conv2_fwd"); + auto new_output_2 = inputModel->getPlaceByTensorName("resnetv17_stage1_conv3_fwd"); + inputModel->overrideAllOutputs({new_output_1, new_output_2}); + break; + } + } + +#if 1 // Complete convert auto ngFunc = FE->convert(inputModel); -#else +#else // Decode first, than finalize conversion -- should give identical to simple `convert` result auto ngFunc = FE->decode(inputModel); FE->convert(ngFunc); #endif From aa4d7b621cfc475c89d7fffcfc47602890917667 Mon Sep 17 00:00:00 2001 From: tomdol Date: Mon, 12 Apr 2021 15:23:11 -0400 Subject: [PATCH 109/116] Preserve the input names when extracting subgraphs --- .../src/detail/subgraph_extraction.cpp | 8 +++---- ...aph__linear_model_deeper_head_cut.prototxt | 4 ++-- .../subgraph__linear_model_head_cut.prototxt | 4 ++-- ngraph/test/onnx/onnx_editor.cpp | 22 ++++++++++++++++++- 4 files changed, 28 insertions(+), 10 deletions(-) diff --git a/ngraph/frontend/onnx_editor/src/detail/subgraph_extraction.cpp b/ngraph/frontend/onnx_editor/src/detail/subgraph_extraction.cpp index 079c566fd2e9e6..9bd2692e082bc4 100644 --- a/ngraph/frontend/onnx_editor/src/detail/subgraph_extraction.cpp +++ b/ngraph/frontend/onnx_editor/src/detail/subgraph_extraction.cpp @@ -159,8 +159,6 @@ namespace edge.m_node_idx, ". Cannot append a new graph input to this node."); - const std::string new_input_name = target_node.output(0) + ":" + edge.m_tensor_name; - // if an edge is connected to an initializer, the initializer is removed and substituted // with an input if (is_graph_initializer(graph, edge.m_tensor_name)) @@ -173,10 +171,10 @@ namespace auto& new_input = *(graph.add_input()); // copy the intermediate tensor properties to the newly created input new_input.MergeFrom(find_tensor_descriptor(graph, edge.m_tensor_name)); - *(new_input.mutable_name()) = new_input_name; + *(new_input.mutable_name()) = edge.m_tensor_name; // attach the new graph input to the target node's input - *target_input = new_input_name; - return {true, InputEdge{edge.m_node_idx, new_input_name}}; + *target_input = edge.m_tensor_name; + return {true, InputEdge{edge.m_node_idx, edge.m_tensor_name}}; } } diff --git a/ngraph/test/models/onnx/model_editor/reference/subgraph__linear_model_deeper_head_cut.prototxt b/ngraph/test/models/onnx/model_editor/reference/subgraph__linear_model_deeper_head_cut.prototxt index 6c718ff0b39166..bbd569818b26c4 100644 --- a/ngraph/test/models/onnx/model_editor/reference/subgraph__linear_model_deeper_head_cut.prototxt +++ b/ngraph/test/models/onnx/model_editor/reference/subgraph__linear_model_deeper_head_cut.prototxt @@ -4,7 +4,7 @@ doc_string: "This model contains the first few nodes of the ONNX Inception V1 mo graph { name: "Inception V1 fragment" node { - input: "pool1/3x3_s2_1:conv1/7x7_s2_2" + input: "conv1/7x7_s2_2" output: "pool1/3x3_s2_1" name: "" op_type: "MaxPool" @@ -31,7 +31,7 @@ graph { } input { - name: "pool1/3x3_s2_1:conv1/7x7_s2_2" + name: "conv1/7x7_s2_2" type { tensor_type { elem_type: 1 diff --git a/ngraph/test/models/onnx/model_editor/reference/subgraph__linear_model_head_cut.prototxt b/ngraph/test/models/onnx/model_editor/reference/subgraph__linear_model_head_cut.prototxt index 46c5056cb63db5..41984db10eac71 100644 --- a/ngraph/test/models/onnx/model_editor/reference/subgraph__linear_model_head_cut.prototxt +++ b/ngraph/test/models/onnx/model_editor/reference/subgraph__linear_model_head_cut.prototxt @@ -4,7 +4,7 @@ doc_string: "This model contains the first few nodes of the ONNX Inception V1 mo graph { name: "Inception V1 fragment" node { - input: "conv1/7x7_s2_2:conv1/7x7_s2_1" + input: "conv1/7x7_s2_1" output: "conv1/7x7_s2_2" name: "" op_type: "Relu" @@ -37,7 +37,7 @@ graph { } input { - name: "conv1/7x7_s2_2:conv1/7x7_s2_1" + name: "conv1/7x7_s2_1" type { tensor_type { elem_type: 1 diff --git a/ngraph/test/onnx/onnx_editor.cpp b/ngraph/test/onnx/onnx_editor.cpp index defcf6745baa10..332c83699eb58c 100644 --- a/ngraph/test/onnx/onnx_editor.cpp +++ b/ngraph/test/onnx/onnx_editor.cpp @@ -655,7 +655,7 @@ NGRAPH_TEST(onnx_editor, subgraph__inputs_getter) editor.cut_graph_fragment({{InputEdge(1, "conv1/7x7_s2_1")}}, {}); - EXPECT_EQ(editor.model_inputs(), (std::vector{"conv1/7x7_s2_2:conv1/7x7_s2_1"})); + EXPECT_EQ(editor.model_inputs(), (std::vector{"conv1/7x7_s2_1"})); } using TestEngine = test::INTERPRETER_Engine; @@ -771,3 +771,23 @@ NGRAPH_TEST(onnx_editor, values__append_two_initializers_mixed_types) test_case.add_expected_output(Shape{2, 2, 1}, {1, 4, 5, 8}); test_case.run(); } + +NGRAPH_TEST(onnx_editor, combined__cut_and_replace_shape) +{ + ONNXModelEditor editor{file_util::path_join( + SERIALIZED_ZOO, "onnx/model_editor/subgraph__inception_head.prototxt")}; + + const auto new_shape = PartialShape({1, 64, 112, 112}); + editor.cut_graph_fragment({{InputEdge(1, "conv1/7x7_s2_1")}}, {}); + editor.set_input_shapes({{"conv1/7x7_s2_1", new_shape}}); + + const auto ref_model = file_util::path_join( + SERIALIZED_ZOO, "onnx/model_editor/reference/subgraph__linear_model_head_cut.prototxt"); + + const auto result = compare_onnx_models(editor.model_string(), ref_model); + + EXPECT_TRUE(result.is_ok) << result.error_message; + + const auto graph_inputs = editor.get_function()->get_parameters(); + EXPECT_TRUE(find_input(graph_inputs, "conv1/7x7_s2_1")->get_partial_shape().same_scheme(new_shape)); +} From 87f26d8de8bdc442c03d39fe1df58e13e2404eb4 Mon Sep 17 00:00:00 2001 From: tomdol Date: Tue, 13 Apr 2021 05:35:18 -0400 Subject: [PATCH 110/116] Additional tests formatting --- ngraph/test/onnx/onnx_editor.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ngraph/test/onnx/onnx_editor.cpp b/ngraph/test/onnx/onnx_editor.cpp index 332c83699eb58c..84aa9333b3cae1 100644 --- a/ngraph/test/onnx/onnx_editor.cpp +++ b/ngraph/test/onnx/onnx_editor.cpp @@ -789,5 +789,6 @@ NGRAPH_TEST(onnx_editor, combined__cut_and_replace_shape) EXPECT_TRUE(result.is_ok) << result.error_message; const auto graph_inputs = editor.get_function()->get_parameters(); - EXPECT_TRUE(find_input(graph_inputs, "conv1/7x7_s2_1")->get_partial_shape().same_scheme(new_shape)); + EXPECT_TRUE( + find_input(graph_inputs, "conv1/7x7_s2_1")->get_partial_shape().same_scheme(new_shape)); } From 366b9806075aca8a8921367d6e8dc9f8ef407b1f Mon Sep 17 00:00:00 2001 From: "Lyalin, Sergey" Date: Fri, 16 Apr 2021 12:51:31 +0300 Subject: [PATCH 111/116] Removed dependency on pdpd and tensorflow --- inference-engine/samples/benchmark_app/main.cpp | 2 +- ngraph/frontend/CMakeLists.txt | 5 +++-- ngraph/frontend/generic/CMakeLists.txt | 7 ++++--- ngraph/frontend/generic/src/frontend_manager.cpp | 8 ++++---- ngraph/python/CMakeLists.txt | 2 +- 5 files changed, 13 insertions(+), 11 deletions(-) diff --git a/inference-engine/samples/benchmark_app/main.cpp b/inference-engine/samples/benchmark_app/main.cpp index d8dd0df6790a15..c70820a0e8bc12 100644 --- a/inference-engine/samples/benchmark_app/main.cpp +++ b/inference-engine/samples/benchmark_app/main.cpp @@ -348,7 +348,7 @@ int main(int argc, char *argv[]) { auto FE = manager.loadByFramework("onnx"); auto inputModel = FE->loadFromFile(FLAGS_m); - int test_scenario = 3; + int test_scenario = 0; // The next test cases are applicable for resnet50-v1-7.onnx model from the official repository diff --git a/ngraph/frontend/CMakeLists.txt b/ngraph/frontend/CMakeLists.txt index 8dcf377140160a..31ee7199f470d3 100644 --- a/ngraph/frontend/CMakeLists.txt +++ b/ngraph/frontend/CMakeLists.txt @@ -10,6 +10,7 @@ endif() if (NGRAPH_ONNX_EDITOR_ENABLE) add_subdirectory(onnx_editor) - add_subdirectory(tensorflow) - add_subdirectory(paddlepaddle) endif() + +#add_subdirectory(tensorflow) +#add_subdirectory(paddlepaddle) diff --git a/ngraph/frontend/generic/CMakeLists.txt b/ngraph/frontend/generic/CMakeLists.txt index 85e3dcf8a2e30d..6f0997f41a8cda 100644 --- a/ngraph/frontend/generic/CMakeLists.txt +++ b/ngraph/frontend/generic/CMakeLists.txt @@ -33,12 +33,13 @@ add_library(ngraph::frontend_manager ALIAS frontend_manager) target_include_directories(frontend_manager PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR}/../tensorflow/include + #${CMAKE_CURRENT_SOURCE_DIR}/../tensorflow/include ${CMAKE_CURRENT_SOURCE_DIR}/../onnx_editor/include ${CMAKE_CURRENT_SOURCE_DIR}/../onnx_import/include ${CMAKE_CURRENT_SOURCE_DIR}/../onnx_editor/include ${CMAKE_CURRENT_SOURCE_DIR}/../onnx_common/include - ${CMAKE_CURRENT_SOURCE_DIR}/../paddlepaddle/include) + #${CMAKE_CURRENT_SOURCE_DIR}/../paddlepaddle/include + ) MESSAGE("HERE4: " ${CMAKE_CURRENT_SOURCE_DIR}) @@ -49,7 +50,7 @@ endif() # TODO: Add other frontends to the list of dependencies temporary; in the produce version they should be discovered # TODO: in runtime. -target_link_libraries(frontend_manager PRIVATE onnx_importer onnx_editor onnx_common tensorflow_frontend paddlepaddle_frontend PUBLIC ngraph) +target_link_libraries(frontend_manager PRIVATE onnx_importer onnx_editor onnx_common PUBLIC ngraph) set(FRONTEND_INSTALL_INCLUDE "${NGRAPH_INSTALL_INCLUDE}/ngraph/frontend/generic") target_include_directories(frontend_manager SYSTEM PUBLIC $ diff --git a/ngraph/frontend/generic/src/frontend_manager.cpp b/ngraph/frontend/generic/src/frontend_manager.cpp index 5368944958ec61..9781d5fc0243b3 100644 --- a/ngraph/frontend/generic/src/frontend_manager.cpp +++ b/ngraph/frontend/generic/src/frontend_manager.cpp @@ -17,9 +17,9 @@ #include #include "onnx_import/onnx.hpp" #include "onnx_editor/editor.hpp" -#include "tensorflow_frontend/tensorflow.hpp" +//#include "tensorflow_frontend/tensorflow.hpp" #include "frontend_manager/frontend_manager.hpp" -#include "paddlepaddle_frontend/frontend.hpp" +//#include "paddlepaddle_frontend/frontend.hpp" namespace ngraph @@ -491,8 +491,8 @@ namespace ngraph void registerDefault() { registerFrontEnd("onnx", [](FrontEndCapabilities){return std::make_shared();}); - registerFrontEnd("pdpd", [](FrontEndCapabilities){return std::make_shared();}); - registerFrontEnd("tf", [](FrontEndCapabilities){return std::make_shared();}); + //registerFrontEnd("pdpd", [](FrontEndCapabilities){return std::make_shared();}); + //registerFrontEnd("tf", [](FrontEndCapabilities){return std::make_shared();}); } public: Impl() { diff --git a/ngraph/python/CMakeLists.txt b/ngraph/python/CMakeLists.txt index 5ad24b2b757326..6da3b895e4832a 100644 --- a/ngraph/python/CMakeLists.txt +++ b/ngraph/python/CMakeLists.txt @@ -79,7 +79,7 @@ pybind11_add_module(_${PROJECT_NAME} MODULE ${SOURCES}) target_include_directories(_${PROJECT_NAME} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src") target_include_directories(_${PROJECT_NAME} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../frontend/generic/include") -target_link_libraries(_${PROJECT_NAME} PRIVATE ngraph::ngraph ngraph::onnx_importer ngraph::frontend_manager ngraph::tensorflow_frontend) +target_link_libraries(_${PROJECT_NAME} PRIVATE ngraph::ngraph ngraph::onnx_importer ngraph::frontend_manager) if (TARGET ngraph::onnx_importer) add_dependencies(_${PROJECT_NAME} ngraph::onnx_importer) endif() From 4c85c2041759fd182e2f207955073a899a748ae0 Mon Sep 17 00:00:00 2001 From: "Lyalin, Sergey" Date: Mon, 19 Apr 2021 18:03:24 +0300 Subject: [PATCH 112/116] WIP port decoding in MO --- model-optimizer/mo/front/extractor.py | 27 ++++++++++++++----- .../frontend_manager/frontend_manager.hpp | 9 +++++-- .../frontend/generic/src/frontend_manager.cpp | 5 ++++ ngraph/test/onnx/onnx_editor.cpp | 1 + 4 files changed, 33 insertions(+), 9 deletions(-) diff --git a/model-optimizer/mo/front/extractor.py b/model-optimizer/mo/front/extractor.py index 9871b3550ddba3..4f76252a9c921d 100644 --- a/model-optimizer/mo/front/extractor.py +++ b/model-optimizer/mo/front/extractor.py @@ -458,24 +458,37 @@ def decodeNameWithPort (graph: Graph, node_name: str): :param node_name: :return: decoded place in the graph """ - # Check exact match with one of the names in the graph first inputModel = graph.graph['input_model'] - #TODO: search for any name, not only a tensor - node = inputModel.getPlaceByTensorName(node_name) + + # First try to interpret node_name as pure FW name and find exact match: + node = inputModel.getPlaceByName(node_name) + if node: return node + + # If there are not matches , try to decode MO syntax + + # Postfix port regexpPost = r'(.*)(:(\d+))' matchPost = re.search(regexpPost, node_name) - nodePost = inputModel.getPlaceByTensorName(matchPost.group(1)) if matchPost else None + # Again search in all names, including tensors and operations + # TODO: Search for operation only? + nodePost = inputModel.getPlaceByName(matchPost.group(1)) if matchPost else None + + # Prefix port regexpPre = r'((\d+):)(.*)' matchPre = re.search(regexpPre, node_name) - nodePre = inputModel.getPlaceByTensorName(matchPre.group(3)) if matchPost else None + # TODO: Search for operation only? + nodePre = inputModel.getPlaceByName(matchPre.group(3)) if matchPost else None + + # Next we try to get the input and output ports for any places, including tensors! + if nodePost and nodePre: raise Error('Name collision for {}'.format(node_name)) if nodePost: - return node.getOutputPort(int(matchPost.group(3))) + return nodePost.getOutputPort(int(matchPost.group(3))) if nodePre: - return node.getInputPort(int(matchPre.group(1))) + return nodePre.getInputPort(int(matchPre.group(1))) raise Error('There is no node with name {}'.format(node_name)) diff --git a/ngraph/frontend/generic/include/frontend_manager/frontend_manager.hpp b/ngraph/frontend/generic/include/frontend_manager/frontend_manager.hpp index aecc9f4f7e8b61..53be3f89ec3dd7 100644 --- a/ngraph/frontend/generic/include/frontend_manager/frontend_manager.hpp +++ b/ngraph/frontend/generic/include/frontend_manager/frontend_manager.hpp @@ -110,10 +110,12 @@ class NGRAPH_API Place /// Returns a port that produces data for this place virtual Ptr getProducingPort () const; - /// For operation node returns reference to an input port with specified index + /// For operation node returns reference to an input port with specified index, + /// for a tensor returns input port of operation that produces that tensor virtual Ptr getInputPort (int inputPortIndex = -1) const; - /// For operation node returns reference to an output port with specified index + /// For operation node returns reference to an output port with specified index, + /// for a tensor returns output port that that produces this tensor virtual Ptr getOutputPort (int outputPortIndex = -1) const; /// Returns all input ports that consume data flows through this place @@ -185,6 +187,9 @@ class NGRAPH_API InputModel /// Returns an operation place by a tensor name following framework conventions, or nullptr if an operation with this name doesn't exist. virtual Place::Ptr getPlaceByOperationName (const std::string& operationName); + /// Returns a tensor place by any name that is convenient for target framework. + virtual Place::Ptr getPlaceByName (const std::string& name); + /// Returns an input port. virtual Place::Ptr getPlaceByOperationAndInputPort (const std::string& operationName, int inputPortIndex); diff --git a/ngraph/frontend/generic/src/frontend_manager.cpp b/ngraph/frontend/generic/src/frontend_manager.cpp index 9781d5fc0243b3..15756eb9f5e3b7 100644 --- a/ngraph/frontend/generic/src/frontend_manager.cpp +++ b/ngraph/frontend/generic/src/frontend_manager.cpp @@ -51,6 +51,11 @@ namespace ngraph FRONT_END_NOT_IMPLEMENTED(getPlaceByOperationName); } + Place::Ptr InputModel::getPlaceByName (const std::string& operationName) + { + FRONT_END_NOT_IMPLEMENTED(getPlaceByName); + } + Place::Ptr InputModel::getPlaceByOperationAndInputPort (const std::string& operationName, int inputPortIndex) { FRONT_END_NOT_IMPLEMENTED(getPlaceByOperationAndInputPort); diff --git a/ngraph/test/onnx/onnx_editor.cpp b/ngraph/test/onnx/onnx_editor.cpp index 9fdf7f1d912bd5..78ac017b9dd576 100644 --- a/ngraph/test/onnx/onnx_editor.cpp +++ b/ngraph/test/onnx/onnx_editor.cpp @@ -279,6 +279,7 @@ NGRAPH_TEST(onnx_editor, subgraph__linear_model_head_cut) SERIALIZED_ZOO, "onnx/model_editor/subgraph__inception_head.prototxt")}; editor.cut_graph_fragment({{InputEdge(1, "conv1/7x7_s2_1")}}, {}); + editor.set_input_shapes({{"conv1/7x7_s2_1", PartialShape({1, 64, 112, 112})}}); const auto ref_model = file_util::path_join( SERIALIZED_ZOO, "onnx/model_editor/reference/subgraph__linear_model_head_cut.prototxt"); From 3de2a712a2fdf2aaf52f5ea34c814933ecaef1d1 Mon Sep 17 00:00:00 2001 From: mbencer Date: Wed, 5 May 2021 15:08:35 +0200 Subject: [PATCH 113/116] apply new compiler rules --- .../onnx_editor/include/onnx_editor/edge_mapper.hpp | 4 ++-- ngraph/frontend/onnx_editor/src/edge_mapper.cpp | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ngraph/frontend/onnx_editor/include/onnx_editor/edge_mapper.hpp b/ngraph/frontend/onnx_editor/include/onnx_editor/edge_mapper.hpp index 95e612807021db..8b91f0c778e60b 100644 --- a/ngraph/frontend/onnx_editor/include/onnx_editor/edge_mapper.hpp +++ b/ngraph/frontend/onnx_editor/include/onnx_editor/edge_mapper.hpp @@ -108,5 +108,5 @@ namespace ngraph std::map m_node_output_name_to_index; std::multimap m_output_consumers_index; }; - } -} + } // namespace onnx_editor +} // namespace ngraph diff --git a/ngraph/frontend/onnx_editor/src/edge_mapper.cpp b/ngraph/frontend/onnx_editor/src/edge_mapper.cpp index 50c02740393c50..eeb244b98425b8 100644 --- a/ngraph/frontend/onnx_editor/src/edge_mapper.cpp +++ b/ngraph/frontend/onnx_editor/src/edge_mapper.cpp @@ -63,12 +63,12 @@ std::vector onnx_editor::EdgeMapper::find_node_indexes(const std::string& n std::string onnx_editor::EdgeMapper::get_node_output_name(int node_index, int output_index) const { - if (node_index >= m_node_outputs.size()) + if (node_index >= static_cast(m_node_outputs.size())) { throw ngraph_error("Node with index: " + std::to_string(node_index) + "is out of scope outputs list"); } - if (output_index >= m_node_outputs[node_index].size()) + if (output_index >= static_cast(m_node_outputs[node_index].size())) { throw ngraph_error("Node with index: " + std::to_string(node_index) + " has not output with index: " + std::to_string(output_index)); @@ -79,12 +79,12 @@ std::string onnx_editor::EdgeMapper::get_node_output_name(int node_index, int ou std::string onnx_editor::EdgeMapper::get_node_input_name(int node_index, int input_index) const { - if (node_index >= m_node_inputs.size()) + if (node_index >= static_cast(m_node_inputs.size())) { throw ngraph_error("Node with index: " + std::to_string(node_index) + "is out of scope inputs list"); } - if (input_index >= m_node_inputs[node_index].size()) + if (input_index >= static_cast(m_node_inputs[node_index].size())) { throw ngraph_error("Node with index: " + std::to_string(node_index) + " has not input with index: " + std::to_string(input_index)); From d0d094e95262852228b57c81d5c0b935cbf5fb91 Mon Sep 17 00:00:00 2001 From: mbencer Date: Wed, 5 May 2021 14:05:09 +0200 Subject: [PATCH 114/116] Use index ports instead of tensor names --- .../include/onnx_editor/edge_mapper.hpp | 5 +- .../include/onnx_editor/editor_types.hpp | 36 +-- .../src/detail/subgraph_extraction.cpp | 229 ++++++-------- .../src/detail/subgraph_extraction.hpp | 6 +- .../frontend/onnx_editor/src/edge_mapper.cpp | 59 ++-- .../models/onnx/model_editor/add_ab.prototxt | 59 ++++ ...om_tensor_with_multiple_consumers.prototxt | 48 ++- ..._tensor_with_multiple_consumers_2.prototxt | 49 ++- ..._tensor_with_multiple_consumers_3.prototxt | 47 ++- ..._tensor_with_multiple_consumers_4.prototxt | 224 ++++++++++++++ ..._tensor_with_multiple_consumers_5.prototxt | 120 ++++++++ ..._graph_initializer_relu2_and_init.prototxt | 12 +- ...le_consumers_of_graph_input_relu2.prototxt | 6 +- ..._from_tensor_with_single_consumer.prototxt | 74 +++++ ngraph/test/onnx/onnx_editor.cpp | 281 ++++++++++++------ 15 files changed, 975 insertions(+), 280 deletions(-) create mode 100644 ngraph/test/models/onnx/model_editor/add_ab.prototxt create mode 100644 ngraph/test/models/onnx/model_editor/reference/subgraph__input_edge_from_tensor_with_multiple_consumers_4.prototxt create mode 100644 ngraph/test/models/onnx/model_editor/reference/subgraph__input_edge_from_tensor_with_multiple_consumers_5.prototxt create mode 100644 ngraph/test/models/onnx/model_editor/reference/subgraph__twice_input_edge_from_tensor_with_single_consumer.prototxt diff --git a/ngraph/frontend/onnx_editor/include/onnx_editor/edge_mapper.hpp b/ngraph/frontend/onnx_editor/include/onnx_editor/edge_mapper.hpp index 8b91f0c778e60b..3e2c6afaa07df5 100644 --- a/ngraph/frontend/onnx_editor/include/onnx_editor/edge_mapper.hpp +++ b/ngraph/frontend/onnx_editor/include/onnx_editor/edge_mapper.hpp @@ -99,8 +99,9 @@ namespace ngraph private: std::vector find_node_indexes(const std::string& node_name, const std::string& output_name) const; - std::string get_node_input_name(int node_index, int input_index) const; - std::string get_node_output_name(int node_index, int output_index) const; + + int get_node_input_idx(int node_index, const std::string& input_name) const; + int get_node_output_idx(int node_index, const std::string& output_name) const; std::vector> m_node_inputs; std::vector> m_node_outputs; diff --git a/ngraph/frontend/onnx_editor/include/onnx_editor/editor_types.hpp b/ngraph/frontend/onnx_editor/include/onnx_editor/editor_types.hpp index 6f941d90869b0a..bb08fb87267699 100644 --- a/ngraph/frontend/onnx_editor/include/onnx_editor/editor_types.hpp +++ b/ngraph/frontend/onnx_editor/include/onnx_editor/editor_types.hpp @@ -19,46 +19,46 @@ namespace ngraph struct Edge { Edge() = delete; - Edge(const int node_idx, std::string tensor_name) + Edge(const int node_idx, const int port_idx) : m_node_idx{node_idx} - , m_tensor_name{std::move(tensor_name)} + , m_port_idx{port_idx} { } const int m_node_idx; - const std::string m_tensor_name; + const int m_port_idx; }; namespace onnx_editor { /// \brief Defines an edge connected to an input of any node in the graph. - /// It consists of a node index in the processed ONNX model and the input name. - /// The index should point to a node in the topological sort of the underlying graph - /// which means it has to be in range: 0 <= node_idx < graph.node_size() + /// It consists of a node index in the processed ONNX model and the port index. + /// The node index should point to a node in the topological sort of the underlying + /// graph which means it has to be in range: 0 <= node_idx < graph.node_size() /// /// For a node number 5, with 3 inputs: /// - /// ----(in_A)----> +--------+ - /// ----(in_B)----> | node 5 | ----(out)----> - /// ----(in_C)----> +--------+ + /// ----(0)----> +--------+ + /// ----(1)----> | node 5 | ----(0)----> + /// ----(2)----> +--------+ /// /// there are 3 possible valid instances of this struct: - /// InputEdge(5, "in_A") - /// InputEdge(5, "in_B") - /// InputEdge(5, "in_C") + /// InputEdge(5, 0) + /// InputEdge(5, 1) + /// InputEdge(5, 2) using InputEdge = Edge; /// \brief Defines an edge connected to an output of any node in the graph. - /// It consists of a node index in the processed ONNX model and the output name. + /// It consists of a node index in the processed ONNX model and the port index. /// /// For a node number 5, with 2 outputs: /// - /// +--------+ ----(out1)----> - /// ----(in_A)----> | node 5 | - /// +--------+ ----(out2)----> + /// +--------+ ----(0)----> + /// ----(0)----> | node 5 | + /// +--------+ ----(1)----> /// /// there are 2 possible valid instances of this struct: - /// OutputEdge(5, "out1") - /// OutputEdge(5, "out2") + /// OutputEdge(5, 0) + /// OutputEdge(5, 1) using OutputEdge = Edge; /// \brief Specifies a single node input by the name or index. diff --git a/ngraph/frontend/onnx_editor/src/detail/subgraph_extraction.cpp b/ngraph/frontend/onnx_editor/src/detail/subgraph_extraction.cpp index 92980dbab0f95d..f598dc75a8b29c 100644 --- a/ngraph/frontend/onnx_editor/src/detail/subgraph_extraction.cpp +++ b/ngraph/frontend/onnx_editor/src/detail/subgraph_extraction.cpp @@ -99,20 +99,49 @@ namespace return *it; } + std::string get_input_tensor_name(ONNX_NAMESPACE::GraphProto& graph, const InputEdge& edge) + { + validate_node_index(graph, edge.m_node_idx); + NGRAPH_CHECK(edge.m_port_idx >= 0 && + edge.m_port_idx < + static_cast(graph.node(edge.m_node_idx).input().size()), + "Node with index: ", + std::to_string(edge.m_node_idx), + " has not input with index: ", + std::to_string(edge.m_port_idx)); + + return graph.node(edge.m_node_idx).input(edge.m_port_idx); + } + + std::string get_output_tensor_name(ONNX_NAMESPACE::GraphProto& graph, const OutputEdge& edge) + { + validate_node_index(graph, edge.m_node_idx); + NGRAPH_CHECK(edge.m_port_idx >= 0 && + edge.m_port_idx < + static_cast(graph.node(edge.m_node_idx).output().size()), + "Node with index: ", + std::to_string(edge.m_node_idx), + " has not output with index: ", + std::to_string(edge.m_port_idx)); + + return graph.node(edge.m_node_idx).output(edge.m_port_idx); + } + /// \brief Inserts a new input to the graph and removes an initializer that produced a tensor /// specified by an input edge passed to this function. void replace_initializer_with_new_input(ONNX_NAMESPACE::GraphProto& graph, const InputEdge& edge) { + const auto tensor_name = get_input_tensor_name(graph, edge); const auto it = std::find_if(std::begin(graph.initializer()), std::end(graph.initializer()), - name_equals(edge.m_tensor_name)); + name_equals(tensor_name)); NGRAPH_CHECK(it != std::end(graph.initializer()), "Could not find an initializer in the graph: '", - edge.m_tensor_name); + tensor_name); - if (!already_exists(graph.input(), edge.m_tensor_name)) + if (!already_exists(graph.input(), tensor_name)) { const auto& initializer = *it; auto& new_input = *(graph.add_input()); @@ -127,7 +156,7 @@ namespace new_dim.set_dim_value(initializer_dim); } - *(new_input.mutable_name()) = edge.m_tensor_name; + *(new_input.mutable_name()) = tensor_name; } graph.mutable_initializer()->erase(it); @@ -137,89 +166,54 @@ namespace /// edge passed to this function. /// \return A new input edge (along with "true") if a new input was added to the graph, /// false + the original edge otherwise. - std::pair append_new_graph_input(ONNX_NAMESPACE::GraphProto& graph, - const InputEdge& edge) + std::pair append_new_graph_input(ONNX_NAMESPACE::GraphProto& graph, + const InputEdge& edge, + int input_consumers) { - if (already_exists(graph.input(), edge.m_tensor_name) && - !is_graph_initializer(graph, edge.m_tensor_name)) + const auto tensor_name = get_input_tensor_name(graph, edge); + if (already_exists(graph.input(), tensor_name) && !is_graph_initializer(graph, tensor_name)) { // no need to append a new input if an edge points to an existing one in the model - return {false, edge}; + return {false, tensor_name}; } auto& target_node = *(graph.mutable_node(edge.m_node_idx)); - auto& node_inputs = *(target_node.mutable_input()); - auto target_input = - std::find(std::begin(node_inputs), std::end(node_inputs), edge.m_tensor_name); - - NGRAPH_CHECK(target_input != std::end(node_inputs), + NGRAPH_CHECK(edge.m_port_idx < target_node.input().size(), "Input '", - edge.m_tensor_name, + edge.m_port_idx, "' not found in the inputs of node ", edge.m_node_idx, ". Cannot append a new graph input to this node."); - // if an edge is connected to an initializer, the initializer is removed and substituted - // with an input - if (is_graph_initializer(graph, edge.m_tensor_name)) + std::string new_input_name; + if (input_consumers > 1) { - replace_initializer_with_new_input(graph, edge); - return {false, edge}; + new_input_name = + target_node.output(0) + "/placeholder_port_" + std::to_string(edge.m_port_idx); } else { - auto& new_input = *(graph.add_input()); - // copy the intermediate tensor properties to the newly created input - new_input.MergeFrom(find_tensor_descriptor(graph, edge.m_tensor_name)); - *(new_input.mutable_name()) = edge.m_tensor_name; - // attach the new graph input to the target node's input - *target_input = edge.m_tensor_name; - return {true, InputEdge{edge.m_node_idx, edge.m_tensor_name}}; - } - } - - /// \brief Replaces a node or initializer (consumed by multiple nodes) with a new input - /// \return Returns an index of a removed node or -1 if an initializer was removed - int replace_source_with_new_input(ONNX_NAMESPACE::GraphProto& graph, const InputEdge& edge) - { - if (already_exists(graph.input(), edge.m_tensor_name) && - !is_graph_initializer(graph, edge.m_tensor_name)) - { - // happens when a user specifies multiple input edges pointing to the same tensor name - return -1; + new_input_name = tensor_name; } - if (is_graph_initializer(graph, edge.m_tensor_name)) + // if an edge is connected to an initializer, the initializer is removed and substituted + // with an input + if (is_graph_initializer(graph, tensor_name)) { replace_initializer_with_new_input(graph, edge); + return {false, tensor_name}; } else { auto& new_input = *(graph.add_input()); // copy the intermediate tensor properties to the newly created input - new_input.MergeFrom(find_tensor_descriptor(graph, edge.m_tensor_name)); - - const auto source_node_idx = - find_source_node_idx(graph, edge.m_node_idx, edge.m_tensor_name); - auto& source_node = *(graph.mutable_node(source_node_idx)); - auto& node_outputs = *source_node.mutable_output(); - auto target_output = - std::find(std::begin(node_outputs), std::end(node_outputs), edge.m_tensor_name); - - NGRAPH_CHECK(target_output != std::end(node_outputs), - "Output '", - edge.m_tensor_name, - "' not found in the outputs of node ", - source_node_idx, - ". Cannot remove the output from this node."); - - // stop produsing tensor "edge.m_tensor_name" by the source node of the processed edge - *target_output = ""; - - return source_node_idx; + new_input.MergeFrom(find_tensor_descriptor(graph, tensor_name)); + *(new_input.mutable_name()) = new_input_name; + // attach the new graph input to the target node's input + auto target_input = target_node.mutable_input(edge.m_port_idx); + *target_input = new_input_name; + return {true, new_input_name}; } - - return -1; } /// \brief Adds new outputs to the ONNX graph for an edge specified by a user @@ -227,27 +221,15 @@ namespace /// original model. void append_new_graph_output(ONNX_NAMESPACE::GraphProto& graph, const OutputEdge& edge) { - if (already_exists(graph.output(), edge.m_tensor_name)) + const auto tensor_name = get_output_tensor_name(graph, edge); + if (already_exists(graph.output(), tensor_name)) { return; } - - auto& target_node = *(graph.mutable_node(edge.m_node_idx)); - const auto& node_outputs = target_node.output(); - const auto target_output = - std::find(std::begin(node_outputs), std::end(node_outputs), edge.m_tensor_name); - - NGRAPH_CHECK(target_output != std::end(node_outputs), - "Output '", - edge.m_tensor_name, - "' not found in the outputs of node ", - edge.m_node_idx, - ". Cannot append a new graph output to this node."); - auto& new_output = *(graph.add_output()); // copy the intermediate tensor's properties to the newly created - new_output.MergeFrom(find_tensor_descriptor(graph, edge.m_tensor_name)); - *(new_output.mutable_name()) = edge.m_tensor_name; + new_output.MergeFrom(find_tensor_descriptor(graph, tensor_name)); + *(new_output.mutable_name()) = tensor_name; } /// \brief Removes all items from a container except the ones whose names are in items_to_keep @@ -299,6 +281,7 @@ namespace SubgraphExtractor::SubgraphExtractor(ONNX_NAMESPACE::GraphProto& graph) : m_onnx_graph(graph) + , m_node_inputs(graph.node_size()) { // gathers information about the graph - input edges of every node and number of "consumers" // of all tensors in the graph @@ -306,7 +289,7 @@ SubgraphExtractor::SubgraphExtractor(ONNX_NAMESPACE::GraphProto& graph) { for (const auto& node_input : graph.node(i).input()) { - m_node_inputs.insert({i, node_input}); + m_node_inputs[i].push_back(node_input); m_tensor_consumers[node_input] += 1; } } @@ -316,35 +299,17 @@ void SubgraphExtractor::add_new_inputs(const std::vector& new_inputs) { for (const auto& input_edge : new_inputs) { - validate_node_index(m_onnx_graph, input_edge.m_node_idx); + const auto tensor_name = get_input_tensor_name(m_onnx_graph, input_edge); - // if a tensor has multiple consumers, its producer(source) should be replaced with a new - // input - this way all consumers of this tensor will now be connected to a new graph input - if (m_tensor_consumers[input_edge.m_tensor_name] > 1) + // in case an edge is connected to a single node, a new graph input should be added + // and connected to that node; the new edge is an edge between the node and new input + const auto new_input = + append_new_graph_input(m_onnx_graph, input_edge, m_tensor_consumers[tensor_name]); + if (new_input.first) { - // remove a node or initializer from a model and insert a new input instead - int idx = replace_source_with_new_input(m_onnx_graph, input_edge); - if (idx != -1) - { - // if a node was replaced with an input, remove input edges from a helper multimap - // for this node because it won't end up in the target subgraph - // m_node_inputs stores information about existing edges in the graph, - // when a node is removed/replaced, information about its edges should also - // be removed (this way this node will be discarded from the original graph) - m_node_inputs.erase(idx); - } - } - else - { - // in case an edge is connected to a single node, a new graph input should be added - // and connected to that node; the new edge is an edge between the node and new input - const auto& new_edge = append_new_graph_input(m_onnx_graph, input_edge); - if (new_edge.first) - { - // the original edge should be replaced with a new one in the helper multimap - // this information will later be used during the subgraph extraction stage - replace_input_edge(input_edge, new_edge.second); - } + // the original edge should be replaced with a new one in the helper multimap + // this information will later be used during the subgraph extraction stage + replace_input_edge(input_edge, new_input.second); } } } @@ -359,23 +324,15 @@ void SubgraphExtractor::add_new_outputs(const std::vector& new_outpu } } -void SubgraphExtractor::replace_input_edge(const InputEdge& old_edge, const InputEdge& new_edge) +void SubgraphExtractor::replace_input_edge(const InputEdge& old_edge, + const std::string& new_edge_name) { - // old_edge = {5, "x"}; new_edge = {5, "y"} - // for a given node index "N", find all of its inputs in the helper multimap (pair of iterators) - // using those iterators find the name of an input tensor that needs to be replaced - const auto node_inputs = m_node_inputs.equal_range(old_edge.m_node_idx); - auto old_input_name = node_inputs.first; - - // find an iterator pointing to an input name that should - while (old_input_name->second != old_edge.m_tensor_name && old_input_name != node_inputs.second) - { - ++old_input_name; - } + // remove the old edge from the helper map and insert a new edge + const auto pos_to_replace_it = + m_node_inputs.at(old_edge.m_node_idx).begin() + old_edge.m_port_idx; - // finally remove the old edge from the helper map and insert a new edge - m_node_inputs.erase(old_input_name); - m_node_inputs.insert({new_edge.m_node_idx, new_edge.m_tensor_name}); + m_node_inputs.at(old_edge.m_node_idx).erase(pos_to_replace_it); + m_node_inputs.at(old_edge.m_node_idx).insert(pos_to_replace_it, new_edge_name); } void SubgraphExtractor::extract_subgraph(std::vector subgraph_outputs) @@ -408,7 +365,8 @@ SubgraphExtractor::SubgraphComponents SubgraphExtractor::discover_output_contrib }; SubgraphComponents output_contributors; - output_contributors.outputs.insert(output_edge.m_tensor_name); + const auto tensor_name = get_output_tensor_name(m_onnx_graph, output_edge); + output_contributors.outputs.insert(tensor_name); // reverse DFS graph traversal std::stack nodes_to_visit; @@ -432,28 +390,28 @@ SubgraphExtractor::SubgraphComponents SubgraphExtractor::discover_output_contrib // and/or keep looking for more contributors further up in the graph // when an input or initializer is reached, the visitor stops the lookup - const auto n_inputs = m_node_inputs.equal_range(n); - for (auto input_name = n_inputs.first; input_name != n_inputs.second; ++input_name) + const auto n_inputs = m_node_inputs[n]; + for (auto& input_name : n_inputs) { - if (is_graph_input(m_onnx_graph, input_name->second)) + if (is_graph_input(m_onnx_graph, input_name)) { - output_contributors.inputs.insert(input_name->second); + output_contributors.inputs.insert(input_name); // when an initializer has a matching graph input - if (is_graph_initializer(m_onnx_graph, input_name->second)) + if (is_graph_initializer(m_onnx_graph, input_name)) { - output_contributors.initializers.insert(input_name->second); + output_contributors.initializers.insert(input_name); } } - else if (is_graph_initializer(m_onnx_graph, input_name->second)) + else if (is_graph_initializer(m_onnx_graph, input_name)) { // when an initializer doesn't have a corresponding input - output_contributors.initializers.insert(input_name->second); + output_contributors.initializers.insert(input_name); } else { // if an edge points to another node (source node) it should be visited // in one of the future iterations - nodes_to_visit.push(find_source_node_idx(m_onnx_graph, n, input_name->second)); + nodes_to_visit.push(find_source_node_idx(m_onnx_graph, n, input_name)); } } } @@ -475,9 +433,12 @@ std::vector SubgraphExtractor::all_output_edges() const for (const auto& graph_output : m_onnx_graph.output()) { - all_outputs.emplace_back( - find_source_node_idx(m_onnx_graph, m_onnx_graph.node_size(), graph_output.name()), - graph_output.name()); + const auto node_index = + find_source_node_idx(m_onnx_graph, m_onnx_graph.node_size(), graph_output.name()); + const auto& node_outputs = m_onnx_graph.node(node_index).output(); + const auto output_port_it = + std::find(std::begin(node_outputs), std::end(node_outputs), graph_output.name()); + all_outputs.emplace_back(node_index, output_port_it - std::begin(node_outputs)); } return all_outputs; diff --git a/ngraph/frontend/onnx_editor/src/detail/subgraph_extraction.hpp b/ngraph/frontend/onnx_editor/src/detail/subgraph_extraction.hpp index 55220d23ad1a9d..c69173b3fdf964 100644 --- a/ngraph/frontend/onnx_editor/src/detail/subgraph_extraction.hpp +++ b/ngraph/frontend/onnx_editor/src/detail/subgraph_extraction.hpp @@ -76,14 +76,14 @@ namespace ngraph private: ONNX_NAMESPACE::GraphProto& m_onnx_graph; - // Graph traversal helper: node index -> node inputs (one-to-many) - std::unordered_multimap m_node_inputs; + // Graph traversal helper: a vector of nodes which have vector of inputs + std::vector> m_node_inputs; // Number of consumers of all tensors in the graph std::map m_tensor_consumers; /// \brief Replaces the old input edge with a new one in the helper struct. /// This is used by the output contributors discovery. - void replace_input_edge(const InputEdge& old_edge, const InputEdge& new_edge); + void replace_input_edge(const InputEdge& old_edge, const std::string& new_edge_name); /// \brief Returns a list of edges of each outputs of the graph "m_onnx_graph" std::vector all_output_edges() const; diff --git a/ngraph/frontend/onnx_editor/src/edge_mapper.cpp b/ngraph/frontend/onnx_editor/src/edge_mapper.cpp index eeb244b98425b8..29fbb4e734de32 100644 --- a/ngraph/frontend/onnx_editor/src/edge_mapper.cpp +++ b/ngraph/frontend/onnx_editor/src/edge_mapper.cpp @@ -61,36 +61,47 @@ std::vector onnx_editor::EdgeMapper::find_node_indexes(const std::string& n return result; }; -std::string onnx_editor::EdgeMapper::get_node_output_name(int node_index, int output_index) const +int onnx_editor::EdgeMapper::get_node_output_idx(int node_index, + const std::string& output_name) const { if (node_index >= static_cast(m_node_outputs.size())) { throw ngraph_error("Node with index: " + std::to_string(node_index) + "is out of scope outputs list"); } - if (output_index >= static_cast(m_node_outputs[node_index].size())) + const auto out_port_idx = std::find( + std::begin(m_node_outputs[node_index]), std::end(m_node_outputs[node_index]), output_name); + if (out_port_idx == std::end(m_node_outputs[node_index])) { throw ngraph_error("Node with index: " + std::to_string(node_index) + - " has not output with index: " + std::to_string(output_index)); + " has not output with name: " + output_name); } - const auto output_name = m_node_outputs[node_index][output_index]; - return output_name; + return (out_port_idx - std::begin(m_node_outputs[node_index])); } -std::string onnx_editor::EdgeMapper::get_node_input_name(int node_index, int input_index) const +int onnx_editor::EdgeMapper::get_node_input_idx(int node_index, const std::string& input_name) const { - if (node_index >= static_cast(m_node_inputs.size())) + if (node_index >= 0 && node_index >= static_cast(m_node_inputs.size())) { throw ngraph_error("Node with index: " + std::to_string(node_index) + "is out of scope inputs list"); } - if (input_index >= static_cast(m_node_inputs[node_index].size())) + const auto matched_inputs = std::count( + std::begin(m_node_inputs[node_index]), std::end(m_node_inputs[node_index]), input_name); + if (matched_inputs == 0) { throw ngraph_error("Node with index: " + std::to_string(node_index) + - " has not input with index: " + std::to_string(input_index)); + " has not input with name: " + input_name); } - const auto input_name = m_node_inputs[node_index][input_index]; - return input_name; + if (matched_inputs > 1) // more indexes with the same name + { + throw ngraph_error("Node with index: " + std::to_string(node_index) + + " has more than one inputs with name: " + input_name + + ". You should use port indexes to distinguish them."); + } + const auto in_port_idx = std::find( + std::begin(m_node_inputs[node_index]), std::end(m_node_inputs[node_index]), input_name); + return (in_port_idx - std::begin(m_node_inputs[node_index])); } InputEdge onnx_editor::EdgeMapper::find_input_edge(const EditorNode& node, @@ -143,14 +154,14 @@ InputEdge onnx_editor::EdgeMapper::find_input_edge(const EditorNode& node, " and input index: " + std::to_string(in.m_input_index) + " are ambiguous to determine input edge"); } - if (!in.m_input_name.empty()) + if (in.m_input_index != -1) // input index is set { - return InputEdge{node_index, in.m_input_name}; + return InputEdge{node_index, in.m_input_index}; } - else if (in.m_input_index != -1) // input index is set + if (!in.m_input_name.empty()) { - const auto& input_name = get_node_input_name(node_index, in.m_input_index); - return InputEdge{node_index, input_name}; + const auto input_idx = get_node_input_idx(node_index, in.m_input_name); + return InputEdge{node_index, input_idx}; } else { @@ -203,14 +214,14 @@ OutputEdge onnx_editor::EdgeMapper::find_output_edge(const EditorNode& node, " and output index: " + std::to_string(out.m_output_index) + " are ambiguous to determine output edge"); } - if (!out.m_output_name.empty()) + if (out.m_output_index != -1) // output index is set { - return OutputEdge{node_index, out.m_output_name}; + return OutputEdge{node_index, out.m_output_index}; } - else if (out.m_output_index != -1) // output index is set + if (!out.m_output_name.empty()) { - const auto& output_name = get_node_output_name(node_index, out.m_output_index); - return OutputEdge{node_index, output_name}; + const auto output_idx = get_node_output_idx(node_index, out.m_output_name); + return OutputEdge{node_index, output_idx}; } else { @@ -231,8 +242,10 @@ std::vector std::transform(matched_nodes_range.first, matched_nodes_range.second, std::back_inserter(input_edges), - [&output_name](const std::pair& iter) { - return InputEdge{iter.second, output_name}; + [&output_name, this](const std::pair& iter) { + const auto node_idx = iter.second; + const auto port_idx = this->get_node_input_idx(node_idx, output_name); + return InputEdge{node_idx, port_idx}; }); return input_edges; } diff --git a/ngraph/test/models/onnx/model_editor/add_ab.prototxt b/ngraph/test/models/onnx/model_editor/add_ab.prototxt new file mode 100644 index 00000000000000..b614b84c379dd9 --- /dev/null +++ b/ngraph/test/models/onnx/model_editor/add_ab.prototxt @@ -0,0 +1,59 @@ +ir_version: 3 +producer_name: "nGraph ONNX Importer" +graph { + node { + input: "A" + input: "B" + output: "X" + op_type: "Add" + } + node { + input: "X" + input: "X" + output: "Y" + op_type: "Add" + } + name: "test_graph" + input { + name: "A" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 1 + } + } + } + } + } + input { + name: "B" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 1 + } + } + } + } + } + output { + name: "Y" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 1 + } + } + } + } + } +} +opset_import { + version: 13 +} diff --git a/ngraph/test/models/onnx/model_editor/reference/subgraph__input_edge_from_tensor_with_multiple_consumers.prototxt b/ngraph/test/models/onnx/model_editor/reference/subgraph__input_edge_from_tensor_with_multiple_consumers.prototxt index ade2123bafd865..689ddab137aef9 100644 --- a/ngraph/test/models/onnx/model_editor/reference/subgraph__input_edge_from_tensor_with_multiple_consumers.prototxt +++ b/ngraph/test/models/onnx/model_editor/reference/subgraph__input_edge_from_tensor_with_multiple_consumers.prototxt @@ -2,9 +2,16 @@ ir_version: 7 producer_name: "test_data_generator" graph { node { - input: "relu1" + input: "in1" + output: "relu1" + name: "relu1_name" + op_type: "Relu" + } + node { + input: "add1/placeholder_port_0" input: "in2" output: "add1" + name: "add_ambiguous_name" op_type: "Add" } node { @@ -17,18 +24,21 @@ graph { input: "relu1" input: "add1" output: "add2" + name: "add_ambiguous_name" op_type: "Add" } node { input: "add1" input: "conv1" output: "mul2" + name: "" op_type: "Mul" } node { input: "add2" output: "split1" output: "split2" + name: "split_name" op_type: "Split" attribute { name: "axis" @@ -37,7 +47,7 @@ graph { } } node { - input: "relu1" + input: "mul1/placeholder_port_0" input: "split1" output: "mul1" op_type: "Mul" @@ -52,6 +62,22 @@ graph { float_data: 1 name: "in4" } + input { + name: "in1" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 2 + } + dim { + dim_value: 2 + } + } + } + } + } input { name: "in2" type { @@ -107,7 +133,23 @@ graph { } } input { - name: "relu1" + name: "add1/placeholder_port_0" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 2 + } + dim { + dim_value: 2 + } + } + } + } + } + input { + name: "mul1/placeholder_port_0" type { tensor_type { elem_type: 1 diff --git a/ngraph/test/models/onnx/model_editor/reference/subgraph__input_edge_from_tensor_with_multiple_consumers_2.prototxt b/ngraph/test/models/onnx/model_editor/reference/subgraph__input_edge_from_tensor_with_multiple_consumers_2.prototxt index 5d62d03bb617ac..b219693f3c6ec5 100644 --- a/ngraph/test/models/onnx/model_editor/reference/subgraph__input_edge_from_tensor_with_multiple_consumers_2.prototxt +++ b/ngraph/test/models/onnx/model_editor/reference/subgraph__input_edge_from_tensor_with_multiple_consumers_2.prototxt @@ -1,6 +1,19 @@ ir_version: 7 producer_name: "test_data_generator" graph { + node { + input: "in1" + output: "relu1" + name: "relu1_name" + op_type: "Relu" + } + node { + input: "relu1" + input: "in2" + output: "add1" + name: "add_ambiguous_name" + op_type: "Add" + } node { input: "in3" input: "in4" @@ -8,15 +21,17 @@ graph { op_type: "Conv" } node { - input: "relu1" - input: "add1" + input: "add2/placeholder_port_0" + input: "add2/placeholder_port_1" output: "add2" + name: "add_ambiguous_name" op_type: "Add" } node { input: "add1" input: "conv1" output: "mul2" + name: "" op_type: "Mul" } name: "subgraph_extraction_testing" @@ -29,6 +44,32 @@ graph { float_data: 1 name: "in4" } + input { + name: "in1" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 2 + } + dim { + dim_value: 2 + } + } + } + } + } + input { + name: "in2" + type { + tensor_type { + elem_type: 1 + shape { + } + } + } + } input { name: "in3" type { @@ -74,7 +115,7 @@ graph { } } input { - name: "relu1" + name: "add2/placeholder_port_0" type { tensor_type { elem_type: 1 @@ -90,7 +131,7 @@ graph { } } input { - name: "add1" + name: "add2/placeholder_port_1" type { tensor_type { elem_type: 1 diff --git a/ngraph/test/models/onnx/model_editor/reference/subgraph__input_edge_from_tensor_with_multiple_consumers_3.prototxt b/ngraph/test/models/onnx/model_editor/reference/subgraph__input_edge_from_tensor_with_multiple_consumers_3.prototxt index ea70f359331898..314cb096a9b2e7 100644 --- a/ngraph/test/models/onnx/model_editor/reference/subgraph__input_edge_from_tensor_with_multiple_consumers_3.prototxt +++ b/ngraph/test/models/onnx/model_editor/reference/subgraph__input_edge_from_tensor_with_multiple_consumers_3.prototxt @@ -1,22 +1,31 @@ ir_version: 7 producer_name: "test_data_generator" graph { + node { + input: "in1" + output: "relu1" + name: "relu1_name" + op_type: "Relu" + } node { input: "relu1" input: "in2" output: "add1" + name: "add_ambiguous_name" op_type: "Add" } node { - input: "relu1" + input: "add2/placeholder_port_0" input: "add1" output: "add2" + name: "add_ambiguous_name" op_type: "Add" } node { input: "add2" output: "split1" output: "split2" + name: "split_name" op_type: "Split" attribute { name: "axis" @@ -25,12 +34,28 @@ graph { } } node { - input: "relu1" + input: "mul1/placeholder_port_0" input: "split1" output: "mul1" op_type: "Mul" } name: "subgraph_extraction_testing" + input { + name: "in1" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 2 + } + dim { + dim_value: 2 + } + } + } + } + } input { name: "in2" type { @@ -42,7 +67,23 @@ graph { } } input { - name: "relu1" + name: "add2/placeholder_port_0" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 2 + } + dim { + dim_value: 2 + } + } + } + } + } + input { + name: "mul1/placeholder_port_0" type { tensor_type { elem_type: 1 diff --git a/ngraph/test/models/onnx/model_editor/reference/subgraph__input_edge_from_tensor_with_multiple_consumers_4.prototxt b/ngraph/test/models/onnx/model_editor/reference/subgraph__input_edge_from_tensor_with_multiple_consumers_4.prototxt new file mode 100644 index 00000000000000..dc7c3b7c91db03 --- /dev/null +++ b/ngraph/test/models/onnx/model_editor/reference/subgraph__input_edge_from_tensor_with_multiple_consumers_4.prototxt @@ -0,0 +1,224 @@ +ir_version: 7 +producer_name: "test_data_generator" +graph { + node { + input: "in1" + output: "relu1" + name: "relu1_name" + op_type: "Relu" + } + node { + input: "add1/placeholder_port_0" + input: "in2" + output: "add1" + name: "add_ambiguous_name" + op_type: "Add" + } + node { + input: "in3" + input: "in4" + output: "conv1" + op_type: "Conv" + } + node { + input: "add2/placeholder_port_0" + input: "add1" + output: "add2" + name: "add_ambiguous_name" + op_type: "Add" + } + node { + input: "add1" + input: "conv1" + output: "mul2" + name: "" + op_type: "Mul" + } + node { + input: "add2" + output: "split1" + output: "split2" + name: "split_name" + op_type: "Split" + attribute { + name: "axis" + i: 1 + type: INT + } + } + node { + input: "relu1" + input: "split1" + output: "mul1" + op_type: "Mul" + } + name: "subgraph_extraction_testing" + initializer { + dims: 1 + dims: 1 + dims: 1 + dims: 1 + data_type: 1 + float_data: 1 + name: "in4" + } + input { + name: "in1" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 2 + } + dim { + dim_value: 2 + } + } + } + } + } + input { + name: "in2" + type { + tensor_type { + elem_type: 1 + shape { + } + } + } + } + input { + name: "in3" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 1 + } + dim { + dim_value: 1 + } + dim { + dim_value: 2 + } + dim { + dim_value: 2 + } + } + } + } + } + input { + name: "in4" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 1 + } + dim { + dim_value: 1 + } + dim { + dim_value: 1 + } + dim { + dim_value: 1 + } + } + } + } + } + input { + name: "add1/placeholder_port_0" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 2 + } + dim { + dim_value: 2 + } + } + } + } + } + input { + name: "add2/placeholder_port_0" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 2 + } + dim { + dim_value: 2 + } + } + } + } + } + output { + name: "mul1" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 2 + } + dim { + dim_value: 2 + } + } + } + } + } + output { + name: "split2" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 2 + } + dim { + dim_value: 1 + } + } + } + } + } + output { + name: "mul2" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 1 + } + dim { + dim_value: 1 + } + dim { + dim_value: 2 + } + dim { + dim_value: 2 + } + } + } + } + } +} +opset_import { + version: 13 +} diff --git a/ngraph/test/models/onnx/model_editor/reference/subgraph__input_edge_from_tensor_with_multiple_consumers_5.prototxt b/ngraph/test/models/onnx/model_editor/reference/subgraph__input_edge_from_tensor_with_multiple_consumers_5.prototxt new file mode 100644 index 00000000000000..e2afe1ff1e2702 --- /dev/null +++ b/ngraph/test/models/onnx/model_editor/reference/subgraph__input_edge_from_tensor_with_multiple_consumers_5.prototxt @@ -0,0 +1,120 @@ +ir_version: 7 +producer_name: "test_data_generator" +graph { + node { + input: "in1" + output: "relu1" + name: "relu1_name" + op_type: "Relu" + } + node { + input: "relu1" + input: "in2" + output: "add1" + name: "add_ambiguous_name" + op_type: "Add" + } + node { + input: "add2/placeholder_port_0" + input: "add1" + output: "add2" + name: "add_ambiguous_name" + op_type: "Add" + } + node { + input: "add2" + output: "split1" + output: "split2" + name: "split_name" + op_type: "Split" + attribute { + name: "axis" + i: 1 + type: INT + } + } + node { + input: "relu1" + input: "split1" + output: "mul1" + op_type: "Mul" + } + name: "subgraph_extraction_testing" + input { + name: "in1" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 2 + } + dim { + dim_value: 2 + } + } + } + } + } + input { + name: "in2" + type { + tensor_type { + elem_type: 1 + shape { + } + } + } + } + input { + name: "add2/placeholder_port_0" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 2 + } + dim { + dim_value: 2 + } + } + } + } + } + output { + name: "mul1" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 2 + } + dim { + dim_value: 2 + } + } + } + } + } + output { + name: "split2" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 2 + } + dim { + dim_value: 1 + } + } + } + } + } +} +opset_import { + version: 13 +} diff --git a/ngraph/test/models/onnx/model_editor/reference/subgraph__multiple_consumers_of_graph_initializer_relu2_and_init.prototxt b/ngraph/test/models/onnx/model_editor/reference/subgraph__multiple_consumers_of_graph_initializer_relu2_and_init.prototxt index 186d8f4f01c400..5c5083fb84a36e 100644 --- a/ngraph/test/models/onnx/model_editor/reference/subgraph__multiple_consumers_of_graph_initializer_relu2_and_init.prototxt +++ b/ngraph/test/models/onnx/model_editor/reference/subgraph__multiple_consumers_of_graph_initializer_relu2_and_init.prototxt @@ -4,6 +4,12 @@ graph { node { input: "in1" output: "relu1" + name: "add1" + op_type: "Relu" + } + node { + input: "in1" + output: "relu2" op_type: "Relu" } node { @@ -14,16 +20,18 @@ graph { node { input: "in2" output: "relu4" + name: "relu4_name" op_type: "Relu" } node { input: "relu1" input: "relu2" output: "add1" + name: "add1_name" op_type: "Add" } node { - input: "relu2" + input: "add2/placeholder_port_0" input: "relu3" output: "add2" op_type: "Add" @@ -50,7 +58,7 @@ graph { } } input { - name: "relu2" + name: "add2/placeholder_port_0" type { tensor_type { elem_type: 1 diff --git a/ngraph/test/models/onnx/model_editor/reference/subgraph__multiple_consumers_of_graph_input_relu2.prototxt b/ngraph/test/models/onnx/model_editor/reference/subgraph__multiple_consumers_of_graph_input_relu2.prototxt index c8556c7d366c44..1319a560db2892 100644 --- a/ngraph/test/models/onnx/model_editor/reference/subgraph__multiple_consumers_of_graph_input_relu2.prototxt +++ b/ngraph/test/models/onnx/model_editor/reference/subgraph__multiple_consumers_of_graph_input_relu2.prototxt @@ -3,7 +3,7 @@ producer_name: "test_data_generator" graph { node { input: "in1" - output: "relu1" + output: "relu2" op_type: "Relu" } node { @@ -14,12 +14,14 @@ graph { node { input: "in2" output: "relu4" + name: "relu4_name" op_type: "Relu" } node { input: "relu1" input: "relu2" output: "add1" + name: "add1_name" op_type: "Add" } node { @@ -55,7 +57,7 @@ graph { } } input { - name: "relu2" + name: "relu1" type { tensor_type { elem_type: 1 diff --git a/ngraph/test/models/onnx/model_editor/reference/subgraph__twice_input_edge_from_tensor_with_single_consumer.prototxt b/ngraph/test/models/onnx/model_editor/reference/subgraph__twice_input_edge_from_tensor_with_single_consumer.prototxt new file mode 100644 index 00000000000000..12cbda0da5d621 --- /dev/null +++ b/ngraph/test/models/onnx/model_editor/reference/subgraph__twice_input_edge_from_tensor_with_single_consumer.prototxt @@ -0,0 +1,74 @@ +ir_version: 3 +producer_name: "nGraph ONNX Importer" +graph { + node { + input: "A" + input: "B" + output: "X" + name: "add_node1" + op_type: "Add" + } + node { + input: "X" + input: "Y/placeholder_port_1" + output: "Y" + name: "add_node2" + op_type: "Add" + } + name: "test_graph" + input { + name: "A" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 1 + } + } + } + } + } + input { + name: "B" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 1 + } + } + } + } + } + input { + name: "Y/placeholder_port_1" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 1 + } + } + } + } + } + output { + name: "Y" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 1 + } + } + } + } + } +} +opset_import { + version: 13 +} diff --git a/ngraph/test/onnx/onnx_editor.cpp b/ngraph/test/onnx/onnx_editor.cpp index 7dbe406166ff08..fc784f605eee7c 100644 --- a/ngraph/test/onnx/onnx_editor.cpp +++ b/ngraph/test/onnx/onnx_editor.cpp @@ -273,12 +273,13 @@ NGRAPH_TEST(onnx_editor, shapes__static_to_dynamic_rank_substitution) } } + NGRAPH_TEST(onnx_editor, subgraph__linear_model_head_cut) { ONNXModelEditor editor{file_util::path_join( SERIALIZED_ZOO, "onnx/model_editor/subgraph__inception_head.prototxt")}; - editor.cut_graph_fragment({{InputEdge(1, "conv1/7x7_s2_1")}}, {}); + editor.cut_graph_fragment({{InputEdge(1, 0)}}, {}); const auto ref_model = file_util::path_join( SERIALIZED_ZOO, "onnx/model_editor/reference/subgraph__linear_model_head_cut.prototxt"); @@ -293,8 +294,8 @@ NGRAPH_TEST(onnx_editor, subgraph__linear_model_head_cut_ins_and_outs) ONNXModelEditor editor{file_util::path_join( SERIALIZED_ZOO, "onnx/model_editor/subgraph__inception_head.prototxt")}; - editor.cut_graph_fragment({{InputEdge(1, "conv1/7x7_s2_1")}}, - {{OutputEdge(2, "pool1/3x3_s2_1")}}); + editor.cut_graph_fragment({{InputEdge(1, 0)}}, + {{OutputEdge(2, 0)}}); // expected to behave the same way as subgraph__linear_model_head_cut const auto ref_model = file_util::path_join( @@ -310,7 +311,7 @@ NGRAPH_TEST(onnx_editor, subgraph__linear_model_deeper_head_cut) ONNXModelEditor editor{file_util::path_join( SERIALIZED_ZOO, "onnx/model_editor/subgraph__inception_head.prototxt")}; - editor.cut_graph_fragment({{InputEdge(2, "conv1/7x7_s2_2")}}, {}); + editor.cut_graph_fragment({{InputEdge(2, 0)}}, {}); const auto ref_model = file_util::path_join( SERIALIZED_ZOO, @@ -326,7 +327,7 @@ NGRAPH_TEST(onnx_editor, subgraph__linear_model_tail_cut) ONNXModelEditor editor{file_util::path_join( SERIALIZED_ZOO, "onnx/model_editor/subgraph__inception_head.prototxt")}; - editor.cut_graph_fragment({}, {{OutputEdge{1, "conv1/7x7_s2_2"}}}); + editor.cut_graph_fragment({}, {{OutputEdge{1, 0}}}); const auto ref_model = file_util::path_join( SERIALIZED_ZOO, "onnx/model_editor/reference/subgraph__linear_model_tail_cut.prototxt"); @@ -341,7 +342,7 @@ NGRAPH_TEST(onnx_editor, subgraph__linear_model_tail_cut_ins_and_outs) ONNXModelEditor editor{file_util::path_join( SERIALIZED_ZOO, "onnx/model_editor/subgraph__inception_head.prototxt")}; - editor.cut_graph_fragment({{InputEdge{0, "data_0"}}}, {{OutputEdge{1, "conv1/7x7_s2_2"}}}); + editor.cut_graph_fragment({{InputEdge{0, 0}}}, {{OutputEdge{1, 0}}}); // expected to behave the same way as subgraph__linear_model_tail_cut const auto ref_model = file_util::path_join( @@ -357,7 +358,7 @@ NGRAPH_TEST(onnx_editor, subgraph__linear_model_with_initializer_tail_cut) ONNXModelEditor editor{file_util::path_join( SERIALIZED_ZOO, "onnx/model_editor/subgraph__inception_head_with_initializer.prototxt")}; - editor.cut_graph_fragment({}, {{OutputEdge{1, "conv1/7x7_s2_2"}}}); + editor.cut_graph_fragment({}, {{OutputEdge{1, 0}}}); const auto ref_model = file_util::path_join( SERIALIZED_ZOO, @@ -373,7 +374,7 @@ NGRAPH_TEST(onnx_editor, subgraph__initializer_without_matching_input_tail_cut) ONNXModelEditor editor{file_util::path_join( SERIALIZED_ZOO, "onnx/model_editor/subgraph__initializer_without_matching_input.prototxt")}; - editor.cut_graph_fragment({}, {{OutputEdge{1, "conv1/7x7_s2_2"}}}); + editor.cut_graph_fragment({}, {{OutputEdge{1, 0}}}); const auto ref_model = file_util::path_join(SERIALIZED_ZOO, @@ -390,7 +391,7 @@ NGRAPH_TEST(onnx_editor, subgraph__linear_model_deeper_tail_cut) ONNXModelEditor editor{file_util::path_join( SERIALIZED_ZOO, "onnx/model_editor/subgraph__inception_head.prototxt")}; - editor.cut_graph_fragment({}, {{OutputEdge{0, "conv1/7x7_s2_1"}}}); + editor.cut_graph_fragment({}, {{OutputEdge{0, 0}}}); const auto ref_model = file_util::path_join( SERIALIZED_ZOO, @@ -420,8 +421,8 @@ NGRAPH_TEST(onnx_editor, subgraph__initializer_to_input_replacement) ONNXModelEditor editor{file_util::path_join( SERIALIZED_ZOO, "onnx/model_editor/subgraph__inception_head_with_initializer.prototxt")}; - editor.cut_graph_fragment({{InputEdge{0, "conv1/7x7_s2_b_0"}}}, - {{OutputEdge{0, "conv1/7x7_s2_1"}}}); + editor.cut_graph_fragment({{InputEdge{0, 2}}}, + {{OutputEdge{0, 0}}}); const auto ref_model = file_util::path_join( SERIALIZED_ZOO, @@ -437,8 +438,8 @@ NGRAPH_TEST(onnx_editor, subgraph__initializer_to_input_replacement_2) ONNXModelEditor editor{file_util::path_join( SERIALIZED_ZOO, "onnx/model_editor/subgraph__initializer_without_matching_input.prototxt")}; - editor.cut_graph_fragment({{InputEdge{0, "conv1/7x7_s2_b_0"}}}, - {{OutputEdge{0, "conv1/7x7_s2_1"}}}); + editor.cut_graph_fragment({{InputEdge{0, 2}}}, + {{OutputEdge{0, 0}}}); const auto ref_model = file_util::path_join( SERIALIZED_ZOO, @@ -454,7 +455,7 @@ NGRAPH_TEST(onnx_editor, subgraph__multiout_op_output_edge) ONNXModelEditor editor{file_util::path_join( SERIALIZED_ZOO, "onnx/model_editor/subgraph_extraction_tests.prototxt")}; - editor.cut_graph_fragment({}, {{OutputEdge{5, "split2"}}}); + editor.cut_graph_fragment({}, {{OutputEdge{5, 1}}}); const auto ref_model = file_util::path_join( SERIALIZED_ZOO, "onnx/model_editor/reference/subgraph__multiout_op_output_edge.prototxt"); @@ -469,8 +470,8 @@ NGRAPH_TEST(onnx_editor, subgraph__existing_inputs_and_outputs_based_extraction) ONNXModelEditor editor{file_util::path_join( SERIALIZED_ZOO, "onnx/model_editor/subgraph_extraction_tests.prototxt")}; - editor.cut_graph_fragment({{InputEdge{1, "in2"}, InputEdge{2, "in3"}}}, - {{OutputEdge{4, "mul2"}}}); + editor.cut_graph_fragment({{InputEdge{1, 1}, InputEdge{2, 0}}}, + {{OutputEdge{4, 0}}}); const auto ref_model = file_util::path_join(SERIALIZED_ZOO, @@ -482,13 +483,30 @@ NGRAPH_TEST(onnx_editor, subgraph__existing_inputs_and_outputs_based_extraction) EXPECT_TRUE(result.is_ok) << result.error_message; } +NGRAPH_TEST(onnx_editor, subgraph__twice_input_edge_from_tensor_with_single_consumer) +{ + ONNXModelEditor editor{file_util::path_join( + SERIALIZED_ZOO, "onnx/model_editor/add_ab.prototxt")}; + + editor.cut_graph_fragment({InputEdge{1, 1}}, {}); + + const auto ref_model = + file_util::path_join(SERIALIZED_ZOO, + "onnx/model_editor/reference/" + "subgraph__twice_input_edge_from_tensor_with_single_consumer.prototxt"); + + const auto result = compare_onnx_models(editor.model_string(), ref_model); + + EXPECT_TRUE(result.is_ok) << result.error_message; +} + NGRAPH_TEST(onnx_editor, subgraph__input_edge_from_tensor_with_multiple_consumers) { ONNXModelEditor editor{file_util::path_join( SERIALIZED_ZOO, "onnx/model_editor/subgraph_extraction_tests.prototxt")}; - editor.cut_graph_fragment({{InputEdge{1, "relu1"}, InputEdge{6, "relu1"}}}, - {{OutputEdge{6, "mul1"}, OutputEdge{4, "mul2"}}}); + editor.cut_graph_fragment({{InputEdge{1, 0}, InputEdge{6, 0}}}, + {{OutputEdge{6, 0}, OutputEdge{4, 0}}}); const auto ref_model = file_util::path_join(SERIALIZED_ZOO, @@ -505,8 +523,8 @@ NGRAPH_TEST(onnx_editor, subgraph__input_edge_from_tensor_with_multiple_consumer ONNXModelEditor editor{file_util::path_join( SERIALIZED_ZOO, "onnx/model_editor/subgraph_extraction_tests.prototxt")}; - editor.cut_graph_fragment({{InputEdge{3, "relu1"}, InputEdge{3, "add1"}}}, - {{OutputEdge{3, "add2"}, OutputEdge{4, "mul2"}}}); + editor.cut_graph_fragment({{InputEdge{3, 0}, InputEdge{3, 1}}}, + {{OutputEdge{3, 0}, OutputEdge{4, 0}}}); const auto ref_model = file_util::path_join(SERIALIZED_ZOO, @@ -523,8 +541,8 @@ NGRAPH_TEST(onnx_editor, subgraph__input_edge_from_tensor_with_multiple_consumer ONNXModelEditor editor{file_util::path_join( SERIALIZED_ZOO, "onnx/model_editor/subgraph_extraction_tests.prototxt")}; - editor.cut_graph_fragment({{InputEdge{3, "relu1"}, InputEdge{6, "relu1"}}}, - {{OutputEdge{6, "mul1"}, OutputEdge{5, "split2"}}}); + editor.cut_graph_fragment({{InputEdge{3, 0}, InputEdge{6, 0}}}, + {{OutputEdge{6, 0}, OutputEdge{5, 1}}}); const auto ref_model = file_util::path_join(SERIALIZED_ZOO, @@ -541,14 +559,31 @@ NGRAPH_TEST(onnx_editor, subgraph__input_edge_from_tensor_with_multiple_consumer ONNXModelEditor editor{file_util::path_join( SERIALIZED_ZOO, "onnx/model_editor/subgraph_extraction_tests.prototxt")}; - editor.cut_graph_fragment({{InputEdge{3, "relu1"}}}, - {{OutputEdge{6, "mul1"}, OutputEdge{5, "split2"}}}); + editor.cut_graph_fragment({{InputEdge{1, 0}, InputEdge{3, 0}}}, {}); + + const auto ref_model = + file_util::path_join(SERIALIZED_ZOO, + "onnx/model_editor/reference/" + "subgraph__input_edge_from_tensor_with_multiple_consumers_4.prototxt"); + + const auto result = compare_onnx_models(editor.model_string(), ref_model); + + EXPECT_TRUE(result.is_ok) << result.error_message; +} + +NGRAPH_TEST(onnx_editor, subgraph__input_edge_from_tensor_with_multiple_consumers_5) +{ + ONNXModelEditor editor{file_util::path_join( + SERIALIZED_ZOO, "onnx/model_editor/subgraph_extraction_tests.prototxt")}; + + editor.cut_graph_fragment({InputEdge{3, 0}}, + {{OutputEdge{6,0}, OutputEdge{5, 1}}}); // expected to behave the same way as the test above const auto ref_model = file_util::path_join(SERIALIZED_ZOO, "onnx/model_editor/reference/" - "subgraph__input_edge_from_tensor_with_multiple_consumers_3.prototxt"); + "subgraph__input_edge_from_tensor_with_multiple_consumers_5.prototxt"); const auto result = compare_onnx_models(editor.model_string(), ref_model); @@ -560,7 +595,7 @@ NGRAPH_TEST(onnx_editor, subgraph__multiple_consumers_of_graph_input_relu2) ONNXModelEditor editor{file_util::path_join( SERIALIZED_ZOO, "onnx/model_editor/subgraph_extraction_tests_2.prototxt")}; - editor.cut_graph_fragment({{InputEdge{4, "relu2"}}}, {}); + editor.cut_graph_fragment({{InputEdge{4, 0}}}, {}); const auto ref_model = file_util::path_join(SERIALIZED_ZOO, @@ -577,7 +612,7 @@ NGRAPH_TEST(onnx_editor, subgraph__multiple_consumers_of_graph_initializer) ONNXModelEditor editor{file_util::path_join( SERIALIZED_ZOO, "onnx/model_editor/subgraph_extraction_tests_2.prototxt")}; - editor.cut_graph_fragment({{InputEdge{2, "in2"}}}, {}); + editor.cut_graph_fragment({{InputEdge{2, 0}}}, {}); const auto ref_model = file_util::path_join(SERIALIZED_ZOO, @@ -594,7 +629,7 @@ NGRAPH_TEST(onnx_editor, subgraph__multiple_consumers_of_graph_initializer_2) ONNXModelEditor editor{file_util::path_join( SERIALIZED_ZOO, "onnx/model_editor/subgraph_extraction_tests_2.prototxt")}; - editor.cut_graph_fragment({{InputEdge{2, "in2"}, InputEdge{3, "in2"}}}, {}); + editor.cut_graph_fragment({{InputEdge{2, 0}, InputEdge{3, 0}}}, {}); // same as above const auto ref_model = @@ -612,7 +647,7 @@ NGRAPH_TEST(onnx_editor, subgraph__multiple_consumers_of_graph_initializer_relu2 ONNXModelEditor editor{file_util::path_join( SERIALIZED_ZOO, "onnx/model_editor/subgraph_extraction_tests_2.prototxt")}; - editor.cut_graph_fragment({{InputEdge{5, "relu2"}, InputEdge{3, "in2"}}}, {}); + editor.cut_graph_fragment({{InputEdge{5, 0}, InputEdge{3, 0}}}, {}); const auto ref_model = file_util::path_join( SERIALIZED_ZOO, @@ -630,18 +665,36 @@ NGRAPH_TEST(onnx_editor, subgraph__invalid_edge_idx) file_util::path_join(SERIALIZED_ZOO, "onnx/model_editor/subgraph__inception_head.prototxt"); ONNXModelEditor editor{model_path}; - - EXPECT_THROW(editor.cut_graph_fragment({{InputEdge{15, "x"}}}, {}), ngraph::ngraph_error); + try + { + editor.cut_graph_fragment({{InputEdge{15, 0}}}, {}); + } + catch (const std::exception& e) + { + std::string msg{e.what()}; + EXPECT_TRUE( + msg.find("The specified node index is out of range of nodes in the original model") != + std::string::npos); + } } -NGRAPH_TEST(onnx_editor, subgraph__invalid_edge_name) +NGRAPH_TEST(onnx_editor, subgraph__invalid_port_idx) { const auto model_path = file_util::path_join(SERIALIZED_ZOO, "onnx/model_editor/subgraph__inception_head.prototxt"); ONNXModelEditor editor{model_path}; - - EXPECT_THROW(editor.cut_graph_fragment({{InputEdge{0, "x"}}}, {}), ngraph::ngraph_error); + try + { + editor.cut_graph_fragment({{InputEdge{0, 3}}}, {}); + } + catch (const std::exception& e) + { + std::string msg{e.what()}; + EXPECT_TRUE( + msg.find("Node with index: 0 has not input with index: 3") != + std::string::npos); + } } NGRAPH_TEST(onnx_editor, subgraph__inputs_getter) @@ -652,7 +705,7 @@ NGRAPH_TEST(onnx_editor, subgraph__inputs_getter) EXPECT_EQ(editor.model_inputs(), (std::vector{"data_0", "conv1/7x7_s2_w_0", "conv1/7x7_s2_b_0"})); - editor.cut_graph_fragment({{InputEdge(1, "conv1/7x7_s2_1")}}, {}); + editor.cut_graph_fragment({{InputEdge{1, 0}}}, {}); EXPECT_EQ(editor.model_inputs(), (std::vector{"conv1/7x7_s2_1"})); } @@ -667,12 +720,12 @@ NGRAPH_TEST(onnx_editor, editor_api_select_input_edge_by_output_name_and_input_n const InputEdge edge = editor.find_input_edge(EditorNode{EditorOutput{"conv1/7x7_s2_2"}}, EditorInput{"conv1/7x7_s2_1"}); EXPECT_EQ(edge.m_node_idx, 1); - EXPECT_EQ(edge.m_tensor_name, "conv1/7x7_s2_1"); + EXPECT_EQ(edge.m_port_idx, 0); const InputEdge edge2 = editor.find_input_edge(EditorNode{EditorOutput{"conv1/7x7_s2_1"}}, EditorInput{"data_0"}); EXPECT_EQ(edge2.m_node_idx, 0); - EXPECT_EQ(edge2.m_tensor_name, "data_0"); + EXPECT_EQ(edge2.m_port_idx, 0); } NGRAPH_TEST(onnx_editor, editor_api_select_input_edge_by_output_name_and_input_index) @@ -683,17 +736,17 @@ NGRAPH_TEST(onnx_editor, editor_api_select_input_edge_by_output_name_and_input_i const InputEdge edge = editor.find_input_edge(EditorNode{EditorOutput{"conv1/7x7_s2_2"}}, EditorInput{0}); EXPECT_EQ(edge.m_node_idx, 1); - EXPECT_EQ(edge.m_tensor_name, "conv1/7x7_s2_1"); + EXPECT_EQ(edge.m_port_idx, 0); const InputEdge edge2 = editor.find_input_edge(EditorNode{EditorOutput{"conv1/7x7_s2_1"}}, EditorInput{1}); EXPECT_EQ(edge2.m_node_idx, 0); - EXPECT_EQ(edge2.m_tensor_name, "conv1/7x7_s2_w_0"); + EXPECT_EQ(edge2.m_port_idx, 1); const InputEdge edge3 = editor.find_input_edge(EditorNode{EditorOutput{"conv1/7x7_s2_1"}}, EditorInput{2}); EXPECT_EQ(edge3.m_node_idx, 0); - EXPECT_EQ(edge3.m_tensor_name, "conv1/7x7_s2_b_0"); + EXPECT_EQ(edge3.m_port_idx, 2); } NGRAPH_TEST(onnx_editor, editor_api_select_input_edge_by_node_name_and_input_name) @@ -704,12 +757,12 @@ NGRAPH_TEST(onnx_editor, editor_api_select_input_edge_by_node_name_and_input_nam const InputEdge edge = editor.find_input_edge(EditorNode{"relu1"}, EditorInput{"conv1/7x7_s2_1"}); EXPECT_EQ(edge.m_node_idx, 1); - EXPECT_EQ(edge.m_tensor_name, "conv1/7x7_s2_1"); + EXPECT_EQ(edge.m_port_idx, 0); const InputEdge edge2 = editor.find_input_edge(EditorNode{"conv1"}, EditorInput{"conv1/7x7_s2_w_0"}); EXPECT_EQ(edge2.m_node_idx, 0); - EXPECT_EQ(edge2.m_tensor_name, "conv1/7x7_s2_w_0"); + EXPECT_EQ(edge2.m_port_idx, 1); } NGRAPH_TEST(onnx_editor, editor_api_select_input_edge_by_node_name_and_input_index) @@ -719,11 +772,11 @@ NGRAPH_TEST(onnx_editor, editor_api_select_input_edge_by_node_name_and_input_ind const InputEdge edge = editor.find_input_edge(EditorNode{"relu1_name"}, EditorInput{0}); EXPECT_EQ(edge.m_node_idx, 0); - EXPECT_EQ(edge.m_tensor_name, "in1"); + EXPECT_EQ(edge.m_port_idx, 0); const InputEdge edge2 = editor.find_input_edge(EditorNode{"split_name"}, EditorInput{0}); EXPECT_EQ(edge2.m_node_idx, 5); - EXPECT_EQ(edge2.m_tensor_name, "add2"); + EXPECT_EQ(edge2.m_port_idx, 0); } NGRAPH_TEST(onnx_editor, editor_api_select_input_edge_empty_node_name) @@ -733,7 +786,6 @@ NGRAPH_TEST(onnx_editor, editor_api_select_input_edge_empty_node_name) try { - const InputEdge edge = editor.find_input_edge(EditorNode{""}, EditorInput{"conv1/7x7_s2_1"}); } catch (const std::exception& e) @@ -754,23 +806,23 @@ NGRAPH_TEST(onnx_editor, editor_api_select_output_edge_by_output_name) const OutputEdge edge = editor.find_output_edge(EditorNode{EditorOutput{"mul2"}}, EditorOutput{"mul2"}); EXPECT_EQ(edge.m_node_idx, 4); - EXPECT_EQ(edge.m_tensor_name, "mul2"); + EXPECT_EQ(edge.m_port_idx, 0); const OutputEdge edge2 = editor.find_output_edge(EditorNode{EditorOutput{"split1"}}, EditorOutput{"split2"}); EXPECT_EQ(edge2.m_node_idx, 5); - EXPECT_EQ(edge2.m_tensor_name, "split2"); + EXPECT_EQ(edge2.m_port_idx, 1); // simplified overload const OutputEdge edge3 = editor.find_output_edge("mul2"); EXPECT_EQ(edge3.m_node_idx, 4); - EXPECT_EQ(edge3.m_tensor_name, "mul2"); + EXPECT_EQ(edge3.m_port_idx, 0); const OutputEdge edge4 = editor.find_output_edge("split2"); EXPECT_EQ(edge4.m_node_idx, 5); - EXPECT_EQ(edge4.m_tensor_name, "split2"); + EXPECT_EQ(edge4.m_port_idx, 1); } NGRAPH_TEST(onnx_editor, editor_api_select_output_edge_by_output_name_and_output_index) @@ -781,17 +833,17 @@ NGRAPH_TEST(onnx_editor, editor_api_select_output_edge_by_output_name_and_output const OutputEdge edge = editor.find_output_edge(EditorNode{EditorOutput{"add2"}}, EditorOutput{0}); EXPECT_EQ(edge.m_node_idx, 3); - EXPECT_EQ(edge.m_tensor_name, "add2"); + EXPECT_EQ(edge.m_port_idx, 0); const OutputEdge edge2 = editor.find_output_edge(EditorNode{EditorOutput{"split1"}}, EditorOutput{1}); EXPECT_EQ(edge2.m_node_idx, 5); - EXPECT_EQ(edge2.m_tensor_name, "split2"); + EXPECT_EQ(edge2.m_port_idx, 1); const OutputEdge edge3 = editor.find_output_edge(EditorNode{EditorOutput{"split2"}}, EditorOutput{0}); EXPECT_EQ(edge3.m_node_idx, 5); - EXPECT_EQ(edge3.m_tensor_name, "split1"); + EXPECT_EQ(edge3.m_port_idx, 0); } NGRAPH_TEST(onnx_editor, editor_api_select_output_edge_by_node_name_and_output_name) @@ -802,12 +854,12 @@ NGRAPH_TEST(onnx_editor, editor_api_select_output_edge_by_node_name_and_output_n const OutputEdge edge = editor.find_output_edge(EditorNode{"relu1_name"}, EditorOutput{"relu1"}); EXPECT_EQ(edge.m_node_idx, 0); - EXPECT_EQ(edge.m_tensor_name, "relu1"); + EXPECT_EQ(edge.m_port_idx, 0); const OutputEdge edge2 = editor.find_output_edge(EditorNode{"split_name"}, EditorOutput{"split2"}); EXPECT_EQ(edge2.m_node_idx, 5); - EXPECT_EQ(edge2.m_tensor_name, "split2"); + EXPECT_EQ(edge2.m_port_idx, 1); } NGRAPH_TEST(onnx_editor, editor_api_select_output_edge_by_node_name_and_output_index) @@ -817,11 +869,11 @@ NGRAPH_TEST(onnx_editor, editor_api_select_output_edge_by_node_name_and_output_i const OutputEdge edge = editor.find_output_edge(EditorNode{"relu1_name"}, EditorOutput{0}); EXPECT_EQ(edge.m_node_idx, 0); - EXPECT_EQ(edge.m_tensor_name, "relu1"); + EXPECT_EQ(edge.m_port_idx, 0); const OutputEdge edge2 = editor.find_output_edge(EditorNode{"split_name"}, EditorOutput{1}); EXPECT_EQ(edge2.m_node_idx, 5); - EXPECT_EQ(edge2.m_tensor_name, "split2"); + EXPECT_EQ(edge2.m_port_idx, 1); } NGRAPH_TEST(onnx_editor, editor_api_select_edge_const_network) @@ -832,15 +884,15 @@ NGRAPH_TEST(onnx_editor, editor_api_select_edge_const_network) const InputEdge edge = editor.find_input_edge(EditorNode{EditorOutput{"relu4"}}, EditorInput{0}); EXPECT_EQ(edge.m_node_idx, 3); - EXPECT_EQ(edge.m_tensor_name, "in2"); + EXPECT_EQ(edge.m_port_idx, 0); const OutputEdge edge2 = editor.find_output_edge(EditorNode{"relu4_name"}, EditorOutput{0}); EXPECT_EQ(edge2.m_node_idx, 3); - EXPECT_EQ(edge2.m_tensor_name, "relu4"); + EXPECT_EQ(edge2.m_port_idx, 0); const OutputEdge edge3 = editor.find_output_edge(EditorNode{"add1_name"}, EditorOutput{0}); EXPECT_EQ(edge3.m_node_idx, 4); - EXPECT_EQ(edge3.m_tensor_name, "add1"); + EXPECT_EQ(edge3.m_port_idx, 0); } NGRAPH_TEST(onnx_editor, editor_api_select_edge_error_handling) @@ -851,8 +903,7 @@ NGRAPH_TEST(onnx_editor, editor_api_select_edge_error_handling) // node with given output name not found try { - const InputEdge edge = - editor.find_input_edge(EditorNode{EditorOutput{"not_existed"}}, EditorInput{0}); + editor.find_input_edge(EditorNode{EditorOutput{"not_existed"}}, EditorInput{0}); } catch (const std::exception& e) { @@ -865,7 +916,7 @@ NGRAPH_TEST(onnx_editor, editor_api_select_edge_error_handling) // node with given name not found try { - const InputEdge edge = editor.find_input_edge(EditorNode{"not_existed"}, EditorInput{0}); + editor.find_input_edge(EditorNode{"not_existed"}, EditorInput{0}); } catch (const std::exception& e) { @@ -878,7 +929,7 @@ NGRAPH_TEST(onnx_editor, editor_api_select_edge_error_handling) // input index out of scope try { - const InputEdge edge = editor.find_input_edge(EditorNode{"relu4_name"}, EditorInput{1}); + editor.find_input_edge(EditorNode{"relu4_name"}, EditorInput{1}); } catch (const std::exception& e) { @@ -890,8 +941,7 @@ NGRAPH_TEST(onnx_editor, editor_api_select_edge_error_handling) // output index out of scope try { - const OutputEdge edge = - editor.find_output_edge(EditorNode{"relu4_name"}, EditorOutput{1}); + editor.find_output_edge(EditorNode{"relu4_name"}, EditorOutput{1}); } catch (const std::exception& e) { @@ -899,6 +949,30 @@ NGRAPH_TEST(onnx_editor, editor_api_select_edge_error_handling) EXPECT_TRUE(msg.find("Node with index: 3 has not output with index: 1") != std::string::npos); } + + // input name not found + try + { + editor.find_input_edge(EditorNode{"relu4_name"}, EditorInput{"not_existed"}); + } + catch (const std::exception& e) + { + std::string msg{e.what()}; + EXPECT_TRUE(msg.find("Node with index: 3 has not input with name: not_existed") != + std::string::npos); + } + + // output name not found + try + { + editor.find_output_edge(EditorNode{"relu4_name"}, EditorOutput{"not_existed"}); + } + catch (const std::exception& e) + { + std::string msg{e.what()}; + EXPECT_TRUE(msg.find("Node with index: 3 has not output with name: not_existed") != + std::string::npos); + } } // Nodes with ambiguous node names tests @@ -909,11 +983,11 @@ NGRAPH_TEST(onnx_editor, editor_api_select_input_edge_by_ambiguous_node_name_but InputEdge edge = editor.find_input_edge(EditorNode{"add_ambiguous_name"}, EditorInput{"in2"}); EXPECT_EQ(edge.m_node_idx, 1); - EXPECT_EQ(edge.m_tensor_name, "in2"); + EXPECT_EQ(edge.m_port_idx, 1); const InputEdge edge2 = editor.find_input_edge(EditorNode{"add_ambiguous_name"}, EditorInput{"add1"}); EXPECT_EQ(edge2.m_node_idx, 3); - EXPECT_EQ(edge2.m_tensor_name, "add1"); + EXPECT_EQ(edge2.m_port_idx, 1); } NGRAPH_TEST(onnx_editor, editor_api_select_input_edge_by_ambiguous_node_name_and_not_matched_input) @@ -923,7 +997,7 @@ NGRAPH_TEST(onnx_editor, editor_api_select_input_edge_by_ambiguous_node_name_and try { - const InputEdge edge = editor.find_input_edge(EditorNode{"add_ambiguous_name"}, EditorInput{"in3"}); + editor.find_input_edge(EditorNode{"add_ambiguous_name"}, EditorInput{"in3"}); } catch (const std::exception& e) { @@ -934,7 +1008,7 @@ NGRAPH_TEST(onnx_editor, editor_api_select_input_edge_by_ambiguous_node_name_and try { - const InputEdge edge = editor.find_input_edge(EditorNode{"add_ambiguous_name"}, EditorInput{"relu1"}); + editor.find_input_edge(EditorNode{"add_ambiguous_name"}, EditorInput{"relu1"}); } catch (const std::exception& e) { @@ -951,7 +1025,7 @@ NGRAPH_TEST(onnx_editor, editor_api_select_input_edge_by_ambiguous_node_name_and try { - const InputEdge edge = editor.find_input_edge(EditorNode{"add_ambiguous_name"}, EditorInput{0}); + editor.find_input_edge(EditorNode{"add_ambiguous_name"}, EditorInput{0}); } catch (const std::exception& e) { @@ -968,11 +1042,11 @@ NGRAPH_TEST(onnx_editor, editor_api_select_output_edge_by_ambiguous_node_name_bu const OutputEdge edge = editor.find_output_edge(EditorNode{"add_ambiguous_name"}, EditorOutput{"add1"}); EXPECT_EQ(edge.m_node_idx, 1); - EXPECT_EQ(edge.m_tensor_name, "add1"); + EXPECT_EQ(edge.m_port_idx, 0); const OutputEdge edge2 = editor.find_output_edge(EditorNode{"add_ambiguous_name"}, EditorOutput{"add2"}); EXPECT_EQ(edge2.m_node_idx, 3); - EXPECT_EQ(edge2.m_tensor_name, "add2"); + EXPECT_EQ(edge2.m_port_idx, 0); } NGRAPH_TEST(onnx_editor, editor_api_select_output_edge_by_the_same_node_name_and_output_name) @@ -982,11 +1056,11 @@ NGRAPH_TEST(onnx_editor, editor_api_select_output_edge_by_the_same_node_name_and const OutputEdge edge = editor.find_output_edge(EditorNode{"add1"}, EditorOutput{0}); EXPECT_EQ(edge.m_node_idx, 0); - EXPECT_EQ(edge.m_tensor_name, "relu1"); + EXPECT_EQ(edge.m_port_idx, 0); const OutputEdge edge2 = editor.find_output_edge(EditorNode{EditorOutput{"add1"}}, EditorOutput{0}); EXPECT_EQ(edge2.m_node_idx, 4); - EXPECT_EQ(edge2.m_tensor_name, "add1"); + EXPECT_EQ(edge2.m_port_idx, 0); } NGRAPH_TEST(onnx_editor, editor_api_select_output_edge_by_ambiguous_node_name_and_not_matched_output) @@ -996,7 +1070,7 @@ NGRAPH_TEST(onnx_editor, editor_api_select_output_edge_by_ambiguous_node_name_an try { - const OutputEdge edge = editor.find_output_edge(EditorNode{"add_ambiguous_name"}, EditorOutput{"split2"}); + editor.find_output_edge(EditorNode{"add_ambiguous_name"}, EditorOutput{"split2"}); } catch (const std::exception& e) { @@ -1013,7 +1087,7 @@ NGRAPH_TEST(onnx_editor, editor_api_select_output_edge_by_ambiguous_node_name_an try { - const OutputEdge edge = editor.find_output_edge(EditorNode{"add_ambiguous_name"}, EditorOutput{0}); + editor.find_output_edge(EditorNode{"add_ambiguous_name"}, EditorOutput{0}); } catch (const std::exception& e) { @@ -1054,16 +1128,16 @@ NGRAPH_TEST(onnx_editor, editor_api_use_edge_mapper_with_graph_cutter) const auto input_edge_4 = editor.find_input_edge( EditorNode(EditorOutput("relu1")), EditorInput(0)); EXPECT_EQ(input_edge_4.m_node_idx, 0); - EXPECT_EQ(input_edge_4.m_tensor_name, "in1"); + EXPECT_EQ(input_edge_4.m_port_idx, 0); const auto input_edge_5 = editor.find_input_edge( EditorNode(EditorOutput("add1")), EditorInput(1)); EXPECT_EQ(input_edge_5.m_node_idx, 1); - EXPECT_EQ(input_edge_5.m_tensor_name, "in2"); + EXPECT_EQ(input_edge_5.m_port_idx, 1); const auto output_edge_3 = editor.find_output_edge("mul2"); EXPECT_EQ(output_edge_3.m_node_idx, 3); - EXPECT_EQ(output_edge_3.m_tensor_name, "mul2"); + EXPECT_EQ(output_edge_3.m_port_idx, 0); } NGRAPH_TEST(onnx_editor, editor_api_find_output_consumers) @@ -1074,23 +1148,23 @@ NGRAPH_TEST(onnx_editor, editor_api_find_output_consumers) std::vector output_consumers = editor.find_output_consumers("relu1"); EXPECT_EQ(output_consumers.size(), 3); EXPECT_EQ(output_consumers[0].m_node_idx, 1); - EXPECT_EQ(output_consumers[0].m_tensor_name, "relu1"); + EXPECT_EQ(output_consumers[0].m_port_idx, 0); EXPECT_EQ(output_consumers[1].m_node_idx, 3); - EXPECT_EQ(output_consumers[1].m_tensor_name, "relu1"); + EXPECT_EQ(output_consumers[1].m_port_idx, 0); EXPECT_EQ(output_consumers[2].m_node_idx, 6); - EXPECT_EQ(output_consumers[2].m_tensor_name, "relu1"); + EXPECT_EQ(output_consumers[2].m_port_idx, 0); output_consumers = editor.find_output_consumers("add1"); EXPECT_EQ(output_consumers.size(), 2); EXPECT_EQ(output_consumers[0].m_node_idx, 3); - EXPECT_EQ(output_consumers[0].m_tensor_name, "add1"); + EXPECT_EQ(output_consumers[0].m_port_idx, 1); EXPECT_EQ(output_consumers[1].m_node_idx, 4); - EXPECT_EQ(output_consumers[1].m_tensor_name, "add1"); + EXPECT_EQ(output_consumers[1].m_port_idx, 0); output_consumers = editor.find_output_consumers("in3"); EXPECT_EQ(output_consumers.size(), 1); EXPECT_EQ(output_consumers[0].m_node_idx, 2); - EXPECT_EQ(output_consumers[0].m_tensor_name, "in3"); + EXPECT_EQ(output_consumers[0].m_port_idx, 0); } NGRAPH_TEST(onnx_editor, editor_api_find_output_consumers_empty_result) @@ -1129,6 +1203,41 @@ NGRAPH_TEST(onnx_editor, editor_api_is_correct_and_unambiguous_node) EXPECT_EQ(is_correct_node, false); } +NGRAPH_TEST(onnx_editor, editor_api_input_edge_from_tensor_with_single_consumer) +{ + ONNXModelEditor editor{file_util::path_join( + SERIALIZED_ZOO, "onnx/model_editor/add_ab.prototxt")}; + + const auto edge = editor.find_input_edge(EditorNode{EditorOutput{"Y"}}, EditorInput{1}); + editor.cut_graph_fragment({edge}, {}); + + const auto ref_model = + file_util::path_join(SERIALIZED_ZOO, + "onnx/model_editor/reference/" + "subgraph__twice_input_edge_from_tensor_with_single_consumer.prototxt"); + + const auto result = compare_onnx_models(editor.model_string(), ref_model); + + EXPECT_TRUE(result.is_ok) << result.error_message; +} + +NGRAPH_TEST(onnx_editor, editor_api_input_edge_from_tensor_with_single_consumer_ambiguous) +{ + ONNXModelEditor editor{file_util::path_join( + SERIALIZED_ZOO, "onnx/model_editor/add_ab.prototxt")}; + + try + { + editor.find_input_edge(EditorNode{EditorOutput{"Y"}}, EditorInput{"X"}); + } + catch (const std::exception& e) + { + std::string msg{e.what()}; + EXPECT_TRUE(msg.find("Node with index: 1 has more than one inputs with name: X") != + std::string::npos); + } +} + using TestEngine = test::INTERPRETER_Engine; NGRAPH_TEST(onnx_editor, values__append_one_initializer) @@ -1249,7 +1358,7 @@ NGRAPH_TEST(onnx_editor, combined__cut_and_replace_shape) SERIALIZED_ZOO, "onnx/model_editor/subgraph__inception_head.prototxt")}; const auto new_shape = PartialShape({1, 64, 112, 112}); - editor.cut_graph_fragment({{InputEdge(1, "conv1/7x7_s2_1")}}, {}); + editor.cut_graph_fragment({{InputEdge(1, 0)}}, {}); editor.set_input_shapes({{"conv1/7x7_s2_1", new_shape}}); const auto ref_model = file_util::path_join( From 1036cfa4afd2bb2f2d3de8df94845d1c0ed27369 Mon Sep 17 00:00:00 2001 From: mbencer Date: Thu, 6 May 2021 09:20:54 +0200 Subject: [PATCH 115/116] refactor + comments improvement --- .../onnx_editor/src/detail/subgraph_extraction.cpp | 11 ++++------- .../onnx_editor/src/detail/subgraph_extraction.hpp | 7 ++++--- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/ngraph/frontend/onnx_editor/src/detail/subgraph_extraction.cpp b/ngraph/frontend/onnx_editor/src/detail/subgraph_extraction.cpp index f598dc75a8b29c..76388759f1ba8b 100644 --- a/ngraph/frontend/onnx_editor/src/detail/subgraph_extraction.cpp +++ b/ngraph/frontend/onnx_editor/src/detail/subgraph_extraction.cpp @@ -164,6 +164,7 @@ namespace /// \brief Inserts a new input to the graph and connects it to the node designated by an input /// edge passed to this function. + /// \note input_consumers is number of nodes which consume a new input /// \return A new input edge (along with "true") if a new input was added to the graph, /// false + the original edge otherwise. std::pair append_new_graph_input(ONNX_NAMESPACE::GraphProto& graph, @@ -325,14 +326,10 @@ void SubgraphExtractor::add_new_outputs(const std::vector& new_outpu } void SubgraphExtractor::replace_input_edge(const InputEdge& old_edge, - const std::string& new_edge_name) + const std::string& new_input_name) { - // remove the old edge from the helper map and insert a new edge - const auto pos_to_replace_it = - m_node_inputs.at(old_edge.m_node_idx).begin() + old_edge.m_port_idx; - - m_node_inputs.at(old_edge.m_node_idx).erase(pos_to_replace_it); - m_node_inputs.at(old_edge.m_node_idx).insert(pos_to_replace_it, new_edge_name); + // set a new name of an input indicated by the old_edge + m_node_inputs.at(old_edge.m_node_idx).at(old_edge.m_port_idx) = new_input_name; } void SubgraphExtractor::extract_subgraph(std::vector subgraph_outputs) diff --git a/ngraph/frontend/onnx_editor/src/detail/subgraph_extraction.hpp b/ngraph/frontend/onnx_editor/src/detail/subgraph_extraction.hpp index c69173b3fdf964..191f9e72cd329d 100644 --- a/ngraph/frontend/onnx_editor/src/detail/subgraph_extraction.hpp +++ b/ngraph/frontend/onnx_editor/src/detail/subgraph_extraction.hpp @@ -76,14 +76,15 @@ namespace ngraph private: ONNX_NAMESPACE::GraphProto& m_onnx_graph; - // Graph traversal helper: a vector of nodes which have vector of inputs + // Graph traversal helper: the input names of each node std::vector> m_node_inputs; // Number of consumers of all tensors in the graph std::map m_tensor_consumers; - /// \brief Replaces the old input edge with a new one in the helper struct. + /// \brief Replace the name of an input indicated by the old_edge with a new one in the + /// helper struct. /// This is used by the output contributors discovery. - void replace_input_edge(const InputEdge& old_edge, const std::string& new_edge_name); + void replace_input_edge(const InputEdge& old_edge, const std::string& new_input_name); /// \brief Returns a list of edges of each outputs of the graph "m_onnx_graph" std::vector all_output_edges() const; From 22afa62abc0b89292c2ec069e5766cb5db6af1ef Mon Sep 17 00:00:00 2001 From: "Lyalin, Sergey" Date: Fri, 7 May 2021 16:31:54 +0300 Subject: [PATCH 116/116] Switched scenario to 'cut and setPartialShape' --- inference-engine/samples/benchmark_app/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inference-engine/samples/benchmark_app/main.cpp b/inference-engine/samples/benchmark_app/main.cpp index d553f286340659..3afa3958330123 100644 --- a/inference-engine/samples/benchmark_app/main.cpp +++ b/inference-engine/samples/benchmark_app/main.cpp @@ -349,7 +349,7 @@ int main(int argc, char* argv[]) { auto FE = manager.loadByFramework("onnx"); auto inputModel = FE->loadFromFile(FLAGS_m); - int test_scenario = 0; + int test_scenario = 2; // The next test cases are applicable for resnet50-v1-7.onnx model from the official repository