[Core] Remove ngraph env_util.hpp graph_util.hpp util.hpp (#22540)
* Delete env_util * Remove ngraph graph_util (initial) TODO: remove ngraph/graph_util.hpp and remains from graph_util.cpp * Remove ngraph util (initial) TODO: remove ngraph/util.hpp and remains from util.cpp * Remove ngraph util (onnx fe not finished) TODO: remove ngraph/util.hpp and util.cpp. * Use OV in test helpers * Remove ngraph graph_util * [ONNX FE] Rename onnx_import::Node class to ONNX_Node temporarily (to hide conflicts with missing Node from ::ngraph::) * Remove ngraph graph_util from onnx fe * [ONNX FE] Rename onnx_import::ONNX_Node class back to Node * Delete ngraph util * Update copyright notes * Update copyright notes * Fix style * Fix gpu plugin * Remove useless macros --------- Co-authored-by: Pavel Durandin <pavel.durandin@intel.com>
This commit is contained in:
parent
75ee009acd
commit
9bdd36be9c
|
|
@ -297,7 +297,7 @@ auto pow = std::make_shared<ov::opset8::Power>(div->input(1).get_source_output()
|
|||
ov::op::v0::Constant::create(div->get_input_element_type(1), ov::Shape{1}, {-1}));
|
||||
auto mul = std::make_shared<ov::opset8::Multiply>(div->input(0).get_source_output(), pow);
|
||||
mul->set_friendly_name(div->get_friendly_name());
|
||||
ngraph::replace_node(div, mul);
|
||||
ov::replace_node(div, mul);
|
||||
// ! [ov:replace_friendly_name]
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// Copyright (C) 2018-2024 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
#include <openvino/runtime/core.hpp>
|
||||
#include <openvino/opsets/opset8.hpp>
|
||||
#include <openvino/core/preprocess/pre_post_process.hpp>
|
||||
#include "openvino/core/graph_util.hpp"
|
||||
#include "openvino/core/preprocess/pre_post_process.hpp"
|
||||
#include "openvino/opsets/opset8.hpp"
|
||||
#include "openvino/runtime/core.hpp"
|
||||
|
||||
void ppp_input_1(ov::preprocess::PrePostProcessor& ppp) {
|
||||
//! [ov:preprocess:input_1]
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// Copyright (C) 2018-2024 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "template_pattern_transformation.hpp"
|
||||
|
||||
#include "openvino/cc/pass/itt.hpp"
|
||||
#include "openvino/core/graph_util.hpp"
|
||||
#include "openvino/core/rt_info.hpp"
|
||||
#include "openvino/opsets/opset3.hpp"
|
||||
#include "openvino/pass/manager.hpp"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2023 Intel Corporation
|
||||
// Copyright (C) 2023-2024 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
|
@ -104,6 +104,61 @@ ov::NodeVector LinearIR::get_ordered_ops(const std::shared_ptr<ov::Model>& m) {
|
|||
return ov::topological_sort(nodes);
|
||||
}
|
||||
|
||||
namespace {
|
||||
using NodeMap = std::unordered_map<ov::Node*, std::shared_ptr<ov::Node>>;
|
||||
|
||||
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) {
|
||||
if (node_map.count(node.get()) == 0) {
|
||||
// get (already) cloned arguments and clone the node
|
||||
OutputVector cloned_args;
|
||||
for (auto input : node->inputs()) {
|
||||
ov::Output<Node> output = input.get_source_output();
|
||||
cloned_args.push_back(output.for_node(node_map.at(output.get_node())));
|
||||
}
|
||||
std::vector<std::shared_ptr<Node>> cloned_dependencies;
|
||||
for (auto& dependency : node->get_control_dependencies()) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
auto cloned_node = node->copy_with_new_inputs(cloned_args, cloned_dependencies);
|
||||
// There is a friendly name for this node so copy it
|
||||
cloned_node->set_friendly_name(node->get_friendly_name());
|
||||
auto rt_info = node->get_rt_info();
|
||||
cloned_node->get_rt_info() = rt_info;
|
||||
|
||||
for (auto output : node->outputs()) {
|
||||
const auto& output_rt_info = output.get_rt_info();
|
||||
auto new_output = output.for_node(cloned_node);
|
||||
new_output.get_rt_info() = output_rt_info;
|
||||
}
|
||||
|
||||
for (auto input : node->inputs()) {
|
||||
const auto& output_rt_info = input.get_rt_info();
|
||||
auto new_input = cloned_node->input(input.get_index());
|
||||
new_input.get_rt_info() = output_rt_info;
|
||||
}
|
||||
|
||||
node_map[node.get()] = cloned_node;
|
||||
}
|
||||
}
|
||||
|
||||
// create and return vector of cloned nodes
|
||||
// order matches input vector (not necessarily topological)
|
||||
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;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
LinearIR::container LinearIR::deep_copy_range(LinearIR::container::const_iterator begin,
|
||||
LinearIR::container::const_iterator end,
|
||||
ExressionMap& expression_map) {
|
||||
|
|
@ -115,10 +170,8 @@ LinearIR::container LinearIR::deep_copy_range(LinearIR::container::const_iterato
|
|||
}
|
||||
|
||||
// node_map and expr_map map original node pointer (expression) to a new pointer (expression)
|
||||
ngraph::NodeMap node_map;
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
ngraph::clone_nodes(original_nodes, node_map);
|
||||
OPENVINO_SUPPRESS_DEPRECATED_END
|
||||
NodeMap node_map;
|
||||
clone_nodes(original_nodes, node_map);
|
||||
|
||||
for (auto it = begin; it != end; it++) {
|
||||
const auto& expr = *it;
|
||||
|
|
|
|||
|
|
@ -1,55 +0,0 @@
|
|||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#if !defined(IN_OV_COMPONENT) && !defined(NGRAPH_LEGACY_HEADER_INCLUDED)
|
||||
# define NGRAPH_LEGACY_HEADER_INCLUDED
|
||||
# ifdef _MSC_VER
|
||||
# pragma message( \
|
||||
"The nGraph API is deprecated and will be removed in the 2024.0 release. For instructions on transitioning to the new API, please refer to https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html")
|
||||
# else
|
||||
# warning("The nGraph API is deprecated and will be removed in the 2024.0 release. For instructions on transitioning to the new API, please refer to https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html")
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
#include "openvino/core/core_visibility.hpp"
|
||||
#include "openvino/core/deprecated.hpp"
|
||||
|
||||
namespace ngraph {
|
||||
/// \brief Get the names environment variable as a string.
|
||||
/// \param env_var The string name of the environment variable to get.
|
||||
/// \return Returns string by value or an empty string if the environment
|
||||
/// variable is not set.
|
||||
OPENVINO_DEPRECATED("The nGraph API is deprecated and will be removed in the 2024.0 release. "
|
||||
"For instructions on transitioning to the new API, please refer to "
|
||||
"https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html")
|
||||
OPENVINO_API std::string getenv_string(const char* env_var);
|
||||
|
||||
/// \brief Get the names environment variable as an integer. If the value is not a
|
||||
/// valid integer then an exception is thrown.
|
||||
/// \param env_var The string name of the environment variable to get.
|
||||
/// \param default_value The value to return if the environment variable is not set.
|
||||
/// \return Returns value or default_value if the environment variable is not set.
|
||||
OPENVINO_DEPRECATED("The nGraph API is deprecated and will be removed in the 2024.0 release. "
|
||||
"For instructions on transitioning to the new API, please refer to "
|
||||
"https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html")
|
||||
OPENVINO_API int32_t getenv_int(const char* env_var, int32_t default_value = -1);
|
||||
|
||||
/// \brief Get the names environment variable as a boolean. If the value is not a
|
||||
/// valid boolean then an exception is thrown. Valid booleans are one of
|
||||
/// 1, 0, on, off, true, false
|
||||
/// All values are case insensitive.
|
||||
/// If the environment variable is not set the default_value is returned.
|
||||
/// \param env_var The string name of the environment variable to get.
|
||||
/// \param default_value The value to return if the environment variable is not set.
|
||||
/// \return Returns the boolean value of the environment variable.
|
||||
OPENVINO_DEPRECATED("The nGraph API is deprecated and will be removed in the 2024.0 release. "
|
||||
"For instructions on transitioning to the new API, please refer to "
|
||||
"https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html")
|
||||
OPENVINO_API bool getenv_bool(const char* env_var, bool default_value = false);
|
||||
} // namespace ngraph
|
||||
|
|
@ -1,281 +0,0 @@
|
|||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#if !defined(IN_OV_COMPONENT) && !defined(NGRAPH_LEGACY_HEADER_INCLUDED)
|
||||
# define NGRAPH_LEGACY_HEADER_INCLUDED
|
||||
# ifdef _MSC_VER
|
||||
# pragma message( \
|
||||
"The nGraph API is deprecated and will be removed in the 2024.0 release. For instructions on transitioning to the new API, please refer to https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html")
|
||||
# else
|
||||
# warning("The nGraph API is deprecated and will be removed in the 2024.0 release. For instructions on transitioning to the new API, please refer to https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html")
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include <deque>
|
||||
#include <functional>
|
||||
#include <list>
|
||||
#include <memory>
|
||||
#include <stack>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
#include <vector>
|
||||
|
||||
#include "openvino/core/graph_util.hpp"
|
||||
|
||||
namespace ov {
|
||||
namespace op {
|
||||
namespace v0 {
|
||||
class Parameter;
|
||||
class Result;
|
||||
} // namespace v0
|
||||
} // namespace op
|
||||
} // namespace ov
|
||||
namespace ngraph {
|
||||
|
||||
namespace op {
|
||||
namespace v0 {
|
||||
using ov::op::v0::Parameter;
|
||||
using ov::op::v0::Result;
|
||||
} // namespace v0
|
||||
} // namespace op
|
||||
|
||||
using ov::compare_constants;
|
||||
using ov::replace_node;
|
||||
using ov::replace_node_update_name;
|
||||
using ov::replace_nodes;
|
||||
using ov::replace_output_update_name;
|
||||
using ov::topological_sort;
|
||||
using ov::traverse_nodes;
|
||||
|
||||
using NodeMap = std::unordered_map<ov::Node*, std::shared_ptr<ov::Node>>;
|
||||
|
||||
OPENVINO_DEPRECATED("The nGraph API is deprecated and will be removed in the 2024.0 release. "
|
||||
"For instructions on transitioning to the new API, please refer to "
|
||||
"https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html")
|
||||
OPENVINO_API
|
||||
ov::NodeVector find_common_args(std::shared_ptr<ov::Node> target, std::shared_ptr<ov::Node> replacement);
|
||||
|
||||
/// Topological sort of just nodes
|
||||
template <typename T>
|
||||
OPENVINO_DEPRECATED("The nGraph API is deprecated and will be removed in the 2024.0 release. "
|
||||
"For instructions on transitioning to the new API, please refer to "
|
||||
"https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html")
|
||||
std::vector<std::shared_ptr<ov::Node>> subgraph_topological_sort(T nodes) {
|
||||
std::stack<ov::Node*, std::vector<ov::Node*>> nodes_to_do;
|
||||
std::unordered_set<ov::Node*> nodes_done;
|
||||
std::unordered_set<ov::Node*> nodes_to_emit;
|
||||
std::vector<std::shared_ptr<ov::Node>> result;
|
||||
|
||||
for (auto& node : nodes) {
|
||||
nodes_to_emit.insert(node.get());
|
||||
nodes_to_do.push(node.get());
|
||||
}
|
||||
// NB: Some centos versions implement std::list::size() by counting elements
|
||||
size_t nodes_remaining = nodes_to_emit.size();
|
||||
while (nodes_to_do.size() > 0 && nodes_remaining > 0) {
|
||||
ov::Node* node = nodes_to_do.top();
|
||||
if (nodes_done.count(node) == 0) {
|
||||
bool can_add = true;
|
||||
size_t arg_count = node->get_input_size();
|
||||
for (size_t i = 0; i < arg_count; ++i) {
|
||||
ov::Node* dep = node->get_input_node_ptr(arg_count - i - 1);
|
||||
if (nodes_done.count(dep) == 0 && nodes_to_emit.count(node) != 0) {
|
||||
can_add = false;
|
||||
nodes_to_do.push(dep);
|
||||
}
|
||||
}
|
||||
for (auto& depptr : node->get_control_dependencies()) {
|
||||
ov::Node* dep = depptr.get();
|
||||
if (nodes_done.count(dep) == 0) {
|
||||
can_add = false;
|
||||
nodes_to_do.push(dep);
|
||||
}
|
||||
}
|
||||
if (can_add) {
|
||||
if (nodes_to_emit.count(node) != 0) {
|
||||
result.push_back(node->shared_from_this());
|
||||
nodes_remaining--;
|
||||
}
|
||||
nodes_to_do.pop();
|
||||
nodes_done.insert(node);
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
nodes_to_do.pop();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
OPENVINO_DEPRECATED("The nGraph API is deprecated and will be removed in the 2024.0 release. "
|
||||
"For instructions on transitioning to the new API, please refer to "
|
||||
"https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html")
|
||||
void validate_nodes_and_infer_types(const T& nodes) {
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
for (auto& node : subgraph_topological_sort(nodes)) {
|
||||
node->revalidate_and_infer_types();
|
||||
}
|
||||
OPENVINO_SUPPRESS_DEPRECATED_END
|
||||
}
|
||||
|
||||
// Check if all paths from X to a result go through Y
|
||||
OPENVINO_DEPRECATED("The nGraph API is deprecated and will be removed in the 2024.0 release. "
|
||||
"For instructions on transitioning to the new API, please refer to "
|
||||
"https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html")
|
||||
OPENVINO_API
|
||||
bool is_post_dominated(ov::Node* X, ov::Node* Y);
|
||||
|
||||
OPENVINO_DEPRECATED("The nGraph API is deprecated and will be removed in the 2024.0 release. "
|
||||
"For instructions on transitioning to the new API, please refer to "
|
||||
"https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html")
|
||||
OPENVINO_API
|
||||
bool is_equal_to_const_value(const std::string& const_value, const ov::Output<ov::Node>& reduce_constant);
|
||||
|
||||
// input nodes are cloned and returned
|
||||
// NodeMap input may contain default node mapping i.e. pre-cloned nodes
|
||||
// NodeMap output (by reference) fully maps input and cloned nodes
|
||||
OPENVINO_DEPRECATED("The nGraph API is deprecated and will be removed in the 2024.0 release. "
|
||||
"For instructions on transitioning to the new API, please refer to "
|
||||
"https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html")
|
||||
OPENVINO_API
|
||||
std::vector<std::shared_ptr<ov::Node>> clone_nodes(const std::vector<std::shared_ptr<ov::Node>>& nodes,
|
||||
NodeMap& node_map);
|
||||
|
||||
// input nodes are cloned and returned
|
||||
// NodeMap input may contain default node mapping i.e. pre-cloned nodes
|
||||
// NodeMap output (by reference) fully maps input and cloned nodes
|
||||
OPENVINO_DEPRECATED("The nGraph API is deprecated and will be removed in the 2024.0 release. "
|
||||
"For instructions on transitioning to the new API, please refer to "
|
||||
"https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html")
|
||||
OPENVINO_API
|
||||
std::list<std::shared_ptr<ov::Node>> clone_nodes(const std::vector<std::shared_ptr<ov::Node>>& nodes,
|
||||
ov::RawNodeOutputMap& node_map);
|
||||
|
||||
OPENVINO_DEPRECATED("The nGraph API is deprecated and will be removed in the 2024.0 release. "
|
||||
"For instructions on transitioning to the new API, please refer to "
|
||||
"https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html")
|
||||
OPENVINO_API
|
||||
std::pair<std::shared_ptr<op::v0::Result>, std::shared_ptr<op::v0::Parameter>> insert_result_parameter_split(
|
||||
const std::shared_ptr<ov::Node>& src_node,
|
||||
const std::shared_ptr<ov::Node>& dst_node);
|
||||
|
||||
OPENVINO_DEPRECATED("The nGraph API is deprecated and will be removed in the 2024.0 release. "
|
||||
"For instructions on transitioning to the new API, please refer to "
|
||||
"https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html")
|
||||
OPENVINO_API
|
||||
void insert_new_node_between(const std::shared_ptr<ov::Node>& src_node,
|
||||
const std::shared_ptr<ov::Node>& dst_node,
|
||||
const std::shared_ptr<ov::Node>& new_node);
|
||||
|
||||
OPENVINO_DEPRECATED("The nGraph API is deprecated and will be removed in the 2024.0 release. "
|
||||
"For instructions on transitioning to the new API, please refer to "
|
||||
"https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html")
|
||||
OPENVINO_API
|
||||
std::shared_ptr<ov::Node> make_zero(const ov::element::Type& element_type, const ov::Shape& shape);
|
||||
|
||||
OPENVINO_DEPRECATED("The nGraph API is deprecated and will be removed in the 2024.0 release. "
|
||||
"For instructions on transitioning to the new API, please refer to "
|
||||
"https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html")
|
||||
OPENVINO_API
|
||||
std::shared_ptr<ov::Node> make_constant_from_string(std::string val,
|
||||
const ov::element::Type& element_type,
|
||||
const ov::Shape& shape);
|
||||
|
||||
OPENVINO_DEPRECATED("The nGraph API is deprecated and will be removed in the 2024.0 release. "
|
||||
"For instructions on transitioning to the new API, please refer to "
|
||||
"https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html")
|
||||
OPENVINO_API
|
||||
bool is_zero(const ov::Output<ov::Node>& reduce_constant);
|
||||
|
||||
OPENVINO_DEPRECATED("The nGraph API is deprecated and will be removed in the 2024.0 release. "
|
||||
"For instructions on transitioning to the new API, please refer to "
|
||||
"https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html")
|
||||
OPENVINO_API
|
||||
ov::NodeVector get_subgraph_outputs(const ov::NodeVector& nodes,
|
||||
const ov::NodeVector& exclusions,
|
||||
bool ignore_unused = false,
|
||||
bool ignore_output_duplicates = true);
|
||||
|
||||
// Extract sub-graph computing the `results`. Stops backward traversal at either a Parameter
|
||||
// node
|
||||
// or a node that belongs to args
|
||||
OPENVINO_DEPRECATED("The nGraph API is deprecated and will be removed in the 2024.0 release. "
|
||||
"For instructions on transitioning to the new API, please refer to "
|
||||
"https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html")
|
||||
OPENVINO_API
|
||||
ov::NodeVector extract_subgraph(const ov::NodeVector& results, const ov::NodeVector& args);
|
||||
|
||||
OPENVINO_DEPRECATED("The nGraph API is deprecated and will be removed in the 2024.0 release. "
|
||||
"For instructions on transitioning to the new API, please refer to "
|
||||
"https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html")
|
||||
OPENVINO_API
|
||||
bool is_one(const ov::Output<ov::Node>& reduce_constant);
|
||||
|
||||
// Returns true if `node` is live in the graph i.e. a result op
|
||||
// transitively uses this `node`
|
||||
OPENVINO_DEPRECATED("The nGraph API is deprecated and will be removed in the 2024.0 release. "
|
||||
"For instructions on transitioning to the new API, please refer to "
|
||||
"https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html")
|
||||
OPENVINO_API
|
||||
bool is_used(ov::Node* node);
|
||||
|
||||
// Returns count of `node` users that are still live in the graph
|
||||
OPENVINO_DEPRECATED("The nGraph API is deprecated and will be removed in the 2024.0 release. "
|
||||
"For instructions on transitioning to the new API, please refer to "
|
||||
"https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html")
|
||||
OPENVINO_API
|
||||
size_t get_user_count(ov::Node* node);
|
||||
|
||||
OPENVINO_DEPRECATED("The nGraph API is deprecated and will be removed in the 2024.0 release. "
|
||||
"For instructions on transitioning to the new API, please refer to "
|
||||
"https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html")
|
||||
OPENVINO_API
|
||||
bool is_strided(const ov::Strides& strides);
|
||||
|
||||
OPENVINO_DEPRECATED("The nGraph API is deprecated and will be removed in the 2024.0 release. "
|
||||
"For instructions on transitioning to the new API, please refer to "
|
||||
"https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html")
|
||||
OPENVINO_API
|
||||
bool is_valid_rank(const std::shared_ptr<ov::Node>& node, std::vector<size_t> valid_ranks);
|
||||
|
||||
OPENVINO_DEPRECATED("The nGraph API is deprecated and will be removed in the 2024.0 release. "
|
||||
"For instructions on transitioning to the new API, please refer to "
|
||||
"https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html")
|
||||
OPENVINO_API
|
||||
void plot_graph(std::shared_ptr<ov::Model> f,
|
||||
const std::string& filename,
|
||||
std::function<void(const ov::Node& node, std::vector<std::string>& attributes)> = nullptr);
|
||||
|
||||
/// \return A vector containing handles for each input of dst that is connected to an output
|
||||
/// of `src`.
|
||||
OPENVINO_DEPRECATED("The nGraph API is deprecated and will be removed in the 2024.0 release. "
|
||||
"For instructions on transitioning to the new API, please refer to "
|
||||
"https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html")
|
||||
OPENVINO_API
|
||||
std::vector<ov::Input<ov::Node>> get_inputs_from(ov::Node& src, ov::Node& dst);
|
||||
/// \return A vector containing a handle for each output of src that is connected to an input
|
||||
/// of `dst`.
|
||||
OPENVINO_DEPRECATED("The nGraph API is deprecated and will be removed in the 2024.0 release. "
|
||||
"For instructions on transitioning to the new API, please refer to "
|
||||
"https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html")
|
||||
OPENVINO_API
|
||||
std::vector<ov::Output<ov::Node>> get_outputs_to(ov::Node& src, ov::Node& dst);
|
||||
|
||||
/// Checks the func for graph cycles starting from results going backwards, then from parameters
|
||||
/// going forward.
|
||||
/// It returns true if a cycle is found and the first cycle encountered.
|
||||
OPENVINO_DEPRECATED("The nGraph API is deprecated and will be removed in the 2024.0 release. "
|
||||
"For instructions on transitioning to the new API, please refer to "
|
||||
"https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html")
|
||||
OPENVINO_API
|
||||
bool check_for_cycles(const ov::Model* func, ov::NodeVector& cycle_nodes, bool& is_bkwd_cycle);
|
||||
} // namespace ngraph
|
||||
|
||||
using ngraph::replace_node;
|
||||
using ngraph::replace_output_update_name;
|
||||
|
|
@ -1,337 +0,0 @@
|
|||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#if !defined(IN_OV_COMPONENT) && !defined(NGRAPH_LEGACY_HEADER_INCLUDED)
|
||||
# define NGRAPH_LEGACY_HEADER_INCLUDED
|
||||
# ifdef _MSC_VER
|
||||
# pragma message( \
|
||||
"The nGraph API is deprecated and will be removed in the 2024.0 release. For instructions on transitioning to the new API, please refer to https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html")
|
||||
# else
|
||||
# warning("The nGraph API is deprecated and will be removed in the 2024.0 release. For instructions on transitioning to the new API, please refer to https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html")
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include <algorithm>
|
||||
#include <chrono>
|
||||
#include <cmath>
|
||||
#include <cstdlib> // llvm 8.1 gets confused about `malloc` otherwise
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <typeindex>
|
||||
#include <typeinfo>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
#include "ngraph/graph_util.hpp"
|
||||
#include "ngraph/shape.hpp"
|
||||
#include "openvino/core/axis_vector.hpp"
|
||||
#include "openvino/core/enum_mask.hpp"
|
||||
#include "openvino/core/type/element_type.hpp"
|
||||
#include "openvino/core/type/element_type_traits.hpp"
|
||||
#include "openvino/runtime/tensor.hpp"
|
||||
|
||||
namespace ov {
|
||||
class Node;
|
||||
}
|
||||
namespace ngraph {
|
||||
using ov::EnumMask;
|
||||
using ov::Node;
|
||||
class stopwatch;
|
||||
class Tensor;
|
||||
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
template <typename T>
|
||||
OPENVINO_DEPRECATED("The nGraph API is deprecated and will be removed in the 2024.0 release. "
|
||||
"For instructions on transitioning to the new API, please refer to "
|
||||
"https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html")
|
||||
std::string join(const T& v, const std::string& sep = ", ") {
|
||||
std::ostringstream ss;
|
||||
size_t count = 0;
|
||||
for (const auto& x : v) {
|
||||
if (count++ > 0) {
|
||||
ss << sep;
|
||||
}
|
||||
ss << x;
|
||||
}
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
OPENVINO_DEPRECATED("The nGraph API is deprecated and will be removed in the 2024.0 release. "
|
||||
"For instructions on transitioning to the new API, please refer to "
|
||||
"https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html")
|
||||
std::string vector_to_string(const T& v) {
|
||||
std::ostringstream os;
|
||||
os << "[ " << ngraph::join(v) << " ]";
|
||||
return os.str();
|
||||
}
|
||||
|
||||
OPENVINO_API
|
||||
OPENVINO_DEPRECATED("The nGraph API is deprecated and will be removed in the 2024.0 release. "
|
||||
"For instructions on transitioning to the new API, please refer to "
|
||||
"https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html")
|
||||
size_t hash_combine(const std::vector<size_t>& list);
|
||||
OPENVINO_API
|
||||
OPENVINO_DEPRECATED("The nGraph API is deprecated and will be removed in the 2024.0 release. "
|
||||
"For instructions on transitioning to the new API, please refer to "
|
||||
"https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html")
|
||||
void dump(std::ostream& out, const void*, size_t);
|
||||
OPENVINO_API
|
||||
OPENVINO_DEPRECATED("The nGraph API is deprecated and will be removed in the 2024.0 release. "
|
||||
"For instructions on transitioning to the new API, please refer to "
|
||||
"https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html")
|
||||
std::string to_lower(const std::string& s);
|
||||
OPENVINO_API
|
||||
OPENVINO_DEPRECATED("The nGraph API is deprecated and will be removed in the 2024.0 release. "
|
||||
"For instructions on transitioning to the new API, please refer to "
|
||||
"https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html")
|
||||
std::string to_upper(const std::string& s);
|
||||
OPENVINO_API
|
||||
OPENVINO_DEPRECATED("The nGraph API is deprecated and will be removed in the 2024.0 release. "
|
||||
"For instructions on transitioning to the new API, please refer to "
|
||||
"https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html")
|
||||
std::string trim(const std::string& s);
|
||||
OPENVINO_API
|
||||
OPENVINO_DEPRECATED("The nGraph API is deprecated and will be removed in the 2024.0 release. "
|
||||
"For instructions on transitioning to the new API, please refer to "
|
||||
"https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html")
|
||||
std::vector<std::string> split(const std::string& s, char delimiter, bool trim = false);
|
||||
|
||||
template <typename T>
|
||||
OPENVINO_DEPRECATED("The nGraph API is deprecated and will be removed in the 2024.0 release. "
|
||||
"For instructions on transitioning to the new API, please refer to "
|
||||
"https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html")
|
||||
std::string locale_string(T x) {
|
||||
std::stringstream ss;
|
||||
ss.imbue(std::locale(""));
|
||||
ss << x;
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
class OPENVINO_API OPENVINO_DEPRECATED("It is obsolete structure and will be removed soon") stopwatch {
|
||||
public:
|
||||
void start() {
|
||||
if (m_active == false) {
|
||||
m_total_count++;
|
||||
m_active = true;
|
||||
m_start_time = m_clock.now();
|
||||
}
|
||||
}
|
||||
|
||||
void stop() {
|
||||
if (m_active == true) {
|
||||
auto end_time = m_clock.now();
|
||||
m_last_time = end_time - m_start_time;
|
||||
m_total_time += m_last_time;
|
||||
m_active = false;
|
||||
}
|
||||
}
|
||||
|
||||
size_t get_call_count() const;
|
||||
size_t get_seconds() const;
|
||||
size_t get_milliseconds() const;
|
||||
size_t get_microseconds() const;
|
||||
std::chrono::nanoseconds get_timer_value() const;
|
||||
size_t get_nanoseconds() const;
|
||||
|
||||
size_t get_total_seconds() const;
|
||||
size_t get_total_milliseconds() const;
|
||||
size_t get_total_microseconds() const;
|
||||
size_t get_total_nanoseconds() const;
|
||||
|
||||
private:
|
||||
std::chrono::high_resolution_clock m_clock;
|
||||
std::chrono::time_point<std::chrono::high_resolution_clock> m_start_time;
|
||||
bool m_active = false;
|
||||
std::chrono::nanoseconds m_total_time = std::chrono::high_resolution_clock::duration::zero();
|
||||
std::chrono::nanoseconds m_last_time = std::chrono::high_resolution_clock::duration::zero();
|
||||
size_t m_total_count = 0;
|
||||
};
|
||||
|
||||
/// Parses a string containing a literal of the underlying type.
|
||||
template <typename T>
|
||||
OPENVINO_DEPRECATED("The nGraph API is deprecated and will be removed in the 2024.0 release. "
|
||||
"For instructions on transitioning to the new API, please refer to "
|
||||
"https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html")
|
||||
T parse_string(const std::string& s) {
|
||||
T result;
|
||||
std::stringstream ss;
|
||||
|
||||
ss << s;
|
||||
ss >> result;
|
||||
|
||||
// Check that (1) parsing succeeded and (2) the entire string was used.
|
||||
if (ss.fail() || ss.rdbuf()->in_avail() != 0) {
|
||||
OPENVINO_THROW("Could not parse literal '" + s + "'");
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// template specializations for float and double to handle INFINITY, -INFINITY
|
||||
/// and NaN values.
|
||||
template <>
|
||||
OPENVINO_DEPRECATED("The nGraph API is deprecated and will be removed in the 2024.0 release. "
|
||||
"For instructions on transitioning to the new API, please refer to "
|
||||
"https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html")
|
||||
OPENVINO_API float parse_string<float>(const std::string& s);
|
||||
template <>
|
||||
OPENVINO_DEPRECATED("The nGraph API is deprecated and will be removed in the 2024.0 release. "
|
||||
"For instructions on transitioning to the new API, please refer to "
|
||||
"https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html")
|
||||
OPENVINO_API double parse_string<double>(const std::string& s);
|
||||
|
||||
/// template specializations for int8_t and uint8_t to handle the fact that default
|
||||
/// implementation ends up treating values as characters so that the number "0" turns into
|
||||
/// the parsed value 48, which is it's ASCII value
|
||||
template <>
|
||||
OPENVINO_DEPRECATED("The nGraph API is deprecated and will be removed in the 2024.0 release. "
|
||||
"For instructions on transitioning to the new API, please refer to "
|
||||
"https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html")
|
||||
OPENVINO_API int8_t parse_string<int8_t>(const std::string& s);
|
||||
template <>
|
||||
OPENVINO_DEPRECATED("The nGraph API is deprecated and will be removed in the 2024.0 release. "
|
||||
"For instructions on transitioning to the new API, please refer to "
|
||||
"https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html")
|
||||
OPENVINO_API uint8_t parse_string<uint8_t>(const std::string& s);
|
||||
|
||||
/// Parses a list of strings containing literals of the underlying type.
|
||||
template <typename T>
|
||||
OPENVINO_DEPRECATED("The nGraph API is deprecated and will be removed in the 2024.0 release. "
|
||||
"For instructions on transitioning to the new API, please refer to "
|
||||
"https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html")
|
||||
std::vector<T> parse_string(const std::vector<std::string>& ss) {
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
std::vector<T> result(ss.size());
|
||||
std::transform(ss.begin(), ss.end(), result.begin(), [](const std::string& s) {
|
||||
return parse_string<T>(s);
|
||||
});
|
||||
return result;
|
||||
OPENVINO_SUPPRESS_DEPRECATED_END
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
OPENVINO_DEPRECATED("The nGraph API is deprecated and will be removed in the 2024.0 release. "
|
||||
"For instructions on transitioning to the new API, please refer to "
|
||||
"https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html")
|
||||
T ceil_div(const T& x, const T& y) {
|
||||
return (x == 0 ? 0 : (1 + (x - 1) / y));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
OPENVINO_DEPRECATED("The nGraph API is deprecated and will be removed in the 2024.0 release. "
|
||||
"For instructions on transitioning to the new API, please refer to "
|
||||
"https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html")
|
||||
T subtract_or_zero(T x, T y) {
|
||||
return y > x ? 0 : x - y;
|
||||
}
|
||||
|
||||
OPENVINO_API
|
||||
OPENVINO_DEPRECATED("The nGraph API is deprecated and will be removed in the 2024.0 release. "
|
||||
"For instructions on transitioning to the new API, please refer to "
|
||||
"https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html")
|
||||
void* ngraph_malloc(size_t size);
|
||||
OPENVINO_API
|
||||
OPENVINO_DEPRECATED("The nGraph API is deprecated and will be removed in the 2024.0 release. "
|
||||
"For instructions on transitioning to the new API, please refer to "
|
||||
"https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html")
|
||||
void ngraph_free(void*);
|
||||
|
||||
OPENVINO_API
|
||||
OPENVINO_DEPRECATED("The nGraph API is deprecated and will be removed in the 2024.0 release. "
|
||||
"For instructions on transitioning to the new API, please refer to "
|
||||
"https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html")
|
||||
size_t round_up(size_t size, size_t alignment);
|
||||
|
||||
/// \brief Function to query parsed version information of the version of ngraph which
|
||||
/// contains this function. Version information strictly follows Semantic Versioning
|
||||
/// http://semver.org
|
||||
/// \param version The major part of the version
|
||||
/// \param major Returns the major part of the version
|
||||
/// \param minor Returns the minor part of the version
|
||||
/// \param patch Returns the patch part of the version
|
||||
/// \param extra Returns the extra part of the version. This includes everything following
|
||||
/// the patch version number.
|
||||
///
|
||||
/// \note Throws a runtime_error if there is an error during parsing
|
||||
OPENVINO_API
|
||||
OPENVINO_DEPRECATED("The nGraph API is deprecated and will be removed in the 2024.0 release. "
|
||||
"For instructions on transitioning to the new API, please refer to "
|
||||
"https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html")
|
||||
void parse_version_string(std::string version, size_t& major, size_t& minor, size_t& patch, std::string& extra);
|
||||
|
||||
template <typename T>
|
||||
OPENVINO_DEPRECATED("The nGraph API is deprecated and will be removed in the 2024.0 release. "
|
||||
"For instructions on transitioning to the new API, please refer to "
|
||||
"https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html")
|
||||
T double_to_int(double x, double float_to_int_converter(double)) {
|
||||
if (!std::is_integral<T>()) {
|
||||
OPENVINO_THROW("Function double_to_int template parameter must be an integral type.");
|
||||
}
|
||||
|
||||
x = float_to_int_converter(x);
|
||||
|
||||
double min_t = static_cast<double>(std::numeric_limits<T>::min());
|
||||
if (x < min_t) {
|
||||
return std::numeric_limits<T>::min();
|
||||
}
|
||||
|
||||
double max_t = static_cast<double>(std::numeric_limits<T>::max());
|
||||
if (x > max_t) {
|
||||
return std::numeric_limits<T>::max();
|
||||
}
|
||||
|
||||
return static_cast<T>(x);
|
||||
}
|
||||
} // end namespace ngraph
|
||||
|
||||
template <typename T>
|
||||
OPENVINO_DEPRECATED("The nGraph API is deprecated and will be removed in the 2024.0 release. "
|
||||
"For instructions on transitioning to the new API, please refer to "
|
||||
"https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html")
|
||||
std::vector<T> read_vector(std::shared_ptr<ov::Tensor> tv) {
|
||||
if (ov::element::from<T>() != tv->get_element_type()) {
|
||||
OPENVINO_THROW("read_vector type must match Tensor type");
|
||||
}
|
||||
size_t element_count = ngraph::shape_size(tv->get_shape());
|
||||
size_t size = element_count * sizeof(T);
|
||||
std::vector<T> rc(element_count);
|
||||
std::memcpy(rc.data(), tv->data(), size);
|
||||
return rc;
|
||||
}
|
||||
|
||||
template <class T, ov::element::Type_t ET>
|
||||
OPENVINO_DEPRECATED("The nGraph API is deprecated and will be removed in the 2024.0 release. "
|
||||
"For instructions on transitioning to the new API, please refer to "
|
||||
"https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html")
|
||||
std::vector<T> array_2_vector(typename ov::element_type_traits<ET>::value_type* data, size_t size) {
|
||||
std::vector<T> result(size);
|
||||
for (size_t i = 0; i < size; i++) {
|
||||
result[i] = static_cast<T>(data[i]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
OPENVINO_DEPRECATED("The nGraph API is deprecated and will be removed in the 2024.0 release. "
|
||||
"For instructions on transitioning to the new API, please refer to "
|
||||
"https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html")
|
||||
std::vector<float> OPENVINO_API read_float_vector(std::shared_ptr<ov::Tensor> tv);
|
||||
|
||||
OPENVINO_DEPRECATED("The nGraph API is deprecated and will be removed in the 2024.0 release. "
|
||||
"For instructions on transitioning to the new API, please refer to "
|
||||
"https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html")
|
||||
std::vector<int64_t> OPENVINO_API read_index_vector(std::shared_ptr<ov::Tensor> tv);
|
||||
|
||||
OPENVINO_API
|
||||
OPENVINO_DEPRECATED("The nGraph API is deprecated and will be removed in the 2024.0 release. "
|
||||
"For instructions on transitioning to the new API, please refer to "
|
||||
"https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html")
|
||||
std::ostream& operator<<(std::ostream& os, const ov::NodeVector& nv);
|
||||
OPENVINO_SUPPRESS_DEPRECATED_END
|
||||
|
|
@ -20,9 +20,12 @@
|
|||
#include "openvino/op/constant.hpp"
|
||||
#include "openvino/op/util/attr_types.hpp"
|
||||
#include "openvino/op/util/variable_context.hpp"
|
||||
#include "openvino/runtime/tensor.hpp"
|
||||
|
||||
namespace ngraph {
|
||||
using ov::CoordinateDiff;
|
||||
using ov::Shape;
|
||||
using ov::Strides;
|
||||
using ov::op::v0::Constant;
|
||||
|
||||
namespace element {
|
||||
|
|
@ -34,7 +37,7 @@ OPENVINO_DEPRECATED("The nGraph API is deprecated and will be removed in the 202
|
|||
"For instructions on transitioning to the new API, please refer to "
|
||||
"https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html")
|
||||
OPENVINO_API
|
||||
Strides conv_default_strides(const Node* node,
|
||||
Strides conv_default_strides(const ov::Node* node,
|
||||
const ov::PartialShape& data_batch_shape,
|
||||
const ov::PartialShape& filters_shape);
|
||||
|
||||
|
|
@ -42,7 +45,7 @@ OPENVINO_DEPRECATED("The nGraph API is deprecated and will be removed in the 202
|
|||
"For instructions on transitioning to the new API, please refer to "
|
||||
"https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html")
|
||||
OPENVINO_API
|
||||
CoordinateDiff conv_default_padding(const Node* node,
|
||||
CoordinateDiff conv_default_padding(const ov::Node* node,
|
||||
const ov::PartialShape& data_batch_shape,
|
||||
const ov::PartialShape& filters_shape);
|
||||
|
||||
|
|
@ -50,7 +53,7 @@ OPENVINO_DEPRECATED("The nGraph API is deprecated and will be removed in the 202
|
|||
"For instructions on transitioning to the new API, please refer to "
|
||||
"https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html")
|
||||
OPENVINO_API
|
||||
ov::PartialShape infer_windowed_reduction_output_shape(const Node* node,
|
||||
ov::PartialShape infer_windowed_reduction_output_shape(const ov::Node* node,
|
||||
const ov::PartialShape& data_shape,
|
||||
const Strides& data_dilation,
|
||||
const CoordinateDiff& data_padding_below,
|
||||
|
|
@ -64,7 +67,7 @@ ov::PartialShape infer_windowed_reduction_output_shape(const Node* node,
|
|||
OPENVINO_DEPRECATED("The nGraph API is deprecated and will be removed in the 2024.0 release. "
|
||||
"For instructions on transitioning to the new API, please refer to "
|
||||
"https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html")
|
||||
void validate_conv_params_spatial_dimensions(const Node* node,
|
||||
void validate_conv_params_spatial_dimensions(const ov::Node* node,
|
||||
const size_t num_spatial_dims,
|
||||
const ov::op::PadType auto_pad,
|
||||
Strides& strides,
|
||||
|
|
@ -76,7 +79,7 @@ OPENVINO_DEPRECATED("The nGraph API is deprecated and will be removed in the 202
|
|||
"For instructions on transitioning to the new API, please refer to "
|
||||
"https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html")
|
||||
OPENVINO_API
|
||||
ov::PartialShape infer_batched_pooling_forward(const Node* node,
|
||||
ov::PartialShape infer_batched_pooling_forward(const ov::Node* node,
|
||||
const ov::PartialShape& data_batch_shape,
|
||||
const CoordinateDiff& data_padding_below,
|
||||
const CoordinateDiff& data_padding_above,
|
||||
|
|
@ -90,7 +93,7 @@ OPENVINO_DEPRECATED("The nGraph API is deprecated and will be removed in the 202
|
|||
"For instructions on transitioning to the new API, please refer to "
|
||||
"https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html")
|
||||
OPENVINO_API
|
||||
ov::PartialShape infer_slice_shape(const Node* node,
|
||||
ov::PartialShape infer_slice_shape(const ov::Node* node,
|
||||
const ov::PartialShape& input_shape,
|
||||
const std::vector<int64_t>& begin,
|
||||
const std::vector<int64_t>& end,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// Copyright (C) 2018-2024 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
|
@ -7,21 +7,14 @@
|
|||
#include <cmath>
|
||||
#include <cstring>
|
||||
|
||||
#ifndef IN_OV_COMPONENT
|
||||
# define IN_OV_COMPONENT
|
||||
# define WAS_OV_LIBRARY_DEFINED_CONSTANT
|
||||
#endif
|
||||
|
||||
#include "ngraph/util.hpp"
|
||||
#include "openvino/core/rtti.hpp"
|
||||
|
||||
#ifdef WAS_OV_LIBRARY_DEFINED_CONSTANT
|
||||
# undef IN_OV_COMPONENT
|
||||
# undef WAS_OV_LIBRARY_DEFINED_CONSTANT
|
||||
#endif
|
||||
#include "openvino/core/axis_set.hpp"
|
||||
#include "openvino/core/axis_vector.hpp"
|
||||
#include "openvino/core/coordinate_diff.hpp"
|
||||
#include "openvino/core/graph_util.hpp"
|
||||
#include "openvino/core/rtti.hpp"
|
||||
#include "openvino/core/type/element_type.hpp"
|
||||
#include "openvino/core/type/element_type_traits.hpp"
|
||||
#include "openvino/op/op.hpp"
|
||||
|
||||
namespace ov {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,19 +0,0 @@
|
|||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "ngraph/env_util.hpp"
|
||||
|
||||
#include "openvino/util/env_util.hpp"
|
||||
|
||||
std::string ngraph::getenv_string(const char* env_var) {
|
||||
return ov::util::getenv_string(env_var);
|
||||
}
|
||||
|
||||
int32_t ngraph::getenv_int(const char* env_var, int32_t default_value) {
|
||||
return ov::util::getenv_int(env_var, default_value);
|
||||
}
|
||||
|
||||
bool ngraph::getenv_bool(const char* env_var, bool default_value) {
|
||||
return ov::util::getenv_bool(env_var, default_value);
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// Copyright (C) 2018-2024 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
|
@ -340,346 +340,14 @@ void save_model(const std::shared_ptr<const ov::Model>& m, const std::string& ou
|
|||
manager.run_passes(cloned);
|
||||
}
|
||||
|
||||
} // namespace ov
|
||||
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
|
||||
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) {
|
||||
node1_args.insert(node);
|
||||
};
|
||||
|
||||
traverse_nodes({std::move(node1)}, compute_node1_args, ov::NodeVector{});
|
||||
|
||||
std::unordered_set<std::shared_ptr<Node>> node2_args;
|
||||
|
||||
auto compute_node2_args = [&node2_args](const std::shared_ptr<Node>& node) {
|
||||
node2_args.insert(node);
|
||||
};
|
||||
|
||||
traverse_nodes({std::move(node2)}, compute_node2_args, ov::NodeVector{});
|
||||
|
||||
ov::NodeVector common_args;
|
||||
for (const auto& e : node1_args) {
|
||||
if (node2_args.count(e) > 0) {
|
||||
common_args.push_back(e);
|
||||
}
|
||||
}
|
||||
|
||||
return common_args;
|
||||
}
|
||||
|
||||
// Check if all paths from X to a result go through 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) {
|
||||
ov::Node* curr = stack.top();
|
||||
visited.insert(curr);
|
||||
if (ov::op::util::is_output(curr)) {
|
||||
return false;
|
||||
}
|
||||
stack.pop();
|
||||
if (curr != Y) {
|
||||
for (const auto& next : curr->get_users()) {
|
||||
if (visited.count(next.get()) == 0) {
|
||||
stack.push(next.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
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) {
|
||||
if (node_map.count(node.get()) == 0) {
|
||||
// get (already) cloned arguments and clone the node
|
||||
ov::OutputVector cloned_args;
|
||||
for (auto input : node->inputs()) {
|
||||
ov::Output<Node> output = input.get_source_output();
|
||||
cloned_args.push_back(output.for_node(node_map.at(output.get_node())));
|
||||
}
|
||||
std::vector<std::shared_ptr<Node>> cloned_dependencies;
|
||||
for (auto& dependency : node->get_control_dependencies()) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
auto cloned_node = node->copy_with_new_inputs(cloned_args, cloned_dependencies);
|
||||
// There is a friendly name for this node so copy it
|
||||
cloned_node->set_friendly_name(node->get_friendly_name());
|
||||
auto rt_info = node->get_rt_info();
|
||||
cloned_node->get_rt_info() = rt_info;
|
||||
|
||||
for (auto output : node->outputs()) {
|
||||
const auto& output_rt_info = output.get_rt_info();
|
||||
auto new_output = output.for_node(cloned_node);
|
||||
new_output.get_rt_info() = output_rt_info;
|
||||
}
|
||||
|
||||
for (auto input : node->inputs()) {
|
||||
const auto& output_rt_info = input.get_rt_info();
|
||||
auto new_input = cloned_node->input(input.get_index());
|
||||
new_input.get_rt_info() = output_rt_info;
|
||||
}
|
||||
|
||||
node_map[node.get()] = cloned_node;
|
||||
}
|
||||
}
|
||||
|
||||
// create and return vector of cloned nodes
|
||||
// order matches input vector (not necessarily topological)
|
||||
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<ov::Node>> clone_nodes(const std::vector<std::shared_ptr<ov::Node>>& nodes,
|
||||
ov::RawNodeOutputMap& output_map) {
|
||||
// for each node in topological order
|
||||
auto sorted_nodes = topological_sort(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) {
|
||||
if (output_map.count(value) == 0) {
|
||||
// We need this node cloned
|
||||
// get (already) cloned arguments and clone the node
|
||||
ov::OutputVector cloned_args;
|
||||
for (const auto& value : node->input_values()) {
|
||||
cloned_args.push_back(output_map.at(value));
|
||||
}
|
||||
ov::NodeVector cloned_dependencies;
|
||||
for (auto& dependency : node->get_control_dependencies()) {
|
||||
for (const auto& dependency_value : dependency->outputs()) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
auto cloned_node = node->copy_with_new_inputs(cloned_args, cloned_dependencies);
|
||||
cloned_nodes.push_back(cloned_node);
|
||||
// There is a friendly name for this node so copy it
|
||||
cloned_node->set_friendly_name(node->get_friendly_name());
|
||||
auto rt_info = node->get_rt_info();
|
||||
cloned_node->get_rt_info() = rt_info;
|
||||
for (const auto& cloned_value : cloned_node->outputs()) {
|
||||
auto original_value = node_outputs.at(cloned_value.get_index());
|
||||
if (output_map.count(original_value) == 0) {
|
||||
output_map[original_value] = cloned_value;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return cloned_nodes;
|
||||
}
|
||||
|
||||
bool is_equal_to_const_value(const std::string& const_value, const ov::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;
|
||||
}
|
||||
}
|
||||
|
||||
// Insert result and parameter node between src_node and dst_node by splitting the graph
|
||||
//
|
||||
// Before: | After:
|
||||
// (Device:0) (Device:1) | (Device:0) (Device:0) (Device:1) (Device:1)
|
||||
// +-----+---+ +---+-----+ | +-----+---+ +---+-----+ +-----+---+ +---+-----+
|
||||
// | | | | | | | | | | | | | | | | | | |
|
||||
// | | o +--[0]--> i | | | | | o +--[4]--> i | | | | o +--[8]--> i | |
|
||||
// | | <--[1]--+ | | | | | <--[5]--+ | | | | <--[9]--+ | |
|
||||
// | src +---+ +---+ dst | | | src +---+ +---+ res | | par +---+ +---+ dst |
|
||||
// | | | | | | | | | | | | |
|
||||
// | +------[2]------> | | | +------[6]------> | | +------[10]-----> |
|
||||
// | <------[3]------+ | | | <------[7]------+ | | <------[11]-----+ |
|
||||
// +-----+ +-----+ | +-----+ +-----+ +-----+ +-----+
|
||||
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
|
||||
std::shared_ptr<ov::op::v0::Parameter> par_node =
|
||||
std::make_shared<ov::op::v0::Parameter>(src_node->get_output_element_type(0), src_node->get_output_shape(0));
|
||||
|
||||
// Fix input / output among src, dst and par
|
||||
std::vector<ov::Input<Node>> dst_inputs = get_inputs_from(*src_node, *dst_node);
|
||||
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<ov::Output<Node>> src_outputs = get_outputs_to(*src_node, *dst_node);
|
||||
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]
|
||||
src_output.remove_target_input(dst_input);
|
||||
|
||||
// Remove [0] (again), add [8], remove [1], add [9]
|
||||
dst_input.replace_source_output(par_node->output(0));
|
||||
|
||||
// Add res node
|
||||
// Add [4], [5], [6], [7]
|
||||
std::shared_ptr<ov::op::v0::Result> res_node = std::make_shared<ov::op::v0::Result>(src_node);
|
||||
|
||||
return make_pair(res_node, par_node);
|
||||
}
|
||||
|
||||
// Insert unary node between two nodes like S->D => S->N->D
|
||||
// Before: | After:
|
||||
// +-----+---+ +---+-----+ | +-----+---+ +---+-----+---+ +---+-----+
|
||||
// | | | | | | | | | | | | | | | | |
|
||||
// | | o +--[0]--> i | | | | | o +--[4]--> i | | o +--[8]--> i | |
|
||||
// | | <--[1]--+ | | | | | <--[5]--+ | | <--[9]--+ | |
|
||||
// | src +---+ +---+ dst | | | src +---+ +---+ new +---+ +---+ dst |
|
||||
// | | | | | | | | | | |
|
||||
// | +------[2]------> | | | +------[6]------> +------[10]-----> |
|
||||
// | <------[3]------+ | | | <------[7]------+ <------[11]-----+ |
|
||||
// +-----+ +-----+ | +-----+ +-----+ +-----+
|
||||
// |
|
||||
// +-----+---+ +---+-----+ |
|
||||
// | | | | | | |
|
||||
// | | o +--[4]--> i | | |
|
||||
// | | <--[5]--+ | | |
|
||||
// | src +---+ +---+ new | |
|
||||
// | | | | |
|
||||
// | +------[6]------> | |
|
||||
// | <------[7]------+ | |
|
||||
// +-----+ +-----+ |
|
||||
//
|
||||
// This cannot be achieved by ngraph::replace_node().
|
||||
// With replace_node(), we could do:
|
||||
// [ S S ]
|
||||
// [ / \ | ]
|
||||
// [ / \ => N ]
|
||||
// [ / \ / \ ]
|
||||
// [ D0 D1 D0 D1 ]
|
||||
//
|
||||
// But we want:
|
||||
// [ S S ]
|
||||
// [ / \ / \ ]
|
||||
// [ / \ => N0 N1 ]
|
||||
// [ / \ / \ ]
|
||||
// [ D0 D1 D0 D1 ]
|
||||
//
|
||||
// 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 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<ov::Input<Node>> dst_inputs = get_inputs_from(*src_node, *dst_node);
|
||||
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<ov::Output<Node>> src_outputs = get_outputs_to(*src_node, *dst_node);
|
||||
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<ov::Node> make_zero(const ov::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<ov::op::v1::Broadcast>(
|
||||
zero,
|
||||
ov::op::v0::Constant::create(ov::element::u64, Shape{shape.size()}, shape));
|
||||
}
|
||||
return zero;
|
||||
}
|
||||
|
||||
std::shared_ptr<ov::Node> make_constant_from_string(std::string val,
|
||||
const ov::element::Type& element_type,
|
||||
const Shape& shape) {
|
||||
auto cvals = std::vector<std::string>(shape_size(shape), val);
|
||||
return std::make_shared<ov::op::v0::Constant>(element_type, shape, cvals);
|
||||
}
|
||||
|
||||
bool is_zero(const ov::Output<Node>& reduce_constant) {
|
||||
auto result_bool = is_equal_to_const_value("0", reduce_constant);
|
||||
return result_bool;
|
||||
}
|
||||
|
||||
bool is_one(const ov::Output<Node>& reduce_constant) {
|
||||
auto result_bool = is_equal_to_const_value("1", reduce_constant);
|
||||
return result_bool;
|
||||
}
|
||||
|
||||
ov::NodeVector get_subgraph_outputs(const ov::NodeVector& nodes,
|
||||
const ov::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());
|
||||
|
||||
ov::NodeVector outputs;
|
||||
|
||||
for (const auto& n : nodes) {
|
||||
if (exclusions_set.count(n) != 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (const auto& u : n->get_users()) {
|
||||
bool add_output = nodes_set.count(u) == 0 && (!ignore_unused || is_used(u.get()));
|
||||
// check if output is already captured
|
||||
add_output &= (ignore_output_duplicates || std::find(outputs.begin(), outputs.end(), n) == outputs.end());
|
||||
if (add_output) {
|
||||
outputs.push_back(n);
|
||||
}
|
||||
}
|
||||
}
|
||||
return outputs;
|
||||
}
|
||||
|
||||
ov::NodeVector extract_subgraph(const ov::NodeVector& results, const ov::NodeVector& args) {
|
||||
ov::NodeVector subgraph;
|
||||
traverse_nodes(
|
||||
results,
|
||||
[&](const std::shared_ptr<Node>& n) {
|
||||
subgraph.push_back(n);
|
||||
},
|
||||
args);
|
||||
return subgraph;
|
||||
}
|
||||
|
||||
bool 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) {
|
||||
ov::Node* n = stack.top();
|
||||
Node* n = stack.top();
|
||||
if (instances_seen.count(n) == 0) {
|
||||
if (ov::op::util::is_output(n)) {
|
||||
return true;
|
||||
|
|
@ -695,153 +363,4 @@ bool is_used(Node* node) {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
bool is_strided(const Strides& strides) {
|
||||
return std::any_of(strides.begin(), strides.end(), [](size_t stride) {
|
||||
return stride != 1;
|
||||
});
|
||||
}
|
||||
|
||||
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) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void plot_graph(std::shared_ptr<ov::Model> 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<ov::Input<ov::Node>> get_inputs_from(Node& src, Node& dst) {
|
||||
std::vector<ov::Input<Node>> result;
|
||||
|
||||
for (auto& input : dst.inputs()) {
|
||||
if (input.get_source_output().get_node() == &src) {
|
||||
result.push_back(input);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
std::vector<ov::Output<ov::Node>> get_outputs_to(Node& src, Node& dst) {
|
||||
std::vector<ov::Output<Node>> result;
|
||||
|
||||
for (auto& output : src.outputs()) {
|
||||
bool targets_dst = false;
|
||||
|
||||
for (auto& input : output.get_target_inputs()) {
|
||||
if (input.get_node() == &dst) {
|
||||
targets_dst = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (targets_dst) {
|
||||
result.push_back(output);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
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++) {
|
||||
auto arg = node->get_input_node_shared_ptr(i);
|
||||
if (path_set.find(arg) != path_set.end()) {
|
||||
for (const auto& it : path) {
|
||||
cycle_nodes.push_back(it);
|
||||
}
|
||||
// last node
|
||||
cycle_nodes.push_back(arg);
|
||||
return true;
|
||||
}
|
||||
if (check_for_cycles_bkwd(arg, path, path_set, cycle_nodes)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
path_set.erase(path.back());
|
||||
path.pop_back();
|
||||
return false;
|
||||
}
|
||||
|
||||
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()) {
|
||||
if (path_set.find(arg) != path_set.end()) {
|
||||
for (const auto& it : path) {
|
||||
cycle_nodes.push_back(it);
|
||||
}
|
||||
// last node
|
||||
cycle_nodes.push_back(arg);
|
||||
return true;
|
||||
}
|
||||
if (check_for_cycles_fwd(arg, path, path_set, cycle_nodes)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
path_set.erase(path.back());
|
||||
path.pop_back();
|
||||
return false;
|
||||
}
|
||||
|
||||
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
|
||||
std::unordered_set<std::shared_ptr<Node>> path_set;
|
||||
if (check_for_cycles_bkwd(res, path, path_set, cycle_nodes)) {
|
||||
is_bkwd_cycle = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
for (const auto& res : func->get_sinks()) {
|
||||
std::deque<std::shared_ptr<Node>> path;
|
||||
// mirror of path stack for faster cycle check
|
||||
std::unordered_set<std::shared_ptr<Node>> path_set;
|
||||
if (check_for_cycles_bkwd(res, path, path_set, cycle_nodes)) {
|
||||
is_bkwd_cycle = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
for (const auto& param : func->get_parameters()) {
|
||||
std::deque<std::shared_ptr<Node>> path;
|
||||
// mirror of path stack for faster cycle check
|
||||
std::unordered_set<std::shared_ptr<Node>> path_set;
|
||||
if (check_for_cycles_fwd(param, path, path_set, cycle_nodes)) {
|
||||
is_bkwd_cycle = false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// no cycles
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace ngraph
|
||||
} // namespace ov
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// Copyright (C) 2018-2024 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
|
@ -13,6 +13,7 @@
|
|||
#include "layout_utils.hpp"
|
||||
#include "openvino/core/attribute_visitor.hpp"
|
||||
#include "openvino/core/except.hpp"
|
||||
#include "openvino/core/graph_util.hpp"
|
||||
#include "openvino/core/meta_data.hpp"
|
||||
#include "openvino/core/partial_shape.hpp"
|
||||
#include "openvino/op/parameter.hpp"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// Copyright (C) 2018-2024 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
|
@ -15,6 +15,7 @@
|
|||
#include "openvino/core/descriptor/input.hpp"
|
||||
#include "openvino/core/rt_info.hpp"
|
||||
#include "openvino/core/shape_util.hpp"
|
||||
#include "openvino/op/util/op_types.hpp"
|
||||
#include "openvino/pass/constant_folding.hpp"
|
||||
#include "openvino/pass/pattern/matcher.hpp"
|
||||
#include "shape_validation.hpp"
|
||||
|
|
@ -513,16 +514,18 @@ bool ov::Node::has_same_type(std::shared_ptr<const Node> node) const {
|
|||
return true;
|
||||
}
|
||||
|
||||
namespace ov {
|
||||
bool is_used(Node* node);
|
||||
}
|
||||
|
||||
ov::NodeVector ov::Node::get_users(bool check_is_used) const {
|
||||
NodeVector result;
|
||||
for (const auto& output : outputs()) {
|
||||
for (auto input : output.get_target_inputs()) {
|
||||
Node* input_node = input.get_node();
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
if (!check_is_used || ngraph::is_used(input_node)) {
|
||||
if (!check_is_used || is_used(input_node)) {
|
||||
result.push_back(input_node->shared_from_this());
|
||||
}
|
||||
OPENVINO_SUPPRESS_DEPRECATED_END
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// Copyright (C) 2018-2024 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
|
@ -12,7 +12,6 @@
|
|||
#include <unordered_map>
|
||||
|
||||
#include "itt.hpp"
|
||||
#include "ngraph/util.hpp"
|
||||
#include "openvino/pass/graph_rewrite.hpp"
|
||||
#include "openvino/pass/visualize_tree.hpp"
|
||||
#include "openvino/util/env_util.hpp"
|
||||
|
|
@ -55,6 +54,44 @@ void ov::pass::Manager::set_per_pass_validation(bool new_state) {
|
|||
m_per_pass_validation = new_state;
|
||||
}
|
||||
|
||||
namespace {
|
||||
class stopwatch {
|
||||
public:
|
||||
void start() {
|
||||
if (m_active == false) {
|
||||
m_active = true;
|
||||
m_start_time = m_clock.now();
|
||||
}
|
||||
}
|
||||
|
||||
void stop() {
|
||||
if (m_active == true) {
|
||||
auto end_time = m_clock.now();
|
||||
m_last_time = end_time - m_start_time;
|
||||
m_active = false;
|
||||
}
|
||||
}
|
||||
|
||||
std::chrono::nanoseconds get_timer_value() const {
|
||||
if (m_active) {
|
||||
return (m_clock.now() - m_start_time);
|
||||
} else {
|
||||
return m_last_time;
|
||||
}
|
||||
}
|
||||
|
||||
size_t get_milliseconds() const {
|
||||
return std::chrono::duration_cast<std::chrono::milliseconds>(get_timer_value()).count();
|
||||
}
|
||||
|
||||
private:
|
||||
std::chrono::high_resolution_clock m_clock;
|
||||
std::chrono::time_point<std::chrono::high_resolution_clock> m_start_time;
|
||||
bool m_active = false;
|
||||
std::chrono::nanoseconds m_last_time = std::chrono::high_resolution_clock::duration::zero();
|
||||
};
|
||||
} // namespace
|
||||
|
||||
bool ov::pass::Manager::run_passes(shared_ptr<ov::Model> func) {
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
OV_ITT_SCOPED_TASK(ov::itt::domains::core, "pass::Manager::run_passes");
|
||||
|
|
@ -63,8 +100,8 @@ bool ov::pass::Manager::run_passes(shared_ptr<ov::Model> func) {
|
|||
ov::util::getenv_bool("NGRAPH_PROFILE_PASS_ENABLE") || ov::util::getenv_bool("OV_PROFILE_PASS_ENABLE");
|
||||
|
||||
size_t index = 0;
|
||||
ngraph::stopwatch pass_timer;
|
||||
ngraph::stopwatch overall_timer;
|
||||
stopwatch pass_timer;
|
||||
stopwatch overall_timer;
|
||||
overall_timer.start();
|
||||
bool pass_applied = false;
|
||||
bool function_changed = false;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// Copyright (C) 2018-2024 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
|
@ -12,6 +12,8 @@
|
|||
#include "openvino/util/log.hpp"
|
||||
|
||||
namespace ov {
|
||||
bool is_used(Node* node);
|
||||
|
||||
namespace pass {
|
||||
namespace pattern {
|
||||
MatcherState::MatcherState(Matcher* matcher)
|
||||
|
|
@ -83,8 +85,30 @@ void Matcher::capture(const std::set<Node*>& static_nodes) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
ov::NodeVector get_subgraph_outputs(const NodeVector& nodes, const NodeVector& exclusions, bool ignore_unused) {
|
||||
const std::set<std::shared_ptr<Node>> exclusions_set(exclusions.begin(), exclusions.end());
|
||||
const std::set<std::shared_ptr<Node>> nodes_set(nodes.begin(), nodes.end());
|
||||
|
||||
NodeVector outputs;
|
||||
|
||||
for (const auto& n : nodes) {
|
||||
if (exclusions_set.count(n) != 0)
|
||||
continue;
|
||||
|
||||
for (const auto& u : n->get_users()) {
|
||||
bool add_output = nodes_set.count(u) == 0 && (!ignore_unused || is_used(u.get()));
|
||||
if (add_output) {
|
||||
outputs.push_back(n);
|
||||
}
|
||||
}
|
||||
}
|
||||
return outputs;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
bool Matcher::is_contained_match(const NodeVector& exclusions, bool ignore_unused) {
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
if (exclusions.empty()) {
|
||||
NodeVector label_exclusions;
|
||||
for (const auto& entry : m_pattern_map) {
|
||||
|
|
@ -93,11 +117,10 @@ bool Matcher::is_contained_match(const NodeVector& exclusions, bool ignore_unuse
|
|||
label_exclusions.push_back(entry.second.get_node_shared_ptr());
|
||||
}
|
||||
}
|
||||
return ngraph::get_subgraph_outputs(get_matched_nodes(), label_exclusions, ignore_unused).size() < 2;
|
||||
return get_subgraph_outputs(get_matched_nodes(), label_exclusions, ignore_unused).size() < 2;
|
||||
}
|
||||
|
||||
return ngraph::get_subgraph_outputs(get_matched_nodes(), exclusions).size() < 2;
|
||||
OPENVINO_SUPPRESS_DEPRECATED_END
|
||||
return get_subgraph_outputs(get_matched_nodes(), exclusions, false).size() < 2;
|
||||
}
|
||||
|
||||
bool Matcher::match_value(const ov::Output<Node>& pattern_value, const ov::Output<Node>& graph_value) {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// Copyright (C) 2018-2024 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
|
@ -26,7 +26,7 @@ std::shared_ptr<ov::Model> ngraph::specialize_function(std::shared_ptr<ov::Model
|
|||
OPENVINO_ASSERT(f->get_parameters().size() == parameter_element_types.size());
|
||||
OPENVINO_ASSERT(f->get_parameters().size() == parameter_values.size());
|
||||
|
||||
NodeMap m;
|
||||
std::unordered_map<ov::Node*, std::shared_ptr<ov::Node>> m;
|
||||
|
||||
for (size_t i = 0; i < parameter_shapes.size(); i++) {
|
||||
OPENVINO_ASSERT(f->get_parameters()[i]->get_element_type().is_dynamic() ||
|
||||
|
|
@ -58,7 +58,7 @@ std::shared_ptr<ov::Model> ngraph::specialize_function(std::shared_ptr<ov::Model
|
|||
|
||||
ov::NodeVector cloned_dependencies;
|
||||
for (auto& dependency : old_node->get_control_dependencies()) {
|
||||
std::shared_ptr<Node> dependent = m.at(dependency.get());
|
||||
std::shared_ptr<ov::Node> dependent = m.at(dependency.get());
|
||||
if (find(cloned_dependencies.begin(), cloned_dependencies.end(), dependent) == cloned_dependencies.end()) {
|
||||
cloned_dependencies.push_back(dependent);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,393 +0,0 @@
|
|||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "ngraph/util.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <deque>
|
||||
#include <forward_list>
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
#include <numeric>
|
||||
#include <unordered_set>
|
||||
|
||||
#include "openvino/util/common_util.hpp"
|
||||
#include "openvino/util/log.hpp"
|
||||
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
|
||||
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;
|
||||
size_t index = 0;
|
||||
while (index < len) {
|
||||
out << std::hex << std::setw(8) << std::setfill('0') << index;
|
||||
for (int i = 0; i < 8; i++) {
|
||||
if (index + i < len) {
|
||||
out << " " << std::hex << std::setw(2) << std::setfill('0') << static_cast<uint32_t>(data[i]);
|
||||
} else {
|
||||
out << " ";
|
||||
}
|
||||
}
|
||||
out << " ";
|
||||
for (int i = 8; i < 16; i++) {
|
||||
if (index + i < len) {
|
||||
out << " " << std::hex << std::setw(2) << std::setfill('0') << static_cast<uint32_t>(data[i]);
|
||||
} else {
|
||||
out << " ";
|
||||
}
|
||||
}
|
||||
out << " ";
|
||||
for (int i = 0; i < 16; i++) {
|
||||
char ch = (index + i < len ? data[i] : ' ');
|
||||
out << ((ch < 32) ? '.' : ch);
|
||||
}
|
||||
out << "\n";
|
||||
data += 16;
|
||||
index += 16;
|
||||
}
|
||||
out.flags(flags);
|
||||
}
|
||||
|
||||
std::string to_lower(const std::string& s) {
|
||||
return ov::util::to_lower(s);
|
||||
}
|
||||
|
||||
std::string to_upper(const std::string& s) {
|
||||
return ov::util::to_upper(s);
|
||||
}
|
||||
|
||||
std::string trim(const std::string& s) {
|
||||
return ov::util::trim(s);
|
||||
}
|
||||
|
||||
std::vector<std::string> split(const std::string& src, char delimiter, bool do_trim) {
|
||||
return ov::util::split(src, delimiter, do_trim);
|
||||
}
|
||||
|
||||
size_t hash_combine(const std::vector<size_t>& list) {
|
||||
return ov::util::hash_combine(list);
|
||||
}
|
||||
|
||||
void* ngraph_malloc(size_t size) {
|
||||
auto ptr = malloc(size);
|
||||
if (size != 0 && !ptr) {
|
||||
OPENVINO_ERR << "malloc failed to allocate memory of size " << size;
|
||||
throw std::bad_alloc();
|
||||
}
|
||||
return ptr;
|
||||
}
|
||||
|
||||
void ngraph_free(void* ptr) {
|
||||
if (ptr) {
|
||||
free(ptr);
|
||||
}
|
||||
}
|
||||
|
||||
size_t round_up(size_t size, size_t alignment) {
|
||||
if (alignment == 0) {
|
||||
return size;
|
||||
}
|
||||
|
||||
size_t remainder = size % alignment;
|
||||
if (remainder == 0) {
|
||||
return size;
|
||||
}
|
||||
|
||||
return size + alignment - remainder;
|
||||
}
|
||||
|
||||
size_t stopwatch::get_call_count() const {
|
||||
return m_total_count;
|
||||
}
|
||||
|
||||
size_t stopwatch::get_seconds() const {
|
||||
return std::chrono::duration_cast<std::chrono::seconds>(get_timer_value()).count();
|
||||
}
|
||||
|
||||
size_t stopwatch::get_milliseconds() const {
|
||||
return std::chrono::duration_cast<std::chrono::milliseconds>(get_timer_value()).count();
|
||||
}
|
||||
|
||||
size_t stopwatch::get_microseconds() const {
|
||||
return std::chrono::duration_cast<std::chrono::microseconds>(get_timer_value()).count();
|
||||
}
|
||||
|
||||
size_t stopwatch::get_nanoseconds() const {
|
||||
return get_timer_value().count();
|
||||
}
|
||||
|
||||
std::chrono::nanoseconds stopwatch::get_timer_value() const {
|
||||
if (m_active) {
|
||||
return (m_clock.now() - m_start_time);
|
||||
} else {
|
||||
return m_last_time;
|
||||
}
|
||||
}
|
||||
|
||||
size_t stopwatch::get_total_seconds() const {
|
||||
return std::chrono::duration_cast<std::chrono::seconds>(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 stopwatch::get_total_microseconds() const {
|
||||
return std::chrono::duration_cast<std::chrono::microseconds>(m_total_time).count();
|
||||
}
|
||||
|
||||
size_t stopwatch::get_total_nanoseconds() const {
|
||||
return m_total_time.count();
|
||||
}
|
||||
|
||||
template <>
|
||||
float parse_string<float>(const std::string& s) {
|
||||
const char* tmp = s.c_str();
|
||||
char* end;
|
||||
float result = strtof(tmp, &end);
|
||||
if (*end != 0) {
|
||||
throw std::runtime_error("Could not parse literal '" + s + "'");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
template <>
|
||||
double parse_string<double>(const std::string& s) {
|
||||
const char* tmp = s.c_str();
|
||||
char* end;
|
||||
double result = strtod(tmp, &end);
|
||||
if (*end != 0) {
|
||||
throw std::runtime_error("Could not parse literal '" + s + "'");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
template <>
|
||||
int8_t parse_string<int8_t>(const std::string& s) {
|
||||
char* err;
|
||||
int8_t result = static_cast<int8_t>(strtol(s.c_str(), &err, 10));
|
||||
|
||||
// Check that (1) parsing succeeded and (2) the entire string was used.
|
||||
if (*err != 0) {
|
||||
throw std::runtime_error("Could not parse literal '" + s + "'");
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
template <>
|
||||
uint8_t parse_string<uint8_t>(const std::string& s) {
|
||||
char* err;
|
||||
int8_t result = static_cast<int8_t>(strtol(s.c_str(), &err, 10));
|
||||
|
||||
// Check that (1) parsing succeeded and (2) the entire string was used.
|
||||
if (*err != 0) {
|
||||
throw std::runtime_error("Could not parse literal '" + s + "'");
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
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;
|
||||
size_t end;
|
||||
extra = "";
|
||||
start = (version[0] == 'v' ? 1 : 0);
|
||||
end = version.find_first_of('.', start);
|
||||
std::string major_str = version.substr(start, end - start);
|
||||
start = end + 1;
|
||||
|
||||
end = version.find_first_of('.', start);
|
||||
std::string minor_str = version.substr(start, end - start);
|
||||
start = end + 1;
|
||||
|
||||
end = version.find_first_of("-+", start);
|
||||
std::string patch_str = version.substr(start, end - start);
|
||||
start = end;
|
||||
|
||||
if (start != std::string::npos) {
|
||||
extra = version.substr(start);
|
||||
}
|
||||
|
||||
size_t err;
|
||||
bool error = false;
|
||||
try {
|
||||
major = stoi(major_str, &err);
|
||||
if (err != major_str.size()) {
|
||||
error = true;
|
||||
}
|
||||
minor = stoi(minor_str, &err);
|
||||
if (err != minor_str.size()) {
|
||||
error = true;
|
||||
}
|
||||
patch = stoi(patch_str, &err);
|
||||
if (err != patch_str.size()) {
|
||||
error = true;
|
||||
}
|
||||
} catch (...) {
|
||||
error = true;
|
||||
}
|
||||
if (error) {
|
||||
OPENVINO_THROW("Error parsing version string '", version, "'");
|
||||
}
|
||||
}
|
||||
} // namespace ngraph
|
||||
|
||||
std::vector<float> read_float_vector(std::shared_ptr<ov::Tensor> tv) {
|
||||
std::vector<float> float_vec;
|
||||
ov::element::Type element_type = tv->get_element_type();
|
||||
|
||||
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 == 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 == 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 == 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 == 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 == 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 == 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 == 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 == 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 == 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 == 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 == 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));
|
||||
}
|
||||
} else {
|
||||
OPENVINO_THROW("Unsupported OpenVINO element type.");
|
||||
}
|
||||
|
||||
return float_vec;
|
||||
}
|
||||
|
||||
std::vector<int64_t> read_index_vector(std::shared_ptr<ov::Tensor> tv) {
|
||||
std::vector<int64_t> index_vec;
|
||||
ov::element::Type element_type = tv->get_element_type();
|
||||
|
||||
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 == 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 == 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 == 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 == 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 == 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 == 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 == 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 == ov::element::i64) {
|
||||
index_vec = read_vector<int64_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 == 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 == 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 == 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));
|
||||
}
|
||||
} else {
|
||||
OPENVINO_THROW("Unsupported OpenVINO element type.");
|
||||
}
|
||||
|
||||
return index_vec;
|
||||
}
|
||||
|
|
@ -14,6 +14,7 @@
|
|||
#include "openvino/op/gather.hpp"
|
||||
#include "openvino/op/negative.hpp"
|
||||
#include "openvino/op/ops.hpp"
|
||||
#include "openvino/util/common_util.hpp"
|
||||
#include "sequnce_generator.hpp"
|
||||
#include "validation_util.hpp"
|
||||
|
||||
|
|
@ -28,7 +29,7 @@ using ov::op::v0::Negative;
|
|||
} // namespace v0
|
||||
} // namespace op
|
||||
|
||||
Strides conv_default_strides(const Node* /* node */,
|
||||
Strides conv_default_strides(const ov::Node* /* node */,
|
||||
const ov::PartialShape& data_batch_shape,
|
||||
const ov::PartialShape& filters_shape) {
|
||||
size_t rank;
|
||||
|
|
@ -44,7 +45,7 @@ Strides conv_default_strides(const Node* /* node */,
|
|||
return Strides(rank, 1);
|
||||
}
|
||||
|
||||
CoordinateDiff conv_default_padding(const Node* /* node */,
|
||||
CoordinateDiff conv_default_padding(const ov::Node* /* node */,
|
||||
const ov::PartialShape& data_batch_shape,
|
||||
const ov::PartialShape& filters_shape) {
|
||||
size_t rank;
|
||||
|
|
@ -67,7 +68,7 @@ CoordinateDiff conv_default_padding(const Node* /* node */,
|
|||
// TODO(amprocte): The messages here would be a bit friendlier if we didn't say "after
|
||||
// padding/after dilation" for cases where there is actually no padding/dilation.
|
||||
//
|
||||
ov::PartialShape infer_windowed_reduction_output_shape(const Node* node,
|
||||
ov::PartialShape infer_windowed_reduction_output_shape(const ov::Node* node,
|
||||
const ov::PartialShape& data_shape,
|
||||
const Strides& data_dilation,
|
||||
const CoordinateDiff& data_padding_below,
|
||||
|
|
@ -182,10 +183,10 @@ ov::PartialShape infer_windowed_reduction_output_shape(const Node* node,
|
|||
".");
|
||||
|
||||
if (ceil_mode) {
|
||||
output_shape[i] =
|
||||
ceil_div(static_cast<size_t>(data_padded_dilated_dim) - static_cast<size_t>(window_dilated_dim),
|
||||
window_strides[i]) +
|
||||
1;
|
||||
output_shape[i] = ov::util::ceil_div(static_cast<size_t>(data_padded_dilated_dim) -
|
||||
static_cast<size_t>(window_dilated_dim),
|
||||
window_strides[i]) +
|
||||
1;
|
||||
} else {
|
||||
output_shape[i] =
|
||||
((static_cast<size_t>(data_padded_dilated_dim) - static_cast<size_t>(window_dilated_dim)) /
|
||||
|
|
@ -199,7 +200,7 @@ ov::PartialShape infer_windowed_reduction_output_shape(const Node* node,
|
|||
return output_shape;
|
||||
}
|
||||
|
||||
void validate_conv_params_spatial_dimensions(const Node* node,
|
||||
void validate_conv_params_spatial_dimensions(const ov::Node* node,
|
||||
const size_t num_spatial_dims,
|
||||
const ov::op::PadType auto_pad,
|
||||
Strides& strides,
|
||||
|
|
@ -232,7 +233,7 @@ void validate_conv_params_spatial_dimensions(const Node* node,
|
|||
//
|
||||
// Infers the output batch shape and element type for batched pooling fprop.
|
||||
//
|
||||
ov::PartialShape infer_batched_pooling_forward(const Node* node,
|
||||
ov::PartialShape infer_batched_pooling_forward(const ov::Node* node,
|
||||
const ov::PartialShape& data_batch_shape,
|
||||
const CoordinateDiff& data_padding_below,
|
||||
const CoordinateDiff& data_padding_above,
|
||||
|
|
@ -322,7 +323,7 @@ ov::PartialShape infer_batched_pooling_forward(const Node* node,
|
|||
return data_batch_output_shape;
|
||||
}
|
||||
|
||||
ov::PartialShape infer_slice_shape(const Node* node,
|
||||
ov::PartialShape infer_slice_shape(const ov::Node* node,
|
||||
const ov::PartialShape& input_shape,
|
||||
const std::vector<int64_t>& begin,
|
||||
const std::vector<int64_t>& end,
|
||||
|
|
@ -603,7 +604,7 @@ int64_t ov::util::clip(const int64_t& value, const int64_t& min, const int64_t&
|
|||
return std::min(std::max(value, min), max);
|
||||
};
|
||||
|
||||
std::shared_ptr<ov::op::v0::Constant> ov::util::constantfold_subgraph(const ov::Output<Node>& subgraph_sink) {
|
||||
std::shared_ptr<ov::op::v0::Constant> ov::util::constantfold_subgraph(const ov::Output<ov::Node>& subgraph_sink) {
|
||||
if (const auto& c = ov::as_type_ptr<op::v0::Constant>(subgraph_sink.get_node_shared_ptr()))
|
||||
return c;
|
||||
|
||||
|
|
@ -640,7 +641,7 @@ namespace ov {
|
|||
namespace util {
|
||||
using ov::op::v0::Constant;
|
||||
|
||||
std::shared_ptr<Constant> get_constant_from_source(const ov::Output<Node>& source) {
|
||||
std::shared_ptr<Constant> get_constant_from_source(const ov::Output<ov::Node>& source) {
|
||||
if (const auto& c = ov::as_type_ptr<Constant>(source.get_node_shared_ptr())) {
|
||||
return c;
|
||||
} else if (has_and_set_equal_bounds(source)) {
|
||||
|
|
@ -743,7 +744,7 @@ std::vector<ov::PartialShape> get_tensors_partial_shapes(const TensorVector& ten
|
|||
return shapes;
|
||||
}
|
||||
|
||||
std::vector<ov::PartialShape> get_node_input_partial_shapes(const Node& node) {
|
||||
std::vector<ov::PartialShape> get_node_input_partial_shapes(const ov::Node& node) {
|
||||
std::vector<ov::PartialShape> shapes;
|
||||
shapes.reserve(node.get_input_size());
|
||||
for (size_t i = 0; i < node.get_input_size(); ++i) {
|
||||
|
|
@ -758,7 +759,7 @@ bool is_rank_compatible_any_of(const Rank& r, std::initializer_list<Rank> others
|
|||
});
|
||||
}
|
||||
|
||||
bool evaluate_as_partial_shape(const ov::Output<Node>& output, ov::PartialShape& pshape) {
|
||||
bool evaluate_as_partial_shape(const ov::Output<ov::Node>& output, ov::PartialShape& pshape) {
|
||||
Tensor lb, ub;
|
||||
std::tie(lb, ub) = evaluate_both_bounds(output);
|
||||
bool shape_defined = false;
|
||||
|
|
@ -791,7 +792,7 @@ bool evaluate_as_partial_shape(const ov::Output<Node>& output, ov::PartialShape&
|
|||
return shape_defined;
|
||||
}
|
||||
|
||||
bool default_label_evaluator(const Node* node, TensorLabelVector& output_labels) {
|
||||
bool default_label_evaluator(const ov::Node* node, TensorLabelVector& output_labels) {
|
||||
return default_label_evaluator(node, {0}, output_labels);
|
||||
}
|
||||
|
||||
|
|
@ -820,7 +821,7 @@ std::vector<size_t> normalize_axes(const std::string& node_description,
|
|||
return new_axes;
|
||||
}
|
||||
|
||||
void normalize_axes(const Node* node, const int64_t& tensor_rank, std::vector<int64_t>& axes) {
|
||||
void normalize_axes(const ov::Node* node, const int64_t& tensor_rank, std::vector<int64_t>& axes) {
|
||||
const auto axis_checker = cmp::Between<int64_t, cmp::BOTH>(-tensor_rank, tensor_rank ? (tensor_rank - 1) : 0);
|
||||
const auto invalid_axis = std::find_if_not(axes.cbegin(), axes.cend(), axis_checker);
|
||||
NODE_VALIDATION_CHECK(node,
|
||||
|
|
@ -829,7 +830,7 @@ void normalize_axes(const Node* node, const int64_t& tensor_rank, std::vector<in
|
|||
std::for_each(axes.begin(), axes.end(), normalize_axis_to(tensor_rank));
|
||||
}
|
||||
|
||||
int64_t normalize_axis(const Node* node, std::int64_t axis, const Rank& tensor_rank) {
|
||||
int64_t normalize_axis(const ov::Node* node, std::int64_t axis, const Rank& tensor_rank) {
|
||||
return ov::util::normalize_axis(node->description(), axis, tensor_rank);
|
||||
}
|
||||
|
||||
|
|
@ -853,7 +854,7 @@ int64_t normalize_axis(const std::string& node_description, std::int64_t axis, c
|
|||
tensor_rank_value ? (tensor_rank_value - 1) : 0);
|
||||
}
|
||||
|
||||
int64_t normalize_axis(const Node* node,
|
||||
int64_t normalize_axis(const ov::Node* node,
|
||||
std::int64_t axis,
|
||||
std::uint64_t tensor_rank,
|
||||
std::int64_t axis_range_min,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// Copyright (C) 2018-2024 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
|
@ -9,7 +9,6 @@
|
|||
#include "common_test_utils/graph_comparator.hpp"
|
||||
#include "common_test_utils/test_tools.hpp"
|
||||
#include "common_test_utils/type_prop.hpp"
|
||||
#include "ngraph/graph_util.hpp"
|
||||
#include "openvino/core/except.hpp"
|
||||
#include "openvino/op/abs.hpp"
|
||||
#include "openvino/op/acos.hpp"
|
||||
|
|
@ -128,9 +127,8 @@ TEST(build_graph, no_arg_construction) {
|
|||
add1->set_argument(0, acos0);
|
||||
add1->set_argument(1, abs0);
|
||||
NodeVector ops{arg0, arg1, add0, abs0, acos0, add1};
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
ngraph::validate_nodes_and_infer_types(ops);
|
||||
OPENVINO_SUPPRESS_DEPRECATED_END
|
||||
for (const auto& op : ov::topological_sort(ops))
|
||||
op->revalidate_and_infer_types();
|
||||
ASSERT_EQ(add1->get_output_shape(0), Shape{7});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// Copyright (C) 2018-2024 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
|
@ -588,14 +588,21 @@ TEST(pattern, test_sort) {
|
|||
}
|
||||
|
||||
TEST(pattern, label_on_skip) {
|
||||
const auto zero = std::string{"0"};
|
||||
const auto is_zero = [&zero](const Output<Node>& node) {
|
||||
if (const auto c = as_type_ptr<op::v0::Constant>(node.get_node_shared_ptr())) {
|
||||
return (c->get_all_data_elements_bitwise_identical() && c->convert_value_to_string(0) == zero);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
Shape shape{2, 2};
|
||||
auto a = make_shared<op::v0::Parameter>(element::i32, shape);
|
||||
auto b = make_shared<op::v0::Parameter>(element::i32, Shape{});
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
auto iconst = ngraph::make_zero(element::i32, Shape{});
|
||||
auto iconst = op::v0::Constant::create(element::i32, Shape{}, {0.0f});
|
||||
auto label = std::make_shared<pattern::op::Label>(iconst);
|
||||
auto const_label = std::make_shared<pattern::op::Label>(iconst, ngraph::is_zero, NodeVector{iconst});
|
||||
OPENVINO_SUPPRESS_DEPRECATED_END
|
||||
auto const_label = std::make_shared<pattern::op::Label>(iconst, is_zero, NodeVector{iconst});
|
||||
|
||||
auto bcst_pred = [](std::shared_ptr<Node> n) {
|
||||
return ov::as_type_ptr<op::v1::Broadcast>(n) != nullptr;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// Copyright (C) 2018-2024 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// Copyright (C) 2018-2024 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
|
@ -9,9 +9,9 @@
|
|||
#include <array>
|
||||
|
||||
#include "common_test_utils/type_prop.hpp"
|
||||
#include "ngraph/util.hpp"
|
||||
#include "openvino/op/constant.hpp"
|
||||
#include "openvino/op/space_to_batch.hpp"
|
||||
#include "openvino/util/common_util.hpp"
|
||||
|
||||
using namespace std;
|
||||
using namespace testing;
|
||||
|
|
@ -377,7 +377,7 @@ TEST(type_prop, batch_to_space_output_dynamic_shape_5D_when_batch_is_dynamic) {
|
|||
auto batch_to_space = make_shared<ov::op::v1::BatchToSpace>(data, block_shape, crops_begin, crops_end);
|
||||
|
||||
EXPECT_EQ(batch_to_space->get_output_partial_shape(0),
|
||||
(ov::PartialShape{{ngraph::ceil_div(959, (6 * 5 * 16)), 962 / (6 * 5 * 16)},
|
||||
(ov::PartialShape{{ov::util::ceil_div(959, (6 * 5 * 16)), 962 / (6 * 5 * 16)},
|
||||
{2 * 6 - 2 - 2, 34 * 6 - 2 - 2},
|
||||
{9 * 5 - 1, 21 * 5 - 1},
|
||||
{100, 162},
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// Copyright (C) 2018-2024 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
|
@ -7,7 +7,7 @@
|
|||
#include <gtest/gtest.h>
|
||||
|
||||
#include "common_test_utils/type_prop.hpp"
|
||||
#include "ngraph/util.hpp"
|
||||
#include "openvino/util/common_util.hpp"
|
||||
|
||||
using namespace std;
|
||||
using namespace ov;
|
||||
|
|
@ -49,7 +49,7 @@ TEST(type_prop, depth_to_space_output_dynamicshape_block_first_5D_when_depth_is_
|
|||
|
||||
ASSERT_EQ(depth_to_space->get_output_partial_shape(0),
|
||||
(PartialShape{{2, 10},
|
||||
{ngraph::ceil_div(81, 27), 82 / 27},
|
||||
{ov::util::ceil_div(81, 27), 82 / 27},
|
||||
{3 * 3, 7 * 3},
|
||||
{423 * 3, 3000 * 3},
|
||||
{235 * 3, 1345 * 3}}));
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// Copyright (C) 2018-2024 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// Copyright (C) 2018-2024 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
|
@ -231,7 +231,7 @@ template <typename T>
|
|||
std::shared_ptr<ov::op::v0::Constant> Node::Impl::get_attribute_as_constant(const std::string& name) const {
|
||||
const auto value = get_attribute_value<T>(name);
|
||||
const ov::element::Type type = ov::element::from<T>();
|
||||
return std::make_shared<ov::op::v0::Constant>(type, Shape{}, value);
|
||||
return std::make_shared<ov::op::v0::Constant>(type, ov::Shape{}, value);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
|
|
@ -239,7 +239,7 @@ std::shared_ptr<ov::op::v0::Constant> Node::Impl::get_attribute_as_constant(cons
|
|||
T default_value) const {
|
||||
const auto value = get_attribute_value<T>(name, default_value);
|
||||
const ov::element::Type type = ov::element::from<T>();
|
||||
return std::make_shared<ov::op::v0::Constant>(type, Shape{}, value);
|
||||
return std::make_shared<ov::op::v0::Constant>(type, ov::Shape{}, value);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
|
|
@ -248,7 +248,7 @@ std::shared_ptr<ov::op::v0::Constant> Node::Impl::get_attribute_as_constant(cons
|
|||
ov::element::Type type) const {
|
||||
const auto value = get_attribute_value<T>(name, default_value);
|
||||
return std::make_shared<ov::op::v0::Constant>(type == ov::element::undefined ? ov::element::from<T>() : type,
|
||||
Shape{},
|
||||
ov::Shape{},
|
||||
value);
|
||||
}
|
||||
|
||||
|
|
@ -257,7 +257,7 @@ std::shared_ptr<ov::op::v0::Constant> Node::Impl::get_attribute_as_constant(cons
|
|||
ov::element::Type type) const {
|
||||
const auto value = get_attribute_value<T>(name);
|
||||
return std::make_shared<ov::op::v0::Constant>(type == ov::element::undefined ? ov::element::from<T>() : type,
|
||||
Shape{},
|
||||
ov::Shape{},
|
||||
value);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// Copyright (C) 2018-2024 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
|
@ -23,11 +23,11 @@ public:
|
|||
: m_values{sparse_tensor.values(), model_dir, mmap_cache},
|
||||
m_indices{sparse_tensor.indices(), model_dir, mmap_cache},
|
||||
m_shape{std::begin(sparse_tensor.dims()), std::end(sparse_tensor.dims())} {
|
||||
if (m_shape == Shape{0}) {
|
||||
if (m_shape == ov::Shape{0}) {
|
||||
// It's possible to construct a sparse tensor in ONNX with "dims: 0" property
|
||||
// Such tensor contains a scalar. This results in a Shape{0} stored in m_shape.
|
||||
// In OpenVINO a scalar is represented with Shape{} and thus this replacement.
|
||||
m_shape = Shape{};
|
||||
m_shape = ov::Shape{};
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -37,7 +37,7 @@ public:
|
|||
SparseTensor& operator=(const SparseTensor&) = delete;
|
||||
SparseTensor& operator=(SparseTensor&&) = delete;
|
||||
|
||||
const Shape& get_shape() const {
|
||||
const ov::Shape& get_shape() const {
|
||||
return m_shape;
|
||||
}
|
||||
|
||||
|
|
@ -60,7 +60,7 @@ public:
|
|||
private:
|
||||
Tensor m_values;
|
||||
Tensor m_indices;
|
||||
Shape m_shape;
|
||||
ov::Shape m_shape;
|
||||
};
|
||||
|
||||
inline std::ostream& operator<<(std::ostream& outs, const SparseTensor& tensor) {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// Copyright (C) 2018-2024 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
|
@ -92,11 +92,11 @@ public:
|
|||
m_shape{std::begin(tensor.dims()), std::end(tensor.dims())},
|
||||
m_model_dir{model_dir},
|
||||
m_mmap_cache{mmap_cache} {
|
||||
if (m_shape == Shape{0}) {
|
||||
if (m_shape == ov::Shape{0}) {
|
||||
// It's possible to construct a tensor in ONNX with "dims: 0" property
|
||||
// Such tensor contains a scalar. This results in a Shape{0} stored in m_shape.
|
||||
// In OpenVINO a scalar is represented with Shape{} and thus this replacement.
|
||||
m_shape = Shape{};
|
||||
m_shape = ov::Shape{};
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -106,7 +106,7 @@ public:
|
|||
Tensor& operator=(const Tensor&) = delete;
|
||||
Tensor& operator=(Tensor&&) = delete;
|
||||
|
||||
const Shape& get_shape() const {
|
||||
const ov::Shape& get_shape() const {
|
||||
return m_shape;
|
||||
}
|
||||
template <typename T>
|
||||
|
|
@ -331,7 +331,7 @@ private:
|
|||
}
|
||||
|
||||
const ONNX_NAMESPACE::TensorProto* m_tensor_proto;
|
||||
Shape m_shape;
|
||||
ov::Shape m_shape;
|
||||
std::string m_model_dir;
|
||||
detail::MappedMemoryHandles m_mmap_cache;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
//*****************************************************************************
|
||||
// Copyright 2017-2022 Intel Corporation
|
||||
// Copyright (C) 2017-2024 Intel Corporation
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
|
|
@ -18,15 +18,15 @@
|
|||
|
||||
namespace ngraph {
|
||||
namespace frontend {
|
||||
std::shared_ptr<Node> ONNXFrameworkNode::clone_with_new_inputs(const ov::OutputVector& inputs) const {
|
||||
std::shared_ptr<ov::Node> ONNXFrameworkNode::clone_with_new_inputs(const ov::OutputVector& inputs) const {
|
||||
return std::make_shared<ONNXFrameworkNode>(m_node, inputs);
|
||||
}
|
||||
|
||||
std::shared_ptr<Node> ONNXSubgraphFrameworkNode::clone_with_new_inputs(const ov::OutputVector& inputs) const {
|
||||
std::shared_ptr<ov::Node> ONNXSubgraphFrameworkNode::clone_with_new_inputs(const ov::OutputVector& inputs) const {
|
||||
return std::make_shared<ONNXSubgraphFrameworkNode>(m_node, m_models, inputs);
|
||||
}
|
||||
|
||||
std::shared_ptr<Node> NotSupportedONNXNode::clone_with_new_inputs(const ov::OutputVector& inputs) const {
|
||||
std::shared_ptr<ov::Node> NotSupportedONNXNode::clone_with_new_inputs(const ov::OutputVector& inputs) const {
|
||||
const auto& attrs = get_attrs();
|
||||
std::string error_message = attrs.at(failed_conversion_key);
|
||||
return std::make_shared<NotSupportedONNXNode>(inputs,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
//*****************************************************************************
|
||||
// Copyright 2017-2022 Intel Corporation
|
||||
// Copyright (C) 2017-2024 Intel Corporation
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
|
|
@ -56,7 +56,7 @@ public:
|
|||
return ov_nodes;
|
||||
}
|
||||
|
||||
virtual std::shared_ptr<Node> clone_with_new_inputs(const ov::OutputVector& inputs) const override;
|
||||
virtual std::shared_ptr<ov::Node> clone_with_new_inputs(const ov::OutputVector& inputs) const override;
|
||||
|
||||
virtual bool visit_attributes(ov::AttributeVisitor& visitor) override {
|
||||
// TODO: implement reading as well, now it work for serialization only
|
||||
|
|
@ -90,7 +90,7 @@ public:
|
|||
return m_models;
|
||||
}
|
||||
|
||||
virtual std::shared_ptr<Node> clone_with_new_inputs(const ov::OutputVector& inputs) const override;
|
||||
virtual std::shared_ptr<ov::Node> clone_with_new_inputs(const ov::OutputVector& inputs) const override;
|
||||
|
||||
private:
|
||||
std::vector<std::shared_ptr<ov::Model>> m_models;
|
||||
|
|
@ -123,7 +123,7 @@ public:
|
|||
return attrs[failed_conversion_key];
|
||||
}
|
||||
|
||||
virtual std::shared_ptr<Node> clone_with_new_inputs(const ov::OutputVector& inputs) const override;
|
||||
virtual std::shared_ptr<ov::Node> clone_with_new_inputs(const ov::OutputVector& inputs) const override;
|
||||
virtual bool visit_attributes(ov::AttributeVisitor& visitor) override;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// Copyright (C) 2018-2024 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
|
@ -65,12 +65,12 @@ ov::OutputVector aten(const Node& node) {
|
|||
const auto data_type = emb_tbl_in.get_element_type();
|
||||
const auto ind_type = indices_in.get_element_type();
|
||||
|
||||
const auto zero_const = std::make_shared<v0::Constant>(ind_type, Shape{}, 0);
|
||||
const auto zero_const = std::make_shared<v0::Constant>(ind_type, ov::Shape{}, 0);
|
||||
|
||||
// Shape aligned node, filled with zeros
|
||||
const auto zero_of_data_type_const = std::make_shared<v0::Constant>(data_type, Shape{1}, 0);
|
||||
const auto zero_of_data_type_const = std::make_shared<v0::Constant>(data_type, ov::Shape{1}, 0);
|
||||
const auto weights_shape_node = std::make_shared<v3::ShapeOf>(emb_tbl_in, ind_type);
|
||||
const auto weights_last_dim_idx = std::make_shared<v0::Constant>(ov::element::i32, Shape{1}, -1);
|
||||
const auto weights_last_dim_idx = std::make_shared<v0::Constant>(ov::element::i32, ov::Shape{1}, -1);
|
||||
const auto weights_last_dim =
|
||||
std::make_shared<v8::Gather>(weights_shape_node, weights_last_dim_idx, zero_const);
|
||||
const auto zero_col_node = std::make_shared<v3::Broadcast>(zero_of_data_type_const, weights_last_dim);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// Copyright (C) 2018-2024 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
|
@ -31,7 +31,8 @@ ov::OutputVector bitshift(const Node& node) {
|
|||
"attribute. Given: ",
|
||||
direction);
|
||||
|
||||
auto shift = std::make_shared<v1::Power>(v0::Constant::create(input_y.get_element_type(), Shape{1}, {2}), input_y);
|
||||
auto shift =
|
||||
std::make_shared<v1::Power>(v0::Constant::create(input_y.get_element_type(), ov::Shape{1}, {2}), input_y);
|
||||
|
||||
if (direction == "RIGHT") {
|
||||
return {std::make_shared<v1::Divide>(input_x, shift)};
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// Copyright (C) 2018-2024 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
|
@ -39,6 +39,7 @@
|
|||
#include "ov_models/ov_builders/split.hpp"
|
||||
|
||||
using namespace ov::op;
|
||||
using ov::Shape;
|
||||
|
||||
namespace ngraph {
|
||||
namespace onnx_import {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// Copyright (C) 2018-2024 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
|
@ -17,6 +17,7 @@
|
|||
#include "openvino/op/slice.hpp"
|
||||
|
||||
using namespace ov::op;
|
||||
using ov::Shape;
|
||||
|
||||
namespace ngraph {
|
||||
namespace onnx_import {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// Copyright (C) 2018-2024 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
|
@ -20,6 +20,7 @@
|
|||
#include "openvino/op/tanh.hpp"
|
||||
|
||||
using namespace ov::op;
|
||||
using ov::Shape;
|
||||
|
||||
namespace ngraph {
|
||||
namespace onnx_import {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// Copyright (C) 2018-2024 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
|
@ -16,6 +16,7 @@
|
|||
#include "openvino/op/relu.hpp"
|
||||
|
||||
using namespace ov::op;
|
||||
using ov::Shape;
|
||||
|
||||
namespace ngraph {
|
||||
namespace onnx_import {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// Copyright (C) 2018-2024 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
|
@ -11,6 +11,7 @@
|
|||
#include "openvino/op/mvn.hpp"
|
||||
|
||||
using namespace ov::op;
|
||||
using ov::Shape;
|
||||
|
||||
namespace ngraph {
|
||||
namespace onnx_import {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// Copyright (C) 2018-2024 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
|
@ -11,6 +11,7 @@
|
|||
#include "ov_models/ov_builders/reshape.hpp"
|
||||
|
||||
using namespace ov::op;
|
||||
using ov::Shape;
|
||||
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
namespace ngraph {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// Copyright (C) 2018-2024 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
|
@ -13,6 +13,7 @@
|
|||
#include "openvino/op/constant.hpp"
|
||||
|
||||
using namespace ov::op;
|
||||
using ov::Shape;
|
||||
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
namespace ngraph {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// Copyright (C) 2018-2024 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
|
@ -21,6 +21,8 @@
|
|||
|
||||
using namespace ov::op;
|
||||
using ov::CoordinateDiff;
|
||||
using ov::Shape;
|
||||
using ov::Strides;
|
||||
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
namespace ngraph {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// Copyright (C) 2018-2024 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
|
@ -11,6 +11,7 @@
|
|||
#include "openvino/op/strided_slice.hpp"
|
||||
|
||||
using namespace ov::op;
|
||||
using ov::Shape;
|
||||
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
namespace ngraph {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// Copyright (C) 2018-2024 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
|
@ -27,7 +27,7 @@ ov::OutputVector cum_sum(const Node& node) {
|
|||
const auto& axis_shape = inputs.at(1).get_partial_shape();
|
||||
axis = axis_shape.is_dynamic() ? inputs.at(1) : ngraph::onnx_import::reshape::interpret_as_scalar(inputs.at(1));
|
||||
} else {
|
||||
axis = v0::Constant::create(ov::element::i64, Shape{}, {0}); // default
|
||||
axis = v0::Constant::create(ov::element::i64, ov::Shape{}, {0}); // default
|
||||
}
|
||||
return ov::OutputVector{std::make_shared<v0::CumSum>(data, axis, exclusive, reverse)};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// Copyright (C) 2018-2024 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
|
@ -131,7 +131,7 @@ std::shared_ptr<ov::Node> reshape_input(const ov::Output<ov::Node>& input,
|
|||
target_dims.push_back(1);
|
||||
}
|
||||
|
||||
const auto target_shape = v0::Constant::create(ov::element::i64, Shape{target_dims.size()}, target_dims);
|
||||
const auto target_shape = v0::Constant::create(ov::element::i64, ov::Shape{target_dims.size()}, target_dims);
|
||||
|
||||
return std::make_shared<v1::Reshape>(input, target_shape, true);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// Copyright (C) 2018-2024 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
|
@ -25,8 +25,9 @@ ov::OutputVector build_dropout(const Node& node, bool training_mode) {
|
|||
const bool return_mask = node.get_outputs_size() > 1;
|
||||
|
||||
if (return_mask) {
|
||||
const auto mask = std::make_shared<v3::Broadcast>(v0::Constant::create(ov::element::boolean, Shape{}, {true}),
|
||||
std::make_shared<v3::ShapeOf>(input_data));
|
||||
const auto mask =
|
||||
std::make_shared<v3::Broadcast>(v0::Constant::create(ov::element::boolean, ov::Shape{}, {true}),
|
||||
std::make_shared<v3::ShapeOf>(input_data));
|
||||
return {input_data, mask};
|
||||
} else {
|
||||
return {input_data};
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// Copyright (C) 2018-2024 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
|
@ -23,6 +23,7 @@
|
|||
#include "utils/common.hpp"
|
||||
|
||||
using namespace ov::op;
|
||||
using ov::Shape;
|
||||
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
namespace ngraph {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// Copyright (C) 2018-2024 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
|
@ -9,6 +9,7 @@
|
|||
#include "utils/common.hpp"
|
||||
|
||||
using namespace ov::op;
|
||||
using ov::Shape;
|
||||
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
namespace ngraph {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// Copyright (C) 2018-2024 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
|
@ -23,7 +23,7 @@ inline ov::OutputVector gather(const Node& node) {
|
|||
|
||||
return {std::make_shared<ov::op::v8::Gather>(data,
|
||||
indices,
|
||||
ov::op::v0::Constant::create(ov::element::i64, Shape{}, {axis}))};
|
||||
ov::op::v0::Constant::create(ov::element::i64, ov::Shape{}, {axis}))};
|
||||
}
|
||||
|
||||
} // namespace set_1
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// Copyright (C) 2018-2024 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
|
@ -11,6 +11,7 @@
|
|||
#include "ov_models/ov_builders/reshape.hpp"
|
||||
|
||||
using namespace ov::op;
|
||||
using ov::Shape;
|
||||
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
namespace ngraph {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// Copyright (C) 2018-2024 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
|
@ -11,6 +11,7 @@
|
|||
#include "openvino/op/squeeze.hpp"
|
||||
|
||||
using namespace ov::op;
|
||||
using ov::Shape;
|
||||
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
namespace ngraph {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// Copyright (C) 2018-2024 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
|
@ -11,6 +11,7 @@
|
|||
#include "openvino/op/squeeze.hpp"
|
||||
|
||||
using namespace ov::op;
|
||||
using ov::Shape;
|
||||
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
namespace ngraph {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// Copyright (C) 2018-2024 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
|
@ -14,6 +14,7 @@
|
|||
#include "openvino/op/unsqueeze.hpp"
|
||||
|
||||
using namespace ov::op;
|
||||
using ov::Shape;
|
||||
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
namespace ngraph {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// Copyright (C) 2018-2024 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
|
@ -14,6 +14,7 @@
|
|||
#include "utils/recurrent.hpp"
|
||||
|
||||
using namespace ov::op;
|
||||
using ov::Shape;
|
||||
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
namespace ngraph {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// Copyright (C) 2018-2024 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
|
@ -8,6 +8,7 @@
|
|||
#include "openvino/op/hard_sigmoid.hpp"
|
||||
|
||||
using namespace ov::op;
|
||||
using ov::Shape;
|
||||
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
namespace ngraph {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// Copyright (C) 2018-2024 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
|
@ -18,6 +18,7 @@
|
|||
#include "validation_util.hpp"
|
||||
|
||||
using namespace ov::op;
|
||||
using ov::Shape;
|
||||
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
namespace ngraph {
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ using namespace ov::op;
|
|||
using namespace ov::op::v0;
|
||||
using namespace ov::op::v1;
|
||||
using namespace ov::op::v8;
|
||||
using ov::Shape;
|
||||
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
namespace ngraph {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// Copyright (C) 2018-2024 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
|
@ -9,6 +9,7 @@
|
|||
#include "openvino/op/prelu.hpp"
|
||||
|
||||
using namespace ov::op;
|
||||
using ov::Shape;
|
||||
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
namespace ngraph {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// Copyright (C) 2018-2024 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
|
@ -14,6 +14,7 @@
|
|||
#include "validation_util.hpp"
|
||||
|
||||
using namespace ov::op;
|
||||
using ov::Shape;
|
||||
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
namespace ngraph {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// Copyright (C) 2018-2024 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
|
@ -14,6 +14,7 @@
|
|||
#include "utils/common.hpp"
|
||||
|
||||
using namespace ov::op;
|
||||
using ov::Shape;
|
||||
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
namespace ngraph {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// Copyright (C) 2018-2024 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
|
@ -19,6 +19,7 @@
|
|||
#include "ov_models/ov_builders/split.hpp"
|
||||
|
||||
using namespace ov::op;
|
||||
using ov::Shape;
|
||||
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
namespace ngraph {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// Copyright (C) 2018-2024 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
|
@ -26,7 +26,7 @@ ov::OutputVector max_roi_pool(const Node& node) {
|
|||
const auto pooled_shape = node.get_attribute_value<std::vector<size_t>>("pooled_shape");
|
||||
const auto spatial_scale = node.get_attribute_value<float>("spatial_scale", 1.0);
|
||||
|
||||
return {std::make_shared<v0::ROIPooling>(X, rois, Shape(pooled_shape), spatial_scale, "max")};
|
||||
return {std::make_shared<v0::ROIPooling>(X, rois, ov::Shape(pooled_shape), spatial_scale, "max")};
|
||||
}
|
||||
} // namespace set_1
|
||||
} // namespace op
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// Copyright (C) 2018-2024 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
|
@ -18,7 +18,7 @@ namespace op {
|
|||
namespace set_1 {
|
||||
ov::OutputVector mean(const Node& node) {
|
||||
auto sum = variadic::make_ng_variadic_op<v1::Add>(node).front();
|
||||
auto count = v0::Constant::create(sum.get_element_type(), Shape{}, {node.get_ng_inputs().size()});
|
||||
auto count = v0::Constant::create(sum.get_element_type(), ov::Shape{}, {node.get_ng_inputs().size()});
|
||||
|
||||
return {std::make_shared<v1::Divide>(sum, count)};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// Copyright (C) 2018-2024 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
|
@ -31,7 +31,7 @@ ov::OutputVector mean_variance_normalization(const Node& node) {
|
|||
auto axes = node.get_attribute_value<std::vector<std::int64_t>>("axes", {0, 2, 3});
|
||||
const std::vector<std::size_t> normalized_axes =
|
||||
ov::util::normalize_axes(node.get_description(), axes, data.get_partial_shape().rank());
|
||||
auto const_axes = v0::Constant::create(ov::element::i64, Shape{normalized_axes.size()}, normalized_axes);
|
||||
auto const_axes = v0::Constant::create(ov::element::i64, ov::Shape{normalized_axes.size()}, normalized_axes);
|
||||
return {std::make_shared<v6::MVN>(data, const_axes, true, 1e-09f, ov::op::MVNEpsMode::OUTSIDE_SQRT)};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// Copyright (C) 2018-2024 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
|
@ -21,9 +21,9 @@ inline ov::OutputVector nms_rotated(const Node& node) {
|
|||
auto iou_threshold = node.get_attribute_value<float>("iou_threshold");
|
||||
auto score_threshold = node.get_attribute_value<float>("score_threshold");
|
||||
auto max_output_boxes_per_class =
|
||||
ov::op::v0::Constant::create(ov::element::i64, Shape{1}, {std::numeric_limits<int64_t>::max()});
|
||||
auto iou_threshold_const = ov::op::v0::Constant::create(ov::element::f32, Shape{}, {iou_threshold});
|
||||
auto score_threshold_const = ov::op::v0::Constant::create(ov::element::f32, Shape{}, {score_threshold});
|
||||
ov::op::v0::Constant::create(ov::element::i64, ov::Shape{1}, {std::numeric_limits<int64_t>::max()});
|
||||
auto iou_threshold_const = ov::op::v0::Constant::create(ov::element::f32, ov::Shape{}, {iou_threshold});
|
||||
auto score_threshold_const = ov::op::v0::Constant::create(ov::element::f32, ov::Shape{}, {score_threshold});
|
||||
|
||||
auto nms = std::make_shared<ov::op::v13::NMSRotated>(node.get_ng_inputs().at(0),
|
||||
node.get_ng_inputs().at(1),
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// Copyright (C) 2018-2024 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
|
@ -10,6 +10,7 @@
|
|||
#include "utils/reshape.hpp"
|
||||
|
||||
using namespace ov::op;
|
||||
using ov::Shape;
|
||||
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
namespace ngraph {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2022 Intel Corporation
|
||||
// Copyright (C) 2022-2024 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
|
@ -12,6 +12,7 @@
|
|||
#include "openvino/op/shape_of.hpp"
|
||||
|
||||
using namespace ov::op;
|
||||
using ov::Shape;
|
||||
|
||||
namespace ngraph {
|
||||
namespace onnx_import {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// Copyright (C) 2018-2024 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
|
@ -13,6 +13,7 @@
|
|||
#include "utils/common.hpp"
|
||||
|
||||
using namespace ov::op;
|
||||
using ov::Shape;
|
||||
|
||||
namespace ngraph {
|
||||
namespace onnx_import {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// Copyright (C) 2018-2024 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
|
@ -15,6 +15,7 @@
|
|||
#include "openvino/op/unsqueeze.hpp"
|
||||
|
||||
using namespace ov::op;
|
||||
using ov::Shape;
|
||||
|
||||
namespace ngraph {
|
||||
namespace onnx_import {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// Copyright (C) 2018-2024 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
|
@ -10,6 +10,7 @@
|
|||
#include "utils/reshape.hpp"
|
||||
|
||||
using namespace ov::op;
|
||||
using ov::Shape;
|
||||
|
||||
namespace ngraph {
|
||||
namespace onnx_import {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// Copyright (C) 2018-2024 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
|
@ -16,6 +16,7 @@
|
|||
#include "validation_util.hpp"
|
||||
|
||||
using namespace ov::op;
|
||||
using ov::Shape;
|
||||
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
namespace ngraph {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// Copyright (C) 2018-2024 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
|
@ -10,6 +10,7 @@
|
|||
#include "utils/common.hpp"
|
||||
|
||||
using namespace ov::op;
|
||||
using ov::Shape;
|
||||
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
namespace ngraph {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// Copyright (C) 2018-2024 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
|
@ -9,6 +9,7 @@
|
|||
#include "utils/common.hpp"
|
||||
|
||||
using namespace ov::op;
|
||||
using ov::Shape;
|
||||
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
namespace ngraph {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// Copyright (C) 2018-2024 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
|
@ -8,6 +8,7 @@
|
|||
#include "openvino/op/divide.hpp"
|
||||
|
||||
using namespace ov::op;
|
||||
using ov::Shape;
|
||||
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
namespace ngraph {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// Copyright (C) 2018-2024 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
|
@ -24,6 +24,7 @@
|
|||
#include "utils/common.hpp"
|
||||
|
||||
using namespace ov::op;
|
||||
using ov::Shape;
|
||||
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
namespace ngraph {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// Copyright (C) 2018-2024 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
|
@ -49,7 +49,7 @@ ov::OutputVector scan_to_tensor_iterator(const ov::OutputVector& node_inputs,
|
|||
for (int64_t i = 0; i < num_scan_inputs; ++i) {
|
||||
const auto in_idx = num_initial_values + i;
|
||||
auto axis = scan_input_axes[i];
|
||||
const auto axis_node = v0::Constant::create(ov::element::i64, Shape{1}, {axis});
|
||||
const auto axis_node = v0::Constant::create(ov::element::i64, ov::Shape{1}, {axis});
|
||||
auto shape = node_inputs[in_idx + in_offset].get_partial_shape();
|
||||
if (shape.rank().is_static()) {
|
||||
axis = ov::util::normalize_axis(node_description,
|
||||
|
|
@ -70,7 +70,7 @@ ov::OutputVector scan_to_tensor_iterator(const ov::OutputVector& node_inputs,
|
|||
for (size_t i = 0; i < num_scan_outputs; ++i) {
|
||||
const auto out_idx = num_initial_values + i;
|
||||
const auto axis = scan_output_axes[i];
|
||||
const auto axis_node = v0::Constant::create(ov::element::i64, Shape{1}, {axis});
|
||||
const auto axis_node = v0::Constant::create(ov::element::i64, ov::Shape{1}, {axis});
|
||||
body_outputs[out_idx] = std::make_shared<v0::Unsqueeze>(body_outputs[out_idx], axis_node);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// Copyright (C) 2018-2024 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
|
@ -19,9 +19,9 @@ ov::OutputVector selu(const Node& node) {
|
|||
auto alpha = node.get_attribute_value<double>("alpha", 1.67326319217681884765625);
|
||||
auto gamma = node.get_attribute_value<double>("gamma", 1.05070102214813232421875);
|
||||
|
||||
auto alpha_node = v0::Constant::create(data.get_element_type(), Shape{}, {alpha});
|
||||
auto alpha_node = v0::Constant::create(data.get_element_type(), ov::Shape{}, {alpha});
|
||||
|
||||
auto gamma_node = v0::Constant::create(data.get_element_type(), Shape{}, {gamma});
|
||||
auto gamma_node = v0::Constant::create(data.get_element_type(), ov::Shape{}, {gamma});
|
||||
|
||||
return {std::make_shared<v0::Selu>(data, alpha_node, gamma_node)};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// Copyright (C) 2018-2024 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
|
@ -30,16 +30,16 @@ ov::OutputVector shrink(const Node& node) {
|
|||
std::shared_ptr<v0::Constant> negative_lambd;
|
||||
const auto input_element_type = input.get_element_type();
|
||||
if (input_element_type.is_signed()) {
|
||||
negative_lambd = v0::Constant::create(input_element_type, Shape{}, {-lambd});
|
||||
negative_lambd = v0::Constant::create(input_element_type, ov::Shape{}, {-lambd});
|
||||
} else {
|
||||
// Passing -lambd to unsigned type constant will cause an overflow.
|
||||
// For unsigned types the lowest possible value is 0.
|
||||
negative_lambd = v0::Constant::create(input_element_type, Shape{}, {0});
|
||||
negative_lambd = v0::Constant::create(input_element_type, ov::Shape{}, {0});
|
||||
}
|
||||
|
||||
const auto positive_lambd = v0::Constant::create(input_element_type, Shape{}, {lambd});
|
||||
const auto positive_lambd = v0::Constant::create(input_element_type, ov::Shape{}, {lambd});
|
||||
|
||||
const auto bias_tensor = v0::Constant::create(input_element_type, Shape{}, {bias});
|
||||
const auto bias_tensor = v0::Constant::create(input_element_type, ov::Shape{}, {bias});
|
||||
|
||||
// Create a mask indicating locations of values that need to be adjusted
|
||||
// by adding and subtracting bias
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// Copyright (C) 2018-2024 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
|
@ -17,7 +17,7 @@ namespace op {
|
|||
namespace set_1 {
|
||||
ov::OutputVector size(const Node& node) {
|
||||
auto data = node.get_ng_inputs().at(0);
|
||||
auto axes = v0::Constant::create(ov::element::i32, Shape{}, {0});
|
||||
auto axes = v0::Constant::create(ov::element::i32, ov::Shape{}, {0});
|
||||
auto input_shape = std::make_shared<v3::ShapeOf>(data);
|
||||
return {std::make_shared<v1::ReduceProd>(input_shape, axes)};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// Copyright (C) 2018-2024 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
|
@ -12,6 +12,8 @@
|
|||
|
||||
using namespace ov::op;
|
||||
|
||||
using ov::Shape;
|
||||
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
namespace ngraph {
|
||||
namespace onnx_import {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// Copyright (C) 2018-2024 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
|
@ -38,7 +38,7 @@ ov::OutputVector softmax(const Node& node) {
|
|||
std::shared_ptr<ov::Node> result;
|
||||
switch (data_rank.get_length()) {
|
||||
case 0: {
|
||||
result = v0::Constant::create(data.get_element_type(), Shape{}, {1});
|
||||
result = v0::Constant::create(data.get_element_type(), ov::Shape{}, {1});
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
|
|
@ -61,7 +61,7 @@ ov::OutputVector softmax(const Node& node) {
|
|||
std::shared_ptr<ov::Node> result;
|
||||
switch (data_rank.get_length()) {
|
||||
case 0: {
|
||||
result = v0::Constant::create(data.get_element_type(), Shape{}, {1});
|
||||
result = v0::Constant::create(data.get_element_type(), ov::Shape{}, {1});
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// Copyright (C) 2018-2024 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
|
@ -39,7 +39,7 @@ ov::OutputVector split(const Node& node) {
|
|||
const auto outputs_number = node.get_output_names().size();
|
||||
return ov::op::util::split(inputs.at(0), outputs_number, axis);
|
||||
} else {
|
||||
const auto axis_node = v0::Constant::create(ov::element::Type_t::i64, Shape{}, {axis});
|
||||
const auto axis_node = v0::Constant::create(ov::element::Type_t::i64, ov::Shape{}, {axis});
|
||||
return {std::make_shared<v1::VariadicSplit>(inputs.at(0), axis_node, inputs.at(1))->outputs()};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// Copyright (C) 2018-2024 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
|
@ -21,7 +21,7 @@ ov::OutputVector squeeze(const Node& node) {
|
|||
if (axes.empty()) {
|
||||
return {std::make_shared<v0::Squeeze>(data)};
|
||||
} else {
|
||||
const auto axes_const = std::make_shared<v0::Constant>(ov::element::i64, Shape{axes.size()}, axes);
|
||||
const auto axes_const = std::make_shared<v0::Constant>(ov::element::i64, ov::Shape{axes.size()}, axes);
|
||||
return {std::make_shared<v0::Squeeze>(data, axes_const)};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// Copyright (C) 2018-2024 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
|
@ -19,6 +19,7 @@
|
|||
#include "utils/dft.hpp"
|
||||
|
||||
using namespace ov::op;
|
||||
using ov::Shape;
|
||||
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
namespace ngraph {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// Copyright (C) 2018-2024 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
|
@ -20,7 +20,7 @@ ov::OutputVector thresholded_relu(const Node& node) {
|
|||
const auto data = node.get_ng_inputs().at(0);
|
||||
const double alpha = node.get_attribute_value<double>("alpha", 1.0);
|
||||
|
||||
const auto alpha_node = v0::Constant::create(data.get_element_type(), Shape{}, {alpha});
|
||||
const auto alpha_node = v0::Constant::create(data.get_element_type(), ov::Shape{}, {alpha});
|
||||
|
||||
const auto data_map =
|
||||
std::make_shared<v0::Convert>(std::make_shared<v1::Greater>(data, alpha_node), data.get_element_type());
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2022 Intel Corporation
|
||||
// Copyright (C) 2022-2024 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
|
@ -43,8 +43,8 @@ ov::OutputVector trilu(const Node& node) {
|
|||
}
|
||||
|
||||
const auto shape = std::make_shared<v3::ShapeOf>(input);
|
||||
const auto zero = v0::Constant::create(ov::element::i64, Shape{}, {0});
|
||||
const auto one = v0::Constant::create(ov::element::i64, Shape{}, {1});
|
||||
const auto zero = v0::Constant::create(ov::element::i64, ov::Shape{}, {0});
|
||||
const auto one = v0::Constant::create(ov::element::i64, ov::Shape{}, {1});
|
||||
|
||||
// The approach here is to create a mask, that later can be used in Select operator
|
||||
// to choose appropiate values from the input
|
||||
|
|
@ -74,8 +74,8 @@ ov::OutputVector trilu(const Node& node) {
|
|||
// fetch last two dimensions of input shape
|
||||
// M = shape[-1]
|
||||
// N = shape[-2]
|
||||
const auto M = std::make_shared<v8::Gather>(shape, v0::Constant::create(ov::element::i32, Shape{}, {-1}), zero);
|
||||
const auto N = std::make_shared<v8::Gather>(shape, v0::Constant::create(ov::element::i32, Shape{}, {-2}), zero);
|
||||
const auto M = std::make_shared<v8::Gather>(shape, v0::Constant::create(ov::element::i32, ov::Shape{}, {-1}), zero);
|
||||
const auto N = std::make_shared<v8::Gather>(shape, v0::Constant::create(ov::element::i32, ov::Shape{}, {-2}), zero);
|
||||
|
||||
// create 2D tensor with shape [1, M] and values [[0, 1, ..., M - 1]]
|
||||
const auto horizontal_range =
|
||||
|
|
@ -98,7 +98,8 @@ ov::OutputVector trilu(const Node& node) {
|
|||
mask = std::make_shared<v1::LessEqual>(horizontal_range, vertical_range);
|
||||
}
|
||||
|
||||
return {std::make_shared<v1::Select>(mask, input, v0::Constant::create(input.get_element_type(), Shape{}, {0}))};
|
||||
return {
|
||||
std::make_shared<v1::Select>(mask, input, v0::Constant::create(input.get_element_type(), ov::Shape{}, {0}))};
|
||||
}
|
||||
|
||||
} // namespace set_1
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// Copyright (C) 2018-2024 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
|
@ -73,7 +73,7 @@ ov::OutputVector upsample(const onnx_import::Node& node) {
|
|||
scales[rank_size - 1] = width_scale;
|
||||
scales[rank_size - 2] = height_scale;
|
||||
|
||||
const auto scales_const = v0::Constant::create(ov::element::f32, Shape({scales.size()}), scales);
|
||||
const auto scales_const = v0::Constant::create(ov::element::f32, ov::Shape({scales.size()}), scales);
|
||||
|
||||
return std::make_shared<v11::Interpolate>(data, scales_const, get_attributes(mode))->outputs();
|
||||
}
|
||||
|
|
@ -94,7 +94,7 @@ ov::OutputVector upsample(const onnx_import::Node& node) {
|
|||
"Input tensor's rank is required to be the same as number of "
|
||||
"elements of 'scales' attribute.");
|
||||
|
||||
const auto scales_const = v0::Constant::create(ov::element::f32, Shape({scales.size()}), scales);
|
||||
const auto scales_const = v0::Constant::create(ov::element::f32, ov::Shape({scales.size()}), scales);
|
||||
|
||||
return std::make_shared<v11::Interpolate>(data, scales_const, get_attributes(mode))->outputs();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// Copyright (C) 2018-2024 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
|
@ -21,6 +21,7 @@
|
|||
#include "openvino/op/subtract.hpp"
|
||||
|
||||
using namespace ov::op;
|
||||
using ov::Shape;
|
||||
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
namespace ngraph {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// Copyright (C) 2018-2024 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
|
@ -75,7 +75,7 @@ std::shared_ptr<ov::Node> get_monotonic_range_along_node_rank(const ov::Output<o
|
|||
///
|
||||
/// \return A Constant node representing shifted identity matrix.
|
||||
template <typename T = double>
|
||||
std::shared_ptr<ov::op::v0::Constant> shifted_square_identity(const Shape output_shape,
|
||||
std::shared_ptr<ov::op::v0::Constant> shifted_square_identity(const ov::Shape output_shape,
|
||||
const ov::element::Type& output_type,
|
||||
const std::int64_t shift) {
|
||||
std::vector<T> identity_matrix(shape_size(output_shape), T{0});
|
||||
|
|
@ -101,7 +101,7 @@ std::shared_ptr<ov::op::v0::Constant> shifted_square_identity(const Shape output
|
|||
/// \return A Constant node representing identity matrix with shape (n, n).
|
||||
template <typename T = double>
|
||||
std::shared_ptr<ov::op::v0::Constant> square_identity(const size_t n, const ov::element::Type& type) {
|
||||
return shifted_square_identity(Shape{n, n}, type, 0);
|
||||
return shifted_square_identity(ov::Shape{n, n}, type, 0);
|
||||
}
|
||||
|
||||
/// \brief Performs validation of an input that is expected to be a scalar.
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// Copyright (C) 2018-2024 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
|
@ -18,7 +18,7 @@ namespace convpool {
|
|||
///
|
||||
/// \param node The Node ptr representing Conv or Pool operation.
|
||||
/// \return The kernel Shape object representing its dimensions (height, width, depth).
|
||||
Shape get_kernel_shape(const Node& node);
|
||||
ov::Shape get_kernel_shape(const Node& node);
|
||||
|
||||
///
|
||||
/// \brief Get number of pixels to stride operation by in each direction.
|
||||
|
|
@ -28,7 +28,7 @@ Shape get_kernel_shape(const Node& node);
|
|||
///
|
||||
/// \return The kernel Shape object representing its dimensions (height, width,
|
||||
/// depth).
|
||||
Strides get_strides(const Node& node, const std::size_t kernel_rank = 0UL);
|
||||
ov::Strides get_strides(const Node& node, const std::size_t kernel_rank = 0UL);
|
||||
|
||||
///
|
||||
/// \brief Get number of pixels for filter dilation in each direction.
|
||||
|
|
@ -38,7 +38,7 @@ Strides get_strides(const Node& node, const std::size_t kernel_rank = 0UL);
|
|||
///
|
||||
/// \return The Strides object containing number of pixels for filter dilation
|
||||
/// (height, width, depth).
|
||||
Strides get_dilations(const Node& node, const std::size_t kernel_rank = 0UL);
|
||||
ov::Strides get_dilations(const Node& node, const std::size_t kernel_rank = 0UL);
|
||||
|
||||
/// \brief Gets the 'ceil_mode' (rounding type) attribute value.
|
||||
///
|
||||
|
|
@ -82,10 +82,10 @@ std::pair<ov::CoordinateDiff, ov::CoordinateDiff> get_pads(const Node& node);
|
|||
/// \param[in,out] padding_above The paddings above axis.
|
||||
///
|
||||
/// \see ov::op::PadType
|
||||
void calculate_auto_pads(const Shape& data_shape,
|
||||
const Shape& filter_shape,
|
||||
const Strides& strides,
|
||||
const Strides& dilations,
|
||||
void calculate_auto_pads(const ov::Shape& data_shape,
|
||||
const ov::Shape& filter_shape,
|
||||
const ov::Strides& strides,
|
||||
const ov::Strides& dilations,
|
||||
const ov::op::PadType& pad_type,
|
||||
ov::CoordinateDiff& padding_below,
|
||||
ov::CoordinateDiff& padding_above);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// Copyright (C) 2018-2024 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
|
@ -15,6 +15,7 @@
|
|||
#include "utils/convpool.hpp"
|
||||
|
||||
using namespace ov::op;
|
||||
using ov::Shape;
|
||||
|
||||
namespace ngraph {
|
||||
namespace onnx_import {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// Copyright (C) 2018-2024 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
|
@ -55,11 +55,11 @@ protected:
|
|||
Node m_onnx_node;
|
||||
OPENVINO_SUPPRESS_DEPRECATED_END
|
||||
const ov::OutputVector m_inputs;
|
||||
Shape m_kernel_shape;
|
||||
Strides m_strides;
|
||||
Strides m_dilations;
|
||||
Shape m_padding_below;
|
||||
Shape m_padding_above;
|
||||
ov::Shape m_kernel_shape;
|
||||
ov::Strides m_strides;
|
||||
ov::Strides m_dilations;
|
||||
ov::Shape m_padding_below;
|
||||
ov::Shape m_padding_above;
|
||||
ov::op::PadType m_auto_pad;
|
||||
ov::op::RoundingType m_rounding_type;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// Copyright (C) 2018-2024 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
|
@ -22,6 +22,7 @@
|
|||
#include "ov_models/ov_builders/split.hpp"
|
||||
|
||||
using namespace ov::op;
|
||||
using ov::Shape;
|
||||
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
namespace ngraph {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// Copyright (C) 2018-2024 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
|
@ -20,6 +20,7 @@
|
|||
#include "utils/reshape.hpp"
|
||||
|
||||
using namespace ov::op;
|
||||
using ov::Shape;
|
||||
|
||||
namespace ngraph {
|
||||
namespace onnx_import {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// Copyright (C) 2018-2024 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// Copyright (C) 2018-2024 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
|
@ -15,7 +15,7 @@ const std::vector<ov::PartialShape> inputAndQuantizationShapes = {
|
|||
{ 1ul, 4ul, 16ul, 16ul },
|
||||
};
|
||||
|
||||
const std::vector<ov::AxisSet> reductionAxes = { { 2, 3 }, { 1, 2, 3 } };
|
||||
const std::vector<ov::AxisSet> reductionAxes = {{2, 3}, {1, 2, 3}};
|
||||
|
||||
const std::vector<bool> normalizeVariance = { true, false };
|
||||
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@
|
|||
#include "single_op_tests/topk.hpp"
|
||||
|
||||
namespace {
|
||||
using ov::test::TopKLayerTest;
|
||||
using ov::test::TopK11LayerTest;
|
||||
using ov::test::TopKLayerTest;
|
||||
|
||||
std::vector<ov::Shape> shapes = {{10, 10, 10}};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// Copyright (C) 2018-2024 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
|
@ -11,8 +11,6 @@
|
|||
#include "ov_lpt_models/common/fake_quantize_on_data.hpp"
|
||||
#include "ov_lpt_models/common/dequantization_operations.hpp"
|
||||
|
||||
using namespace ngraph;
|
||||
|
||||
namespace LayerTestsDefinitions {
|
||||
|
||||
typedef std::
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// Copyright (C) 2018-2024 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
|
@ -10,8 +10,6 @@
|
|||
#include "shared_test_classes/base/low_precision_transformations/layer_transformation.hpp"
|
||||
#include "ov_lpt_models/common/fake_quantize_on_data.hpp"
|
||||
|
||||
using namespace ngraph;
|
||||
|
||||
namespace LayerTestsDefinitions {
|
||||
|
||||
typedef std::tuple<ov::element::Type, ov::PartialShape, std::string, ov::AxisSet, bool> MVNTransformationParams;
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@
|
|||
#include <iterator>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <ngraph/ngraph.hpp>
|
||||
#include <numeric>
|
||||
#include <ostream>
|
||||
#include <set>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// Copyright (C) 2018-2024 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
|
@ -13,13 +13,12 @@
|
|||
|
||||
namespace LayerTestsDefinitions {
|
||||
|
||||
using BroadcastParamsTuple = typename std::tuple<
|
||||
InferenceEngine::SizeVector, // target shape
|
||||
ov::AxisSet, // axes mapping
|
||||
ov::op::BroadcastType, // broadcast mode
|
||||
InferenceEngine::SizeVector, // Input shape
|
||||
InferenceEngine::Precision, // Network precision
|
||||
std::string>; // Device name
|
||||
using BroadcastParamsTuple = typename std::tuple<InferenceEngine::SizeVector, // target shape
|
||||
ov::AxisSet, // axes mapping
|
||||
ov::op::BroadcastType, // broadcast mode
|
||||
InferenceEngine::SizeVector, // Input shape
|
||||
InferenceEngine::Precision, // Network precision
|
||||
std::string>; // Device name
|
||||
|
||||
class BroadcastLayerTest : public testing::WithParamInterface<BroadcastParamsTuple>,
|
||||
virtual public LayerTestsUtils::LayerTestsCommon {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// Copyright (C) 2018-2024 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
|
@ -65,18 +65,18 @@ protected:
|
|||
} // namespace v11
|
||||
|
||||
//Interpolate-1 test
|
||||
typedef std::tuple<
|
||||
InferenceEngine::Precision, // Net precision
|
||||
InferenceEngine::Precision, // Input precision, output is the same
|
||||
InferenceEngine::Layout, // Input layout, output is the same
|
||||
InferenceEngine::SizeVector, // Input shapes
|
||||
InferenceEngine::SizeVector, // Target shapes
|
||||
std::string, // InterpolateMode
|
||||
ov::AxisSet, // Axes
|
||||
bool, // AntiAlias
|
||||
std::vector<size_t>, // Pads
|
||||
LayerTestsUtils::TargetDevice // Device name
|
||||
> Interpolate1LayerTestParams;
|
||||
typedef std::tuple<InferenceEngine::Precision, // Net precision
|
||||
InferenceEngine::Precision, // Input precision, output is the same
|
||||
InferenceEngine::Layout, // Input layout, output is the same
|
||||
InferenceEngine::SizeVector, // Input shapes
|
||||
InferenceEngine::SizeVector, // Target shapes
|
||||
std::string, // InterpolateMode
|
||||
ov::AxisSet, // Axes
|
||||
bool, // AntiAlias
|
||||
std::vector<size_t>, // Pads
|
||||
LayerTestsUtils::TargetDevice // Device name
|
||||
>
|
||||
Interpolate1LayerTestParams;
|
||||
|
||||
class Interpolate1LayerTest : public testing::WithParamInterface<Interpolate1LayerTestParams>,
|
||||
virtual public LayerTestsUtils::LayerTestsCommon {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// Copyright (C) 2018-2024 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
|
@ -11,15 +11,15 @@
|
|||
|
||||
namespace LayerTestsDefinitions {
|
||||
|
||||
typedef std::tuple<
|
||||
InferenceEngine::SizeVector, // Input shapes
|
||||
InferenceEngine::Precision, // Input precision
|
||||
ov::AxisSet, // Reduction axes
|
||||
bool, // Across channels
|
||||
bool, // Normalize variance
|
||||
double, // Epsilon
|
||||
std::string // Device name
|
||||
> mvn1Params;
|
||||
typedef std::tuple<InferenceEngine::SizeVector, // Input shapes
|
||||
InferenceEngine::Precision, // Input precision
|
||||
ov::AxisSet, // Reduction axes
|
||||
bool, // Across channels
|
||||
bool, // Normalize variance
|
||||
double, // Epsilon
|
||||
std::string // Device name
|
||||
>
|
||||
mvn1Params;
|
||||
|
||||
class Mvn1LayerTest : public testing::WithParamInterface<mvn1Params>, virtual public LayerTestsUtils::LayerTestsCommon {
|
||||
public:
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue