Cleanup Core API added common header (#7994)

This commit is contained in:
Ilya Churaev 2021-10-14 12:58:43 +03:00 committed by GitHub
parent d2a671b3cd
commit eb838d5699
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 121 additions and 54 deletions

View File

@ -67,9 +67,11 @@ using EvaluationContext = std::map<std::string, std::shared_ptr<Variant>>;
using ResultVector = std::vector<std::shared_ptr<ngraph::op::v0::Result>>;
const auto node_validation_failure_loc_string = ov::node_validation_failure_loc_string;
const auto check_single_output_arg = ov::check_single_output_arg;
const auto check_single_output_args = ov::check_single_output_args;
NGRAPH_API
const std::shared_ptr<Node>& check_single_output_arg(const std::shared_ptr<Node>& node, size_t i);
NGRAPH_API
const NodeVector& check_single_output_args(const NodeVector& args);
const auto as_output_vector = ov::as_output_vector;
const auto as_node_vector = ov::as_node_vector;

View File

@ -0,0 +1,59 @@
// Copyright (C) 2018-2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
//
// The public OpenVINO core API
//
#include "openvino/core/attribute_adapter.hpp"
#include "openvino/core/attribute_visitor.hpp"
#include "openvino/core/axis_set.hpp"
#include "openvino/core/axis_vector.hpp"
#include "openvino/core/coordinate.hpp"
#include "openvino/core/coordinate_diff.hpp"
#include "openvino/core/core_visibility.hpp"
#include "openvino/core/deprecated.hpp"
#include "openvino/core/dimension.hpp"
#include "openvino/core/enum_mask.hpp"
#include "openvino/core/enum_names.hpp"
#include "openvino/core/except.hpp"
#include "openvino/core/function.hpp"
#include "openvino/core/graph_util.hpp"
#include "openvino/core/interval.hpp"
#include "openvino/core/layout.hpp"
#include "openvino/core/node.hpp"
#include "openvino/core/node_input.hpp"
#include "openvino/core/node_output.hpp"
#include "openvino/core/node_vector.hpp"
#include "openvino/core/partial_shape.hpp"
#include "openvino/core/rank.hpp"
#include "openvino/core/rtti.hpp"
#include "openvino/core/shape.hpp"
#include "openvino/core/strides.hpp"
#include "openvino/core/type.hpp"
#include "openvino/core/validation_util.hpp"
#include "openvino/core/variant.hpp"
#include "openvino/core/version.hpp"
#include "openvino/core/visibility.hpp"
// Descriptor
#include "openvino/core/descriptor/input.hpp"
#include "openvino/core/descriptor/output.hpp"
#include "openvino/core/descriptor/tensor.hpp"
// Preprocessing
#include "openvino/core/preprocess/color_format.hpp"
#include "openvino/core/preprocess/input_info.hpp"
#include "openvino/core/preprocess/input_network_info.hpp"
#include "openvino/core/preprocess/input_tensor_info.hpp"
#include "openvino/core/preprocess/output_info.hpp"
#include "openvino/core/preprocess/output_network_info.hpp"
#include "openvino/core/preprocess/output_tensor_info.hpp"
#include "openvino/core/preprocess/postprocess_steps.hpp"
#include "openvino/core/preprocess/pre_post_process.hpp"
#include "openvino/core/preprocess/preprocess_steps.hpp"
#include "openvino/core/preprocess/resize_algorithm.hpp"
// type
#include "openvino/core/type/element_type.hpp"

View File

@ -265,7 +265,8 @@ std::vector<std::shared_ptr<Node>> topological_sort(T root_nodes) {
// NodeMap input may contain default node mapping i.e. pre-cloned nodes
// NodeMap output (by reference) fully maps input and cloned function ops
OPENVINO_API
std::shared_ptr<ov::Function> clone_function(const ov::Function& func, NodeMap& node_map);
std::shared_ptr<ov::Function> clone_function(const ov::Function& func,
std::unordered_map<Node*, std::shared_ptr<Node>>& node_map);
// input function is cloned and returned
OPENVINO_API

View File

@ -75,27 +75,9 @@ class Node;
/// environment) for evaluating ov::Function.
using EvaluationContext = std::map<std::string, std::shared_ptr<Variant>>;
using ResultVector = std::vector<std::shared_ptr<ov::op::v0::Result>>;
OPENVINO_API
std::string node_validation_failure_loc_string(const Node* node);
OPENVINO_API
const std::shared_ptr<Node>& check_single_output_arg(const std::shared_ptr<Node>& node, size_t i);
OPENVINO_API
const NodeVector& check_single_output_args(const NodeVector& args);
OPENVINO_API
OutputVector as_output_vector(const NodeVector& args);
OPENVINO_API
NodeVector as_node_vector(const OutputVector& values);
/// Returns a ResultVector referencing values.
OPENVINO_API
ResultVector as_result_vector(const OutputVector& values);
/// Alias useful for cloning
using NodeMap = std::unordered_map<Node*, std::shared_ptr<Node>>;
/// \brief Used in evaluator switch statement so that the case type and evaluate call
/// are guaranteed to have the types match.
///

View File

@ -37,7 +37,6 @@ public:
/// \param node A `shared_ptr` to the node for the output handle.
/// \param index The index of the output.
///
/// TODO: Make a plan to deprecate this.
Output(const std::shared_ptr<Node>& node, size_t index);
/// \brief Constructs a Output, referencing the zeroth output of the node.
@ -56,7 +55,6 @@ public:
Node* get_node() const;
/// \return A `shared_ptr` to the node referred to by this output handle.
///
/// TODO: Make a plan to deprecate this.
std::shared_ptr<Node> get_node_shared_ptr() const;
/// \return The index of the output referred to by this output handle.
@ -84,7 +82,6 @@ public:
/// \brief Removes a target input from the output referenced by this output handle.
/// \param target_input The target input to remove.
///
// TODO(amprocte): Investigate whether this really ought to be public.
void remove_target_input(const Input<Node>& target_input) const;
/// \brief Replace all users of this value with replacement
@ -114,7 +111,6 @@ public:
/// \param node A `shared_ptr` to the node for the output handle.
/// \param index The index of the output.
///
/// TODO: Make a plan to deprecate this.
Output(const std::shared_ptr<const Node>& node, size_t index);
/// \brief Constructs a Output, referencing the zeroth output of the node.
@ -134,7 +130,6 @@ public:
const Node* get_node() const;
/// \return A `shared_ptr` to the node referred to by this output handle.
///
/// TODO: Make a plan to deprecate this.
std::shared_ptr<const Node> get_node_shared_ptr() const;
/// \return The index of the output referred to by this output handle.
size_t get_index() const;

View File

@ -7,6 +7,8 @@
#include <memory>
#include <vector>
#include "openvino/core/core_visibility.hpp"
namespace ov {
template <typename NodeType>
@ -14,6 +16,23 @@ class Output;
class Node;
namespace op {
namespace v0 {
class Result;
} // namespace v0
} // namespace op
using NodeVector = std::vector<std::shared_ptr<Node>>;
using OutputVector = std::vector<Output<Node>>;
using ResultVector = std::vector<std::shared_ptr<ov::op::v0::Result>>;
OPENVINO_API
OutputVector as_output_vector(const NodeVector& args);
OPENVINO_API
NodeVector as_node_vector(const OutputVector& values);
/// Returns a ResultVector referencing values.
OPENVINO_API
ResultVector as_result_vector(const OutputVector& values);
} // namespace ov

View File

@ -600,44 +600,18 @@ std::string ov::node_validation_failure_loc_string(const Node* node) {
return ss.str();
}
const std::shared_ptr<ov::Node>& ov::check_single_output_arg(const std::shared_ptr<Node>& node, size_t i) {
const std::shared_ptr<ov::Node>& ngraph::check_single_output_arg(const std::shared_ptr<Node>& node, size_t i) {
NGRAPH_CHECK(node->get_output_size() == 1, "Argument ", i, node, " must produce exactly one value.");
return node;
}
const ov::NodeVector& ov::check_single_output_args(const NodeVector& args) {
const ov::NodeVector& ngraph::check_single_output_args(const NodeVector& args) {
for (size_t i = 0; i < args.size(); ++i) {
ngraph::check_single_output_arg(args.at(i), i);
}
return args;
}
ov::OutputVector ov::as_output_vector(const NodeVector& args) {
OutputVector output_vector;
for (const auto& arg : args) {
output_vector.push_back(arg);
}
return output_vector;
}
ov::NodeVector ov::as_node_vector(const OutputVector& values) {
NodeVector node_vector;
for (auto& value : values) {
node_vector.emplace_back(value.get_node_shared_ptr());
}
return node_vector;
}
ov::ResultVector ov::as_result_vector(const OutputVector& values) {
ResultVector result;
for (auto value : values) {
shared_ptr<Node> node = value.get_node_shared_ptr();
result.push_back(ov::is_type<ngraph::op::Result>(node) ? ov::as_type_ptr<ngraph::op::Result>(node)
: make_shared<ngraph::op::Result>(value));
}
return result;
}
bool ov::Node::match_value(ngraph::pattern::Matcher* matcher,
const Output<Node>& pattern_value,
const Output<Node>& graph_value) {

View File

@ -0,0 +1,35 @@
// Copyright (C) 2018-2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include "openvino/core/node_vector.hpp"
#include "openvino/core/node_output.hpp"
#include "openvino/core/type.hpp"
#include "openvino/op/result.hpp"
ov::OutputVector ov::as_output_vector(const ov::NodeVector& args) {
ov::OutputVector output_vector;
for (const auto& arg : args) {
output_vector.push_back(arg);
}
return output_vector;
}
ov::NodeVector ov::as_node_vector(const ov::OutputVector& values) {
NodeVector node_vector;
for (auto& value : values) {
node_vector.emplace_back(value.get_node_shared_ptr());
}
return node_vector;
}
ov::ResultVector ov::as_result_vector(const OutputVector& values) {
ResultVector result;
for (const auto& value : values) {
std::shared_ptr<Node> node = value.get_node_shared_ptr();
result.push_back(ov::is_type<ov::op::v0::Result>(node) ? ov::as_type_ptr<ov::op::v0::Result>(node)
: std::make_shared<ov::op::v0::Result>(value));
}
return result;
}