Removed legacy headers from pass implementations (#18921)
* Removed legacy headers from pass implementations * Fixed build * Remove std and ov usings
This commit is contained in:
parent
0cad2f1324
commit
af8e41bcea
@ -26,12 +26,9 @@ namespace pass {
|
||||
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
/**
|
||||
* @brief Serialize transformation converts ngraph::Function into IR files
|
||||
* @brief Serialize transformation converts ov::Model into IR files
|
||||
* @attention
|
||||
* - dynamic shapes are not supported
|
||||
* - order of generated layers in xml file is ngraph specific (given by
|
||||
* get_ordered_ops()); MO generates file with different order, but they are
|
||||
* logically equivalent
|
||||
* \ingroup ov_pass_cpp_api
|
||||
*/
|
||||
class OPENVINO_API Serialize : public ov::pass::ModelPass {
|
||||
@ -69,7 +66,7 @@ private:
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief StreamSerialize transformation converts ngraph::Function into single binary stream
|
||||
* @brief StreamSerialize transformation converts ov::Model into single binary stream
|
||||
* @attention
|
||||
* - dynamic shapes are not supported
|
||||
* \ingroup ov_pass_cpp_api
|
||||
|
@ -157,10 +157,10 @@ std::ostream& ov::descriptor::operator<<(std::ostream& out, const ov::descriptor
|
||||
names += ", ";
|
||||
names += name;
|
||||
}
|
||||
NGRAPH_SUPPRESS_DEPRECATED_START
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
if (names.empty())
|
||||
names = get_ov_tensor_legacy_name(tensor);
|
||||
NGRAPH_SUPPRESS_DEPRECATED_END
|
||||
OPENVINO_SUPPRESS_DEPRECATED_END
|
||||
out << "Tensor(" << names << ")";
|
||||
return out;
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ void Output<Node>::replace(const Output<Node>& replacement) {
|
||||
input.replace_source_output(replacement);
|
||||
}
|
||||
replacement.get_tensor_ptr()->add_names(get_tensor_ptr()->get_names());
|
||||
NGRAPH_SUPPRESS_DEPRECATED_START
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
// In legacy API we rely on output port tensor name and use it as an input or output name for the model
|
||||
// Due to m_name is just a string, and we can't store multiple aliases for single output port we have to
|
||||
// handle two situations during replacement:
|
||||
@ -89,7 +89,7 @@ void Output<Node>::replace(const Output<Node>& replacement) {
|
||||
ov::descriptor::set_ov_tensor_legacy_name(replacement.get_tensor(),
|
||||
ov::descriptor::get_ov_tensor_legacy_name(get_tensor()));
|
||||
}
|
||||
NGRAPH_SUPPRESS_DEPRECATED_END
|
||||
OPENVINO_SUPPRESS_DEPRECATED_END
|
||||
|
||||
ov::copy_output_runtime_info({*this, replacement}, {replacement});
|
||||
}
|
||||
|
@ -11,7 +11,7 @@
|
||||
#include "openvino/opsets/opset.hpp"
|
||||
#include "openvino/util/log.hpp"
|
||||
|
||||
NGRAPH_SUPPRESS_DEPRECATED_START
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
ngraph::OpSet::OpSet(const ov::OpSet& opset) : ov::OpSet(opset) {}
|
||||
|
||||
ngraph::OpSet::OpSet(const ngraph::OpSet& opset) : ov::OpSet(opset) {}
|
||||
|
@ -4,8 +4,7 @@
|
||||
|
||||
#include "openvino/pass/constant_folding.hpp"
|
||||
|
||||
#include <openvino/cc/pass/itt.hpp>
|
||||
|
||||
#include "openvino/cc/pass/itt.hpp"
|
||||
#include "openvino/core/rt_info.hpp"
|
||||
#include "openvino/core/validation_util.hpp"
|
||||
#include "openvino/op/constant.hpp"
|
||||
@ -14,8 +13,6 @@
|
||||
#include "openvino/op/util/shape_of_base.hpp"
|
||||
#include "openvino/op/util/sub_graph_base.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
/**
|
||||
* \brief Check if \ref ov::Output<ov::Node> can be folded base on `can_be_folded` attribute.
|
||||
*
|
||||
@ -143,8 +140,8 @@ bool ov::pass::ConstantFolding::pre_calculated_values_folding(const std::shared_
|
||||
node->get_rt_info()["can_be_folded"] = can_be_folded;
|
||||
}
|
||||
|
||||
deque<shared_ptr<Node>> nodes;
|
||||
set<shared_ptr<Node>> visited;
|
||||
std::deque<std::shared_ptr<Node>> nodes;
|
||||
std::set<std::shared_ptr<Node>> visited;
|
||||
for (auto& r : model->get_results())
|
||||
nodes.push_back(r);
|
||||
for (auto& r : model->get_sinks())
|
||||
|
@ -2,20 +2,16 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "ngraph/pass/convert_fp32_to_fp16.hpp"
|
||||
#include "openvino/pass/convert_fp32_to_fp16.hpp"
|
||||
|
||||
#include <openvino/cc/pass/itt.hpp>
|
||||
|
||||
#include "ngraph/graph_util.hpp"
|
||||
#include "ngraph/pass/manager.hpp"
|
||||
#include "openvino/cc/pass/itt.hpp"
|
||||
#include "openvino/pass/manager.hpp"
|
||||
#include "transformations/convert_precision.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
bool ov::pass::ConvertFP32ToFP16::run_on_model(const std::shared_ptr<ov::Model>& f) {
|
||||
RUN_ON_MODEL_SCOPE(ConvertFP32ToFP16);
|
||||
ov::pass::Manager m(get_pass_config());
|
||||
m.register_pass<ov::pass::ConvertPrecision>(precisions_map{{ngraph::element::f32, ngraph::element::f16}});
|
||||
m.register_pass<ov::pass::ConvertPrecision>(precisions_map{{ov::element::f32, ov::element::f16}});
|
||||
m.run_passes(f);
|
||||
return false;
|
||||
}
|
||||
|
@ -2,21 +2,19 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "ngraph/pass/graph_rewrite.hpp"
|
||||
#include "openvino/pass/graph_rewrite.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <deque>
|
||||
#include <iostream>
|
||||
#include <ngraph/pattern/op/wrap_type.hpp>
|
||||
#include <openvino/cc/pass/itt.hpp>
|
||||
#include <regex>
|
||||
#include <string>
|
||||
#include <unordered_set>
|
||||
#include <vector>
|
||||
|
||||
#include "ngraph/env_util.hpp"
|
||||
#include "ngraph/log.hpp"
|
||||
#include "ngraph/op/util/sub_graph_base.hpp"
|
||||
#include "openvino/cc/pass/itt.hpp"
|
||||
#include "openvino/op/util/multi_subgraph_base.hpp"
|
||||
#include "openvino/pass/pattern/op/wrap_type.hpp"
|
||||
#include "openvino/util/log.hpp"
|
||||
#include "perf_counters.hpp"
|
||||
|
||||
@ -120,7 +118,7 @@ bool ov::pass::GraphRewrite::apply_matcher_passes(std::shared_ptr<Model> f,
|
||||
// and use it in unordered_map as key for fast MatcherPass search. Otherwise type is unknown
|
||||
// and default algorithm is used.
|
||||
if (auto p = std::dynamic_pointer_cast<pattern::op::Pattern>(root)) {
|
||||
if (auto any_type = std::dynamic_pointer_cast<pattern::op::WrapType>(p)) {
|
||||
if (auto any_type = std::dynamic_pointer_cast<ov::pass::pattern::op::WrapType>(p)) {
|
||||
for (const auto& root_type_info : any_type->get_wrapped_types()) {
|
||||
type_to_matcher[root_type_info].push_back(matcher_index);
|
||||
}
|
||||
@ -180,7 +178,7 @@ bool ov::pass::GraphRewrite::apply_matcher_passes(std::shared_ptr<Model> f,
|
||||
continue;
|
||||
|
||||
// Recursive apply Matchers for sub-graph based nodes
|
||||
if (auto sub_graph_node = std::dynamic_pointer_cast<ngraph::op::util::MultiSubGraphOp>(node)) {
|
||||
if (auto sub_graph_node = std::dynamic_pointer_cast<ov::op::util::MultiSubGraphOp>(node)) {
|
||||
if (sub_graph_node->get_transformations_allowed()) {
|
||||
size_t sub_graphs_num = sub_graph_node->get_internal_subgraphs_size();
|
||||
for (size_t sub_graph_ind = 0; sub_graph_ind < sub_graphs_num; ++sub_graph_ind) {
|
||||
|
@ -2,43 +2,38 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "ngraph/pass/low_latency.hpp"
|
||||
#include "openvino/pass/low_latency.hpp"
|
||||
|
||||
#include <memory>
|
||||
#include <ngraph/log.hpp>
|
||||
#include <ngraph/opsets/opset1.hpp>
|
||||
#include <ngraph/opsets/opset6.hpp>
|
||||
#include <ngraph/opsets/opset7.hpp>
|
||||
#include <ngraph/pattern/op/wrap_type.hpp>
|
||||
#include <ngraph/rt_info.hpp>
|
||||
#include <openvino/cc/pass/itt.hpp>
|
||||
#include <openvino/op/util/variable.hpp>
|
||||
#include <openvino/opsets/opset1.hpp>
|
||||
#include <openvino/opsets/opset9.hpp>
|
||||
#include <openvino/util/log.hpp>
|
||||
|
||||
using namespace std;
|
||||
#include "openvino/cc/pass/itt.hpp"
|
||||
#include "openvino/core/rt_info.hpp"
|
||||
#include "openvino/op/util/variable.hpp"
|
||||
#include "openvino/opsets/opset1.hpp"
|
||||
#include "openvino/opsets/opset9.hpp"
|
||||
#include "openvino/pass/graph_rewrite.hpp"
|
||||
#include "openvino/util/log.hpp"
|
||||
|
||||
namespace {
|
||||
string generate_variable_name(const string& op_name, const string& param_name, int64_t variable_idx) {
|
||||
return op_name + "/" + param_name + "/" + "variable_" + to_string(variable_idx);
|
||||
std::string generate_variable_name(const std::string& op_name, const std::string& param_name, int64_t variable_idx) {
|
||||
return op_name + "/" + param_name + "/" + "variable_" + std::to_string(variable_idx);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace {
|
||||
|
||||
const string msg_low_latency_2_already_applied = "LowLatency2 transformation cannot be applied because the "
|
||||
const std::string msg_low_latency_2_already_applied = "LowLatency2 transformation cannot be applied because the "
|
||||
"ReadValue node is already an input to the TensorIterator."
|
||||
"LowLatency2 transformation may have already been applied, please"
|
||||
"do not call it more then once.";
|
||||
const string msg_low_latency_already_applied = "LowLatency2 transformation cannot be applied because the "
|
||||
const std::string msg_low_latency_already_applied = "LowLatency2 transformation cannot be applied because the "
|
||||
"ReadValue node is already inside the TensorIterator. "
|
||||
"LowLatency transformation may have been applied, please do "
|
||||
"not call LowLatency2 after LowLatency.";
|
||||
|
||||
void unroll_single_iteration(const shared_ptr<ov::op::util::SubGraphOp>& sub_graph_op,
|
||||
const shared_ptr<ov::Model>& outer_f) {
|
||||
void unroll_single_iteration(const std::shared_ptr<ov::op::util::SubGraphOp>& sub_graph_op,
|
||||
const std::shared_ptr<ov::Model>& outer_f) {
|
||||
using namespace ov::opset9;
|
||||
|
||||
const auto& params = sub_graph_op->get_function()->get_parameters();
|
||||
@ -59,9 +54,9 @@ void unroll_single_iteration(const shared_ptr<ov::op::util::SubGraphOp>& sub_gra
|
||||
const auto& connect_to = results.at(out->m_body_value_index)->get_input_source_output(0);
|
||||
for (auto& input_to : sub_graph_op->output(out->m_output_index).get_target_inputs()) {
|
||||
// create IE output name
|
||||
string out_name = sub_graph_op->get_friendly_name();
|
||||
std::string out_name = sub_graph_op->get_friendly_name();
|
||||
if (sub_graph_op->get_output_size() != 1)
|
||||
out_name += "." + to_string(out->m_output_index);
|
||||
out_name += "." + std::to_string(out->m_output_index);
|
||||
|
||||
// IECompatibility: insert identity (Unsqueeze + Squeeze) to store the TensorIterator
|
||||
// output names
|
||||
@ -90,16 +85,16 @@ ov::Output<ov::Node> create_init_subgraph(const ov::Output<ov::Node>& in_node, o
|
||||
return broadcast->output(0);
|
||||
}
|
||||
|
||||
shared_ptr<ov::opset9::Assign> replace_with_memory(const ov::Input<ov::Node>& input,
|
||||
std::shared_ptr<ov::opset9::Assign> replace_with_memory(const ov::Input<ov::Node>& input,
|
||||
const ov::Output<ov::Node>& output,
|
||||
const string& variable_name,
|
||||
const std::string& variable_name,
|
||||
bool use_const_initializer,
|
||||
ov::pass::NodeRegistry& to) {
|
||||
using namespace ov::opset9;
|
||||
using namespace ov::op::util;
|
||||
|
||||
VariableInfo var_info{ov::PartialShape::dynamic(), ov::element::dynamic, variable_name};
|
||||
auto variable = make_shared<Variable>(var_info);
|
||||
auto variable = std::make_shared<Variable>(var_info);
|
||||
|
||||
ov::Output<ov::Node> read_value_in = input.get_source_output();
|
||||
if (use_const_initializer) {
|
||||
@ -113,25 +108,25 @@ shared_ptr<ov::opset9::Assign> replace_with_memory(const ov::Input<ov::Node>& in
|
||||
return assign;
|
||||
}
|
||||
|
||||
std::vector<shared_ptr<ov::opset9::Assign>> replace_with_memory(const shared_ptr<ov::Node>& node,
|
||||
const vector<size_t>& indexes,
|
||||
std::vector<std::shared_ptr<ov::opset9::Assign>> replace_with_memory(const std::shared_ptr<ov::Node>& node,
|
||||
const std::vector<size_t>& indexes,
|
||||
bool use_const_initializer,
|
||||
ov::pass::NodeRegistry& to) {
|
||||
std::vector<shared_ptr<ov::opset9::Assign>> new_assigns;
|
||||
std::vector<std::shared_ptr<ov::opset9::Assign>> new_assigns;
|
||||
size_t var_idx = 0;
|
||||
for (const auto& idx : indexes) {
|
||||
auto in = node->input(idx);
|
||||
auto out = node->output(idx);
|
||||
new_assigns.push_back(replace_with_memory(in,
|
||||
out,
|
||||
node->get_friendly_name() + "/variable_" + to_string(var_idx++),
|
||||
node->get_friendly_name() + "/variable_" + std::to_string(var_idx++),
|
||||
use_const_initializer,
|
||||
to));
|
||||
}
|
||||
return new_assigns;
|
||||
}
|
||||
|
||||
bool need_unroll(const shared_ptr<ov::Node>& op) {
|
||||
bool need_unroll(const std::shared_ptr<ov::Node>& op) {
|
||||
const auto p_shape = op->get_input_partial_shape(0);
|
||||
if (p_shape.rank().is_dynamic() || p_shape[1].is_dynamic() || p_shape[1].get_length() != 1) {
|
||||
return false;
|
||||
@ -139,13 +134,13 @@ bool need_unroll(const shared_ptr<ov::Node>& op) {
|
||||
return true;
|
||||
}
|
||||
|
||||
ov::OutputVector prepare_inputs(const shared_ptr<ov::Node>& op, size_t seq_len_idx, ov::pass::NodeRegistry& to) {
|
||||
ov::OutputVector prepare_inputs(const std::shared_ptr<ov::Node>& op, size_t seq_len_idx, ov::pass::NodeRegistry& to) {
|
||||
using namespace ov::opset9;
|
||||
ov::OutputVector inputs;
|
||||
auto axis_0 = to.make<Constant>(ov::element::i32, ov::Shape{1}, 0);
|
||||
auto axis_1 = to.make<Constant>(ov::element::i32, ov::Shape{1}, 1);
|
||||
size_t num_lstm_inputs_without_peepholes = 7;
|
||||
for (size_t i = 0; i < min(op->get_input_size(), num_lstm_inputs_without_peepholes); ++i) {
|
||||
for (size_t i = 0; i < std::min(op->get_input_size(), num_lstm_inputs_without_peepholes); ++i) {
|
||||
if (i < seq_len_idx) {
|
||||
inputs.push_back(to.make<Squeeze>(op->get_input_source_output(i), axis_1));
|
||||
} else if (i > seq_len_idx) {
|
||||
@ -155,14 +150,14 @@ ov::OutputVector prepare_inputs(const shared_ptr<ov::Node>& op, size_t seq_len_i
|
||||
return inputs;
|
||||
}
|
||||
|
||||
std::vector<shared_ptr<ov::opset9::Assign>> process_sequence(const shared_ptr<ov::Node>& op,
|
||||
std::vector<std::shared_ptr<ov::opset9::Assign>> process_sequence(const std::shared_ptr<ov::Node>& op,
|
||||
bool m_use_const_initializer,
|
||||
ov::pass::NodeRegistry& to) {
|
||||
using namespace ov::opset9;
|
||||
shared_ptr<ov::Node> cell;
|
||||
std::vector<shared_ptr<ov::opset9::Assign>> new_assigns;
|
||||
std::shared_ptr<ov::Node> cell;
|
||||
std::vector<std::shared_ptr<ov::opset9::Assign>> new_assigns;
|
||||
bool unroll = false;
|
||||
if (auto lstm_seq_v0 = dynamic_pointer_cast<ov::opset1::LSTMSequence>(op)) {
|
||||
if (auto lstm_seq_v0 = std::dynamic_pointer_cast<ov::opset1::LSTMSequence>(op)) {
|
||||
unroll = need_unroll(op);
|
||||
new_assigns = replace_with_memory(op, {1, 2}, m_use_const_initializer, to);
|
||||
if (unroll) {
|
||||
@ -179,7 +174,7 @@ std::vector<shared_ptr<ov::opset9::Assign>> process_sequence(const shared_ptr<ov
|
||||
lstm_seq_v0->get_activations_beta(),
|
||||
lstm_seq_v0->get_clip_threshold());
|
||||
}
|
||||
} else if (auto lstm_seq_v5 = dynamic_pointer_cast<LSTMSequence>(op)) {
|
||||
} else if (auto lstm_seq_v5 = std::dynamic_pointer_cast<LSTMSequence>(op)) {
|
||||
unroll = need_unroll(op);
|
||||
new_assigns = replace_with_memory(op, {1, 2}, m_use_const_initializer, to);
|
||||
if (unroll) {
|
||||
@ -196,7 +191,7 @@ std::vector<shared_ptr<ov::opset9::Assign>> process_sequence(const shared_ptr<ov
|
||||
lstm_seq_v5->get_activations_beta(),
|
||||
lstm_seq_v5->get_clip());
|
||||
}
|
||||
} else if (auto gru_seq = dynamic_pointer_cast<GRUSequence>(op)) {
|
||||
} else if (auto gru_seq = std::dynamic_pointer_cast<GRUSequence>(op)) {
|
||||
unroll = need_unroll(op);
|
||||
new_assigns = replace_with_memory(op, {1}, m_use_const_initializer, to);
|
||||
if (unroll) {
|
||||
@ -213,7 +208,7 @@ std::vector<shared_ptr<ov::opset9::Assign>> process_sequence(const shared_ptr<ov
|
||||
gru_seq->get_clip(),
|
||||
gru_seq->get_linear_before_reset());
|
||||
}
|
||||
} else if (auto rnn_seq = dynamic_pointer_cast<RNNSequence>(op)) {
|
||||
} else if (auto rnn_seq = std::dynamic_pointer_cast<RNNSequence>(op)) {
|
||||
unroll = need_unroll(op);
|
||||
new_assigns = replace_with_memory(op, {1}, m_use_const_initializer, to);
|
||||
if (unroll) {
|
||||
@ -235,7 +230,7 @@ std::vector<shared_ptr<ov::opset9::Assign>> process_sequence(const shared_ptr<ov
|
||||
}
|
||||
|
||||
if (unroll && cell) {
|
||||
auto axis_1_2 = to.make<Constant>(ov::element::i32, ov::Shape{2}, vector<int>{1, 2});
|
||||
auto axis_1_2 = to.make<Constant>(ov::element::i32, ov::Shape{2}, std::vector<int>{1, 2});
|
||||
auto axis_1 = to.make<Constant>(ov::element::i32, ov::Shape{1}, 1);
|
||||
ov::OutputVector outputs;
|
||||
|
||||
@ -246,7 +241,7 @@ std::vector<shared_ptr<ov::opset9::Assign>> process_sequence(const shared_ptr<ov
|
||||
size_t idx = 1;
|
||||
for (const auto& out : cell->outputs()) {
|
||||
auto unsqueeze_state = to.make<Unsqueeze>(out, axis_1);
|
||||
unsqueeze_state->set_friendly_name(op->get_friendly_name() + ":" + to_string(idx++));
|
||||
unsqueeze_state->set_friendly_name(op->get_friendly_name() + ":" + std::to_string(idx++));
|
||||
outputs.push_back(unsqueeze_state);
|
||||
}
|
||||
replace_node(op, outputs);
|
||||
@ -256,7 +251,7 @@ std::vector<shared_ptr<ov::opset9::Assign>> process_sequence(const shared_ptr<ov
|
||||
}
|
||||
} // namespace
|
||||
|
||||
bool ov::pass::LowLatency2::run_on_model(const shared_ptr<Model>& f) {
|
||||
bool ov::pass::LowLatency2::run_on_model(const std::shared_ptr<Model>& f) {
|
||||
RUN_ON_MODEL_SCOPE(LowLatency2);
|
||||
using namespace ov::opset9;
|
||||
using namespace ov::op::util;
|
||||
@ -264,20 +259,20 @@ bool ov::pass::LowLatency2::run_on_model(const shared_ptr<Model>& f) {
|
||||
|
||||
ov::SinkVector assigns;
|
||||
for (const auto& op : f->get_ordered_ops()) {
|
||||
if (const auto& sub_graph_op = dynamic_pointer_cast<SubGraphOp>(op)) {
|
||||
if (const auto& sub_graph_op = std::dynamic_pointer_cast<SubGraphOp>(op)) {
|
||||
int64_t variable_id = 0;
|
||||
const auto& func = sub_graph_op->get_function();
|
||||
const auto& params = func->get_parameters();
|
||||
for (const auto& in : sub_graph_op->get_input_descriptions()) {
|
||||
// Process all back edges
|
||||
if (const auto& merged_in = dynamic_pointer_cast<SubGraphOp::MergedInputDescription>(in)) {
|
||||
if (const auto& merged_in = std::dynamic_pointer_cast<SubGraphOp::MergedInputDescription>(in)) {
|
||||
// create new Variable
|
||||
const string& param_name = params.at(merged_in->m_body_parameter_index)->get_friendly_name();
|
||||
const string& var_name =
|
||||
const std::string& param_name = params.at(merged_in->m_body_parameter_index)->get_friendly_name();
|
||||
const std::string& var_name =
|
||||
generate_variable_name(sub_graph_op->get_friendly_name(), param_name, variable_id);
|
||||
|
||||
const auto& input = sub_graph_op->input(merged_in->m_input_index);
|
||||
if (dynamic_pointer_cast<ReadValueBase>(input.get_source_output().get_node_shared_ptr()) !=
|
||||
if (std::dynamic_pointer_cast<ReadValueBase>(input.get_source_output().get_node_shared_ptr()) !=
|
||||
nullptr) {
|
||||
OPENVINO_DEBUG << msg_low_latency_2_already_applied;
|
||||
return false;
|
||||
@ -301,9 +296,10 @@ bool ov::pass::LowLatency2::run_on_model(const shared_ptr<Model>& f) {
|
||||
* ---> Layers -> ...
|
||||
*/
|
||||
const auto& out_desc = sub_graph_op->get_output_descriptions();
|
||||
bool is_output_exist = any_of(out_desc.begin(),
|
||||
bool is_output_exist =
|
||||
any_of(out_desc.begin(),
|
||||
out_desc.end(),
|
||||
[&merged_in](const shared_ptr<SubGraphOp::OutputDescription>& out) {
|
||||
[&merged_in](const std::shared_ptr<SubGraphOp::OutputDescription>& out) {
|
||||
return out->m_body_value_index == merged_in->m_body_value_index;
|
||||
});
|
||||
// Create new output if it doesn't exist.
|
||||
|
@ -5,50 +5,46 @@
|
||||
#include "openvino/pass/make_stateful.hpp"
|
||||
|
||||
#include <memory>
|
||||
#include <ngraph/rt_info.hpp>
|
||||
#include <openvino/cc/pass/itt.hpp>
|
||||
#include <openvino/op/util/variable.hpp>
|
||||
#include <openvino/opsets/opset8.hpp>
|
||||
|
||||
using namespace std;
|
||||
using namespace ngraph;
|
||||
using namespace opset8;
|
||||
using namespace op::util;
|
||||
#include "openvino/cc/pass/itt.hpp"
|
||||
#include "openvino/core/rt_info.hpp"
|
||||
#include "openvino/op/util/variable.hpp"
|
||||
#include "openvino/opsets/opset8.hpp"
|
||||
|
||||
namespace {
|
||||
|
||||
std::tuple<ov::pass::MakeStateful::ParamResPairs, std::vector<std::string>> find_param_results_by_names(
|
||||
const shared_ptr<ngraph::Function>& func,
|
||||
const std::shared_ptr<ov::Model>& model,
|
||||
const std::map<std::string, std::string>& param_res_names) {
|
||||
ov::pass::MakeStateful::ParamResPairs pairs_to_replace;
|
||||
std::vector<std::string> variable_names;
|
||||
const auto& params = func->get_parameters();
|
||||
const auto& results = func->get_results();
|
||||
const auto& params = model->get_parameters();
|
||||
const auto& results = model->get_results();
|
||||
|
||||
std::set<Node*> uniq_params;
|
||||
std::set<Node*> uniq_res;
|
||||
std::set<ov::Node*> uniq_params;
|
||||
std::set<ov::Node*> uniq_res;
|
||||
|
||||
// find corresponding param and result by name and add to the list
|
||||
for (const auto& param_res : param_res_names) {
|
||||
const auto& param_name = param_res.first;
|
||||
const auto& res_name = param_res.second;
|
||||
auto param = std::find_if(params.begin(), params.end(), [&](const std::shared_ptr<ngraph::Node>& node) {
|
||||
auto param = std::find_if(params.begin(), params.end(), [&](const std::shared_ptr<ov::Node>& node) {
|
||||
const auto& possible_names = node->output(0).get_names();
|
||||
return possible_names.find(param_name) != possible_names.end();
|
||||
});
|
||||
NGRAPH_CHECK(param != params.end(),
|
||||
OPENVINO_ASSERT(param != params.end(),
|
||||
"The tensor name ",
|
||||
param_name,
|
||||
" is not associated with any of "
|
||||
"Parameters in the network.");
|
||||
uniq_params.insert(param->get());
|
||||
|
||||
auto res = std::find_if(results.begin(), results.end(), [&](const std::shared_ptr<ngraph::Node>& node) {
|
||||
auto res = std::find_if(results.begin(), results.end(), [&](const std::shared_ptr<ov::Node>& node) {
|
||||
const auto& possible_names = node->output(0).get_names();
|
||||
return possible_names.find(res_name) != possible_names.end();
|
||||
});
|
||||
|
||||
NGRAPH_CHECK(res != results.end(),
|
||||
OPENVINO_ASSERT(res != results.end(),
|
||||
"The tensor name ",
|
||||
res_name,
|
||||
" is not associated with any of "
|
||||
@ -57,9 +53,9 @@ std::tuple<ov::pass::MakeStateful::ParamResPairs, std::vector<std::string>> find
|
||||
// In case of several Results connected to one output tensor,
|
||||
// We can't determine what result we need to take exactly.
|
||||
// But we can take first unused, the order is not important, data is the same.
|
||||
opset8::Result* unused_res = nullptr;
|
||||
ov::op::v0::Result* unused_res = nullptr;
|
||||
for (const auto& target_in : (*res)->input_value(0).get_target_inputs()) {
|
||||
auto is_target_res = ov::as_type<opset8::Result>(target_in.get_node());
|
||||
auto is_target_res = ov::as_type<ov::op::v0::Result>(target_in.get_node());
|
||||
if (!is_target_res) {
|
||||
continue;
|
||||
}
|
||||
@ -68,13 +64,13 @@ std::tuple<ov::pass::MakeStateful::ParamResPairs, std::vector<std::string>> find
|
||||
break;
|
||||
}
|
||||
}
|
||||
NGRAPH_CHECK(unused_res != nullptr,
|
||||
OPENVINO_ASSERT(unused_res != nullptr,
|
||||
"All Result operations associated with the tensor ",
|
||||
res_name,
|
||||
" are already involved in the transformation.");
|
||||
uniq_res.insert(unused_res);
|
||||
|
||||
if (auto casted = std::dynamic_pointer_cast<opset8::Result>(unused_res->shared_from_this()))
|
||||
if (auto casted = std::dynamic_pointer_cast<ov::op::v0::Result>(unused_res->shared_from_this()))
|
||||
pairs_to_replace.emplace_back(*param, casted);
|
||||
variable_names.push_back(param_name + res_name);
|
||||
}
|
||||
@ -96,32 +92,32 @@ bool ov::pass::MakeStateful::run_on_model(const std::shared_ptr<ov::Model>& f) {
|
||||
}
|
||||
}
|
||||
|
||||
VariableVector variables;
|
||||
ov::op::util::VariableVector variables;
|
||||
SinkVector sinks;
|
||||
|
||||
for (size_t i = 0; i < m_param_res_pairs.size(); ++i) {
|
||||
const auto& param = m_param_res_pairs[i].first;
|
||||
const auto& res = m_param_res_pairs[i].second;
|
||||
|
||||
NGRAPH_CHECK(param->get_partial_shape().is_static(),
|
||||
OPENVINO_ASSERT(param->get_partial_shape().is_static(),
|
||||
"Shape of Parameter ",
|
||||
param->get_friendly_name(),
|
||||
" must be static. MakeStateful transformation doesn't support dynamic shapes.");
|
||||
|
||||
// Create Variable
|
||||
std::string var_name = variable_names[i];
|
||||
auto variable =
|
||||
std::make_shared<Variable>(VariableInfo{param->get_shape(), param->get_element_type(), var_name});
|
||||
auto variable = std::make_shared<ov::op::util::Variable>(
|
||||
ov::op::util::VariableInfo{param->get_shape(), param->get_element_type(), var_name});
|
||||
variables.push_back(variable);
|
||||
|
||||
// Create ReadValue
|
||||
auto const_zero = make_shared<Constant>(param->get_element_type(), param->get_shape(), 0);
|
||||
auto read_val = make_shared<ReadValue>(const_zero, variable);
|
||||
auto const_zero = std::make_shared<ov::op::v0::Constant>(param->get_element_type(), param->get_shape(), 0);
|
||||
auto read_val = std::make_shared<ov::op::v6::ReadValue>(const_zero, variable);
|
||||
replace_node(param, read_val);
|
||||
copy_runtime_info(param, {read_val, const_zero});
|
||||
ov::copy_runtime_info(param, {read_val, const_zero});
|
||||
|
||||
// Create Assign
|
||||
auto assign = make_shared<Assign>(res->input_value(0), variable);
|
||||
auto assign = std::make_shared<ov::op::v6::Assign>(res->input_value(0), variable);
|
||||
copy_runtime_info(res, assign);
|
||||
|
||||
// Update Function
|
||||
|
@ -2,7 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "ngraph/pass/manager.hpp"
|
||||
#include "openvino/pass/manager.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <iomanip>
|
||||
@ -12,14 +12,10 @@
|
||||
#include <unordered_map>
|
||||
|
||||
#include "itt.hpp"
|
||||
#include "ngraph/function.hpp"
|
||||
#include "ngraph/graph_util.hpp"
|
||||
#include "ngraph/log.hpp"
|
||||
#include "ngraph/node.hpp"
|
||||
#include "ngraph/pass/graph_rewrite.hpp"
|
||||
#include "ngraph/pass/pass.hpp"
|
||||
#include "ngraph/pass/visualize_tree.hpp"
|
||||
#include "ngraph/util.hpp"
|
||||
#include "openvino/pass/graph_rewrite.hpp"
|
||||
#include "openvino/pass/visualize_tree.hpp"
|
||||
#include "openvino/util/env_util.hpp"
|
||||
#include "openvino/util/log.hpp"
|
||||
#include "perf_counters.hpp"
|
||||
@ -61,7 +57,7 @@ void ov::pass::Manager::set_per_pass_validation(bool new_state) {
|
||||
}
|
||||
|
||||
bool ov::pass::Manager::run_passes(shared_ptr<ov::Model> func) {
|
||||
NGRAPH_SUPPRESS_DEPRECATED_START
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
OV_ITT_SCOPED_TASK(ov::itt::domains::core, "pass::Manager::run_passes");
|
||||
|
||||
static bool profile_enabled =
|
||||
@ -93,7 +89,7 @@ bool ov::pass::Manager::run_passes(shared_ptr<ov::Model> func) {
|
||||
continue;
|
||||
}
|
||||
// GraphRewrite is a temporary container for MatcherPass to make execution
|
||||
// on on entire ngraph::Function
|
||||
// on on entire ov::Model
|
||||
pass_applied = GraphRewrite(matcher_pass).run_on_model(func);
|
||||
} else if (auto function_pass = dynamic_pointer_cast<ModelPass>(pass)) {
|
||||
// This checks is to skip the graph transformation when the graph pass relies on
|
||||
@ -147,7 +143,7 @@ bool ov::pass::Manager::run_passes(shared_ptr<ov::Model> func) {
|
||||
if (profile_enabled) {
|
||||
cout << "passes done in " << overall_timer.get_milliseconds() << "ms\n";
|
||||
}
|
||||
NGRAPH_SUPPRESS_DEPRECATED_END
|
||||
OPENVINO_SUPPRESS_DEPRECATED_END
|
||||
|
||||
return function_changed;
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
namespace ov {
|
||||
namespace pass {
|
||||
openvino::itt::handle_t PerfCounters::operator[](::ngraph::Node::type_info_t const& type_inf) {
|
||||
openvino::itt::handle_t PerfCounters::operator[](ov::Node::type_info_t const& type_inf) {
|
||||
std::lock_guard<std::mutex> guard(m_mutex);
|
||||
auto it = m_counters.find(&type_inf);
|
||||
if (it != m_counters.end())
|
||||
|
@ -2,11 +2,13 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
#pragma once
|
||||
|
||||
#include <itt.hpp>
|
||||
#include <mutex>
|
||||
#include <ngraph/node.hpp>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "openvino/core/node.hpp"
|
||||
|
||||
namespace ov {
|
||||
namespace pass {
|
||||
class PerfCounters {
|
||||
@ -16,10 +18,10 @@ class PerfCounters {
|
||||
public:
|
||||
PerfCounters() = default;
|
||||
|
||||
openvino::itt::handle_t operator[](::ngraph::Node::type_info_t const& type_inf);
|
||||
openvino::itt::handle_t operator[](ov::Node::type_info_t const& type_inf);
|
||||
|
||||
private:
|
||||
using key = ::ngraph::Node::type_info_t const*;
|
||||
using key = ov::Node::type_info_t const*;
|
||||
using value = openvino::itt::handle_t;
|
||||
using counters_map = std::unordered_map<key, value>;
|
||||
|
||||
|
@ -12,8 +12,6 @@
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
|
||||
#include "ngraph/ops.hpp"
|
||||
#include "ngraph/opsets/opset.hpp"
|
||||
#include "openvino/core/coordinate_diff.hpp"
|
||||
#include "openvino/core/except.hpp"
|
||||
#include "openvino/core/meta_data.hpp"
|
||||
@ -439,7 +437,8 @@ public:
|
||||
ov::as_type<ov::AttributeAdapter<ov::op::v5::Loop::SpecialBodyPorts>>(&adapter)) {
|
||||
special_body_ports_on_adapter(a->get(), parameter_mapping, result_mapping, port_map);
|
||||
}
|
||||
} else if (const auto& a = ov::as_type<ov::AttributeAdapter<std::shared_ptr<ngraph::Variable>>>(&adapter)) {
|
||||
} else if (const auto& a =
|
||||
ov::as_type<ov::AttributeAdapter<std::shared_ptr<ov::op::util::Variable>>>(&adapter)) {
|
||||
m_xml_node.append_attribute(name.c_str()).set_value(a->get()->get_info().variable_id.c_str());
|
||||
} else if (const auto& a =
|
||||
ov::as_type<ov::AttributeAdapter<std::shared_ptr<ngraph::runtime::AlignedBuffer>>>(&adapter)) {
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
#include "openvino/pass/validate.hpp"
|
||||
|
||||
#include <openvino/cc/pass/itt.hpp>
|
||||
#include "openvino/cc/pass/itt.hpp"
|
||||
|
||||
bool ov::pass::Validate::run_on_model(const std::shared_ptr<ov::Model>& m) {
|
||||
RUN_ON_MODEL_SCOPE(Validate);
|
||||
|
@ -2,25 +2,19 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "ngraph/pass/visualize_tree.hpp"
|
||||
#include "openvino/pass/visualize_tree.hpp"
|
||||
|
||||
#include <cmath>
|
||||
#include <fstream>
|
||||
#include <openvino/cc/pass/itt.hpp>
|
||||
|
||||
#include "ngraph/env_util.hpp"
|
||||
#include "ngraph/file_util.hpp"
|
||||
#include "ngraph/function.hpp"
|
||||
#include "ngraph/graph_util.hpp"
|
||||
#include "ngraph/node.hpp"
|
||||
#include "ngraph/op/constant.hpp"
|
||||
#include "ngraph/op/parameter.hpp"
|
||||
#include "ngraph/op/util/op_types.hpp"
|
||||
#include "ngraph/pass/pass.hpp"
|
||||
#include "ngraph/util.hpp"
|
||||
|
||||
using namespace ngraph;
|
||||
using namespace std;
|
||||
#include "openvino/cc/pass/itt.hpp"
|
||||
#include "openvino/core/type.hpp"
|
||||
#include "openvino/op/constant.hpp"
|
||||
#include "openvino/op/parameter.hpp"
|
||||
#include "openvino/op/util/op_types.hpp"
|
||||
#include "openvino/util/common_util.hpp"
|
||||
#include "openvino/util/env_util.hpp"
|
||||
#include "openvino/util/file_util.hpp"
|
||||
|
||||
/*
|
||||
* As we are visualizing the graph, we will make some tweaks to the generated dot file to make
|
||||
@ -105,7 +99,7 @@ using namespace std;
|
||||
class HeightMap {
|
||||
public:
|
||||
HeightMap() {}
|
||||
HeightMap(std::set<Node*> initials) {
|
||||
HeightMap(std::set<ov::Node*> initials) {
|
||||
for (auto& n : initials) {
|
||||
m_heights[n] = 0;
|
||||
}
|
||||
@ -130,29 +124,27 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
std::unordered_map<Node*, int64_t> m_heights;
|
||||
std::unordered_map<ov::Node*, int64_t> m_heights;
|
||||
};
|
||||
|
||||
static std::string label_edge(const std::shared_ptr<Node>& /* src */,
|
||||
const std::shared_ptr<Node>& dst,
|
||||
static std::string label_edge(const std::shared_ptr<ov::Node>& /* src */,
|
||||
const std::shared_ptr<ov::Node>& dst,
|
||||
size_t arg_index,
|
||||
int64_t jump_distance) {
|
||||
std::stringstream ss;
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
if (getenv_bool("OV_VISUALIZE_TREE_EDGE_LABELS")) {
|
||||
if (ov::util::getenv_bool("OV_VISUALIZE_TREE_EDGE_LABELS")) {
|
||||
ss << "[label=\" " << dst->input_value(arg_index).get_index() << " -> " << arg_index << " \"]";
|
||||
} else if (getenv_bool("OV_VISUALIZE_TREE_EDGE_JUMP_DISTANCE")) {
|
||||
} else if (ov::util::getenv_bool("OV_VISUALIZE_TREE_EDGE_JUMP_DISTANCE")) {
|
||||
if (jump_distance > 1) {
|
||||
ss << "[label=\"jump=" << jump_distance << "\"]";
|
||||
}
|
||||
}
|
||||
OPENVINO_SUPPRESS_DEPRECATED_END
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
static std::string get_attribute_values(const std::map<std::string, ov::Any>& attributes,
|
||||
const std::string& delimiter = ", ") {
|
||||
stringstream ss;
|
||||
std::stringstream ss;
|
||||
bool first = true;
|
||||
for (const auto& item : attributes) {
|
||||
ss << (first ? " " : delimiter) << item.first;
|
||||
@ -173,9 +165,9 @@ static std::string get_attribute_values(const std::map<std::string, ov::Any>& at
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
bool pass::VisualizeTree::run_on_model(const std::shared_ptr<ov::Model>& f) {
|
||||
bool ov::pass::VisualizeTree::run_on_model(const std::shared_ptr<ov::Model>& f) {
|
||||
RUN_ON_MODEL_SCOPE(VisualizeTree);
|
||||
unordered_map<Node*, HeightMap> height_maps;
|
||||
std::unordered_map<Node*, HeightMap> height_maps;
|
||||
|
||||
for (auto& node : f->get_ops()) {
|
||||
if (node->description() == "Result") {
|
||||
@ -201,7 +193,7 @@ bool pass::VisualizeTree::run_on_model(const std::shared_ptr<ov::Model>& f) {
|
||||
|
||||
size_t fake_node_ctr = 0;
|
||||
|
||||
traverse_nodes(f, [&](shared_ptr<Node> node) {
|
||||
traverse_nodes(f, [&](std::shared_ptr<Node> node) {
|
||||
add_node_arguments(node, height_maps, fake_node_ctr);
|
||||
});
|
||||
|
||||
@ -213,30 +205,29 @@ bool pass::VisualizeTree::run_on_model(const std::shared_ptr<ov::Model>& f) {
|
||||
return false;
|
||||
}
|
||||
|
||||
pass::VisualizeTree::VisualizeTree(const string& file_name, node_modifiers_t nm, bool dot_only)
|
||||
ov::pass::VisualizeTree::VisualizeTree(const std::string& file_name, node_modifiers_t nm, bool dot_only)
|
||||
: m_name{file_name},
|
||||
m_node_modifiers{nm},
|
||||
m_dot_only(dot_only) {}
|
||||
|
||||
void pass::VisualizeTree::add_node_arguments(shared_ptr<Node> node,
|
||||
unordered_map<Node*, HeightMap>& height_maps,
|
||||
void ov::pass::VisualizeTree::add_node_arguments(std::shared_ptr<Node> node,
|
||||
std::unordered_map<Node*, HeightMap>& height_maps,
|
||||
size_t& fake_node_ctr) {
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
static const int const_max_elements = getenv_int("OV_VISUALIZE_TREE_CONST_MAX_ELEMENTS", 7);
|
||||
OPENVINO_SUPPRESS_DEPRECATED_END
|
||||
static const int const_max_elements = ov::util::getenv_int("OV_VISUALIZE_TREE_CONST_MAX_ELEMENTS", 7);
|
||||
|
||||
size_t arg_index = 0;
|
||||
for (auto input_value : node->input_values()) {
|
||||
auto arg = input_value.get_node_shared_ptr();
|
||||
size_t jump_distance = height_maps[arg.get()].max_jump_to(height_maps[node.get()]);
|
||||
if (ov::is_type<ngraph::op::Constant>(arg) || ov::is_type<ngraph::op::Parameter>(arg)) {
|
||||
auto clone_name = "CLONE_" + to_string(fake_node_ctr);
|
||||
auto color = string("color=\"") + (arg->description() == "Parameter" ? "blue" : "black") + string("\"");
|
||||
if (ov::is_type<ov::op::v0::Constant>(arg) || ov::is_type<ov::op::v0::Parameter>(arg)) {
|
||||
auto clone_name = "CLONE_" + std::to_string(fake_node_ctr);
|
||||
auto color =
|
||||
std::string("color=\"") + (arg->description() == "Parameter" ? "blue" : "black") + std::string("\"");
|
||||
std::vector<std::string> attributes{"shape=\"box\"",
|
||||
"style=\"dashed\"",
|
||||
color,
|
||||
string("label=\"") + get_node_name(arg) + string("\n") +
|
||||
get_constant_value(arg, const_max_elements) + string("\"")};
|
||||
std::string("label=\"") + get_node_name(arg) + std::string("\n") +
|
||||
get_constant_value(arg, const_max_elements) + std::string("\"")};
|
||||
|
||||
if (m_node_modifiers && !arg->output(0).get_rt_info().empty()) {
|
||||
m_node_modifiers(*arg, attributes);
|
||||
@ -253,8 +244,8 @@ void pass::VisualizeTree::add_node_arguments(shared_ptr<Node> node,
|
||||
} else if (jump_distance > max_jump_distance) {
|
||||
m_ss << add_attributes(arg);
|
||||
m_ss << add_attributes(node);
|
||||
auto recv_node_name = "RECV_" + to_string(fake_node_ctr);
|
||||
auto send_node_name = "SEND_" + to_string(fake_node_ctr);
|
||||
auto recv_node_name = "RECV_" + std::to_string(fake_node_ctr);
|
||||
auto send_node_name = "SEND_" + std::to_string(fake_node_ctr);
|
||||
m_ss << " " << recv_node_name
|
||||
<< "[shape=\"box\" style=\"solid,filled\" "
|
||||
"fillcolor=\"#ffcccc\" label=\"Receive["
|
||||
@ -278,8 +269,8 @@ void pass::VisualizeTree::add_node_arguments(shared_ptr<Node> node,
|
||||
}
|
||||
}
|
||||
|
||||
string pass::VisualizeTree::add_attributes(shared_ptr<Node> node) {
|
||||
string rc;
|
||||
std::string ov::pass::VisualizeTree::add_attributes(std::shared_ptr<Node> node) {
|
||||
std::string rc;
|
||||
if (m_nodes_with_attributes.find(node) == m_nodes_with_attributes.end()) {
|
||||
m_nodes_with_attributes.insert(node);
|
||||
rc = get_attributes(node);
|
||||
@ -287,7 +278,7 @@ string pass::VisualizeTree::add_attributes(shared_ptr<Node> node) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
static std::string pretty_partial_shape(const PartialShape& shape) {
|
||||
static std::string pretty_partial_shape(const ov::PartialShape& shape) {
|
||||
std::stringstream ss;
|
||||
|
||||
if (shape.rank().is_dynamic()) {
|
||||
@ -300,7 +291,7 @@ static std::string pretty_partial_shape(const PartialShape& shape) {
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static std::string pretty_min_max_denormal_value(const vector<T>& values) {
|
||||
static std::string pretty_min_max_denormal_value(const std::vector<T>& values) {
|
||||
std::stringstream ss;
|
||||
|
||||
T min_value = values[0];
|
||||
@ -336,7 +327,7 @@ static std::string pretty_min_max_denormal_value(const vector<T>& values) {
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static std::string pretty_value(const vector<T>& values, size_t max_elements, bool allow_obfuscate = false) {
|
||||
static std::string pretty_value(const std::vector<T>& values, size_t max_elements, bool allow_obfuscate = false) {
|
||||
std::stringstream ss;
|
||||
for (size_t i = 0; i < values.size(); ++i) {
|
||||
if (i < max_elements) {
|
||||
@ -362,53 +353,51 @@ static std::string pretty_value(const vector<T>& values, size_t max_elements, bo
|
||||
ss << value;
|
||||
}
|
||||
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
const std::string additional_ss =
|
||||
getenv_bool("OV_VISUALIZE_TREE_MIN_MAX_DENORMAL") ? pretty_min_max_denormal_value(values) : "";
|
||||
ov::util::getenv_bool("OV_VISUALIZE_TREE_MIN_MAX_DENORMAL") ? pretty_min_max_denormal_value(values) : "";
|
||||
if (!additional_ss.empty()) {
|
||||
ss << std::endl << "(" << additional_ss << ")";
|
||||
}
|
||||
OPENVINO_SUPPRESS_DEPRECATED_END
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
static std::string get_value(const shared_ptr<ov::op::v0::Constant>& constant,
|
||||
static std::string get_value(const std::shared_ptr<ov::op::v0::Constant>& constant,
|
||||
size_t max_elements,
|
||||
bool allow_obfuscate = false) {
|
||||
std::stringstream ss;
|
||||
switch (constant->get_output_element_type(0)) {
|
||||
case element::Type_t::undefined:
|
||||
case ov::element::Type_t::undefined:
|
||||
ss << "[ undefined value ]";
|
||||
break;
|
||||
case element::Type_t::dynamic:
|
||||
case ov::element::Type_t::dynamic:
|
||||
ss << "[ dynamic value ]";
|
||||
break;
|
||||
case element::Type_t::u1:
|
||||
case ov::element::Type_t::u1:
|
||||
ss << "[ u1 value ]";
|
||||
break;
|
||||
case element::Type_t::u4:
|
||||
case ov::element::Type_t::u4:
|
||||
ss << "[ u4 value ]";
|
||||
break;
|
||||
case element::Type_t::i4:
|
||||
case ov::element::Type_t::i4:
|
||||
ss << "[ i4 value ]";
|
||||
break;
|
||||
case element::Type_t::bf16:
|
||||
case element::Type_t::f16:
|
||||
case element::Type_t::f32:
|
||||
case element::Type_t::f64:
|
||||
case ov::element::Type_t::bf16:
|
||||
case ov::element::Type_t::f16:
|
||||
case ov::element::Type_t::f32:
|
||||
case ov::element::Type_t::f64:
|
||||
ss << "[" << pretty_value(constant->cast_vector<double>(), max_elements, allow_obfuscate) << "]";
|
||||
break;
|
||||
case element::Type_t::i8:
|
||||
case element::Type_t::i16:
|
||||
case element::Type_t::i32:
|
||||
case element::Type_t::i64:
|
||||
case ov::element::Type_t::i8:
|
||||
case ov::element::Type_t::i16:
|
||||
case ov::element::Type_t::i32:
|
||||
case ov::element::Type_t::i64:
|
||||
ss << "[" << pretty_value(constant->cast_vector<int64_t>(), max_elements, allow_obfuscate) << "]";
|
||||
break;
|
||||
case element::Type_t::boolean:
|
||||
case element::Type_t::u8:
|
||||
case element::Type_t::u16:
|
||||
case element::Type_t::u32:
|
||||
case element::Type_t::u64:
|
||||
case ov::element::Type_t::boolean:
|
||||
case ov::element::Type_t::u8:
|
||||
case ov::element::Type_t::u16:
|
||||
case ov::element::Type_t::u32:
|
||||
case ov::element::Type_t::u64:
|
||||
ss << "[" << pretty_value(constant->cast_vector<uint64_t>(), max_elements, allow_obfuscate) << "]";
|
||||
break;
|
||||
}
|
||||
@ -429,9 +418,7 @@ static std::string get_bounds_and_label_info(const ov::Output<ov::Node> output)
|
||||
if (size == 0) {
|
||||
label << "empty";
|
||||
} else {
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
static const int const_max_elements = getenv_int("OV_VISUALIZE_TREE_CONST_MAX_ELEMENTS", 7);
|
||||
OPENVINO_SUPPRESS_DEPRECATED_END
|
||||
static const int const_max_elements = ov::util::getenv_int("OV_VISUALIZE_TREE_CONST_MAX_ELEMENTS", 7);
|
||||
label << " lower: "
|
||||
<< (lower ? get_value(std::make_shared<ov::op::v0::Constant>(lower), const_max_elements, true) : "NONE");
|
||||
label << " upper: "
|
||||
@ -441,7 +428,7 @@ static std::string get_bounds_and_label_info(const ov::Output<ov::Node> output)
|
||||
return label.str();
|
||||
}
|
||||
|
||||
std::string pass::VisualizeTree::get_constant_value(std::shared_ptr<Node> node, size_t max_elements) {
|
||||
std::string ov::pass::VisualizeTree::get_constant_value(std::shared_ptr<Node> node, size_t max_elements) {
|
||||
std::stringstream ss;
|
||||
ss << "{" << node->get_element_type().to_string() << "}";
|
||||
ss << pretty_partial_shape(node->get_output_partial_shape(0));
|
||||
@ -451,11 +438,11 @@ std::string pass::VisualizeTree::get_constant_value(std::shared_ptr<Node> node,
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
string pass::VisualizeTree::get_attributes(shared_ptr<Node> node) {
|
||||
vector<string> attributes;
|
||||
std::string ov::pass::VisualizeTree::get_attributes(std::shared_ptr<Node> node) {
|
||||
std::vector<std::string> attributes;
|
||||
attributes.push_back("shape=box");
|
||||
|
||||
if (ngraph::op::is_output(node)) {
|
||||
if (ov::op::util::is_output(node)) {
|
||||
attributes.push_back("color=crimson");
|
||||
attributes.push_back("penwidth=1.5");
|
||||
} else {
|
||||
@ -464,23 +451,21 @@ string pass::VisualizeTree::get_attributes(shared_ptr<Node> node) {
|
||||
|
||||
// Construct the label attribute
|
||||
{
|
||||
stringstream label;
|
||||
std::stringstream label;
|
||||
label << "label=\"" << get_node_name(node);
|
||||
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
static const bool nvtos =
|
||||
getenv_bool("NGRAPH_VISUALIZE_TREE_OUTPUT_SHAPES") || getenv_bool("OV_VISUALIZE_TREE_OUTPUT_SHAPES");
|
||||
static const bool nvtot =
|
||||
getenv_bool("NGRAPH_VISUALIZE_TREE_OUTPUT_TYPES") || getenv_bool("OV_VISUALIZE_TREE_OUTPUT_TYPES");
|
||||
static const bool nvtio = getenv_bool("OV_VISUALIZE_TREE_IO");
|
||||
static const bool nvtrti = getenv_bool("OV_VISUALIZE_TREE_RUNTIME_INFO");
|
||||
static const bool ovpvl = getenv_bool("OV_VISUALIZE_PARTIAL_VALUES_AND_LABELS");
|
||||
OPENVINO_SUPPRESS_DEPRECATED_END
|
||||
static const bool nvtos = ov::util::getenv_bool("NGRAPH_VISUALIZE_TREE_OUTPUT_SHAPES") ||
|
||||
ov::util::getenv_bool("OV_VISUALIZE_TREE_OUTPUT_SHAPES");
|
||||
static const bool nvtot = ov::util::getenv_bool("NGRAPH_VISUALIZE_TREE_OUTPUT_TYPES") ||
|
||||
ov::util::getenv_bool("OV_VISUALIZE_TREE_OUTPUT_TYPES");
|
||||
static const bool nvtio = ov::util::getenv_bool("OV_VISUALIZE_TREE_IO");
|
||||
static const bool nvtrti = ov::util::getenv_bool("OV_VISUALIZE_TREE_RUNTIME_INFO");
|
||||
static const bool ovpvl = ov::util::getenv_bool("OV_VISUALIZE_PARTIAL_VALUES_AND_LABELS");
|
||||
|
||||
if (nvtos || nvtot || nvtio) {
|
||||
if (nvtio) {
|
||||
for (const auto& input : node->inputs()) {
|
||||
label << "\\nin" << to_string(input.get_index()) << ": ";
|
||||
label << "\\nin" << std::to_string(input.get_index()) << ": ";
|
||||
if (nvtot)
|
||||
label << "{" << input.get_element_type().to_string() << "}";
|
||||
if (nvtos)
|
||||
@ -495,7 +480,7 @@ string pass::VisualizeTree::get_attributes(shared_ptr<Node> node) {
|
||||
}
|
||||
for (const auto& output : node->outputs()) {
|
||||
if (nvtio)
|
||||
label << "\\nout" << to_string(output.get_index()) << ": ";
|
||||
label << "\\nout" << std::to_string(output.get_index()) << ": ";
|
||||
if (nvtot)
|
||||
label << "{" << output.get_element_type().to_string() << "}";
|
||||
if (nvtos)
|
||||
@ -521,26 +506,23 @@ string pass::VisualizeTree::get_attributes(shared_ptr<Node> node) {
|
||||
m_node_modifiers(*node, attributes);
|
||||
}
|
||||
|
||||
stringstream ss;
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
ss << " " << node->get_name() << " [" << join(attributes, " ") << "]\n";
|
||||
OPENVINO_SUPPRESS_DEPRECATED_END
|
||||
std::stringstream ss;
|
||||
ss << " " << node->get_name() << " [" << ov::util::join(attributes, " ") << "]\n";
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
string pass::VisualizeTree::get_node_name(shared_ptr<Node> node) {
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
static const bool nvtmn = getenv_bool("OV_VISUALIZE_TREE_MEMBERS_NAME");
|
||||
string rc = (nvtmn ? string("friendly_name: ") : "") + node->get_friendly_name();
|
||||
std::string ov::pass::VisualizeTree::get_node_name(std::shared_ptr<Node> node) {
|
||||
static const bool nvtmn = ov::util::getenv_bool("OV_VISUALIZE_TREE_MEMBERS_NAME");
|
||||
std::string rc = (nvtmn ? std::string("friendly_name: ") : "") + node->get_friendly_name();
|
||||
if (node->get_friendly_name() != node->get_name()) {
|
||||
rc += "\\n" + (nvtmn ? string("name: ") : "") + node->get_name();
|
||||
rc += "\\n" + (nvtmn ? std::string("name: ") : "") + node->get_name();
|
||||
}
|
||||
const auto type_info = node->get_type_info();
|
||||
rc += "\\n" + (nvtmn ? string("type_name: ") : "") + std::string(type_info.version_id) +
|
||||
rc += "\\n" + (nvtmn ? std::string("type_name: ") : "") + std::string(type_info.version_id) +
|
||||
"::" + std::string(type_info.name);
|
||||
|
||||
static const bool nvttn = getenv_bool("OV_VISUALIZE_TREE_TENSORS_NAME");
|
||||
static const bool nvttn = ov::util::getenv_bool("OV_VISUALIZE_TREE_TENSORS_NAME");
|
||||
if (nvttn) {
|
||||
auto to_string = [](const std::unordered_set<std::string>& names) {
|
||||
std::stringstream ss;
|
||||
@ -553,7 +535,7 @@ string pass::VisualizeTree::get_node_name(shared_ptr<Node> node) {
|
||||
};
|
||||
|
||||
if (node->get_input_size() != 0) {
|
||||
rc += "\\n" + (nvtmn ? string("in_tensor_names: ") : "");
|
||||
rc += "\\n" + (nvtmn ? std::string("in_tensor_names: ") : "");
|
||||
for (size_t i = 0; i < node->get_input_size(); ++i) {
|
||||
const auto input = node->input(i);
|
||||
const auto tensor_ptr = input.get_tensor_ptr();
|
||||
@ -565,7 +547,7 @@ string pass::VisualizeTree::get_node_name(shared_ptr<Node> node) {
|
||||
}
|
||||
}
|
||||
if (node->get_output_size() != 0) {
|
||||
rc += "\\n" + (nvtmn ? string("out_tensor_names: ") : "");
|
||||
rc += "\\n" + (nvtmn ? std::string("out_tensor_names: ") : "");
|
||||
for (size_t i = 0; i < node->get_output_size(); ++i) {
|
||||
const auto output = node->output(i);
|
||||
const auto tensor_ptr = output.get_tensor_ptr();
|
||||
@ -578,35 +560,33 @@ string pass::VisualizeTree::get_node_name(shared_ptr<Node> node) {
|
||||
}
|
||||
}
|
||||
|
||||
static const bool nvtrti = getenv_bool("OV_VISUALIZE_TREE_RUNTIME_INFO");
|
||||
static const bool nvtrti = ov::util::getenv_bool("OV_VISUALIZE_TREE_RUNTIME_INFO");
|
||||
if (nvtrti) {
|
||||
const auto rt = node->get_rt_info();
|
||||
if (!rt.empty()) {
|
||||
rc += "\\nrt info: " + get_attribute_values(rt, "\\n");
|
||||
}
|
||||
}
|
||||
OPENVINO_SUPPRESS_DEPRECATED_END
|
||||
return rc;
|
||||
}
|
||||
|
||||
void pass::VisualizeTree::render() const {
|
||||
NGRAPH_SUPPRESS_DEPRECATED_START
|
||||
string ext = file_util::get_file_ext(m_name);
|
||||
string output_format = ext.substr(1);
|
||||
string dot_file = m_name;
|
||||
if (to_lower(ext) != ".dot") {
|
||||
void ov::pass::VisualizeTree::render() const {
|
||||
std::string ext = ov::util::get_file_ext(m_name);
|
||||
std::string output_format = ext.substr(1);
|
||||
std::string dot_file = m_name;
|
||||
if (ov::util::to_lower(ext) != ".dot") {
|
||||
dot_file += ".dot";
|
||||
}
|
||||
ofstream out(dot_file);
|
||||
std::ofstream out(dot_file);
|
||||
if (out) {
|
||||
out << "digraph \n{\n";
|
||||
out << m_ss.str();
|
||||
out << "}\n";
|
||||
out.close();
|
||||
|
||||
if (!m_dot_only && to_lower(ext) != ".dot") {
|
||||
if (!m_dot_only && ov::util::to_lower(ext) != ".dot") {
|
||||
#ifndef _WIN32
|
||||
stringstream ss;
|
||||
std::stringstream ss;
|
||||
ss << "dot -T" << output_format << " " << dot_file << " -o" << m_name;
|
||||
auto cmd = ss.str();
|
||||
auto stream = popen(cmd.c_str(), "r");
|
||||
@ -616,5 +596,4 @@ void pass::VisualizeTree::render() const {
|
||||
#endif
|
||||
}
|
||||
}
|
||||
NGRAPH_SUPPRESS_DEPRECATED_END
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ void Matcher::capture(const std::set<Node*>& static_nodes) {
|
||||
}
|
||||
}
|
||||
bool Matcher::is_contained_match(const NodeVector& exclusions, bool ignore_unused) {
|
||||
NGRAPH_SUPPRESS_DEPRECATED_START
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
if (exclusions.empty()) {
|
||||
NodeVector label_exclusions;
|
||||
for (const auto& entry : m_pattern_map) {
|
||||
@ -97,7 +97,7 @@ bool Matcher::is_contained_match(const NodeVector& exclusions, bool ignore_unuse
|
||||
}
|
||||
|
||||
return ngraph::get_subgraph_outputs(get_matched_nodes(), exclusions).size() < 2;
|
||||
NGRAPH_SUPPRESS_DEPRECATED_END
|
||||
OPENVINO_SUPPRESS_DEPRECATED_END
|
||||
}
|
||||
|
||||
bool Matcher::match_value(const ov::Output<Node>& pattern_value, const ov::Output<Node>& graph_value) {
|
||||
|
Loading…
Reference in New Issue
Block a user