forked from openvinotoolkit/openvino
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathunconverted_ops_report.hpp
More file actions
76 lines (63 loc) · 3.63 KB
/
unconverted_ops_report.hpp
File metadata and controls
76 lines (63 loc) · 3.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// Copyright (C) 2018-2026 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#pragma once
#include <functional>
#include <map>
#include <memory>
#include <optional>
#include <set>
#include <string>
#include "openvino/core/model.hpp"
#include "openvino/frontend/extension/telemetry.hpp"
#include "openvino/op/util/framework_node.hpp"
#include "openvino/op/util/multi_subgraph_base.hpp"
namespace ov {
namespace frontend {
/// \brief Structure containing information about unconverted operations
/// Map of operation types with no conversion rule (op_type -> empty string)
/// or operations that failed during conversion (op_type -> error message)
struct UnconvertedOpsReport {
std::map<std::string, std::string> unconverted_ops;
bool has_issues() const;
/// \brief Add an unconverted operation if not already present
/// \param op_type Operation type name
/// \param error_message Error message (empty if no converter found, non-empty if conversion failed)
void add(const std::string& op_type, const std::string& error_message = {});
/// \brief Merge another report into this one
void merge(const UnconvertedOpsReport& other);
};
/// \brief Callback type for extracting unconverted operation info from framework-specific nodes
/// \param node The node to check
/// \return Optional pair of (op_type, error_message) if this is an unconverted framework node
using FrameworkNodeExtractor =
std::function<std::optional<std::pair<std::string, std::string>>(const std::shared_ptr<ov::Node>&)>;
/// \brief Collect unconverted operations from a model
/// \param model The model to scan
/// \param extractor Callback to extract info from framework-specific nodes
/// \return Report containing all unconverted operations found
UnconvertedOpsReport collect_unconverted_ops(const std::shared_ptr<ov::Model>& model,
const FrameworkNodeExtractor& extractor);
/// \brief Callback type for adding additional error information
/// \param unsupported_ops Set of unsupported operation types (those without error messages)
/// \return Additional message to append to the error report
using AdditionalErrorCallback = std::function<std::string(const std::set<std::string>&)>;
/// \brief Check conversion result, send telemetry, and optionally throw if there are unconverted operations
/// \param report The unconverted operations report
/// \param telemetry Telemetry extension (can be nullptr)
/// \param telemetry_prefix Frontend name prefix for telemetry events (e.g., "pytorch", "tf", "onnx", "jax")
/// \param error_message_prefix Prefix for filtering error messages in telemetry (e.g., "[PyTorch Frontend] ")
/// If non-empty, error_info telemetry events will be sent
/// \param additional_error Additional error message (e.g., from normalize step)
/// \param additional_callback Optional callback for frontend-specific additional error messages
/// \param throw_on_issues If true (default), throws when there are unconverted ops or additional_error is non-empty
/// \throws ov::frontend::OpConversionFailure if throw_on_issues is true and there are issues
void check_unconverted_ops(const UnconvertedOpsReport& report,
const std::shared_ptr<TelemetryExtension>& telemetry,
const std::string& telemetry_prefix,
const std::string& error_message_prefix = {},
const std::string& additional_error = {},
const AdditionalErrorCallback& additional_callback = nullptr,
bool throw_on_issues = true);
} // namespace frontend
} // namespace ov