Reduce ngraph namespace usage from core component (#20309)
* Reduce ngraph namespace usage from core component * Fixed build * Fixed build 2 * Added missed opset to legacy API
This commit is contained in:
parent
35308ce34d
commit
8020530e67
@ -67,6 +67,8 @@ const NGRAPH_API OpSet& get_opset8();
|
||||
const NGRAPH_API OpSet& get_opset9();
|
||||
const NGRAPH_API OpSet& get_opset10();
|
||||
const NGRAPH_API OpSet& get_opset11();
|
||||
const NGRAPH_API OpSet& get_opset12();
|
||||
const NGRAPH_API OpSet& get_opset13();
|
||||
const NGRAPH_API std::map<std::string, std::function<const ngraph::OpSet&()>>& get_available_opsets();
|
||||
} // namespace ngraph
|
||||
NGRAPH_SUPPRESS_DEPRECATED_END
|
||||
|
@ -10,30 +10,17 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "ngraph/descriptor/input.hpp"
|
||||
#include "ngraph/descriptor/output.hpp"
|
||||
#include "ngraph/function.hpp"
|
||||
#include "ngraph/log.hpp"
|
||||
#include "ngraph/node.hpp"
|
||||
#include "ngraph/op/broadcast.hpp"
|
||||
#include "ngraph/op/constant.hpp"
|
||||
#include "ngraph/op/parameter.hpp"
|
||||
#include "ngraph/op/result.hpp"
|
||||
#include "ngraph/op/tensor_iterator.hpp"
|
||||
#include "ngraph/op/util/op_types.hpp"
|
||||
#include "ngraph/opsets/opset5.hpp"
|
||||
#include "ngraph/opsets/opset8.hpp"
|
||||
#include "ngraph/pass/manager.hpp"
|
||||
#include "ngraph/pass/visualize_tree.hpp"
|
||||
#include "ngraph/rt_info.hpp"
|
||||
#include "ngraph/util.hpp"
|
||||
#include "openvino/core/descriptor/tensor.hpp"
|
||||
#include "openvino/core/rt_info.hpp"
|
||||
#include "openvino/op/broadcast.hpp"
|
||||
#include "openvino/op/constant.hpp"
|
||||
#include "openvino/op/util/op_types.hpp"
|
||||
#include "openvino/pass/manager.hpp"
|
||||
#include "openvino/pass/visualize_tree.hpp"
|
||||
#include "transformations/common_optimizations/compress_float_constants.hpp"
|
||||
#include "transformations/common_optimizations/fused_names_cleanup.hpp"
|
||||
#include "transformations/common_optimizations/mark_precision_sensitive_shapeof_subgraphs.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace {
|
||||
|
||||
void clone_ov_nodes(const std::vector<std::shared_ptr<ov::Node>>& nodes,
|
||||
@ -49,7 +36,7 @@ void clone_ov_nodes(const std::vector<std::shared_ptr<ov::Node>>& nodes,
|
||||
}
|
||||
std::vector<std::shared_ptr<ov::Node>> cloned_dependencies;
|
||||
for (const auto& dependency : node->get_control_dependencies()) {
|
||||
shared_ptr<ov::Node>& dependent = node_map.at(dependency.get());
|
||||
std::shared_ptr<ov::Node>& dependent = node_map.at(dependency.get());
|
||||
if (find(cloned_dependencies.begin(), cloned_dependencies.end(), dependent) ==
|
||||
cloned_dependencies.end()) {
|
||||
cloned_dependencies.push_back(dependent);
|
||||
@ -161,7 +148,7 @@ void replace_node(const std::shared_ptr<Node>& target, const OutputVector& repla
|
||||
|
||||
OPENVINO_ASSERT(target->get_output_size() == replacement_values.size());
|
||||
|
||||
unordered_set<shared_ptr<Node>> replacement_nodes;
|
||||
std::unordered_set<std::shared_ptr<Node>> replacement_nodes;
|
||||
// For each of target's output O with replacement output O_rep:
|
||||
// For each O's connected downstream input I:
|
||||
// Change I's connected upstream output to O_rep
|
||||
@ -179,15 +166,15 @@ void replace_node(const std::shared_ptr<Node>& target, const OutputVector& repla
|
||||
}
|
||||
|
||||
void replace_node(const std::shared_ptr<Node>& target, const std::shared_ptr<Node>& replacement) {
|
||||
auto default_output_order = vector<int64_t>(target->get_output_size());
|
||||
auto default_output_order = std::vector<int64_t>(target->get_output_size());
|
||||
std::iota(default_output_order.begin(), default_output_order.end(), 0);
|
||||
replace_node(target, replacement, default_output_order);
|
||||
}
|
||||
|
||||
void replace_nodes(const std::shared_ptr<Model>& f,
|
||||
const unordered_map<shared_ptr<ov::op::v0::Parameter>, shared_ptr<ov::op::v0::Parameter>>&
|
||||
parameter_replacement_map,
|
||||
const unordered_map<shared_ptr<Node>, shared_ptr<Node>>& body_replacement_map) {
|
||||
const std::unordered_map<std::shared_ptr<ov::op::v0::Parameter>,
|
||||
std::shared_ptr<ov::op::v0::Parameter>>& parameter_replacement_map,
|
||||
const std::unordered_map<std::shared_ptr<Node>, std::shared_ptr<Node>>& body_replacement_map) {
|
||||
auto& params = f->get_parameters();
|
||||
|
||||
for (size_t i = 0; i < params.size(); i++) {
|
||||
@ -231,7 +218,7 @@ std::shared_ptr<Model> clone_ov_model(const Model& func, std::unordered_map<Node
|
||||
|
||||
// get cloned model results and sinks and parameters
|
||||
ResultVector cloned_results;
|
||||
for (shared_ptr<Node> node : func.get_results()) {
|
||||
for (std::shared_ptr<Node> node : func.get_results()) {
|
||||
auto result = ov::as_type_ptr<op::v0::Result>(node_map.at(node.get()));
|
||||
if (!result) {
|
||||
OPENVINO_THROW("Results should be of type op::Result");
|
||||
@ -240,7 +227,7 @@ std::shared_ptr<Model> clone_ov_model(const Model& func, std::unordered_map<Node
|
||||
}
|
||||
SinkVector cloned_sinks;
|
||||
for (const auto& node : func.get_sinks()) {
|
||||
cloned_sinks.push_back(static_pointer_cast<op::Sink>(node_map.at(node.get())));
|
||||
cloned_sinks.push_back(std::static_pointer_cast<op::Sink>(node_map.at(node.get())));
|
||||
}
|
||||
|
||||
std::vector<std::shared_ptr<op::v0::Parameter>> cloned_params;
|
||||
@ -273,8 +260,8 @@ bool compare_constants(const std::shared_ptr<Node>& n1, const std::shared_ptr<No
|
||||
return false;
|
||||
}
|
||||
|
||||
if (static_pointer_cast<op::v0::Constant>(n1)->get_value_strings() !=
|
||||
static_pointer_cast<op::v0::Constant>(n2)->get_value_strings()) {
|
||||
if (std::static_pointer_cast<op::v0::Constant>(n1)->get_value_strings() !=
|
||||
std::static_pointer_cast<op::v0::Constant>(n2)->get_value_strings()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -368,7 +355,8 @@ void save_model(const std::shared_ptr<const ov::Model>& m, const std::string& ou
|
||||
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
|
||||
ngraph::NodeVector ngraph::find_common_args(std::shared_ptr<Node> node1, std::shared_ptr<Node> node2) {
|
||||
namespace ngraph {
|
||||
ov::NodeVector find_common_args(std::shared_ptr<Node> node1, std::shared_ptr<Node> node2) {
|
||||
std::unordered_set<std::shared_ptr<Node>> node1_args;
|
||||
|
||||
auto compute_node1_args = [&node1_args](const std::shared_ptr<Node>& node) {
|
||||
@ -396,15 +384,15 @@ ngraph::NodeVector ngraph::find_common_args(std::shared_ptr<Node> node1, std::sh
|
||||
}
|
||||
|
||||
// Check if all paths from X to a result go through Y
|
||||
bool ngraph::is_post_dominated(Node* X, Node* Y) {
|
||||
bool is_post_dominated(Node* X, Node* Y) {
|
||||
std::unordered_set<Node*> visited;
|
||||
std::stack<Node*, std::vector<Node*>> stack;
|
||||
stack.push(X);
|
||||
|
||||
while (stack.size() > 0) {
|
||||
ngraph::Node* curr = stack.top();
|
||||
ov::Node* curr = stack.top();
|
||||
visited.insert(curr);
|
||||
if (ngraph::op::is_output(curr)) {
|
||||
if (ov::op::util::is_output(curr)) {
|
||||
return false;
|
||||
}
|
||||
stack.pop();
|
||||
@ -419,8 +407,8 @@ bool ngraph::is_post_dominated(Node* X, Node* Y) {
|
||||
return true;
|
||||
}
|
||||
|
||||
std::vector<std::shared_ptr<ngraph::Node>> ngraph::clone_nodes(const std::vector<std::shared_ptr<ngraph::Node>>& nodes,
|
||||
NodeMap& node_map) {
|
||||
std::vector<std::shared_ptr<ov::Node>> clone_nodes(const std::vector<std::shared_ptr<ov::Node>>& nodes,
|
||||
NodeMap& node_map) {
|
||||
// for each node in topological order
|
||||
auto sorted_nodes = topological_sort(nodes);
|
||||
for (const auto& node : sorted_nodes) {
|
||||
@ -433,7 +421,7 @@ std::vector<std::shared_ptr<ngraph::Node>> ngraph::clone_nodes(const std::vector
|
||||
}
|
||||
std::vector<std::shared_ptr<Node>> cloned_dependencies;
|
||||
for (auto& dependency : node->get_control_dependencies()) {
|
||||
shared_ptr<Node>& dependent = node_map.at(dependency.get());
|
||||
std::shared_ptr<Node>& dependent = node_map.at(dependency.get());
|
||||
if (find(cloned_dependencies.begin(), cloned_dependencies.end(), dependent) ==
|
||||
cloned_dependencies.end()) {
|
||||
cloned_dependencies.push_back(dependent);
|
||||
@ -463,18 +451,18 @@ std::vector<std::shared_ptr<ngraph::Node>> ngraph::clone_nodes(const std::vector
|
||||
|
||||
// create and return vector of cloned nodes
|
||||
// order matches input vector (not necessarily topological)
|
||||
std::vector<std::shared_ptr<ngraph::Node>> cloned_nodes;
|
||||
std::vector<std::shared_ptr<ov::Node>> cloned_nodes;
|
||||
for (const auto& node : nodes) {
|
||||
cloned_nodes.push_back(node_map.at(node.get()));
|
||||
}
|
||||
return cloned_nodes;
|
||||
}
|
||||
|
||||
std::list<std::shared_ptr<ngraph::Node>> ngraph::clone_nodes(const std::vector<std::shared_ptr<ngraph::Node>>& nodes,
|
||||
RawNodeOutputMap& output_map) {
|
||||
std::list<std::shared_ptr<ov::Node>> clone_nodes(const std::vector<std::shared_ptr<ov::Node>>& nodes,
|
||||
RawNodeOutputMap& output_map) {
|
||||
// for each node in topological order
|
||||
auto sorted_nodes = topological_sort(nodes);
|
||||
std::list<shared_ptr<Node>> cloned_nodes;
|
||||
std::list<std::shared_ptr<Node>> cloned_nodes;
|
||||
for (const auto& node : sorted_nodes) {
|
||||
auto node_outputs = node->outputs();
|
||||
for (const auto& value : node_outputs) {
|
||||
@ -488,7 +476,7 @@ std::list<std::shared_ptr<ngraph::Node>> ngraph::clone_nodes(const std::vector<s
|
||||
NodeVector cloned_dependencies;
|
||||
for (auto& dependency : node->get_control_dependencies()) {
|
||||
for (const auto& dependency_value : dependency->outputs()) {
|
||||
shared_ptr<Node> dependent = output_map.at(dependency_value).get_node_shared_ptr();
|
||||
std::shared_ptr<Node> dependent = output_map.at(dependency_value).get_node_shared_ptr();
|
||||
if (find(cloned_dependencies.begin(), cloned_dependencies.end(), dependent) ==
|
||||
cloned_dependencies.end()) {
|
||||
cloned_dependencies.push_back(dependent);
|
||||
@ -514,8 +502,8 @@ std::list<std::shared_ptr<ngraph::Node>> ngraph::clone_nodes(const std::vector<s
|
||||
return cloned_nodes;
|
||||
}
|
||||
|
||||
bool ngraph::is_equal_to_const_value(const std::string& const_value, const Output<Node>& reduce_constant) {
|
||||
if (auto rc = ov::as_type_ptr<ngraph::op::Constant>(reduce_constant.get_node_shared_ptr())) {
|
||||
bool is_equal_to_const_value(const std::string& const_value, const Output<Node>& reduce_constant) {
|
||||
if (auto rc = ov::as_type_ptr<ov::op::v0::Constant>(reduce_constant.get_node_shared_ptr())) {
|
||||
return (rc->get_all_data_elements_bitwise_identical() && rc->convert_value_to_string(0) == const_value);
|
||||
} else {
|
||||
return false;
|
||||
@ -535,28 +523,28 @@ bool ngraph::is_equal_to_const_value(const std::string& const_value, const Outpu
|
||||
// | +------[2]------> | | | +------[6]------> | | +------[10]-----> |
|
||||
// | <------[3]------+ | | | <------[7]------+ | | <------[11]-----+ |
|
||||
// +-----+ +-----+ | +-----+ +-----+ +-----+ +-----+
|
||||
pair<shared_ptr<ngraph::op::Result>, shared_ptr<ngraph::op::Parameter>> ngraph::insert_result_parameter_split(
|
||||
const shared_ptr<Node>& src_node,
|
||||
const shared_ptr<Node>& dst_node) {
|
||||
std::pair<std::shared_ptr<ov::op::v0::Result>, std::shared_ptr<ov::op::v0::Parameter>> insert_result_parameter_split(
|
||||
const std::shared_ptr<Node>& src_node,
|
||||
const std::shared_ptr<Node>& dst_node) {
|
||||
if (src_node->get_output_size() != 1) {
|
||||
OPENVINO_THROW("Multiple output per op not supported in graph partition yet.");
|
||||
}
|
||||
|
||||
// Make parameter node
|
||||
shared_ptr<op::Parameter> par_node =
|
||||
make_shared<op::Parameter>(src_node->get_output_element_type(0), src_node->get_output_shape(0));
|
||||
std::shared_ptr<op::Parameter> par_node =
|
||||
std::make_shared<op::Parameter>(src_node->get_output_element_type(0), src_node->get_output_shape(0));
|
||||
|
||||
// Fix input / output among src, dst and par
|
||||
std::vector<Input<Node>> dst_inputs = get_inputs_from(*src_node, *dst_node);
|
||||
NGRAPH_CHECK(dst_inputs.size() == 1,
|
||||
"insert_result_parameter_split encountered more than "
|
||||
"one input between the source and destination nodes");
|
||||
OPENVINO_ASSERT(dst_inputs.size() == 1,
|
||||
"insert_result_parameter_split encountered more than "
|
||||
"one input between the source and destination nodes");
|
||||
auto& dst_input = dst_inputs[0];
|
||||
|
||||
std::vector<Output<Node>> src_outputs = get_outputs_to(*src_node, *dst_node);
|
||||
NGRAPH_CHECK(src_outputs.size() == 1,
|
||||
"insert_result_parameter_split encountered more than "
|
||||
"one output between the source and destination nodes");
|
||||
OPENVINO_ASSERT(src_outputs.size() == 1,
|
||||
"insert_result_parameter_split encountered more than "
|
||||
"one output between the source and destination nodes");
|
||||
auto& src_output = src_outputs[0];
|
||||
|
||||
// Remove [0]
|
||||
@ -567,7 +555,7 @@ pair<shared_ptr<ngraph::op::Result>, shared_ptr<ngraph::op::Parameter>> ngraph::
|
||||
|
||||
// Add res node
|
||||
// Add [4], [5], [6], [7]
|
||||
shared_ptr<op::Result> res_node = make_shared<op::Result>(src_node);
|
||||
std::shared_ptr<op::Result> res_node = std::make_shared<op::Result>(src_node);
|
||||
|
||||
return make_pair(res_node, par_node);
|
||||
}
|
||||
@ -612,58 +600,59 @@ pair<shared_ptr<ngraph::op::Result>, shared_ptr<ngraph::op::Parameter>> ngraph::
|
||||
// Typically new_node is connected to src_node already. The reason we don't create `new_node`
|
||||
// inside the function and return it (similar to ngraph::insert_result_parameter_split) is that
|
||||
// we'll have to templatize its function to call new_node's constructor.
|
||||
void ngraph::insert_new_node_between(const shared_ptr<Node>& src_node,
|
||||
const shared_ptr<Node>& dst_node,
|
||||
const shared_ptr<Node>& new_node) {
|
||||
void insert_new_node_between(const std::shared_ptr<Node>& src_node,
|
||||
const std::shared_ptr<Node>& dst_node,
|
||||
const std::shared_ptr<Node>& new_node) {
|
||||
// Fix input / output
|
||||
std::vector<Input<Node>> dst_inputs = get_inputs_from(*src_node, *dst_node);
|
||||
NGRAPH_CHECK(dst_inputs.size() == 1,
|
||||
"insert_new_node_between encountered more than one "
|
||||
"input between the source and destination nodes");
|
||||
OPENVINO_ASSERT(dst_inputs.size() == 1,
|
||||
"insert_new_node_between encountered more than one "
|
||||
"input between the source and destination nodes");
|
||||
auto& dst_input = dst_inputs[0];
|
||||
|
||||
std::vector<Output<Node>> src_outputs = get_outputs_to(*src_node, *dst_node);
|
||||
NGRAPH_CHECK(src_outputs.size() == 1,
|
||||
"insert_new_node_between encountered more than one "
|
||||
"output between the source and destination nodes");
|
||||
OPENVINO_ASSERT(src_outputs.size() == 1,
|
||||
"insert_new_node_between encountered more than one "
|
||||
"output between the source and destination nodes");
|
||||
auto& src_output = src_outputs[0];
|
||||
|
||||
src_output.remove_target_input(dst_input); // Remove [0]
|
||||
dst_input.replace_source_output(new_node->output(0)); // Remove [0] (again), add [8], remove [1], add [9]
|
||||
}
|
||||
|
||||
std::shared_ptr<ngraph::Node> ngraph::make_zero(const element::Type& element_type, const Shape& shape) {
|
||||
auto zero = op::Constant::create(element_type, Shape{}, {0.0});
|
||||
std::shared_ptr<ov::Node> make_zero(const element::Type& element_type, const Shape& shape) {
|
||||
auto zero = ov::op::v0::Constant::create(element_type, Shape{}, {0.0});
|
||||
if (shape.size() > 0) {
|
||||
return std::make_shared<op::v1::Broadcast>(zero,
|
||||
op::Constant::create(element::u64, Shape{shape.size()}, shape));
|
||||
return std::make_shared<ov::op::v1::Broadcast>(
|
||||
zero,
|
||||
op::v0::Constant::create(element::u64, Shape{shape.size()}, shape));
|
||||
}
|
||||
return zero;
|
||||
}
|
||||
|
||||
std::shared_ptr<ngraph::Node> ngraph::make_constant_from_string(std::string val,
|
||||
const element::Type& element_type,
|
||||
const Shape& shape) {
|
||||
std::shared_ptr<ov::Node> make_constant_from_string(std::string val,
|
||||
const element::Type& element_type,
|
||||
const Shape& shape) {
|
||||
auto cvals = std::vector<std::string>(shape_size(shape), val);
|
||||
return std::make_shared<op::Constant>(element_type, shape, cvals);
|
||||
return std::make_shared<op::v0::Constant>(element_type, shape, cvals);
|
||||
}
|
||||
|
||||
bool ngraph::is_zero(const Output<Node>& reduce_constant) {
|
||||
bool is_zero(const Output<Node>& reduce_constant) {
|
||||
auto result_bool = is_equal_to_const_value("0", reduce_constant);
|
||||
return result_bool;
|
||||
}
|
||||
|
||||
bool ngraph::is_one(const Output<Node>& reduce_constant) {
|
||||
bool is_one(const Output<Node>& reduce_constant) {
|
||||
auto result_bool = is_equal_to_const_value("1", reduce_constant);
|
||||
return result_bool;
|
||||
}
|
||||
|
||||
ngraph::NodeVector ngraph::get_subgraph_outputs(const NodeVector& nodes,
|
||||
const NodeVector& exclusions,
|
||||
bool ignore_unused,
|
||||
bool ignore_output_duplicates) {
|
||||
std::set<shared_ptr<Node>> exclusions_set(exclusions.begin(), exclusions.end());
|
||||
std::set<shared_ptr<Node>> nodes_set(nodes.begin(), nodes.end());
|
||||
ov::NodeVector get_subgraph_outputs(const NodeVector& nodes,
|
||||
const NodeVector& exclusions,
|
||||
bool ignore_unused,
|
||||
bool ignore_output_duplicates) {
|
||||
std::set<std::shared_ptr<Node>> exclusions_set(exclusions.begin(), exclusions.end());
|
||||
std::set<std::shared_ptr<Node>> nodes_set(nodes.begin(), nodes.end());
|
||||
|
||||
NodeVector outputs;
|
||||
|
||||
@ -684,7 +673,7 @@ ngraph::NodeVector ngraph::get_subgraph_outputs(const NodeVector& nodes,
|
||||
return outputs;
|
||||
}
|
||||
|
||||
ngraph::NodeVector ngraph::extract_subgraph(const NodeVector& results, const NodeVector& args) {
|
||||
ov::NodeVector extract_subgraph(const NodeVector& results, const NodeVector& args) {
|
||||
NodeVector subgraph;
|
||||
traverse_nodes(
|
||||
results,
|
||||
@ -695,15 +684,15 @@ ngraph::NodeVector ngraph::extract_subgraph(const NodeVector& results, const Nod
|
||||
return subgraph;
|
||||
}
|
||||
|
||||
bool ngraph::is_used(Node* node) {
|
||||
bool is_used(Node* node) {
|
||||
std::unordered_set<Node*> instances_seen;
|
||||
std::stack<Node*, std::vector<Node*>> stack;
|
||||
stack.push(node);
|
||||
|
||||
while (stack.size() > 0) {
|
||||
ngraph::Node* n = stack.top();
|
||||
ov::Node* n = stack.top();
|
||||
if (instances_seen.count(n) == 0) {
|
||||
if (ngraph::op::is_output(n)) {
|
||||
if (ov::op::util::is_output(n)) {
|
||||
return true;
|
||||
}
|
||||
instances_seen.insert(n);
|
||||
@ -718,7 +707,7 @@ bool ngraph::is_used(Node* node) {
|
||||
return false;
|
||||
}
|
||||
|
||||
size_t ngraph::get_user_count(Node* node) {
|
||||
size_t get_user_count(Node* node) {
|
||||
size_t count = 0;
|
||||
for (const auto& node_user : node->get_users()) {
|
||||
count += is_used(node_user.get());
|
||||
@ -726,13 +715,13 @@ size_t ngraph::get_user_count(Node* node) {
|
||||
return count;
|
||||
}
|
||||
|
||||
bool ngraph::is_strided(const Strides& strides) {
|
||||
bool is_strided(const Strides& strides) {
|
||||
return std::any_of(strides.begin(), strides.end(), [](size_t stride) {
|
||||
return stride != 1;
|
||||
});
|
||||
}
|
||||
|
||||
bool ngraph::is_valid_rank(const std::shared_ptr<Node>& node, std::vector<size_t> valid_ranks) {
|
||||
bool is_valid_rank(const std::shared_ptr<Node>& node, std::vector<size_t> valid_ranks) {
|
||||
auto node_rank = node->get_shape().size();
|
||||
for (auto rank : valid_ranks) {
|
||||
if (rank == node_rank) {
|
||||
@ -742,15 +731,15 @@ bool ngraph::is_valid_rank(const std::shared_ptr<Node>& node, std::vector<size_t
|
||||
return false;
|
||||
}
|
||||
|
||||
void ngraph::plot_graph(std::shared_ptr<Function> f,
|
||||
const std::string& filename,
|
||||
std::function<void(const Node& node, std::vector<std::string>& attributes)> attributes) {
|
||||
ngraph::pass::Manager pass_manager;
|
||||
pass_manager.register_pass<ngraph::pass::VisualizeTree>(filename, attributes);
|
||||
void plot_graph(std::shared_ptr<Function> f,
|
||||
const std::string& filename,
|
||||
std::function<void(const Node& node, std::vector<std::string>& attributes)> attributes) {
|
||||
ov::pass::Manager pass_manager;
|
||||
pass_manager.register_pass<ov::pass::VisualizeTree>(filename, attributes);
|
||||
pass_manager.run_passes(std::move(f));
|
||||
}
|
||||
|
||||
std::vector<ngraph::Input<ngraph::Node>> ngraph::get_inputs_from(Node& src, Node& dst) {
|
||||
std::vector<ov::Input<ov::Node>> get_inputs_from(Node& src, Node& dst) {
|
||||
std::vector<Input<Node>> result;
|
||||
|
||||
for (auto& input : dst.inputs()) {
|
||||
@ -762,7 +751,7 @@ std::vector<ngraph::Input<ngraph::Node>> ngraph::get_inputs_from(Node& src, Node
|
||||
return result;
|
||||
}
|
||||
|
||||
std::vector<ngraph::Output<ngraph::Node>> ngraph::get_outputs_to(Node& src, Node& dst) {
|
||||
std::vector<ov::Output<ov::Node>> get_outputs_to(Node& src, Node& dst) {
|
||||
std::vector<Output<Node>> result;
|
||||
|
||||
for (auto& output : src.outputs()) {
|
||||
@ -783,10 +772,10 @@ std::vector<ngraph::Output<ngraph::Node>> ngraph::get_outputs_to(Node& src, Node
|
||||
return result;
|
||||
}
|
||||
|
||||
static bool check_for_cycles_bkwd(const std::shared_ptr<ngraph::Node>& node,
|
||||
std::deque<std::shared_ptr<ngraph::Node>>& path,
|
||||
std::unordered_set<std::shared_ptr<ngraph::Node>>& path_set,
|
||||
ngraph::NodeVector& cycle_nodes) {
|
||||
static bool check_for_cycles_bkwd(const std::shared_ptr<ov::Node>& node,
|
||||
std::deque<std::shared_ptr<ov::Node>>& path,
|
||||
std::unordered_set<std::shared_ptr<ov::Node>>& path_set,
|
||||
ov::NodeVector& cycle_nodes) {
|
||||
path.push_back(node);
|
||||
path_set.insert(node);
|
||||
for (size_t i = 0; i < node->inputs().size(); i++) {
|
||||
@ -808,10 +797,10 @@ static bool check_for_cycles_bkwd(const std::shared_ptr<ngraph::Node>& node,
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool check_for_cycles_fwd(const std::shared_ptr<ngraph::Node>& node,
|
||||
std::deque<std::shared_ptr<ngraph::Node>>& path,
|
||||
std::unordered_set<std::shared_ptr<ngraph::Node>>& path_set,
|
||||
ngraph::NodeVector& cycle_nodes) {
|
||||
static bool check_for_cycles_fwd(const std::shared_ptr<ov::Node>& node,
|
||||
std::deque<std::shared_ptr<ov::Node>>& path,
|
||||
std::unordered_set<std::shared_ptr<ov::Node>>& path_set,
|
||||
ov::NodeVector& cycle_nodes) {
|
||||
path.push_back(node);
|
||||
path_set.insert(node);
|
||||
for (auto& arg : node->get_users()) {
|
||||
@ -832,7 +821,7 @@ static bool check_for_cycles_fwd(const std::shared_ptr<ngraph::Node>& node,
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ngraph::check_for_cycles(const ngraph::Function* func, ngraph::NodeVector& cycle_nodes, bool& is_bkwd_cycle) {
|
||||
bool check_for_cycles(const ov::Model* func, ov::NodeVector& cycle_nodes, bool& is_bkwd_cycle) {
|
||||
for (const auto& res : func->get_results()) {
|
||||
std::deque<std::shared_ptr<Node>> path;
|
||||
// mirror of path stack for faster cycle check
|
||||
@ -865,3 +854,5 @@ bool ngraph::check_for_cycles(const ngraph::Function* func, ngraph::NodeVector&
|
||||
// no cycles
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace ngraph
|
||||
|
@ -5,17 +5,11 @@
|
||||
#include "ngraph/opsets/opset.hpp"
|
||||
|
||||
#include "itt.hpp"
|
||||
#include "ngraph/deprecated.hpp"
|
||||
#include "ngraph/log.hpp"
|
||||
#include "openvino/op/ops.hpp"
|
||||
#include "openvino/opsets/opset.hpp"
|
||||
#include "openvino/util/log.hpp"
|
||||
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
ngraph::OpSet::OpSet(const ov::OpSet& opset) : ov::OpSet(opset) {}
|
||||
|
||||
ngraph::OpSet::OpSet(const ngraph::OpSet& opset) : ov::OpSet(opset) {}
|
||||
|
||||
ov::OpSet::OpSet(const std::string& name) : m_name(name) {}
|
||||
|
||||
ov::OpSet::OpSet(const ov::OpSet& opset) {
|
||||
@ -51,24 +45,6 @@ ov::Node* ov::OpSet::create_insensitive(const std::string& name) const {
|
||||
return m_factory_registry.create(type_info_it->second);
|
||||
}
|
||||
|
||||
const std::map<std::string, std::function<const ngraph::OpSet&()>>& ngraph::get_available_opsets() {
|
||||
#define _NGRAPH_REG_OPSET(OPSET) \
|
||||
{ #OPSET, ngraph::get_##OPSET }
|
||||
const static std::map<std::string, std::function<const ngraph::OpSet&()>> opset_map = {_NGRAPH_REG_OPSET(opset1),
|
||||
_NGRAPH_REG_OPSET(opset2),
|
||||
_NGRAPH_REG_OPSET(opset3),
|
||||
_NGRAPH_REG_OPSET(opset4),
|
||||
_NGRAPH_REG_OPSET(opset5),
|
||||
_NGRAPH_REG_OPSET(opset6),
|
||||
_NGRAPH_REG_OPSET(opset7),
|
||||
_NGRAPH_REG_OPSET(opset8),
|
||||
_NGRAPH_REG_OPSET(opset9),
|
||||
_NGRAPH_REG_OPSET(opset10),
|
||||
_NGRAPH_REG_OPSET(opset11)};
|
||||
#undef _NGRAPH_REG_OPSET
|
||||
return opset_map;
|
||||
}
|
||||
|
||||
const std::map<std::string, std::function<const ov::OpSet&()>>& ov::get_available_opsets() {
|
||||
#define _OPENVINO_REG_OPSET(OPSET) \
|
||||
{ #OPSET, ov::get_##OPSET }
|
||||
@ -232,57 +208,96 @@ const ov::OpSet& ov::get_opset13() {
|
||||
return opset;
|
||||
}
|
||||
|
||||
const ngraph::OpSet& ngraph::get_opset1() {
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
namespace ngraph {
|
||||
|
||||
OpSet::OpSet(const ov::OpSet& opset) : ov::OpSet(opset) {}
|
||||
|
||||
OpSet::OpSet(const OpSet& opset) : ov::OpSet(opset) {}
|
||||
|
||||
const std::map<std::string, std::function<const OpSet&()>>& get_available_opsets() {
|
||||
#define _REG_OPSET(OPSET) \
|
||||
{ #OPSET, get_##OPSET }
|
||||
const static std::map<std::string, std::function<const OpSet&()>> opset_map = {_REG_OPSET(opset1),
|
||||
_REG_OPSET(opset2),
|
||||
_REG_OPSET(opset3),
|
||||
_REG_OPSET(opset4),
|
||||
_REG_OPSET(opset5),
|
||||
_REG_OPSET(opset6),
|
||||
_REG_OPSET(opset7),
|
||||
_REG_OPSET(opset8),
|
||||
_REG_OPSET(opset9),
|
||||
_REG_OPSET(opset10),
|
||||
_REG_OPSET(opset11),
|
||||
_REG_OPSET(opset12),
|
||||
_REG_OPSET(opset13)};
|
||||
#undef _REG_OPSET
|
||||
return opset_map;
|
||||
}
|
||||
|
||||
const OpSet& get_opset1() {
|
||||
static OpSet opset(ov::get_opset1());
|
||||
return opset;
|
||||
}
|
||||
|
||||
const ngraph::OpSet& ngraph::get_opset2() {
|
||||
const OpSet& get_opset2() {
|
||||
static OpSet opset(ov::get_opset2());
|
||||
return opset;
|
||||
}
|
||||
|
||||
const ngraph::OpSet& ngraph::get_opset3() {
|
||||
const OpSet& get_opset3() {
|
||||
static OpSet opset(ov::get_opset3());
|
||||
return opset;
|
||||
}
|
||||
|
||||
const ngraph::OpSet& ngraph::get_opset4() {
|
||||
const OpSet& get_opset4() {
|
||||
static OpSet opset(ov::get_opset4());
|
||||
return opset;
|
||||
}
|
||||
|
||||
const ngraph::OpSet& ngraph::get_opset5() {
|
||||
const OpSet& get_opset5() {
|
||||
static OpSet opset(ov::get_opset5());
|
||||
return opset;
|
||||
}
|
||||
|
||||
const ngraph::OpSet& ngraph::get_opset6() {
|
||||
const OpSet& get_opset6() {
|
||||
static OpSet opset(ov::get_opset6());
|
||||
return opset;
|
||||
}
|
||||
|
||||
const ngraph::OpSet& ngraph::get_opset7() {
|
||||
const OpSet& get_opset7() {
|
||||
static OpSet opset(ov::get_opset7());
|
||||
return opset;
|
||||
}
|
||||
|
||||
const ngraph::OpSet& ngraph::get_opset8() {
|
||||
const OpSet& get_opset8() {
|
||||
static OpSet opset(ov::get_opset8());
|
||||
return opset;
|
||||
}
|
||||
|
||||
const ngraph::OpSet& ngraph::get_opset9() {
|
||||
const OpSet& get_opset9() {
|
||||
static OpSet opset(ov::get_opset9());
|
||||
return opset;
|
||||
}
|
||||
|
||||
const ngraph::OpSet& ngraph::get_opset10() {
|
||||
const OpSet& get_opset10() {
|
||||
static OpSet opset(ov::get_opset10());
|
||||
return opset;
|
||||
}
|
||||
|
||||
const ngraph::OpSet& ngraph::get_opset11() {
|
||||
const OpSet& get_opset11() {
|
||||
static OpSet opset(ov::get_opset11());
|
||||
return opset;
|
||||
}
|
||||
|
||||
const OpSet& get_opset12() {
|
||||
static OpSet opset(ov::get_opset12());
|
||||
return opset;
|
||||
}
|
||||
|
||||
const OpSet& get_opset13() {
|
||||
static OpSet opset(ov::get_opset13());
|
||||
return opset;
|
||||
}
|
||||
|
||||
} // namespace ngraph
|
||||
|
@ -8,17 +8,18 @@
|
||||
#include <memory>
|
||||
|
||||
#include "ngraph/util.hpp"
|
||||
#include "openvino/util/log.hpp"
|
||||
|
||||
using namespace ngraph;
|
||||
using namespace std;
|
||||
NGRAPH_SUPPRESS_DEPRECATED_START
|
||||
|
||||
namespace ngraph {
|
||||
|
||||
runtime::AlignedBuffer::AlignedBuffer() : m_allocated_buffer(nullptr), m_aligned_buffer(nullptr), m_byte_size(0) {}
|
||||
|
||||
runtime::AlignedBuffer::AlignedBuffer(size_t byte_size, size_t alignment) : m_byte_size(byte_size) {
|
||||
m_byte_size = std::max<size_t>(1, byte_size);
|
||||
size_t allocation_size = m_byte_size + alignment;
|
||||
m_allocated_buffer = static_cast<char*>(ngraph_malloc(allocation_size));
|
||||
m_allocated_buffer = new char[allocation_size];
|
||||
m_aligned_buffer = m_allocated_buffer;
|
||||
size_t mod = (alignment != 0) ? size_t(m_aligned_buffer) % alignment : 0;
|
||||
|
||||
@ -38,14 +39,14 @@ runtime::AlignedBuffer::AlignedBuffer(AlignedBuffer&& other)
|
||||
|
||||
runtime::AlignedBuffer::~AlignedBuffer() {
|
||||
if (m_allocated_buffer != nullptr) {
|
||||
free(m_allocated_buffer);
|
||||
delete[] m_allocated_buffer;
|
||||
}
|
||||
}
|
||||
|
||||
runtime::AlignedBuffer& runtime::AlignedBuffer::operator=(AlignedBuffer&& other) {
|
||||
if (this != &other) {
|
||||
if (m_allocated_buffer != nullptr) {
|
||||
free(m_allocated_buffer);
|
||||
delete[] m_allocated_buffer;
|
||||
}
|
||||
m_allocated_buffer = other.m_allocated_buffer;
|
||||
m_aligned_buffer = other.m_aligned_buffer;
|
||||
@ -56,9 +57,10 @@ runtime::AlignedBuffer& runtime::AlignedBuffer::operator=(AlignedBuffer&& other)
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
} // namespace ngraph
|
||||
|
||||
namespace ov {
|
||||
AttributeAdapter<shared_ptr<ngraph::runtime::AlignedBuffer>>::AttributeAdapter(
|
||||
shared_ptr<ngraph::runtime::AlignedBuffer>& value)
|
||||
: DirectValueAccessor<shared_ptr<ngraph::runtime::AlignedBuffer>>(value) {}
|
||||
AttributeAdapter<std::shared_ptr<ngraph::runtime::AlignedBuffer>>::AttributeAdapter(
|
||||
std::shared_ptr<ngraph::runtime::AlignedBuffer>& value)
|
||||
: DirectValueAccessor<std::shared_ptr<ngraph::runtime::AlignedBuffer>>(value) {}
|
||||
} // namespace ov
|
||||
|
@ -4,10 +4,6 @@
|
||||
|
||||
#include "ngraph/runtime/tensor.hpp"
|
||||
|
||||
#include "ngraph/log.hpp"
|
||||
#include "ngraph/runtime/aligned_buffer.hpp"
|
||||
#include "ngraph/type/element_type.hpp"
|
||||
|
||||
using namespace ngraph;
|
||||
using namespace std;
|
||||
|
||||
|
@ -9,10 +9,9 @@
|
||||
#include "openvino/core/partial_shape.hpp"
|
||||
#include "openvino/core/shape_util.hpp"
|
||||
|
||||
using namespace ngraph;
|
||||
|
||||
namespace ngraph {
|
||||
template <>
|
||||
PartialShape ngraph::project(const PartialShape& shape, const AxisSet& axes) {
|
||||
PartialShape project(const PartialShape& shape, const AxisSet& axes) {
|
||||
if (shape.rank().is_dynamic()) {
|
||||
return shape;
|
||||
} else {
|
||||
@ -29,7 +28,7 @@ PartialShape ngraph::project(const PartialShape& shape, const AxisSet& axes) {
|
||||
}
|
||||
|
||||
template <>
|
||||
PartialShape ngraph::reduce(const PartialShape& shape, const AxisSet& deleted_axes, bool keep_dims) {
|
||||
PartialShape reduce(const PartialShape& shape, const AxisSet& deleted_axes, bool keep_dims) {
|
||||
if (shape.rank().is_dynamic()) {
|
||||
return shape;
|
||||
} else {
|
||||
@ -49,8 +48,8 @@ PartialShape ngraph::reduce(const PartialShape& shape, const AxisSet& deleted_ax
|
||||
}
|
||||
|
||||
template <>
|
||||
PartialShape ngraph::inject_pairs(const PartialShape& shape,
|
||||
std::vector<std::pair<size_t, Dimension>> new_axis_pos_value_pairs) {
|
||||
PartialShape inject_pairs(const PartialShape& shape,
|
||||
std::vector<std::pair<size_t, Dimension>> new_axis_pos_value_pairs) {
|
||||
if (shape.rank().is_dynamic()) {
|
||||
return shape;
|
||||
} else {
|
||||
@ -76,6 +75,7 @@ PartialShape ngraph::inject_pairs(const PartialShape& shape,
|
||||
return PartialShape{result_dims};
|
||||
}
|
||||
}
|
||||
} // namespace ngraph
|
||||
|
||||
namespace ov {
|
||||
template <class TContainer, class TAxes>
|
||||
|
@ -13,21 +13,13 @@
|
||||
#include <numeric>
|
||||
#include <unordered_set>
|
||||
|
||||
#include "ngraph/coordinate_diff.hpp"
|
||||
#include "ngraph/function.hpp"
|
||||
#include "ngraph/graph_util.hpp"
|
||||
#include "ngraph/log.hpp"
|
||||
#include "ngraph/node.hpp"
|
||||
#include "ngraph/op/result.hpp"
|
||||
#include "ngraph/partial_shape.hpp"
|
||||
#include "ngraph/shape.hpp"
|
||||
#include "openvino/util/common_util.hpp"
|
||||
#include "openvino/util/log.hpp"
|
||||
|
||||
NGRAPH_SUPPRESS_DEPRECATED_START
|
||||
using namespace std;
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
|
||||
void ngraph::dump(ostream& out, const void* _data, size_t _size) {
|
||||
namespace ngraph {
|
||||
void dump(std::ostream& out, const void* _data, size_t _size) {
|
||||
auto flags = out.flags();
|
||||
const uint8_t* data = reinterpret_cast<const uint8_t*>(_data);
|
||||
size_t len = _size;
|
||||
@ -61,27 +53,27 @@ void ngraph::dump(ostream& out, const void* _data, size_t _size) {
|
||||
out.flags(flags);
|
||||
}
|
||||
|
||||
std::string ngraph::to_lower(const std::string& s) {
|
||||
std::string to_lower(const std::string& s) {
|
||||
return ov::util::to_lower(s);
|
||||
}
|
||||
|
||||
std::string ngraph::to_upper(const std::string& s) {
|
||||
std::string to_upper(const std::string& s) {
|
||||
return ov::util::to_upper(s);
|
||||
}
|
||||
|
||||
string ngraph::trim(const string& s) {
|
||||
std::string trim(const std::string& s) {
|
||||
return ov::util::trim(s);
|
||||
}
|
||||
|
||||
vector<string> ngraph::split(const string& src, char delimiter, bool do_trim) {
|
||||
std::vector<std::string> split(const std::string& src, char delimiter, bool do_trim) {
|
||||
return ov::util::split(src, delimiter, do_trim);
|
||||
}
|
||||
|
||||
size_t ngraph::hash_combine(const std::vector<size_t>& list) {
|
||||
size_t hash_combine(const std::vector<size_t>& list) {
|
||||
return ov::util::hash_combine(list);
|
||||
}
|
||||
|
||||
void* ngraph::ngraph_malloc(size_t size) {
|
||||
void* ngraph_malloc(size_t size) {
|
||||
auto ptr = malloc(size);
|
||||
if (size != 0 && !ptr) {
|
||||
OPENVINO_ERR << "malloc failed to allocate memory of size " << size;
|
||||
@ -90,13 +82,13 @@ void* ngraph::ngraph_malloc(size_t size) {
|
||||
return ptr;
|
||||
}
|
||||
|
||||
void ngraph::ngraph_free(void* ptr) {
|
||||
void ngraph_free(void* ptr) {
|
||||
if (ptr) {
|
||||
free(ptr);
|
||||
}
|
||||
}
|
||||
|
||||
size_t ngraph::round_up(size_t size, size_t alignment) {
|
||||
size_t round_up(size_t size, size_t alignment) {
|
||||
if (alignment == 0) {
|
||||
return size;
|
||||
}
|
||||
@ -109,27 +101,27 @@ size_t ngraph::round_up(size_t size, size_t alignment) {
|
||||
return size + alignment - remainder;
|
||||
}
|
||||
|
||||
size_t ngraph::stopwatch::get_call_count() const {
|
||||
size_t stopwatch::get_call_count() const {
|
||||
return m_total_count;
|
||||
}
|
||||
|
||||
size_t ngraph::stopwatch::get_seconds() const {
|
||||
return chrono::duration_cast<chrono::seconds>(get_timer_value()).count();
|
||||
size_t stopwatch::get_seconds() const {
|
||||
return std::chrono::duration_cast<std::chrono::seconds>(get_timer_value()).count();
|
||||
}
|
||||
|
||||
size_t ngraph::stopwatch::get_milliseconds() const {
|
||||
return chrono::duration_cast<chrono::milliseconds>(get_timer_value()).count();
|
||||
size_t stopwatch::get_milliseconds() const {
|
||||
return std::chrono::duration_cast<std::chrono::milliseconds>(get_timer_value()).count();
|
||||
}
|
||||
|
||||
size_t ngraph::stopwatch::get_microseconds() const {
|
||||
return chrono::duration_cast<chrono::microseconds>(get_timer_value()).count();
|
||||
size_t stopwatch::get_microseconds() const {
|
||||
return std::chrono::duration_cast<std::chrono::microseconds>(get_timer_value()).count();
|
||||
}
|
||||
|
||||
size_t ngraph::stopwatch::get_nanoseconds() const {
|
||||
size_t stopwatch::get_nanoseconds() const {
|
||||
return get_timer_value().count();
|
||||
}
|
||||
|
||||
chrono::nanoseconds ngraph::stopwatch::get_timer_value() const {
|
||||
std::chrono::nanoseconds stopwatch::get_timer_value() const {
|
||||
if (m_active) {
|
||||
return (m_clock.now() - m_start_time);
|
||||
} else {
|
||||
@ -137,23 +129,22 @@ chrono::nanoseconds ngraph::stopwatch::get_timer_value() const {
|
||||
}
|
||||
}
|
||||
|
||||
size_t ngraph::stopwatch::get_total_seconds() const {
|
||||
return chrono::duration_cast<chrono::seconds>(m_total_time).count();
|
||||
size_t stopwatch::get_total_seconds() const {
|
||||
return std::chrono::duration_cast<std::chrono::seconds>(m_total_time).count();
|
||||
}
|
||||
|
||||
size_t ngraph::stopwatch::get_total_milliseconds() const {
|
||||
return chrono::duration_cast<chrono::milliseconds>(m_total_time).count();
|
||||
size_t stopwatch::get_total_milliseconds() const {
|
||||
return std::chrono::duration_cast<std::chrono::milliseconds>(m_total_time).count();
|
||||
}
|
||||
|
||||
size_t ngraph::stopwatch::get_total_microseconds() const {
|
||||
return chrono::duration_cast<chrono::microseconds>(m_total_time).count();
|
||||
size_t stopwatch::get_total_microseconds() const {
|
||||
return std::chrono::duration_cast<std::chrono::microseconds>(m_total_time).count();
|
||||
}
|
||||
|
||||
size_t ngraph::stopwatch::get_total_nanoseconds() const {
|
||||
size_t stopwatch::get_total_nanoseconds() const {
|
||||
return m_total_time.count();
|
||||
}
|
||||
|
||||
namespace ngraph {
|
||||
template <>
|
||||
float parse_string<float>(const std::string& s) {
|
||||
const char* tmp = s.c_str();
|
||||
@ -201,40 +192,30 @@ uint8_t parse_string<uint8_t>(const std::string& s) {
|
||||
|
||||
return result;
|
||||
}
|
||||
} // namespace ngraph
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const ngraph::NodeVector& nv) {
|
||||
std::vector<std::string> names;
|
||||
for (auto n : nv) {
|
||||
names.push_back(n->get_name());
|
||||
}
|
||||
os << ngraph::vector_to_string(names);
|
||||
return os;
|
||||
}
|
||||
|
||||
ngraph::AxisVector ngraph::get_default_order(const Shape& shape) {
|
||||
AxisVector get_default_order(const Shape& shape) {
|
||||
return get_default_order(shape.size());
|
||||
}
|
||||
|
||||
ngraph::AxisVector ngraph::get_default_order(const PartialShape& shape) {
|
||||
AxisVector get_default_order(const PartialShape& shape) {
|
||||
return get_default_order(shape.rank());
|
||||
}
|
||||
|
||||
ngraph::AxisVector ngraph::get_default_order(size_t rank) {
|
||||
AxisVector get_default_order(size_t rank) {
|
||||
AxisVector default_order(rank);
|
||||
std::iota(begin(default_order), end(default_order), 0);
|
||||
return default_order;
|
||||
}
|
||||
|
||||
ngraph::AxisVector ngraph::get_default_order(const Rank& rank) {
|
||||
NGRAPH_CHECK(rank.is_static(), "Can not calculate default order for dynamic rank");
|
||||
AxisVector get_default_order(const Rank& rank) {
|
||||
OPENVINO_ASSERT(rank.is_static(), "Can not calculate default order for dynamic rank");
|
||||
|
||||
AxisVector default_order(rank.get_length());
|
||||
std::iota(begin(default_order), end(default_order), 0);
|
||||
return default_order;
|
||||
}
|
||||
|
||||
void ngraph::parse_version_string(std::string version, size_t& major, size_t& minor, size_t& patch, string& extra) {
|
||||
void parse_version_string(std::string version, size_t& major, size_t& minor, size_t& patch, std::string& extra) {
|
||||
// Since regex is broken in gcc 4.8 I will just manually parse the version string
|
||||
// Version strings look like `0.25.0-rc.0+7c32240` or `v0.25.0-rc.0+7c32240`
|
||||
size_t start;
|
||||
@ -242,18 +223,18 @@ void ngraph::parse_version_string(std::string version, size_t& major, size_t& mi
|
||||
extra = "";
|
||||
start = (version[0] == 'v' ? 1 : 0);
|
||||
end = version.find_first_of('.', start);
|
||||
string major_str = version.substr(start, end - start);
|
||||
std::string major_str = version.substr(start, end - start);
|
||||
start = end + 1;
|
||||
|
||||
end = version.find_first_of('.', start);
|
||||
string minor_str = version.substr(start, end - start);
|
||||
std::string minor_str = version.substr(start, end - start);
|
||||
start = end + 1;
|
||||
|
||||
end = version.find_first_of("-+", start);
|
||||
string patch_str = version.substr(start, end - start);
|
||||
std::string patch_str = version.substr(start, end - start);
|
||||
start = end;
|
||||
|
||||
if (start != string::npos) {
|
||||
if (start != std::string::npos) {
|
||||
extra = version.substr(start);
|
||||
}
|
||||
|
||||
@ -279,73 +260,74 @@ void ngraph::parse_version_string(std::string version, size_t& major, size_t& mi
|
||||
OPENVINO_THROW("Error parsing version string '", version, "'");
|
||||
}
|
||||
}
|
||||
} // namespace ngraph
|
||||
|
||||
vector<float> read_float_vector(shared_ptr<ngraph::runtime::Tensor> tv) {
|
||||
vector<float> float_vec;
|
||||
ngraph::element::Type element_type = tv->get_element_type();
|
||||
std::vector<float> read_float_vector(std::shared_ptr<ngraph::runtime::Tensor> tv) {
|
||||
std::vector<float> float_vec;
|
||||
ov::element::Type element_type = tv->get_element_type();
|
||||
|
||||
if (element_type == ngraph::element::boolean) {
|
||||
vector<char> vec = read_vector<char>(tv);
|
||||
if (element_type == ov::element::boolean) {
|
||||
std::vector<char> vec = read_vector<char>(tv);
|
||||
// Changed from vector ctor to explicit for loop to add static_cast
|
||||
// This silences MSVC warnings
|
||||
for (char value : vec) {
|
||||
float_vec.push_back(static_cast<float>(value));
|
||||
}
|
||||
} else if (element_type == ngraph::element::bf16) {
|
||||
vector<ngraph::bfloat16> vec = read_vector<ngraph::bfloat16>(tv);
|
||||
float_vec = ngraph::bfloat16::to_float_vector(vec);
|
||||
} else if (element_type == ngraph::element::f16) {
|
||||
vector<ngraph::float16> vec = read_vector<ngraph::float16>(tv);
|
||||
for (ngraph::float16 value : vec) {
|
||||
} else if (element_type == ov::element::bf16) {
|
||||
std::vector<ov::bfloat16> vec = read_vector<ov::bfloat16>(tv);
|
||||
float_vec = ov::bfloat16::to_float_vector(vec);
|
||||
} else if (element_type == ov::element::f16) {
|
||||
std::vector<ov::float16> vec = read_vector<ov::float16>(tv);
|
||||
for (ov::float16 value : vec) {
|
||||
float_vec.push_back(static_cast<float>(value));
|
||||
}
|
||||
} else if (element_type == ngraph::element::f32) {
|
||||
vector<float> vec = read_vector<float>(tv);
|
||||
} else if (element_type == ov::element::f32) {
|
||||
std::vector<float> vec = read_vector<float>(tv);
|
||||
for (float value : vec) {
|
||||
float_vec.push_back(static_cast<float>(value));
|
||||
}
|
||||
} else if (element_type == ngraph::element::f64) {
|
||||
vector<double> vec = read_vector<double>(tv);
|
||||
} else if (element_type == ov::element::f64) {
|
||||
std::vector<double> vec = read_vector<double>(tv);
|
||||
for (double value : vec) {
|
||||
float_vec.push_back(static_cast<float>(value));
|
||||
}
|
||||
} else if (element_type == ngraph::element::i8) {
|
||||
vector<int8_t> vec = read_vector<int8_t>(tv);
|
||||
} else if (element_type == ov::element::i8) {
|
||||
std::vector<int8_t> vec = read_vector<int8_t>(tv);
|
||||
for (int8_t value : vec) {
|
||||
float_vec.push_back(static_cast<float>(value));
|
||||
}
|
||||
} else if (element_type == ngraph::element::i16) {
|
||||
vector<int16_t> vec = read_vector<int16_t>(tv);
|
||||
} else if (element_type == ov::element::i16) {
|
||||
std::vector<int16_t> vec = read_vector<int16_t>(tv);
|
||||
for (int16_t value : vec) {
|
||||
float_vec.push_back(static_cast<float>(value));
|
||||
}
|
||||
} else if (element_type == ngraph::element::i32) {
|
||||
vector<int32_t> vec = read_vector<int32_t>(tv);
|
||||
} else if (element_type == ov::element::i32) {
|
||||
std::vector<int32_t> vec = read_vector<int32_t>(tv);
|
||||
for (int32_t value : vec) {
|
||||
float_vec.push_back(static_cast<float>(value));
|
||||
}
|
||||
} else if (element_type == ngraph::element::i64) {
|
||||
vector<int64_t> vec = read_vector<int64_t>(tv);
|
||||
} else if (element_type == ov::element::i64) {
|
||||
std::vector<int64_t> vec = read_vector<int64_t>(tv);
|
||||
for (int64_t value : vec) {
|
||||
float_vec.push_back(static_cast<float>(value));
|
||||
}
|
||||
} else if (element_type == ngraph::element::u8) {
|
||||
vector<uint8_t> vec = read_vector<uint8_t>(tv);
|
||||
} else if (element_type == ov::element::u8) {
|
||||
std::vector<uint8_t> vec = read_vector<uint8_t>(tv);
|
||||
for (uint8_t value : vec) {
|
||||
float_vec.push_back(static_cast<float>(value));
|
||||
}
|
||||
} else if (element_type == ngraph::element::u16) {
|
||||
vector<uint16_t> vec = read_vector<uint16_t>(tv);
|
||||
} else if (element_type == ov::element::u16) {
|
||||
std::vector<uint16_t> vec = read_vector<uint16_t>(tv);
|
||||
for (uint16_t value : vec) {
|
||||
float_vec.push_back(static_cast<float>(value));
|
||||
}
|
||||
} else if (element_type == ngraph::element::u32) {
|
||||
vector<uint32_t> vec = read_vector<uint32_t>(tv);
|
||||
} else if (element_type == ov::element::u32) {
|
||||
std::vector<uint32_t> vec = read_vector<uint32_t>(tv);
|
||||
for (uint32_t value : vec) {
|
||||
float_vec.push_back(static_cast<float>(value));
|
||||
}
|
||||
} else if (element_type == ngraph::element::u64) {
|
||||
vector<uint64_t> vec = read_vector<uint64_t>(tv);
|
||||
} else if (element_type == ov::element::u64) {
|
||||
std::vector<uint64_t> vec = read_vector<uint64_t>(tv);
|
||||
for (uint64_t value : vec) {
|
||||
float_vec.push_back(static_cast<float>(value));
|
||||
}
|
||||
@ -356,72 +338,72 @@ vector<float> read_float_vector(shared_ptr<ngraph::runtime::Tensor> tv) {
|
||||
return float_vec;
|
||||
}
|
||||
|
||||
vector<int64_t> read_index_vector(shared_ptr<ngraph::runtime::Tensor> tv) {
|
||||
vector<int64_t> index_vec;
|
||||
ngraph::element::Type element_type = tv->get_element_type();
|
||||
std::vector<int64_t> read_index_vector(std::shared_ptr<ngraph::runtime::Tensor> tv) {
|
||||
std::vector<int64_t> index_vec;
|
||||
ov::element::Type element_type = tv->get_element_type();
|
||||
|
||||
if (element_type == ngraph::element::boolean) {
|
||||
vector<char> vec = read_vector<char>(tv);
|
||||
if (element_type == ov::element::boolean) {
|
||||
std::vector<char> vec = read_vector<char>(tv);
|
||||
// Changed from vector ctor to explicit for loop to add static_cast
|
||||
// This silences MSVC warnings
|
||||
for (char value : vec) {
|
||||
index_vec.push_back(static_cast<int64_t>(value));
|
||||
}
|
||||
} else if (element_type == ngraph::element::bf16) {
|
||||
vector<ngraph::bfloat16> vec = read_vector<ngraph::bfloat16>(tv);
|
||||
vector<float> float_vec = ngraph::bfloat16::to_float_vector(vec);
|
||||
} else if (element_type == ov::element::bf16) {
|
||||
std::vector<ov::bfloat16> vec = read_vector<ov::bfloat16>(tv);
|
||||
std::vector<float> float_vec = ov::bfloat16::to_float_vector(vec);
|
||||
for (float value : float_vec) {
|
||||
index_vec.push_back(static_cast<int64_t>(value));
|
||||
}
|
||||
} else if (element_type == ngraph::element::f16) {
|
||||
vector<ngraph::float16> vec = read_vector<ngraph::float16>(tv);
|
||||
for (ngraph::float16 value : vec) {
|
||||
} else if (element_type == ov::element::f16) {
|
||||
std::vector<ov::float16> vec = read_vector<ov::float16>(tv);
|
||||
for (ov::float16 value : vec) {
|
||||
index_vec.push_back(static_cast<int64_t>(static_cast<float>(value)));
|
||||
}
|
||||
} else if (element_type == ngraph::element::f32) {
|
||||
vector<float> vec = read_vector<float>(tv);
|
||||
} else if (element_type == ov::element::f32) {
|
||||
std::vector<float> vec = read_vector<float>(tv);
|
||||
for (float value : vec) {
|
||||
index_vec.push_back(static_cast<int64_t>(value));
|
||||
}
|
||||
} else if (element_type == ngraph::element::f64) {
|
||||
vector<double> vec = read_vector<double>(tv);
|
||||
} else if (element_type == ov::element::f64) {
|
||||
std::vector<double> vec = read_vector<double>(tv);
|
||||
for (double value : vec) {
|
||||
index_vec.push_back(static_cast<int64_t>(value));
|
||||
}
|
||||
} else if (element_type == ngraph::element::i8) {
|
||||
vector<int8_t> vec = read_vector<int8_t>(tv);
|
||||
} else if (element_type == ov::element::i8) {
|
||||
std::vector<int8_t> vec = read_vector<int8_t>(tv);
|
||||
for (int8_t value : vec) {
|
||||
index_vec.push_back(static_cast<int64_t>(value));
|
||||
}
|
||||
} else if (element_type == ngraph::element::i16) {
|
||||
vector<int16_t> vec = read_vector<int16_t>(tv);
|
||||
} else if (element_type == ov::element::i16) {
|
||||
std::vector<int16_t> vec = read_vector<int16_t>(tv);
|
||||
for (int16_t value : vec) {
|
||||
index_vec.push_back(static_cast<int64_t>(value));
|
||||
}
|
||||
} else if (element_type == ngraph::element::i32) {
|
||||
vector<int32_t> vec = read_vector<int32_t>(tv);
|
||||
} else if (element_type == ov::element::i32) {
|
||||
std::vector<int32_t> vec = read_vector<int32_t>(tv);
|
||||
for (int32_t value : vec) {
|
||||
index_vec.push_back(static_cast<int64_t>(value));
|
||||
}
|
||||
} else if (element_type == ngraph::element::i64) {
|
||||
} else if (element_type == ov::element::i64) {
|
||||
index_vec = read_vector<int64_t>(tv);
|
||||
} else if (element_type == ngraph::element::u8) {
|
||||
vector<uint8_t> vec = read_vector<uint8_t>(tv);
|
||||
} else if (element_type == ov::element::u8) {
|
||||
std::vector<uint8_t> vec = read_vector<uint8_t>(tv);
|
||||
for (uint8_t value : vec) {
|
||||
index_vec.push_back(static_cast<int64_t>(value));
|
||||
}
|
||||
} else if (element_type == ngraph::element::u16) {
|
||||
vector<uint16_t> vec = read_vector<uint16_t>(tv);
|
||||
} else if (element_type == ov::element::u16) {
|
||||
std::vector<uint16_t> vec = read_vector<uint16_t>(tv);
|
||||
for (uint16_t value : vec) {
|
||||
index_vec.push_back(static_cast<int64_t>(value));
|
||||
}
|
||||
} else if (element_type == ngraph::element::u32) {
|
||||
vector<uint32_t> vec = read_vector<uint32_t>(tv);
|
||||
} else if (element_type == ov::element::u32) {
|
||||
std::vector<uint32_t> vec = read_vector<uint32_t>(tv);
|
||||
for (uint32_t value : vec) {
|
||||
index_vec.push_back(static_cast<int64_t>(value));
|
||||
}
|
||||
} else if (element_type == ngraph::element::u64) {
|
||||
vector<uint64_t> vec = read_vector<uint64_t>(tv);
|
||||
} else if (element_type == ov::element::u64) {
|
||||
std::vector<uint64_t> vec = read_vector<uint64_t>(tv);
|
||||
for (uint64_t value : vec) {
|
||||
index_vec.push_back(static_cast<int64_t>(value));
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -31,10 +31,6 @@
|
||||
#include "ie_plugin_config.hpp"
|
||||
#include "ie_remote_context.hpp"
|
||||
#include "itt.hpp"
|
||||
#include "ngraph/graph_util.hpp"
|
||||
#include "ngraph/ngraph.hpp"
|
||||
#include "ngraph/opsets/opset.hpp"
|
||||
#include "ngraph/pass/constant_folding.hpp"
|
||||
#include "openvino/core/except.hpp"
|
||||
#include "openvino/core/so_extension.hpp"
|
||||
#include "openvino/op/parameter.hpp"
|
||||
|
Loading…
Reference in New Issue
Block a user