namespace ov::op::util¶
Overview¶
namespace util {
// namespaces
namespace ov::op::util::detail;
namespace ov::op::util::error;
namespace ov::op::util::rfft_common_validation;
// typedefs
typedef std::shared_ptr<Node>(\*)(const std::shared_ptr<Node>&, float, float) ActivationFunctionType;
typedef std::vector<util::SubGraphOp::InputDescription::Ptr> InputDescriptionVector;
typedef std::vector<util::SubGraphOp::OutputDescription::Ptr> OutputDescriptionVector;
typedef std::vector<Variable::Ptr> VariableVector;
typedef std::unordered_map<Variable::Ptr, VariableValue::Ptr> VariableMap;
// enums
enum LSTMPeepholesFormat;
enum LSTMWeightsFormat;
// structs
struct VariableInfo;
// classes
class ActivationFunction;
class ArithmeticReduction;
class ArithmeticReductionKeepDims;
class AssignBase;
class BinaryElementwiseArithmetic;
class BinaryElementwiseComparison;
class BinaryElementwiseLogical;
class BroadcastBase;
class ConvertColorI420Base;
class ConvertColorNV12Base;
class DeformableConvolutionBase;
class DetectionOutputBase;
class EmbeddingBagOffsetsBase;
class EmbeddingBagPackedBase;
class FFTBase;
class FrameworkNode;
class FrameworkNodeAttrs;
class GatherBase;
class GatherNDBase;
class IndexReduction;
class LogicalReduction;
class LogicalReductionKeepDims;
class MaxPoolBase;
class MultiSubGraphOp;
class MulticlassNmsBase;
class RNNCellBase;
class ReadValueBase;
class ReductionBase;
class ScatterBase;
class ScatterNDBase;
class SubGraphOp;
class UnaryElementwiseArithmetic;
class Variable;
class VariableContext;
class VariableExtension;
class VariableValue;
// global functions
template <class T>
bool normalize_single_value(
std::vector<T> vec,
float& value
);
template <class T>
bool has_op_with_type(const std::shared_ptr<const ov::Model>& function);
bool has_decompression_converts(const std::shared_ptr<const ov::Model>& function);
std::string create_ie_output_name(const Output<const Node>& output);
std::string create_ie_output_name(const Output<Node>& output);
std::string get_ie_output_name(const Output<const Node>& output);
std::string get_ie_output_name(const Output<Node>& output);
template <typename T>
bool has_constant_value(
const std::shared_ptr<Node>& node,
const T value,
T epsilon = std::numeric_limits<T>::epsilon()
);
template <typename T>
bool has_constant_value(
const std::shared_ptr<Node>& node,
const std::vector<T> values,
T epsilon = std::numeric_limits<T>::epsilon()
);
bool get_single_value(
const std::shared_ptr<opset4::Constant>& const_node,
float& value
);
std::shared_ptr<Node> normalize_constant(
const std::shared_ptr<opset4::Constant>& constant,
const PartialShape& shape
);
std::shared_ptr<Node> broadcastTo(const Output<Node>& input, const Shape& shape);
std::shared_ptr<Node> reshapeTo(const Output<Node>& input, const Shape& shape);
bool constantIsEqualTo(
const std::shared_ptr<opset4::Constant>& const_node,
float value,
float eps = 1e-5
);
bool has_f16_constants(const std::shared_ptr<const ov::Model>& function);
bool check_for_broadcast(
const PartialShape& ref_shape,
const PartialShape& other_shape
);
std::shared_ptr<Node> activation(
const std::string& activation_name,
const Output<Node>& apply_to
);
bool is_seq_len_provided(
const std::shared_ptr<Node>& seq_len_input,
int64_t max_seq_len
);
std::shared_ptr<Node> try_fold_unary_output(const std::shared_ptr<Node>& node);
std::shared_ptr<Node> clone_try_fold(
const std::shared_ptr<Node>& node,
const OutputVector& inputs
);
bool shapes_equal_except_dynamic_expected_batch(
const PartialShape& expected,
const PartialShape& actual
);
void visit_shape_path(
ov::Node \* node,
std::unordered_set<ov::Node \*>& visited,
std::function<void(ov::Node \*)> func
);
template <typename T, typename... Args>
std::shared_ptr<Node> make_try_fold(Args&&... args);
template <class T>
Output<Node> eltwise_fold(
const Output<Node>& input0,
const Output<Node>& input1
);
std::vector<Input<Node>> get_node_target_inputs(const std::shared_ptr<Node>& node);
std::shared_ptr<Node> node_to_get_shape_value_of_indices_from_shape_node(
const std::shared_ptr<Node>& shape_node,
const std::vector<size_t>& indices
);
std::shared_ptr<Node> node_to_get_shape_value_of_indices_from_shape_source(
const Output<Node>& shape_source,
const std::vector<size_t>& indices
);
bool is_dequantization_subgraph(const Output<Node>& node);
bool can_eliminate_eltwise_node(
const std::shared_ptr<Node>& eltwise,
const Output<Node>& constant,
const Output<Node>& non_constant_input
);
ActivationFunction get_activation_func_by_name(const std::string& func_name);
std::tuple<element::Type, PartialShape> validate_and_infer_elementwise_args(Node \* node);
OPENVINO_API bool is_unary_elementwise_arithmetic(const Node \* node);
OPENVINO_API bool is_binary_elementwise_arithmetic(const Node \* node);
OPENVINO_API bool is_binary_elementwise_comparison(const Node \* node);
OPENVINO_API bool is_binary_elementwise_logical(const Node \* node);
OPENVINO_API bool supports_auto_broadcast(const Node \* node);
OPENVINO_API bool is_op(const Node \* node);
OPENVINO_API bool is_parameter(const Node \* node);
OPENVINO_API bool is_output(const Node \* node);
OPENVINO_API bool is_sink(const Node \* node);
OPENVINO_API bool is_constant(const Node \* node);
OPENVINO_API bool is_commutative(const Node \* node);
OPENVINO_API bool is_unary_elementwise_arithmetic(const std::shared_ptr<Node>& node);
OPENVINO_API bool is_binary_elementwise_arithmetic(const std::shared_ptr<Node>& node);
OPENVINO_API bool is_binary_elementwise_comparison(const std::shared_ptr<Node>& node);
OPENVINO_API bool is_binary_elementwise_logical(const std::shared_ptr<Node>& node);
OPENVINO_API bool supports_auto_broadcast(const std::shared_ptr<Node>& node);
OPENVINO_API bool is_op(const std::shared_ptr<Node>& node);
OPENVINO_API bool is_parameter(const std::shared_ptr<Node>& node);
OPENVINO_API bool is_output(const std::shared_ptr<Node>& node);
OPENVINO_API bool is_sink(const std::shared_ptr<Node>& node);
OPENVINO_API bool is_constant(const std::shared_ptr<Node>& node);
OPENVINO_API bool is_commutative(const std::shared_ptr<Node>& node);
std::shared_ptr<Node> OPENVINO_API convert_lstm_node_format(
const Output<Node>& node,
LSTMWeightsFormat from_format,
LSTMWeightsFormat to_format = LSTMWeightsFormat::FICO,
int64_t axis = 0
);
std::shared_ptr<Node> OPENVINO_API convert_lstm_peepholes_format(
const Output<Node>& node,
LSTMPeepholesFormat from_format,
LSTMPeepholesFormat to_format = LSTMPeepholesFormat::FIO,
int64_t axis = 0
);
template <typename T>
void validate_target_shape_none(
const ov::Node \* op,
const T& arg_shape,
const AxisVector& axes_mapping_val,
const T& target_input_shape
);
template <typename T>
void validate_target_shape_numpy(
const ov::Node \* op,
const T& arg_shape,
const T& target_input_shape
);
template <typename T>
void set_result_shape_pdpd(
const ov::Node \* op,
const T& arg0_shape,
const T& target_input_shape,
T& result_shape,
const ov::op::BroadcastModeSpec& broadcast_spec
);
template <typename T>
void set_result_shape_bidirectional(
const ov::Node \* op,
const T& arg_shape,
T& target_input_shape,
T& result_shape
);
template <class T>
void broadcast_base_shape_infer(
const ov::op::util::BroadcastBase \* op,
const std::vector<T>& input_shapes,
std::vector<T>& output_shapes,
const std::map<size_t, std::shared_ptr<ngraph::runtime::HostTensor>>& constant_data = {}
);
template <
typename T,
typename V = typename std::iterator_traits<typename T::iterator>::value_type::value_type
>
void compute_num_classes(
const DetectionOutputBase \* op,
const DetectionOutputBase::AttributesBase& attrs,
const std::vector<T>& input_shapes,
V& num_classes,
V& num_prior_boxes
);
template <class T>
void shape_infer_base(
const DetectionOutputBase \* op,
const DetectionOutputBase::AttributesBase& attrs,
const std::vector<T>& input_shapes,
std::vector<T>& output_shapes,
int64_t attribute_num_classes
);
template <class T>
void shape_infer(
const ov::op::util::EmbeddingBagOffsetsBase \* op,
const std::vector<T>& input_shapes,
std::vector<T>& output_shapes
);
template <class T>
void check_1D_or_scalar_shape(
const ov::op::v9::Eye \* op,
const T& input_shape,
const std::string name
);
template <class T>
void shape_infer(
const ov::op::util::FFTBase \* op,
const std::vector<T>& input_shapes,
std::vector<T>& output_shapes,
const std::map<size_t, std::shared_ptr<ngraph::runtime::HostTensor>>& constant_data = {}
);
template <class T>
void shape_infer(
const GatherBase \* op,
const std::vector<T>& input_shapes,
std::vector<T>& output_shapes,
const std::map<size_t, std::shared_ptr<ngraph::runtime::HostTensor>>& constant_data = {}
);
template <class T>
void irdft_shape_infer(
const ov::op::v9::IRDFT \* op,
const std::vector<T>& input_shapes,
std::vector<T>& output_shapes,
const std::map<size_t, std::shared_ptr<ngraph::runtime::HostTensor>>& constant_data = {}
);
template <class T>
void shape_infer(
const ov::op::util::MulticlassNmsBase \* op,
const std::vector<T>& input_shapes,
std::vector<T>& output_shapes,
bool static_output = false,
bool ignore_bg_class = false
);
template <typename B>
B get_ouput_dimension_bound(B b);
template <class DimType>
DimType get_rdft_output_dimension(DimType d);
template <class T>
void rdft_shape_infer(
const ov::op::v9::RDFT \* op,
const std::vector<T>& input_shapes,
std::vector<T>& output_shapes,
const std::map<size_t, std::shared_ptr<ngraph::runtime::HostTensor>>& constant_data = {}
);
} // namespace util
Detailed Documentation¶
Global Functions¶
ActivationFunction get_activation_func_by_name(const std::string& func_name)
Gets the activation function by name.
Parameters:
func_name |
The function name |
UnknownActivationFunction |
When provided func_name is unknown. |
Returns:
The activation function object.
std::shared_ptr<Node> OPENVINO_API convert_lstm_node_format(
const Output<Node>& node,
LSTMWeightsFormat from_format,
LSTMWeightsFormat to_format = LSTMWeightsFormat::FICO,
int64_t axis = 0
)
Change data format of provided node.
Parameters:
node |
The input node to be permuted. |
from_format |
Original node weights format. |
to_format |
Weights format to convert to. |
Returns:
Node representing reshaped tensor according to to_format
weights format.