66
77#include < sstream>
88
9- #include " openvino/core/graph_util.hpp"
109#include " openvino/core/model.hpp"
1110#include " openvino/core/node.hpp"
1211#include " openvino/op/util/framework_node.hpp"
@@ -16,17 +15,11 @@ namespace ov {
1615namespace frontend {
1716namespace {
1817
19- struct CollectorContext {
20- const std::vector<UnconvertedOpExtractor>& extractors;
21- UnconvertedOpMap& report;
22- };
23-
2418std::optional<FrameworkNodeErrorInfo> extract_from_framework_node (
2519 const std::shared_ptr<ov::op::util::FrameworkNode>& fw_node) {
2620 if (!fw_node) {
2721 return std::nullopt ;
2822 }
29-
3023 FrameworkNodeErrorInfo info;
3124 const auto & attrs = fw_node->get_attrs ();
3225 info.op_type = attrs.get_type_name ();
@@ -36,16 +29,7 @@ std::optional<FrameworkNodeErrorInfo> extract_from_framework_node(
3629 if (info.op_type .empty ()) {
3730 info.op_type = fw_node->get_friendly_name ();
3831 }
39-
40- std::stringstream consumer;
41- if (fw_node->get_output_size () > 0 ) {
42- auto inputs = fw_node->output (0 ).get_target_inputs ();
43- if (!inputs.empty ()) {
44- consumer << " Consumer: " << *(inputs.begin ()->get_node ());
45- }
46- }
47- info.failure_message = " This is OpenVINO internal type." + consumer.str ();
48-
32+ info.failure_message = " This is OpenVINO internal type." ;
4933 return info;
5034}
5135
@@ -54,51 +38,81 @@ std::optional<FrameworkNodeErrorInfo> extract_node_info(const std::shared_ptr<ov
5438 if (!node) {
5539 return std::nullopt ;
5640 }
57-
5841 for (const auto & extractor : extractors) {
59- if (!extractor) {
60- continue ;
61- }
62- if (auto info = extractor (node)) {
63- return info;
42+ if (extractor) {
43+ if (auto info = extractor (node)) {
44+ return info;
45+ }
6446 }
6547 }
66-
6748 if (const auto & fw_node = ov::as_type_ptr<ov::op::util::FrameworkNode>(node)) {
6849 return extract_from_framework_node (fw_node);
6950 }
70-
7151 return std::nullopt ;
7252}
7353
74- void collect_from_model (const std::shared_ptr<ov::Model>& model, const CollectorContext& ctx) {
54+ void collect_from_model (const std::shared_ptr<ov::Model>& model,
55+ const std::vector<UnconvertedOpExtractor>& extractors,
56+ UnconvertedOpMap& report) {
7557 if (!model) {
7658 return ;
7759 }
78-
7960 for (const auto & node : model->get_ordered_ops ()) {
80- if (auto info = extract_node_info (node, ctx. extractors )) {
81- if (!info->op_type .empty () && ctx. report .count (info->op_type ) == 0 ) {
82- ctx. report .emplace (info->op_type , info->failure_message );
61+ if (auto info = extract_node_info (node, extractors)) {
62+ if (!info->op_type .empty () && report.count (info->op_type ) == 0 ) {
63+ report.emplace (info->op_type , info->failure_message );
8364 }
8465 }
85-
8666 if (const auto & multigraph = ov::as_type_ptr<ov::op::util::MultiSubGraphOp>(node)) {
8767 const size_t subgraphs = multigraph->get_internal_subgraphs_size ();
8868 for (size_t idx = 0 ; idx < subgraphs; ++idx) {
89- collect_from_model (multigraph->get_function (idx), ctx );
69+ collect_from_model (multigraph->get_function (idx), extractors, report );
9070 }
9171 }
9272 }
9373}
9474
9575} // namespace
9676
77+ FrameworkNodeErrorInfo build_framework_node_error_info (const ov::op::util::FrameworkNodeAttrs& attrs,
78+ const std::string& op_type_attr_key,
79+ const std::string& failure_attr_key,
80+ const std::string& version_attr_key) {
81+ FrameworkNodeErrorInfo info;
82+ auto find_attr = [&](const std::string& key) -> std::string {
83+ const auto it = attrs.find (key);
84+ return it == attrs.end () ? std::string{} : it->second ;
85+ };
86+
87+ info.op_type = op_type_attr_key.empty () ? std::string{} : find_attr (op_type_attr_key);
88+ if (info.op_type .empty ()) {
89+ info.op_type = attrs.get_type_name ();
90+ }
91+ if (info.op_type .empty ()) {
92+ info.op_type = " <unknown>" ;
93+ }
94+
95+ const auto version = version_attr_key.empty () ? std::string{} : find_attr (version_attr_key);
96+ if (!version.empty ()) {
97+ info.op_type += " -" + version;
98+ }
99+
100+ const auto & opset_name = attrs.get_opset_name ();
101+ if (!opset_name.empty ()) {
102+ info.op_type = opset_name + " ." + info.op_type ;
103+ }
104+
105+ if (!failure_attr_key.empty ()) {
106+ info.failure_message = find_attr (failure_attr_key);
107+ }
108+
109+ return info;
110+ }
111+
97112UnconvertedOpMap collect_unconverted_ops (const std::shared_ptr<ov::Model>& model,
98113 const std::vector<UnconvertedOpExtractor>& custom_extractors) {
99114 UnconvertedOpMap report;
100- CollectorContext ctx{custom_extractors, report};
101- collect_from_model (model, ctx);
115+ collect_from_model (model, custom_extractors, report);
102116 return report;
103117}
104118
@@ -108,41 +122,41 @@ std::string format_unconverted_ops_report(const UnconvertedOpMap& unconverted_op
108122 std::stringstream error_msg;
109123 error_msg << (header.empty () ? " Model wasn't fully converted." : header);
110124
111- std::stringstream unconverted_ops_msg ;
112- std::stringstream failed_ops_msg ;
113- std::stringstream failed_ops_short ;
114- unconverted_ops_msg << " -- No conversion rule found for operations: " ;
115- failed_ops_msg << " Failed operations detailed log:" ;
116- failed_ops_short << " -- Conversion is failed for: " ;
125+ std::stringstream unsupported_msg ;
126+ std::stringstream failures_msg ;
127+ std::stringstream failed_short ;
128+ unsupported_msg << " -- No conversion rule found for operations: " ;
129+ failures_msg << " Failed operations detailed log:" ;
130+ failed_short << " -- Conversion is failed for: " ;
117131
118132 bool has_unsupported = false ;
119133 bool has_failures = false ;
120134 for (const auto & op : unconverted_ops) {
121135 if (op.second .empty ()) {
122136 if (has_unsupported) {
123- unconverted_ops_msg << " , " ;
137+ unsupported_msg << " , " ;
124138 }
125- unconverted_ops_msg << op.first ;
139+ unsupported_msg << op.first ;
126140 has_unsupported = true ;
127141 } else {
128142 if (has_failures) {
129- failed_ops_short << " , " ;
143+ failed_short << " , " ;
130144 }
131- failed_ops_short << op.first ;
132- failed_ops_msg << " \n -- " << op.first << " with a message:\n " << op.second ;
145+ failed_short << op.first ;
146+ failures_msg << " \n -- " << op.first << " with a message:\n " << op.second ;
133147 has_failures = true ;
134148 }
135149 }
136150
137151 if (has_failures) {
138- error_msg << failed_ops_msg .str ();
152+ error_msg << failures_msg .str ();
139153 }
140154 error_msg << " \n Summary:" << additional_error;
141155 if (has_unsupported) {
142- error_msg << ' \n ' << unconverted_ops_msg .str ();
156+ error_msg << ' \n ' << unsupported_msg .str ();
143157 }
144158 if (has_failures) {
145- error_msg << ' \n ' << failed_ops_short .str ();
159+ error_msg << ' \n ' << failed_short .str ();
146160 }
147161
148162 return error_msg.str ();
0 commit comments