Remove opset usages for transformations (#24220)
### Details: - Remove opset usages for transformations - Use operation versions instead of opsets ### Tickets: - CVS-118087
This commit is contained in:
parent
6f0e530bce
commit
a25a476db2
|
|
@ -11,6 +11,8 @@
|
|||
#include "openvino/op/fake_convert.hpp"
|
||||
#include "openvino/op/fake_quantize.hpp"
|
||||
#include "openvino/op/multiply.hpp"
|
||||
#include "openvino/op/negative.hpp"
|
||||
#include "openvino/op/power.hpp"
|
||||
#include "openvino/op/subtract.hpp"
|
||||
#include "openvino/pass/constant_folding.hpp"
|
||||
#include "openvino/pass/pattern/op/or.hpp"
|
||||
|
|
|
|||
|
|
@ -4,17 +4,17 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "openvino/op/multiclass_nms.hpp"
|
||||
#include "openvino/op/util/multiclass_nms_base.hpp"
|
||||
#include "openvino/opsets/opset9.hpp"
|
||||
#include "transformations_visibility.hpp"
|
||||
|
||||
namespace ov {
|
||||
namespace op {
|
||||
namespace internal {
|
||||
|
||||
class TRANSFORMATIONS_API MulticlassNmsIEInternal : public opset9::MulticlassNms {
|
||||
class TRANSFORMATIONS_API MulticlassNmsIEInternal : public ov::op::v9::MulticlassNms {
|
||||
public:
|
||||
OPENVINO_OP("MulticlassNmsIEInternal", "ie_internal_opset", opset9::MulticlassNms);
|
||||
OPENVINO_OP("MulticlassNmsIEInternal", "ie_internal_opset", ov::op::v9::MulticlassNms);
|
||||
|
||||
MulticlassNmsIEInternal() = default;
|
||||
|
||||
|
|
|
|||
|
|
@ -6,12 +6,11 @@
|
|||
|
||||
#include <memory>
|
||||
|
||||
#include "openvino/opsets/opset1.hpp"
|
||||
#include "openvino/pass/graph_rewrite.hpp"
|
||||
#include "transformations_visibility.hpp"
|
||||
|
||||
using P2Btype =
|
||||
std::unordered_map<std::shared_ptr<ov::opset1::Parameter>, std::unordered_set<std::shared_ptr<ov::Symbol>>>;
|
||||
std::unordered_map<std::shared_ptr<ov::op::v0::Parameter>, std::unordered_set<std::shared_ptr<ov::Symbol>>>;
|
||||
|
||||
namespace ov {
|
||||
namespace pass {
|
||||
|
|
@ -36,17 +35,17 @@ protected:
|
|||
namespace ov {
|
||||
|
||||
namespace batch_util {
|
||||
void mark_batch(const std::shared_ptr<ov::opset1::Parameter>& parameter,
|
||||
void mark_batch(const std::shared_ptr<ov::op::v0::Parameter>& parameter,
|
||||
P2Btype& map,
|
||||
const std::unordered_set<std::shared_ptr<Symbol>>& batches);
|
||||
void mark_no_batch(const std::shared_ptr<ov::opset1::Parameter>& parameter, P2Btype& map);
|
||||
void mark_layout_independent_batch(const std::shared_ptr<ov::opset1::Parameter>& parameter,
|
||||
void mark_no_batch(const std::shared_ptr<ov::op::v0::Parameter>& parameter, P2Btype& map);
|
||||
void mark_layout_independent_batch(const std::shared_ptr<ov::op::v0::Parameter>& parameter,
|
||||
const std::shared_ptr<ov::Node>& result,
|
||||
P2Btype& map);
|
||||
void mark_with_unique_dimension_symbols(const std::shared_ptr<Model>& m);
|
||||
void restore_original_dimensions(
|
||||
const std::shared_ptr<ov::Model>& model,
|
||||
const std::map<std::shared_ptr<ov::opset1::Parameter>, ov::PartialShape>& parameter_to_shape,
|
||||
const std::map<std::shared_ptr<ov::op::v0::Parameter>, ov::PartialShape>& parameter_to_shape,
|
||||
bool leave_batch_dynamic = true,
|
||||
bool clear_symbols = false);
|
||||
bool check_batch_tracks_through_all_the_nodes(const std::shared_ptr<ov::Model>& m);
|
||||
|
|
|
|||
|
|
@ -9,7 +9,16 @@
|
|||
#include <vector>
|
||||
|
||||
#include "openvino/core/rt_info.hpp"
|
||||
#include "openvino/opsets/opset1.hpp"
|
||||
#include "openvino/op/avg_pool.hpp"
|
||||
#include "openvino/op/constant.hpp"
|
||||
#include "openvino/op/convert.hpp"
|
||||
#include "openvino/op/max_pool.hpp"
|
||||
#include "openvino/op/multiply.hpp"
|
||||
#include "openvino/op/reduce_max.hpp"
|
||||
#include "openvino/op/reduce_mean.hpp"
|
||||
#include "openvino/op/reduce_min.hpp"
|
||||
#include "openvino/op/reduce_sum.hpp"
|
||||
#include "openvino/op/reshape.hpp"
|
||||
#include "openvino/pass/graph_rewrite.hpp"
|
||||
#include "transformations_visibility.hpp"
|
||||
|
||||
|
|
@ -69,7 +78,7 @@ ov::matcher_pass_callback ConvertReduceBase::convert_reduce_to_pooling() {
|
|||
|
||||
auto input = reduce->input_value(0);
|
||||
|
||||
auto axes_node = std::dynamic_pointer_cast<ov::opset1::Constant>(reduce->input_value(1).get_node_shared_ptr());
|
||||
auto axes_node = std::dynamic_pointer_cast<ov::op::v0::Constant>(reduce->input_value(1).get_node_shared_ptr());
|
||||
if (!axes_node) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -96,9 +105,9 @@ ov::matcher_pass_callback ConvertReduceBase::convert_reduce_to_pooling() {
|
|||
return input_shape[axis] == 1;
|
||||
})) {
|
||||
const auto reshape_shape = reduce->output(0).get_shape();
|
||||
auto reshape = std::make_shared<ov::opset1::Reshape>(
|
||||
auto reshape = std::make_shared<ov::op::v1::Reshape>(
|
||||
input,
|
||||
ov::opset1::Constant::create(ov::element::i64, ov::Shape{reshape_shape.size()}, reshape_shape),
|
||||
ov::op::v0::Constant::create(ov::element::i64, ov::Shape{reshape_shape.size()}, reshape_shape),
|
||||
true);
|
||||
|
||||
reshape->set_friendly_name(reduce->get_friendly_name());
|
||||
|
|
@ -190,16 +199,16 @@ ov::matcher_pass_callback ConvertReduceBase::convert_reduce_to_pooling() {
|
|||
ov::NodeVector new_ops;
|
||||
|
||||
if (!shape_begin.empty() && shape_begin != input.get_shape()) {
|
||||
input = std::make_shared<ov::opset1::Reshape>(
|
||||
input = std::make_shared<ov::op::v1::Reshape>(
|
||||
input,
|
||||
ov::opset1::Constant::create(ov::element::i64, ov::Shape{shape_begin.size()}, shape_begin),
|
||||
ov::op::v0::Constant::create(ov::element::i64, ov::Shape{shape_begin.size()}, shape_begin),
|
||||
true);
|
||||
input.get_node_shared_ptr()->set_friendly_name(reduce->get_friendly_name() + "/reshape_begin");
|
||||
new_ops.push_back(input.get_node_shared_ptr());
|
||||
}
|
||||
|
||||
if (std::is_same<T, ov::opset1::ReduceMean>()) {
|
||||
input = std::make_shared<ov::opset1::AvgPool>(input,
|
||||
if (std::is_same<T, ov::op::v1::ReduceMean>()) {
|
||||
input = std::make_shared<ov::op::v1::AvgPool>(input,
|
||||
strides,
|
||||
pads_begin,
|
||||
pads_end,
|
||||
|
|
@ -209,8 +218,8 @@ ov::matcher_pass_callback ConvertReduceBase::convert_reduce_to_pooling() {
|
|||
|
||||
input.get_node_shared_ptr()->set_friendly_name(reduce->get_friendly_name() + "/pool");
|
||||
new_ops.push_back(input.get_node_shared_ptr());
|
||||
} else if (std::is_same<T, ov::opset1::ReduceMax>()) {
|
||||
input = std::make_shared<ov::opset1::MaxPool>(input,
|
||||
} else if (std::is_same<T, ov::op::v1::ReduceMax>()) {
|
||||
input = std::make_shared<ov::op::v1::MaxPool>(input,
|
||||
strides,
|
||||
pads_begin,
|
||||
pads_end,
|
||||
|
|
@ -219,16 +228,16 @@ ov::matcher_pass_callback ConvertReduceBase::convert_reduce_to_pooling() {
|
|||
|
||||
input.get_node_shared_ptr()->set_friendly_name(reduce->get_friendly_name() + "/pool");
|
||||
new_ops.push_back(input.get_node_shared_ptr());
|
||||
} else if (std::is_same<T, ov::opset1::ReduceSum>()) {
|
||||
} else if (std::is_same<T, ov::op::v1::ReduceSum>()) {
|
||||
// Fallback to real type because of potential data loss in case of integer AVG Pool
|
||||
bool fallback_to_real = input.get_element_type().is_integral();
|
||||
|
||||
if (fallback_to_real) {
|
||||
input = std::make_shared<ov::opset1::Convert>(input, ov::element::f32);
|
||||
input = std::make_shared<ov::op::v0::Convert>(input, ov::element::f32);
|
||||
new_ops.push_back(input.get_node_shared_ptr());
|
||||
}
|
||||
|
||||
input = std::make_shared<ov::opset1::AvgPool>(input,
|
||||
input = std::make_shared<ov::op::v1::AvgPool>(input,
|
||||
strides,
|
||||
pads_begin,
|
||||
pads_end,
|
||||
|
|
@ -239,14 +248,14 @@ ov::matcher_pass_callback ConvertReduceBase::convert_reduce_to_pooling() {
|
|||
input.get_node_shared_ptr()->set_friendly_name(reduce->get_friendly_name() + "/pool");
|
||||
new_ops.push_back(input.get_node_shared_ptr());
|
||||
|
||||
input = std::make_shared<ov::opset1::Multiply>(
|
||||
input = std::make_shared<ov::op::v1::Multiply>(
|
||||
input,
|
||||
ov::opset1::Constant::create(input.get_element_type(), ov::Shape{1}, {reduction_dims_count}));
|
||||
ov::op::v0::Constant::create(input.get_element_type(), ov::Shape{1}, {reduction_dims_count}));
|
||||
input.get_node_shared_ptr()->set_friendly_name(reduce->get_friendly_name() + "/mul");
|
||||
new_ops.push_back(input.get_node_shared_ptr());
|
||||
|
||||
if (fallback_to_real) {
|
||||
input = std::make_shared<ov::opset1::Convert>(input, reduce->output(0).get_element_type());
|
||||
input = std::make_shared<ov::op::v0::Convert>(input, reduce->output(0).get_element_type());
|
||||
new_ops.push_back(input.get_node_shared_ptr());
|
||||
}
|
||||
} else {
|
||||
|
|
@ -254,9 +263,9 @@ ov::matcher_pass_callback ConvertReduceBase::convert_reduce_to_pooling() {
|
|||
}
|
||||
|
||||
if (shape_end != input.get_shape()) {
|
||||
input = std::make_shared<ov::opset1::Reshape>(
|
||||
input = std::make_shared<ov::op::v1::Reshape>(
|
||||
input,
|
||||
ov::opset1::Constant::create(ov::element::i64, ov::Shape{shape_end.size()}, shape_end),
|
||||
ov::op::v0::Constant::create(ov::element::i64, ov::Shape{shape_end.size()}, shape_end),
|
||||
true);
|
||||
new_ops.push_back(input.get_node_shared_ptr());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,8 @@
|
|||
#include <vector>
|
||||
|
||||
#include "openvino/core/rt_info.hpp"
|
||||
#include "openvino/opsets/opset1.hpp"
|
||||
#include "openvino/op/constant.hpp"
|
||||
#include "openvino/op/reshape.hpp"
|
||||
#include "openvino/pass/graph_rewrite.hpp"
|
||||
#include "transformations_visibility.hpp"
|
||||
|
||||
|
|
@ -109,9 +110,9 @@ ov::matcher_pass_callback CvtReduceBase::convert_reduce_to_reshape() {
|
|||
// convert redundant reduce to reshape if the input shape is supported by reshape
|
||||
if (is_redundant(input_shape, reduce_shape) && input_shape.size() < 6) {
|
||||
const auto reshape_shape = reduce->output(0).get_shape();
|
||||
auto reshape = std::make_shared<ov::opset1::Reshape>(
|
||||
auto reshape = std::make_shared<ov::op::v1::Reshape>(
|
||||
input,
|
||||
ov::opset1::Constant::create(ov::element::i64, ov::Shape{reshape_shape.size()}, reshape_shape),
|
||||
ov::op::v0::Constant::create(ov::element::i64, ov::Shape{reshape_shape.size()}, reshape_shape),
|
||||
true);
|
||||
|
||||
reshape->set_friendly_name(reduce->get_friendly_name());
|
||||
|
|
|
|||
|
|
@ -6,8 +6,9 @@
|
|||
|
||||
#include <utility>
|
||||
|
||||
#include "openvino/op/constant.hpp"
|
||||
#include "openvino/op/transpose.hpp"
|
||||
#include "openvino/op/util/op_types.hpp"
|
||||
#include "openvino/opsets/opset10.hpp"
|
||||
#include "openvino/util/common_util.hpp"
|
||||
#include "transformations/utils/utils.hpp"
|
||||
|
||||
|
|
@ -17,8 +18,8 @@ namespace transpose_sinking {
|
|||
namespace utils {
|
||||
|
||||
struct TransposeInputsInfo {
|
||||
std::shared_ptr<ov::opset10::Transpose> transpose;
|
||||
std::shared_ptr<ov::opset10::Constant> transpose_const;
|
||||
std::shared_ptr<ov::op::v1::Transpose> transpose;
|
||||
std::shared_ptr<ov::op::v0::Constant> transpose_const;
|
||||
size_t input_idx;
|
||||
|
||||
bool isEmpty() const {
|
||||
|
|
@ -90,7 +91,7 @@ namespace sink_backward {
|
|||
*/
|
||||
ov::NodeVector InsertTransposeBeforeNode(
|
||||
const std::shared_ptr<ov::Node>& main_node,
|
||||
const std::shared_ptr<ov::opset10::Constant>& transpose_const,
|
||||
const std::shared_ptr<ov::op::v0::Constant>& transpose_const,
|
||||
std::vector<size_t> input_indexes = {},
|
||||
std::function<std::shared_ptr<ov::Node>(const ov::Output<ov::Node>& node, size_t n_dims)> InsertUnsqueeze =
|
||||
InsertBroadcastUnsqueeze);
|
||||
|
|
@ -114,22 +115,22 @@ bool RemoveTransposeConsumers(const std::shared_ptr<ov::Node>& node);
|
|||
*/
|
||||
ov::Output<ov::Node> ChangeValuesOrder(const ov::Output<ov::Node>& input,
|
||||
const ov::AxisVector& transpose_axis_order,
|
||||
const std::shared_ptr<ov::opset10::Constant>& axis);
|
||||
const std::shared_ptr<ov::op::v0::Constant>& axis);
|
||||
/**
|
||||
* @brief Inserts Gather operation which changes the order of values in @arg input
|
||||
* according to @arg transpose_axis_order along @arg axis.
|
||||
*/
|
||||
Output<Node> ChangeAxes(const Output<Node>& input,
|
||||
const AxisVector& transpose_axis_order,
|
||||
const std::shared_ptr<ov::opset10::Constant>& axis);
|
||||
const std::shared_ptr<ov::op::v0::Constant>& axis);
|
||||
|
||||
/**
|
||||
* @brief Inserts Gather operation which changes the order of values in @arg input
|
||||
* according to @arg transpose_axis_order along @arg axis.
|
||||
*/
|
||||
Output<Node> ChangeAxes(const Output<Node>& input,
|
||||
const std::shared_ptr<ov::opset10::Constant>& transpose_axis_order,
|
||||
const std::shared_ptr<ov::opset10::Constant>& axis);
|
||||
const std::shared_ptr<ov::op::v0::Constant>& transpose_axis_order,
|
||||
const std::shared_ptr<ov::op::v0::Constant>& axis);
|
||||
/**
|
||||
* @brief Returns the updated axes order for case when the initial axes order has more elements
|
||||
* than after TransposeSinking, e.g.:
|
||||
|
|
|
|||
|
|
@ -13,8 +13,8 @@
|
|||
|
||||
#include "openvino/core/descriptor_tensor.hpp"
|
||||
#include "openvino/core/rt_info.hpp"
|
||||
#include "openvino/opsets/opset4.hpp"
|
||||
#include "openvino/opsets/opset8.hpp"
|
||||
#include "openvino/op/constant.hpp"
|
||||
#include "openvino/op/convert.hpp"
|
||||
#include "openvino/pass/graph_rewrite.hpp"
|
||||
#include "transformations/rt_info/attributes.hpp"
|
||||
#include "transformations_visibility.hpp"
|
||||
|
|
@ -65,7 +65,7 @@ bool has_op_with_type(const std::shared_ptr<const ov::Model>& function) {
|
|||
|
||||
inline bool has_decompression_converts(const std::shared_ptr<const ov::Model>& function) {
|
||||
for (const auto& op : function->get_ops()) {
|
||||
if (std::dynamic_pointer_cast<opset8::Convert>(op)) {
|
||||
if (std::dynamic_pointer_cast<ov::op::v0::Convert>(op)) {
|
||||
if (ov::is_decompression(op))
|
||||
return true;
|
||||
}
|
||||
|
|
@ -133,7 +133,7 @@ bool has_constant_value(const std::shared_ptr<Node>& node,
|
|||
return false;
|
||||
}
|
||||
|
||||
auto constant = std::dynamic_pointer_cast<opset4::Constant>(node);
|
||||
auto constant = std::dynamic_pointer_cast<ov::op::v0::Constant>(node);
|
||||
if (!constant) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -167,7 +167,7 @@ bool has_constant_value(const std::shared_ptr<Node>& node,
|
|||
return false;
|
||||
}
|
||||
|
||||
auto constant = std::dynamic_pointer_cast<opset4::Constant>(node);
|
||||
auto constant = std::dynamic_pointer_cast<ov::op::v0::Constant>(node);
|
||||
if (!constant) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -184,18 +184,18 @@ bool has_constant_value(const std::shared_ptr<Node>& node,
|
|||
return const_values == values;
|
||||
}
|
||||
|
||||
TRANSFORMATIONS_API bool get_single_value(const std::shared_ptr<opset4::Constant>& const_node,
|
||||
TRANSFORMATIONS_API bool get_single_value(const std::shared_ptr<ov::op::v0::Constant>& const_node,
|
||||
float& value,
|
||||
bool check_value_range = true);
|
||||
|
||||
TRANSFORMATIONS_API std::shared_ptr<Node> normalize_constant(const std::shared_ptr<opset4::Constant>& constant,
|
||||
TRANSFORMATIONS_API std::shared_ptr<Node> normalize_constant(const std::shared_ptr<ov::op::v0::Constant>& constant,
|
||||
const PartialShape& shape);
|
||||
|
||||
TRANSFORMATIONS_API std::shared_ptr<Node> broadcastTo(const Output<Node>& input, const Shape& shape);
|
||||
|
||||
TRANSFORMATIONS_API std::shared_ptr<Node> reshapeTo(const Output<Node>& input, const Shape& shape);
|
||||
|
||||
TRANSFORMATIONS_API bool constantIsEqualTo(const std::shared_ptr<opset4::Constant>& const_node,
|
||||
TRANSFORMATIONS_API bool constantIsEqualTo(const std::shared_ptr<ov::op::v0::Constant>& const_node,
|
||||
float value,
|
||||
float eps = 1e-5);
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@
|
|||
#include <memory>
|
||||
|
||||
#include "itt.hpp"
|
||||
#include "openvino/opsets/opset9.hpp"
|
||||
|
||||
using namespace std;
|
||||
using namespace ov;
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ using namespace ov;
|
|||
op::internal::MulticlassNmsIEInternal::MulticlassNmsIEInternal(const Output<Node>& boxes,
|
||||
const Output<Node>& scores,
|
||||
const op::util::MulticlassNmsBase::Attributes& attrs)
|
||||
: opset9::MulticlassNms(boxes, scores, attrs) {
|
||||
: ov::op::v9::MulticlassNms(boxes, scores, attrs) {
|
||||
constructor_validate_and_infer_types();
|
||||
}
|
||||
|
||||
|
|
@ -21,7 +21,7 @@ op::internal::MulticlassNmsIEInternal::MulticlassNmsIEInternal(const Output<Node
|
|||
const Output<Node>& scores,
|
||||
const Output<Node>& roisnum,
|
||||
const op::util::MulticlassNmsBase::Attributes& attrs)
|
||||
: opset9::MulticlassNms(boxes, scores, roisnum, attrs) {
|
||||
: ov::op::v9::MulticlassNms(boxes, scores, roisnum, attrs) {
|
||||
constructor_validate_and_infer_types();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,8 @@
|
|||
#include <memory>
|
||||
|
||||
#include "itt.hpp"
|
||||
#include "openvino/opsets/opset5.hpp"
|
||||
#include "openvino/op/constant.hpp"
|
||||
#include "openvino/op/util/op_types.hpp"
|
||||
|
||||
using namespace std;
|
||||
using namespace ov;
|
||||
|
|
@ -104,7 +105,7 @@ int64_t op::internal::NonMaxSuppressionIEInternal::max_boxes_output_from_input()
|
|||
}
|
||||
|
||||
const auto max_output_boxes_input =
|
||||
ov::as_type_ptr<const opset5::Constant>(input_value(max_output_boxes_per_class_port).get_node_shared_ptr());
|
||||
ov::as_type_ptr<const ov::op::v0::Constant>(input_value(max_output_boxes_per_class_port).get_node_shared_ptr());
|
||||
max_output_boxes = max_output_boxes_input->cast_vector<int64_t>().at(0);
|
||||
|
||||
return max_output_boxes;
|
||||
|
|
|
|||
|
|
@ -9,6 +9,11 @@
|
|||
#include "openvino/op/constant.hpp"
|
||||
#include "openvino/op/reshape.hpp"
|
||||
#include "openvino/op/unsqueeze.hpp"
|
||||
#include "openvino/op/util/binary_elementwise_arithmetic.hpp"
|
||||
#include "openvino/op/util/binary_elementwise_bitwise.hpp"
|
||||
#include "openvino/op/util/binary_elementwise_comparison.hpp"
|
||||
#include "openvino/op/util/binary_elementwise_logical.hpp"
|
||||
#include "openvino/op/util/gather_base.hpp"
|
||||
#include "openvino/pass/pattern/op/or.hpp"
|
||||
#include "openvino/pass/pattern/op/wrap_type.hpp"
|
||||
#include "transformations/utils/utils.hpp"
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
#include "itt.hpp"
|
||||
#include "openvino/core/rt_info.hpp"
|
||||
#include "openvino/op/constant.hpp"
|
||||
#include "openvino/op/util/multi_subgraph_base.hpp"
|
||||
#include "openvino/pass/pattern/op/wrap_type.hpp"
|
||||
#include "transformations/utils/utils.hpp"
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
#include "openvino/op/constant.hpp"
|
||||
#include "openvino/op/divide.hpp"
|
||||
#include "openvino/op/erf.hpp"
|
||||
#include "openvino/op/gelu.hpp"
|
||||
#include "openvino/op/multiply.hpp"
|
||||
#include "openvino/op/parameter.hpp"
|
||||
#include "openvino/op/power.hpp"
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
#include "itt.hpp"
|
||||
#include "openvino/op/constant.hpp"
|
||||
#include "openvino/op/divide.hpp"
|
||||
#include "openvino/op/util/multi_subgraph_base.hpp"
|
||||
#include "openvino/op/util/precision_sensitive_attribute.hpp"
|
||||
#include "openvino/pass/pattern/op/wrap_type.hpp"
|
||||
#include "transformations/rt_info/disable_fp16_compression.hpp"
|
||||
|
|
|
|||
|
|
@ -12,11 +12,13 @@
|
|||
#include "itt.hpp"
|
||||
#include "openvino/core/validation_util.hpp"
|
||||
#include "openvino/op/add.hpp"
|
||||
#include "openvino/op/broadcast.hpp"
|
||||
#include "openvino/op/concat.hpp"
|
||||
#include "openvino/op/constant.hpp"
|
||||
#include "openvino/op/convert.hpp"
|
||||
#include "openvino/op/divide.hpp"
|
||||
#include "openvino/op/gather.hpp"
|
||||
#include "openvino/op/gather_elements.hpp"
|
||||
#include "openvino/op/gru_sequence.hpp"
|
||||
#include "openvino/op/lstm_sequence.hpp"
|
||||
#include "openvino/op/multiply.hpp"
|
||||
|
|
@ -26,11 +28,17 @@
|
|||
#include "openvino/op/scatter_elements_update.hpp"
|
||||
#include "openvino/op/scatter_nd_update.hpp"
|
||||
#include "openvino/op/scatter_update.hpp"
|
||||
#include "openvino/op/slice.hpp"
|
||||
#include "openvino/op/split.hpp"
|
||||
#include "openvino/op/squeeze.hpp"
|
||||
#include "openvino/op/strided_slice.hpp"
|
||||
#include "openvino/op/subtract.hpp"
|
||||
#include "openvino/op/tile.hpp"
|
||||
#include "openvino/op/transpose.hpp"
|
||||
#include "openvino/op/unsqueeze.hpp"
|
||||
#include "openvino/op/util/binary_elementwise_comparison.hpp"
|
||||
#include "openvino/op/util/binary_elementwise_logical.hpp"
|
||||
#include "openvino/op/util/op_types.hpp"
|
||||
#include "openvino/op/util/pad_base.hpp"
|
||||
#include "openvino/op/variadic_split.hpp"
|
||||
#include "openvino/pass/pattern/op/optional.hpp"
|
||||
|
|
|
|||
|
|
@ -12,6 +12,9 @@
|
|||
#include "openvino/op/constant.hpp"
|
||||
#include "openvino/op/reshape.hpp"
|
||||
#include "openvino/op/unsqueeze.hpp"
|
||||
#include "openvino/op/util/arithmetic_reductions_keep_dims.hpp"
|
||||
#include "openvino/op/util/binary_elementwise_logical.hpp"
|
||||
#include "openvino/op/util/logical_reduction_keep_dims.hpp"
|
||||
#include "openvino/op/util/reduction_base.hpp"
|
||||
#include "openvino/pass/pattern/op/or.hpp"
|
||||
#include "openvino/pass/pattern/op/wrap_type.hpp"
|
||||
|
|
|
|||
|
|
@ -10,6 +10,9 @@
|
|||
#include "itt.hpp"
|
||||
#include "openvino/op/constant.hpp"
|
||||
#include "openvino/op/reshape.hpp"
|
||||
#include "openvino/op/util/arithmetic_reductions_keep_dims.hpp"
|
||||
#include "openvino/op/util/binary_elementwise_logical.hpp"
|
||||
#include "openvino/op/util/logical_reduction_keep_dims.hpp"
|
||||
#include "openvino/op/util/reduction_base.hpp"
|
||||
#include "openvino/pass/pattern/op/or.hpp"
|
||||
#include "openvino/pass/pattern/op/wrap_type.hpp"
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
#include "openvino/op/constant.hpp"
|
||||
#include "openvino/op/reshape.hpp"
|
||||
#include "openvino/op/transpose.hpp"
|
||||
#include "openvino/op/util/gather_base.hpp"
|
||||
#include "openvino/pass/pattern/op/wrap_type.hpp"
|
||||
#include "transformations/utils/utils.hpp"
|
||||
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
#include "openvino/op/reshape.hpp"
|
||||
#include "openvino/op/shape_of.hpp"
|
||||
#include "openvino/op/squeeze.hpp"
|
||||
#include "openvino/op/util/binary_elementwise_arithmetic.hpp"
|
||||
#include "openvino/pass/pattern/op/or.hpp"
|
||||
#include "openvino/pass/pattern/op/wrap_type.hpp"
|
||||
#include "transformations/rt_info/strides_property.hpp"
|
||||
|
|
|
|||
|
|
@ -18,6 +18,9 @@
|
|||
#include "openvino/op/squeeze.hpp"
|
||||
#include "openvino/op/transpose.hpp"
|
||||
#include "openvino/op/unsqueeze.hpp"
|
||||
#include "openvino/op/util/arithmetic_reductions_keep_dims.hpp"
|
||||
#include "openvino/op/util/binary_elementwise_arithmetic.hpp"
|
||||
#include "openvino/op/util/logical_reduction_keep_dims.hpp"
|
||||
#include "openvino/pass/pattern/op/wrap_type.hpp"
|
||||
#include "transformations/utils/utils.hpp"
|
||||
|
||||
|
|
|
|||
|
|
@ -8,16 +8,7 @@
|
|||
#include <vector>
|
||||
|
||||
#include "itt.hpp"
|
||||
#include "openvino/opsets/opset1.hpp"
|
||||
#include "openvino/opsets/opset10.hpp"
|
||||
#include "openvino/opsets/opset11.hpp"
|
||||
#include "openvino/opsets/opset13.hpp"
|
||||
#include "openvino/opsets/opset3.hpp"
|
||||
#include "openvino/opsets/opset4.hpp"
|
||||
#include "openvino/opsets/opset5.hpp"
|
||||
#include "openvino/opsets/opset6.hpp"
|
||||
#include "openvino/opsets/opset8.hpp"
|
||||
#include "openvino/opsets/opset9.hpp"
|
||||
#include "openvino/op/ops.hpp"
|
||||
#include "openvino/pass/constant_folding.hpp"
|
||||
#include "openvino/pass/manager.hpp"
|
||||
#include "openvino/reference/convert.hpp"
|
||||
|
|
@ -172,7 +163,7 @@ bool convert_node_output_precision(
|
|||
bool function_changed) {
|
||||
bool node_changed = false;
|
||||
// Handle case with Constants as they can have consumers from other ov::Model object
|
||||
const auto constant = ov::as_type_ptr<opset10::Constant>(node);
|
||||
const auto constant = ov::as_type_ptr<ov::op::v0::Constant>(node);
|
||||
const auto it = const_to_internal_output.find(node.get());
|
||||
if (constant && it != const_to_internal_output.end()) {
|
||||
return fuse_type_to_constant(node, precisions, it->second);
|
||||
|
|
@ -252,8 +243,8 @@ bool convert_function_precision(const std::shared_ptr<Model>& f,
|
|||
auto register_constants = [&const_to_internal_output](const std::vector<std::shared_ptr<Node>>& ops) {
|
||||
for (auto& node : ops) {
|
||||
for (auto& input : node->inputs()) {
|
||||
if (auto const_node =
|
||||
std::dynamic_pointer_cast<opset4::Constant>(input.get_source_output().get_node_shared_ptr())) {
|
||||
if (auto const_node = std::dynamic_pointer_cast<ov::op::v0::Constant>(
|
||||
input.get_source_output().get_node_shared_ptr())) {
|
||||
const_to_internal_output[const_node.get()].emplace_back(input);
|
||||
}
|
||||
}
|
||||
|
|
@ -311,7 +302,7 @@ bool convert_function_precision(const std::shared_ptr<Model>& f,
|
|||
// TODO: we need to split NopElimination pass to separate MatcherPasses and call
|
||||
// Convert elimination here
|
||||
for (auto& node : ops) {
|
||||
if (auto convert = std::dynamic_pointer_cast<opset4::Convert>(node)) {
|
||||
if (auto convert = std::dynamic_pointer_cast<ov::op::v0::Convert>(node)) {
|
||||
if (pass::constant_folding_is_disabled(node))
|
||||
continue;
|
||||
// WA for topK, dont remove fake convert
|
||||
|
|
@ -430,53 +421,54 @@ bool ov::pass::ConvertPrecision::run_on_model(const std::shared_ptr<ov::Model>&
|
|||
}
|
||||
|
||||
type_to_fuse_map type_to_fuse{
|
||||
{opset4::Convert::get_type_info_static(), fuse_type_to_convert},
|
||||
{opset4::ShapeOf::get_type_info_static(), fuse_type_to_shapeof},
|
||||
{opset6::Assign::get_type_info_static(),
|
||||
{ov::op::v0::Convert::get_type_info_static(), fuse_type_to_convert},
|
||||
{ov::op::v3::ShapeOf::get_type_info_static(), fuse_type_to_shapeof},
|
||||
{ov::op::v6::Assign::get_type_info_static(),
|
||||
m_store_original_precision_as_rt_attribute ? store_original_type_as_attribute : wrap_into_original_type},
|
||||
{opset6::ReadValue::get_type_info_static(),
|
||||
{ov::op::v6::ReadValue::get_type_info_static(),
|
||||
m_store_original_precision_as_rt_attribute ? store_original_type_as_attribute : wrap_into_original_type},
|
||||
{opset3::NonMaxSuppression::get_type_info_static(), fuse_type_to_nms3},
|
||||
{opset4::NonMaxSuppression::get_type_info_static(), fuse_type_to_nms4},
|
||||
{opset5::NonMaxSuppression::get_type_info_static(), fuse_type_to_nms5},
|
||||
{opset9::NonMaxSuppression::get_type_info_static(), fuse_type_to_nms9},
|
||||
{ov::op::v3::NonMaxSuppression::get_type_info_static(), fuse_type_to_nms3},
|
||||
{ov::op::v4::NonMaxSuppression::get_type_info_static(), fuse_type_to_nms4},
|
||||
{ov::op::v5::NonMaxSuppression::get_type_info_static(), fuse_type_to_nms5},
|
||||
{ov::op::v9::NonMaxSuppression::get_type_info_static(), fuse_type_to_nms9},
|
||||
{op::v13::NMSRotated::get_type_info_static(), fuse_type_to_nms_rotated},
|
||||
{opset8::MatrixNms::get_type_info_static(), fuse_type_to_matrix_nms},
|
||||
{opset8::MulticlassNms::get_type_info_static(), fuse_type_to_multiclass_nms},
|
||||
{opset9::MulticlassNms::get_type_info_static(), fuse_type_to_multiclass_nms},
|
||||
{opset9::GenerateProposals::get_type_info_static(), fuse_type_to_generate_proposals},
|
||||
{opset6::CTCGreedyDecoderSeqLen::get_type_info_static(), fuse_type_to_ctc_greedy_decoder_seq_len},
|
||||
{opset1::TopK::get_type_info_static(), fuse_type_to_topk},
|
||||
{opset4::TopK::get_type_info_static(), fuse_type_to_topk},
|
||||
{opset11::TopK::get_type_info_static(), fuse_type_to_topk},
|
||||
{opset8::MaxPool::get_type_info_static(), fuse_type_to_maxpool},
|
||||
{opset4::NonZero::get_type_info_static(), fuse_type_to_nonzero},
|
||||
{opset4::Bucketize::get_type_info_static(), fuse_type_to_bucketize},
|
||||
{opset4::Equal::get_type_info_static(), fuse_type_to_binary_comparision<opset4::Equal>},
|
||||
{opset4::NotEqual::get_type_info_static(), fuse_type_to_binary_comparision<opset4::NotEqual>},
|
||||
{opset4::Greater::get_type_info_static(), fuse_type_to_binary_comparision<opset4::Greater>},
|
||||
{opset4::GreaterEqual::get_type_info_static(), fuse_type_to_binary_comparision<opset4::GreaterEqual>},
|
||||
{opset4::Less::get_type_info_static(), fuse_type_to_binary_comparision<opset4::Less>},
|
||||
{opset4::LessEqual::get_type_info_static(), fuse_type_to_binary_comparision<opset4::LessEqual>},
|
||||
{opset10::IsFinite::get_type_info_static(), fuse_type_to_binary_comparision<opset10::IsFinite>},
|
||||
{opset10::IsNaN::get_type_info_static(), fuse_type_to_binary_comparision<opset10::IsNaN>},
|
||||
{opset10::IsInf::get_type_info_static(), fuse_type_to_binary_comparision<opset10::IsInf>},
|
||||
{opset4::LogicalAnd::get_type_info_static(), fuse_type_to_logical<opset4::LogicalAnd>},
|
||||
{opset4::LogicalOr::get_type_info_static(), fuse_type_to_logical<opset4::LogicalOr>},
|
||||
{opset4::LogicalXor::get_type_info_static(), fuse_type_to_logical<opset4::LogicalXor>},
|
||||
{opset4::LogicalNot::get_type_info_static(), fuse_type_to_logical<opset4::LogicalNot>},
|
||||
{opset1::Xor::get_type_info_static(), fuse_type_to_logical<opset1::Xor>},
|
||||
{opset4::ReduceLogicalAnd::get_type_info_static(), fuse_type_to_reduce_logical<opset4::ReduceLogicalAnd>},
|
||||
{opset4::ReduceLogicalOr::get_type_info_static(), fuse_type_to_reduce_logical<opset4::ReduceLogicalOr>},
|
||||
{opset1::ShapeOf::get_type_info_static(), fuse_type_to_shapeof_v0},
|
||||
{opset4::Range::get_type_info_static(), fuse_type_to_range_v4},
|
||||
{opset9::Eye::get_type_info_static(), fuse_type_to_eye_v9},
|
||||
{opset10::Unique::get_type_info_static(), fuse_type_to_unique_v10},
|
||||
{opset8::RandomUniform::get_type_info_static(), fuse_type_to_random_uniform_v8},
|
||||
{opset13::Multinomial::get_type_info_static(), fuse_type_to_multinomial_v13},
|
||||
{opset1::PriorBox::get_type_info_static(), fuse_type_to_prior_box<opset1::PriorBox>},
|
||||
{opset8::PriorBox::get_type_info_static(), fuse_type_to_prior_box<opset8::PriorBox>},
|
||||
{opset1::PriorBoxClustered::get_type_info_static(), fuse_type_to_prior_box<opset1::PriorBoxClustered>}};
|
||||
{ov::op::v8::MatrixNms::get_type_info_static(), fuse_type_to_matrix_nms},
|
||||
{ov::op::v8::MulticlassNms::get_type_info_static(), fuse_type_to_multiclass_nms},
|
||||
{ov::op::v9::MulticlassNms::get_type_info_static(), fuse_type_to_multiclass_nms},
|
||||
{ov::op::v9::GenerateProposals::get_type_info_static(), fuse_type_to_generate_proposals},
|
||||
{ov::op::v6::CTCGreedyDecoderSeqLen::get_type_info_static(), fuse_type_to_ctc_greedy_decoder_seq_len},
|
||||
{ov::op::v1::TopK::get_type_info_static(), fuse_type_to_topk},
|
||||
{ov::op::v3::TopK::get_type_info_static(), fuse_type_to_topk},
|
||||
{ov::op::v11::TopK::get_type_info_static(), fuse_type_to_topk},
|
||||
{ov::op::v8::MaxPool::get_type_info_static(), fuse_type_to_maxpool},
|
||||
{ov::op::v3::NonZero::get_type_info_static(), fuse_type_to_nonzero},
|
||||
{ov::op::v3::Bucketize::get_type_info_static(), fuse_type_to_bucketize},
|
||||
{ov::op::v1::Equal::get_type_info_static(), fuse_type_to_binary_comparision<ov::op::v1::Equal>},
|
||||
{ov::op::v1::NotEqual::get_type_info_static(), fuse_type_to_binary_comparision<ov::op::v1::NotEqual>},
|
||||
{ov::op::v1::Greater::get_type_info_static(), fuse_type_to_binary_comparision<ov::op::v1::Greater>},
|
||||
{ov::op::v1::GreaterEqual::get_type_info_static(), fuse_type_to_binary_comparision<ov::op::v1::GreaterEqual>},
|
||||
{ov::op::v1::Less::get_type_info_static(), fuse_type_to_binary_comparision<ov::op::v1::Less>},
|
||||
{ov::op::v1::LessEqual::get_type_info_static(), fuse_type_to_binary_comparision<ov::op::v1::LessEqual>},
|
||||
{ov::op::v10::IsFinite::get_type_info_static(), fuse_type_to_binary_comparision<ov::op::v10::IsFinite>},
|
||||
{ov::op::v10::IsNaN::get_type_info_static(), fuse_type_to_binary_comparision<ov::op::v10::IsNaN>},
|
||||
{ov::op::v10::IsInf::get_type_info_static(), fuse_type_to_binary_comparision<ov::op::v10::IsInf>},
|
||||
{ov::op::v1::LogicalAnd::get_type_info_static(), fuse_type_to_logical<ov::op::v1::LogicalAnd>},
|
||||
{ov::op::v1::LogicalOr::get_type_info_static(), fuse_type_to_logical<ov::op::v1::LogicalOr>},
|
||||
{ov::op::v1::LogicalXor::get_type_info_static(), fuse_type_to_logical<ov::op::v1::LogicalXor>},
|
||||
{ov::op::v1::LogicalNot::get_type_info_static(), fuse_type_to_logical<ov::op::v1::LogicalNot>},
|
||||
{ov::op::v0::Xor::get_type_info_static(), fuse_type_to_logical<ov::op::v0::Xor>},
|
||||
{ov::op::v1::ReduceLogicalAnd::get_type_info_static(),
|
||||
fuse_type_to_reduce_logical<ov::op::v1::ReduceLogicalAnd>},
|
||||
{ov::op::v1::ReduceLogicalOr::get_type_info_static(), fuse_type_to_reduce_logical<ov::op::v1::ReduceLogicalOr>},
|
||||
{ov::op::v0::ShapeOf::get_type_info_static(), fuse_type_to_shapeof_v0},
|
||||
{ov::op::v4::Range::get_type_info_static(), fuse_type_to_range_v4},
|
||||
{ov::op::v9::Eye::get_type_info_static(), fuse_type_to_eye_v9},
|
||||
{ov::op::v10::Unique::get_type_info_static(), fuse_type_to_unique_v10},
|
||||
{ov::op::v8::RandomUniform::get_type_info_static(), fuse_type_to_random_uniform_v8},
|
||||
{ov::op::v13::Multinomial::get_type_info_static(), fuse_type_to_multinomial_v13},
|
||||
{ov::op::v0::PriorBox::get_type_info_static(), fuse_type_to_prior_box<ov::op::v0::PriorBox>},
|
||||
{ov::op::v8::PriorBox::get_type_info_static(), fuse_type_to_prior_box<ov::op::v8::PriorBox>},
|
||||
{ov::op::v0::PriorBoxClustered::get_type_info_static(), fuse_type_to_prior_box<ov::op::v0::PriorBoxClustered>}};
|
||||
|
||||
for (const auto& it : m_additional_type_to_fuse_map) {
|
||||
type_to_fuse[it.first] = it.second;
|
||||
|
|
@ -485,8 +477,8 @@ bool ov::pass::ConvertPrecision::run_on_model(const std::shared_ptr<ov::Model>&
|
|||
type_to_fuse.insert(m_additional_type_to_fuse_map.begin(), m_additional_type_to_fuse_map.end());
|
||||
|
||||
static type_to_fuse_map type_to_extend{
|
||||
{opset4::Select::get_type_info_static(), extend_select_type},
|
||||
{opset1::Reverse::get_type_info_static(), extend_reverse_type},
|
||||
{ov::op::v1::Select::get_type_info_static(), extend_select_type},
|
||||
{ov::op::v1::Reverse::get_type_info_static(), extend_reverse_type},
|
||||
};
|
||||
|
||||
bool is_changed = convert_precision(*this,
|
||||
|
|
@ -521,7 +513,7 @@ bool fuse_type_to_shapeof(const std::shared_ptr<ov::Node>& node, const precision
|
|||
if (it == precisions.end())
|
||||
return false;
|
||||
const auto& to = it->second;
|
||||
if (auto shapeof = ov::as_type_ptr<opset4::ShapeOf>(node)) {
|
||||
if (auto shapeof = ov::as_type_ptr<ov::op::v3::ShapeOf>(node)) {
|
||||
if (to == ov::element::i32 || to == ov::element::i64) {
|
||||
shapeof->set_output_type(to);
|
||||
return true;
|
||||
|
|
@ -535,7 +527,7 @@ bool fuse_type_to_random_uniform_v8(const std::shared_ptr<ov::Node>& node, const
|
|||
if (it == precisions.end())
|
||||
return false;
|
||||
const auto& to = it->second;
|
||||
if (auto random_uniform = ov::as_type_ptr<opset8::RandomUniform>(node)) {
|
||||
if (auto random_uniform = ov::as_type_ptr<ov::op::v8::RandomUniform>(node)) {
|
||||
if (to.is_integral_number() || to.is_real()) {
|
||||
random_uniform->set_out_type(to);
|
||||
return true;
|
||||
|
|
@ -546,7 +538,7 @@ bool fuse_type_to_random_uniform_v8(const std::shared_ptr<ov::Node>& node, const
|
|||
|
||||
bool fuse_type_to_unique_v10(const std::shared_ptr<Node>& node, const precisions_map& precisions) {
|
||||
bool res = false;
|
||||
if (auto unique = ov::as_type_ptr<opset10::Unique>(node)) {
|
||||
if (auto unique = ov::as_type_ptr<ov::op::v10::Unique>(node)) {
|
||||
auto it = precisions.find(node->get_output_element_type(1));
|
||||
if (it != precisions.end()) {
|
||||
unique->set_index_element_type(it->second);
|
||||
|
|
@ -566,7 +558,7 @@ bool fuse_type_to_range_v4(const std::shared_ptr<ov::Node>& node, const precisio
|
|||
if (it == precisions.end())
|
||||
return false;
|
||||
const auto& to = it->second;
|
||||
if (auto range = ov::as_type_ptr<opset4::Range>(node)) {
|
||||
if (auto range = ov::as_type_ptr<ov::op::v4::Range>(node)) {
|
||||
if (to.is_integral_number() || to.is_real()) {
|
||||
range->set_output_type(to);
|
||||
return true;
|
||||
|
|
@ -580,7 +572,7 @@ bool fuse_type_to_eye_v9(const std::shared_ptr<ov::Node>& node, const precisions
|
|||
if (it == precisions.end())
|
||||
return false;
|
||||
const auto& to = it->second;
|
||||
if (auto eye_node = ov::as_type_ptr<opset9::Eye>(node)) {
|
||||
if (auto eye_node = ov::as_type_ptr<ov::op::v9::Eye>(node)) {
|
||||
if (to.is_integral() || to.is_real()) {
|
||||
eye_node->set_out_type(to);
|
||||
return true;
|
||||
|
|
@ -597,14 +589,14 @@ bool fuse_type_to_parameter(const std::shared_ptr<ov::Node>& node,
|
|||
return false;
|
||||
bool changed = false;
|
||||
const auto& to = it->second;
|
||||
if (auto param = ov::as_type_ptr<opset4::Parameter>(node)) {
|
||||
if (auto param = ov::as_type_ptr<ov::op::v0::Parameter>(node)) {
|
||||
if (convert_input_precision) {
|
||||
param->set_element_type(to);
|
||||
param->validate_and_infer_types();
|
||||
changed = true;
|
||||
} else {
|
||||
auto param_consumers = param->output(0).get_target_inputs();
|
||||
auto convert = std::make_shared<opset4::Convert>(param, to);
|
||||
auto convert = std::make_shared<ov::op::v0::Convert>(param, to);
|
||||
for (auto& input : param_consumers) {
|
||||
const auto consumer = input.get_node();
|
||||
if (ov::is_type<ov::op::v0::Result>(consumer) || ov::is_type<ov::op::v0::Convert>(consumer) ||
|
||||
|
|
@ -630,10 +622,10 @@ bool wrap_into_original_type(const std::shared_ptr<ov::Node>& node, const precis
|
|||
const auto& to = it->second;
|
||||
const auto& from = it->first;
|
||||
|
||||
auto convert_before = std::make_shared<opset4::Convert>(node->input_value(0), from);
|
||||
auto convert_before = std::make_shared<ov::op::v0::Convert>(node->input_value(0), from);
|
||||
node->input(0).replace_source_output(convert_before);
|
||||
auto consumers = node->output(0).get_target_inputs();
|
||||
auto convert_after = std::make_shared<opset4::Convert>(node, to);
|
||||
auto convert_after = std::make_shared<ov::op::v0::Convert>(node, to);
|
||||
for (auto& input : consumers) {
|
||||
const auto consumer = input.get_node();
|
||||
if (ov::is_type<ov::op::v0::Result>(consumer) || ov::is_type<ov::op::v0::Convert>(consumer)) {
|
||||
|
|
@ -670,7 +662,7 @@ bool fuse_type_to_convert(const std::shared_ptr<ov::Node>& node, const precision
|
|||
if (it == precisions.end())
|
||||
return false;
|
||||
const auto& to = it->second;
|
||||
if (auto convert = ov::as_type_ptr<opset4::Convert>(node)) {
|
||||
if (auto convert = ov::as_type_ptr<ov::op::v0::Convert>(node)) {
|
||||
convert->set_convert_element_type(to);
|
||||
return true;
|
||||
}
|
||||
|
|
@ -682,7 +674,7 @@ bool fuse_type_to_nms3(const std::shared_ptr<ov::Node>& node, const precisions_m
|
|||
if (it == precisions.end())
|
||||
return false;
|
||||
const auto& to = it->second;
|
||||
if (auto nms = ov::as_type_ptr<opset3::NonMaxSuppression>(node)) {
|
||||
if (auto nms = ov::as_type_ptr<ov::op::v3::NonMaxSuppression>(node)) {
|
||||
if (to == ov::element::i32 || to == ov::element::i64) {
|
||||
nms->set_output_type(to);
|
||||
} else {
|
||||
|
|
@ -698,7 +690,7 @@ bool fuse_type_to_nms4(const std::shared_ptr<ov::Node>& node, const precisions_m
|
|||
if (it == precisions.end())
|
||||
return false;
|
||||
const auto& to = it->second;
|
||||
if (auto nms = ov::as_type_ptr<opset4::NonMaxSuppression>(node)) {
|
||||
if (auto nms = ov::as_type_ptr<ov::op::v4::NonMaxSuppression>(node)) {
|
||||
if (to == ov::element::i32 || to == ov::element::i64) {
|
||||
nms->set_output_type(to);
|
||||
} else {
|
||||
|
|
@ -710,7 +702,7 @@ bool fuse_type_to_nms4(const std::shared_ptr<ov::Node>& node, const precisions_m
|
|||
}
|
||||
|
||||
bool fuse_type_to_nms5(const std::shared_ptr<ov::Node>& node, const precisions_map& precisions) {
|
||||
auto nms = ov::as_type_ptr<opset5::NonMaxSuppression>(node);
|
||||
auto nms = ov::as_type_ptr<ov::op::v5::NonMaxSuppression>(node);
|
||||
if (!nms) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -752,14 +744,15 @@ bool fuse_type_to_nms5(const std::shared_ptr<ov::Node>& node, const precisions_m
|
|||
output_types.push_back(to);
|
||||
}
|
||||
|
||||
auto relaxed_op =
|
||||
std::make_shared<ov::op::TypeRelaxed<opset5::NonMaxSuppression>>(*nms, ov::element::TypeVector{}, output_types);
|
||||
auto relaxed_op = std::make_shared<ov::op::TypeRelaxed<ov::op::v5::NonMaxSuppression>>(*nms,
|
||||
ov::element::TypeVector{},
|
||||
output_types);
|
||||
replace_node(node, relaxed_op);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool fuse_type_to_nms9(const std::shared_ptr<ov::Node>& node, const precisions_map& precisions) {
|
||||
auto nms = ov::as_type_ptr<opset9::NonMaxSuppression>(node);
|
||||
auto nms = ov::as_type_ptr<ov::op::v9::NonMaxSuppression>(node);
|
||||
if (!nms) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -801,8 +794,9 @@ bool fuse_type_to_nms9(const std::shared_ptr<ov::Node>& node, const precisions_m
|
|||
output_types.push_back(to);
|
||||
}
|
||||
|
||||
auto relaxed_op =
|
||||
std::make_shared<ov::op::TypeRelaxed<opset9::NonMaxSuppression>>(*nms, ov::element::TypeVector{}, output_types);
|
||||
auto relaxed_op = std::make_shared<ov::op::TypeRelaxed<ov::op::v9::NonMaxSuppression>>(*nms,
|
||||
ov::element::TypeVector{},
|
||||
output_types);
|
||||
replace_node(node, relaxed_op);
|
||||
return true;
|
||||
}
|
||||
|
|
@ -872,7 +866,7 @@ bool update_type(size_t idx,
|
|||
} // namespace
|
||||
|
||||
bool fuse_type_to_matrix_nms(const std::shared_ptr<ov::Node>& node, const precisions_map& precisions) {
|
||||
auto nms = ov::as_type_ptr<opset8::MatrixNms>(node);
|
||||
auto nms = ov::as_type_ptr<ov::op::v8::MatrixNms>(node);
|
||||
if (!nms) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -885,9 +879,9 @@ bool fuse_type_to_matrix_nms(const std::shared_ptr<ov::Node>& node, const precis
|
|||
bool fuse_type_to_multiclass_nms(const std::shared_ptr<ov::Node>& node, const precisions_map& precisions) {
|
||||
std::shared_ptr<ov::op::util::MulticlassNmsBase> nms;
|
||||
if (ov::is_type<ov::op::v8::MulticlassNms>(node)) {
|
||||
nms = ov::as_type_ptr<opset8::MulticlassNms>(node);
|
||||
nms = ov::as_type_ptr<ov::op::v8::MulticlassNms>(node);
|
||||
} else {
|
||||
nms = ov::as_type_ptr<opset9::MulticlassNms>(node);
|
||||
nms = ov::as_type_ptr<ov::op::v9::MulticlassNms>(node);
|
||||
}
|
||||
if (!nms) {
|
||||
return false;
|
||||
|
|
@ -899,7 +893,7 @@ bool fuse_type_to_multiclass_nms(const std::shared_ptr<ov::Node>& node, const pr
|
|||
}
|
||||
|
||||
bool fuse_type_to_multinomial_v13(const std::shared_ptr<ov::Node>& node, const precisions_map& precisions) {
|
||||
auto multinomial = ov::as_type_ptr<opset13::Multinomial>(node);
|
||||
auto multinomial = ov::as_type_ptr<ov::op::v13::Multinomial>(node);
|
||||
if (!multinomial) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -910,7 +904,7 @@ bool fuse_type_to_multinomial_v13(const std::shared_ptr<ov::Node>& node, const p
|
|||
}
|
||||
|
||||
bool fuse_type_to_generate_proposals(const std::shared_ptr<ov::Node>& node, const precisions_map& precisions) {
|
||||
auto generate_proposals = ov::as_type_ptr<opset9::GenerateProposals>(node);
|
||||
auto generate_proposals = ov::as_type_ptr<ov::op::v9::GenerateProposals>(node);
|
||||
if (!generate_proposals) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -930,7 +924,7 @@ bool fuse_type_to_topk(const std::shared_ptr<ov::Node>& node, const precisions_m
|
|||
}
|
||||
|
||||
bool fuse_type_to_maxpool(const std::shared_ptr<ov::Node>& node, const precisions_map& precisions) {
|
||||
if (auto maxpool = ov::as_type_ptr<opset8::MaxPool>(node)) {
|
||||
if (auto maxpool = ov::as_type_ptr<ov::op::v8::MaxPool>(node)) {
|
||||
return update_type(1, node, precisions, [&](const element::Type& to) {
|
||||
maxpool->set_index_element_type(to);
|
||||
});
|
||||
|
|
@ -940,7 +934,7 @@ bool fuse_type_to_maxpool(const std::shared_ptr<ov::Node>& node, const precision
|
|||
|
||||
bool fuse_type_to_ctc_greedy_decoder_seq_len(const std::shared_ptr<ov::Node>& node, const precisions_map& precisions) {
|
||||
bool res = false;
|
||||
if (auto ctc_decoder = ov::as_type_ptr<opset6::CTCGreedyDecoderSeqLen>(node)) {
|
||||
if (auto ctc_decoder = ov::as_type_ptr<ov::op::v6::CTCGreedyDecoderSeqLen>(node)) {
|
||||
res = update_type(0, node, precisions, [&](const element::Type& to) {
|
||||
ctc_decoder->set_classes_index_type(to);
|
||||
});
|
||||
|
|
@ -956,7 +950,7 @@ bool fuse_type_to_ctc_greedy_decoder_seq_len(const std::shared_ptr<ov::Node>& no
|
|||
}
|
||||
|
||||
bool fuse_type_to_nonzero(const std::shared_ptr<ov::Node>& node, const precisions_map& precisions) {
|
||||
if (auto nonzero = ov::as_type_ptr<opset4::NonZero>(node)) {
|
||||
if (auto nonzero = ov::as_type_ptr<ov::op::v3::NonZero>(node)) {
|
||||
return update_type(0, node, precisions, [&](const element::Type& to) {
|
||||
nonzero->set_output_type(to);
|
||||
});
|
||||
|
|
@ -965,7 +959,7 @@ bool fuse_type_to_nonzero(const std::shared_ptr<ov::Node>& node, const precision
|
|||
}
|
||||
|
||||
bool fuse_type_to_bucketize(const std::shared_ptr<ov::Node>& node, const precisions_map& precisions) {
|
||||
if (auto b = ov::as_type_ptr<opset4::Bucketize>(node)) {
|
||||
if (auto b = ov::as_type_ptr<ov::op::v3::Bucketize>(node)) {
|
||||
return update_type(0, node, precisions, [&](const element::Type& to) {
|
||||
b->set_output_type(to);
|
||||
});
|
||||
|
|
@ -981,10 +975,10 @@ bool fuse_type_to_shapeof_v0(const std::shared_ptr<ov::Node>& node, const precis
|
|||
if (auto type_relaxed = std::dynamic_pointer_cast<ov::op::TypeRelaxedBase>(node)) {
|
||||
type_relaxed->set_overridden_output_type(to);
|
||||
return true;
|
||||
} else if (auto casted = std::dynamic_pointer_cast<opset1::ShapeOf>(node)) {
|
||||
auto relaxed_op = std::make_shared<ov::op::TypeRelaxed<opset1::ShapeOf>>(*casted,
|
||||
ov::element::TypeVector{},
|
||||
ov::element::TypeVector{to});
|
||||
} else if (auto casted = std::dynamic_pointer_cast<ov::op::v0::ShapeOf>(node)) {
|
||||
auto relaxed_op = std::make_shared<ov::op::TypeRelaxed<ov::op::v0::ShapeOf>>(*casted,
|
||||
ov::element::TypeVector{},
|
||||
ov::element::TypeVector{to});
|
||||
replace_node(node, relaxed_op);
|
||||
return true;
|
||||
}
|
||||
|
|
@ -995,11 +989,11 @@ bool extend_select_type(const std::shared_ptr<ov::Node>& node, const precisions_
|
|||
if (auto type_relaxed = std::dynamic_pointer_cast<ov::op::TypeRelaxedBase>(node)) {
|
||||
type_relaxed->set_origin_input_type(ov::element::boolean, 0);
|
||||
return true;
|
||||
} else if (auto casted = std::dynamic_pointer_cast<opset4::Select>(node)) {
|
||||
} else if (auto casted = std::dynamic_pointer_cast<ov::op::v1::Select>(node)) {
|
||||
auto relaxed_op =
|
||||
std::make_shared<op::TypeRelaxed<opset4::Select>>(*casted,
|
||||
ov::element::TypeVector{ov::element::boolean},
|
||||
ov::element::TypeVector{});
|
||||
std::make_shared<op::TypeRelaxed<ov::op::v1::Select>>(*casted,
|
||||
ov::element::TypeVector{ov::element::boolean},
|
||||
ov::element::TypeVector{});
|
||||
replace_node(node, relaxed_op);
|
||||
return true;
|
||||
}
|
||||
|
|
@ -1007,9 +1001,9 @@ bool extend_select_type(const std::shared_ptr<ov::Node>& node, const precisions_
|
|||
}
|
||||
|
||||
bool extend_reverse_type(const std::shared_ptr<ov::Node>& node, const precisions_map& precisions) {
|
||||
if (const auto casted = std::dynamic_pointer_cast<opset1::Reverse>(node)) {
|
||||
if (const auto casted = std::dynamic_pointer_cast<ov::op::v1::Reverse>(node)) {
|
||||
if (casted->get_mode() == ov::op::v1::Reverse::Mode::MASK) {
|
||||
auto relaxed_op = std::make_shared<op::TypeRelaxed<opset1::Reverse>>(
|
||||
auto relaxed_op = std::make_shared<op::TypeRelaxed<ov::op::v1::Reverse>>(
|
||||
*casted,
|
||||
ov::element::TypeVector{casted->get_input_element_type(0), ov::element::boolean},
|
||||
ov::element::TypeVector{casted->get_output_element_type(0)});
|
||||
|
|
@ -1051,14 +1045,14 @@ inline int32_t convert_value<uint32_t, int32_t>(uint32_t val) {
|
|||
|
||||
namespace {
|
||||
template <ov::element::Type_t PREC_FROM, ov::element::Type_t PREC_TO>
|
||||
std::shared_ptr<ov::Node> change_constant_precision(std::shared_ptr<opset4::Constant>& constant) {
|
||||
std::shared_ptr<ov::Node> change_constant_precision(std::shared_ptr<ov::op::v0::Constant>& constant) {
|
||||
using src_type = typename element_type_traits<PREC_FROM>::value_type;
|
||||
using dst_type = typename element_type_traits<PREC_TO>::value_type;
|
||||
|
||||
const auto* src_data = constant->get_data_ptr<src_type>();
|
||||
const auto size = shape_size(constant->get_shape());
|
||||
|
||||
auto new_constant = std::make_shared<opset4::Constant>(PREC_TO, constant->get_shape());
|
||||
auto new_constant = std::make_shared<ov::op::v0::Constant>(PREC_TO, constant->get_shape());
|
||||
new_constant->output(0).set_names(constant->output(0).get_names());
|
||||
auto* dst_data = const_cast<dst_type*>(reinterpret_cast<const dst_type*>(new_constant->get_data_ptr()));
|
||||
if (dst_data == nullptr)
|
||||
|
|
@ -1072,14 +1066,14 @@ std::shared_ptr<ov::Node> change_constant_precision(std::shared_ptr<opset4::Cons
|
|||
|
||||
template <>
|
||||
std::shared_ptr<Node> change_constant_precision<ov::element::Type_t::f32, ov::element::Type_t::f16>(
|
||||
std::shared_ptr<opset4::Constant>& constant) {
|
||||
std::shared_ptr<ov::op::v0::Constant>& constant) {
|
||||
using src_type = typename element_type_traits<ov::element::Type_t::f32>::value_type;
|
||||
using dst_type = typename element_type_traits<ov::element::Type_t::f16>::value_type;
|
||||
|
||||
const auto* src_data = constant->get_data_ptr<src_type>();
|
||||
const auto size = shape_size(constant->get_shape());
|
||||
|
||||
auto new_constant = std::make_shared<opset4::Constant>(ov::element::Type_t::f16, constant->get_shape());
|
||||
auto new_constant = std::make_shared<ov::op::v0::Constant>(ov::element::Type_t::f16, constant->get_shape());
|
||||
new_constant->output(0).set_names(constant->output(0).get_names());
|
||||
auto* dst_data = const_cast<dst_type*>(reinterpret_cast<const dst_type*>(new_constant->get_data_ptr()));
|
||||
if (dst_data == nullptr)
|
||||
|
|
@ -1092,14 +1086,14 @@ std::shared_ptr<Node> change_constant_precision<ov::element::Type_t::f32, ov::el
|
|||
|
||||
template <>
|
||||
std::shared_ptr<Node> change_constant_precision<ov::element::Type_t::f16, ov::element::Type_t::f32>(
|
||||
std::shared_ptr<opset4::Constant>& constant) {
|
||||
std::shared_ptr<ov::op::v0::Constant>& constant) {
|
||||
using src_type = typename element_type_traits<ov::element::Type_t::f16>::value_type;
|
||||
using dst_type = typename element_type_traits<ov::element::Type_t::f32>::value_type;
|
||||
|
||||
const auto* src_data = constant->get_data_ptr<src_type>();
|
||||
const auto size = shape_size(constant->get_shape());
|
||||
|
||||
auto new_constant = std::make_shared<opset4::Constant>(ov::element::Type_t::f32, constant->get_shape());
|
||||
auto new_constant = std::make_shared<ov::op::v0::Constant>(ov::element::Type_t::f32, constant->get_shape());
|
||||
new_constant->output(0).set_names(constant->output(0).get_names());
|
||||
auto* dst_data = const_cast<dst_type*>(reinterpret_cast<const dst_type*>(new_constant->get_data_ptr()));
|
||||
if (dst_data == nullptr)
|
||||
|
|
@ -1192,7 +1186,8 @@ void convert_lp_value(const SRC& src,
|
|||
dst &= new_val;
|
||||
}
|
||||
|
||||
std::shared_ptr<Node> convert_low_precisions_int(std::shared_ptr<opset4::Constant>& constant, ov::element::Type to) {
|
||||
std::shared_ptr<Node> convert_low_precisions_int(std::shared_ptr<ov::op::v0::Constant>& constant,
|
||||
ov::element::Type to) {
|
||||
// Supported integer precisions
|
||||
static const precisions_set_t supported_integer_precisions = {ov::element::i4, ov::element::u4, ov::element::u1};
|
||||
// Get source element type and source data
|
||||
|
|
@ -1208,7 +1203,7 @@ std::shared_ptr<Node> convert_low_precisions_int(std::shared_ptr<opset4::Constan
|
|||
to.get_type_name() + " is not implemented!");
|
||||
|
||||
// Create a new constant operation and get destination data
|
||||
auto new_constant = std::make_shared<opset4::Constant>(to, constant->get_shape());
|
||||
auto new_constant = std::make_shared<ov::op::v0::Constant>(to, constant->get_shape());
|
||||
auto* dst_data = const_cast<uint8_t*>(reinterpret_cast<const uint8_t*>(new_constant->get_data_ptr()));
|
||||
// Check pointers
|
||||
if (src_data == nullptr || dst_data == nullptr)
|
||||
|
|
@ -1306,7 +1301,7 @@ bool fuse_type_to_constant(const std::shared_ptr<ov::Node>& node,
|
|||
if (it == precisions.end())
|
||||
return false;
|
||||
const auto& to = it->second;
|
||||
if (auto constant = ov::as_type_ptr<opset4::Constant>(node)) {
|
||||
if (auto constant = ov::as_type_ptr<ov::op::v0::Constant>(node)) {
|
||||
std::shared_ptr<ov::Node> new_const;
|
||||
if (from == ov::element::u64 && to == ov::element::i32) {
|
||||
new_const = change_constant_precision<ov::element::Type_t::u64, ov::element::Type_t::i32>(constant);
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@
|
|||
#include <vector>
|
||||
|
||||
#include "itt.hpp"
|
||||
#include "openvino/opsets/opset10.hpp"
|
||||
#include "openvino/pass/pattern/op/wrap_type.hpp"
|
||||
#include "transformations/utils/utils.hpp"
|
||||
|
||||
|
|
@ -20,10 +19,10 @@ using namespace pass;
|
|||
ov::pass::FlushFP32SubnormalsToZero::FlushFP32SubnormalsToZero() {
|
||||
MATCHER_SCOPE(FlushFP32SubnormalsToZero);
|
||||
|
||||
auto node_pattern = pattern::wrap_type<opset10::Constant>();
|
||||
auto node_pattern = pattern::wrap_type<ov::op::v0::Constant>();
|
||||
|
||||
matcher_pass_callback callback = [=](pattern::Matcher& m) {
|
||||
auto node = dynamic_pointer_cast<ov::opset10::Constant>(m.get_match_root());
|
||||
auto node = dynamic_pointer_cast<ov::op::v0::Constant>(m.get_match_root());
|
||||
|
||||
if (!node)
|
||||
return false;
|
||||
|
|
@ -43,7 +42,7 @@ ov::pass::FlushFP32SubnormalsToZero::FlushFP32SubnormalsToZero() {
|
|||
if (!has_subnormals)
|
||||
return false;
|
||||
|
||||
auto new_constant = std::make_shared<ov::opset8::Constant>(ov::element::f32, node->get_shape());
|
||||
auto new_constant = std::make_shared<ov::op::v0::Constant>(ov::element::f32, node->get_shape());
|
||||
auto* dst_data = const_cast<float*>(new_constant->get_data_ptr<float>());
|
||||
|
||||
for (size_t i = 0; i < size; ++i) {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,8 @@
|
|||
|
||||
#include "transformations/low_precision/mark_dequantization_subgraph.hpp"
|
||||
|
||||
#include "openvino/opsets/opset10.hpp"
|
||||
#include "openvino/op/multiply.hpp"
|
||||
#include "openvino/op/subtract.hpp"
|
||||
#include "openvino/pass/pattern/op/or.hpp"
|
||||
#include "openvino/pass/pattern/op/wrap_type.hpp"
|
||||
#include "transformations/rt_info/dequantization_node.hpp"
|
||||
|
|
@ -25,11 +26,12 @@ ov::pass::MarkDequantizationSubgraph::MarkDequantizationSubgraph(const element::
|
|||
// Multiply
|
||||
//
|
||||
auto input_pattern = pattern::any_input();
|
||||
auto convert_pattern = pattern::wrap_type<opset10::Convert>({input_pattern}, pattern::consumers_count(1));
|
||||
auto convert_pattern = pattern::wrap_type<ov::op::v0::Convert>({input_pattern}, pattern::consumers_count(1));
|
||||
auto zero_point_pattern = pattern::any_input();
|
||||
auto subtract_pattern = pattern::wrap_type<opset10::Subtract>({convert_pattern, zero_point_pattern});
|
||||
auto multiply_pattern = pattern::wrap_type<opset10::Multiply>({subtract_pattern, pattern::any_input()});
|
||||
auto multiply_no_subtract_pattern = pattern::wrap_type<opset10::Multiply>({convert_pattern, pattern::any_input()});
|
||||
auto subtract_pattern = pattern::wrap_type<ov::op::v1::Subtract>({convert_pattern, zero_point_pattern});
|
||||
auto multiply_pattern = pattern::wrap_type<ov::op::v1::Multiply>({subtract_pattern, pattern::any_input()});
|
||||
auto multiply_no_subtract_pattern =
|
||||
pattern::wrap_type<ov::op::v1::Multiply>({convert_pattern, pattern::any_input()});
|
||||
auto root = std::make_shared<pattern::op::Or>(OutputVector{multiply_pattern, multiply_no_subtract_pattern});
|
||||
|
||||
ov::matcher_pass_callback callback = [OV_CAPTURE_CPY_AND_THIS](pattern::Matcher& m) -> bool {
|
||||
|
|
@ -45,7 +47,7 @@ ov::pass::MarkDequantizationSubgraph::MarkDequantizationSubgraph(const element::
|
|||
auto subtract_it = pattern_map.find(subtract_pattern);
|
||||
if (subtract_it == pattern_map.end()) {
|
||||
for (size_t i = 0; i < multiply->get_input_size(); i++) {
|
||||
const auto node = ov::as_type_ptr<opset10::Convert>(multiply->get_input_node_shared_ptr(i));
|
||||
const auto node = ov::as_type_ptr<ov::op::v0::Convert>(multiply->get_input_node_shared_ptr(i));
|
||||
if (node && std::find(precisions.begin(), precisions.end(), node->get_input_element_type(0)) !=
|
||||
precisions.end()) {
|
||||
convert = node;
|
||||
|
|
@ -65,7 +67,7 @@ ov::pass::MarkDequantizationSubgraph::MarkDequantizationSubgraph(const element::
|
|||
ov::disable_constant_folding(convert);
|
||||
// It is also necessary to avoid precision conversion for constant nodes with input_precision
|
||||
auto keep_const_precision = [&](Node* node) {
|
||||
if (auto constant = ov::as_type<ov::opset10::Constant>(node)) {
|
||||
if (auto constant = ov::as_type<ov::op::v0::Constant>(node)) {
|
||||
const auto& const_et = constant->get_element_type();
|
||||
if (std::find(precisions.begin(), precisions.end(), const_et) != precisions.end())
|
||||
ov::enable_keep_const_precision(convert->get_input_node_shared_ptr(0));
|
||||
|
|
@ -79,8 +81,9 @@ ov::pass::MarkDequantizationSubgraph::MarkDequantizationSubgraph(const element::
|
|||
// mark Subtract as dequantization node
|
||||
ov::mark_as_dequantization_node(subtract_it->second.get_node_shared_ptr());
|
||||
auto zero_point = pattern_map.at(zero_point_pattern).get_node_shared_ptr();
|
||||
if (ov::is_type<opset10::Convert>(zero_point) && input_precision == zero_point->get_input_element_type(0) &&
|
||||
ov::is_type<opset10::Constant>(zero_point->get_input_node_ptr(0))) {
|
||||
if (ov::is_type<ov::op::v0::Convert>(zero_point) &&
|
||||
input_precision == zero_point->get_input_element_type(0) &&
|
||||
ov::is_type<ov::op::v0::Constant>(zero_point->get_input_node_ptr(0))) {
|
||||
if (!fold_subtract_const) {
|
||||
// disable ConstantFolding also for Convert on zero_point
|
||||
// so we don't have to constantfold it and then convert it back to
|
||||
|
|
|
|||
|
|
@ -9,9 +9,9 @@
|
|||
#include "openvino/core/rt_info.hpp"
|
||||
#include "openvino/op/constant.hpp"
|
||||
#include "openvino/op/convert.hpp"
|
||||
#include "openvino/op/multiply.hpp"
|
||||
#include "openvino/op/reshape.hpp"
|
||||
#include "openvino/op/subtract.hpp"
|
||||
#include "openvino/opsets/opset10.hpp"
|
||||
#include "openvino/pass/pattern/op/or.hpp"
|
||||
#include "openvino/pass/pattern/op/pattern.hpp"
|
||||
#include "openvino/pass/pattern/op/wrap_type.hpp"
|
||||
|
|
@ -49,11 +49,11 @@ ov::pass::ConvertGatherToGatherCompressed::ConvertGatherToGatherCompressed() {
|
|||
auto reshape_m = wrap_type<ov::op::v1::Reshape>({mul_m, reshape_const_m}, reshape_3d_to_2d);
|
||||
|
||||
auto last_convert_input = std::make_shared<ov::pass::pattern::op::Or>(ov::OutputVector{reshape_m, mul_m});
|
||||
auto last_convert_m = wrap_type<ov::opset10::Convert>({last_convert_input});
|
||||
auto last_convert_m = wrap_type<ov::op::v0::Convert>({last_convert_input});
|
||||
|
||||
auto dicts_input_m =
|
||||
std::make_shared<ov::pass::pattern::op::Or>(ov::OutputVector{reshape_m, last_convert_m, mul_m});
|
||||
auto gather_m = wrap_type<ov::opset10::Gather>({dicts_input_m, any_input(), wrap_type<ov::op::v0::Constant>()});
|
||||
auto gather_m = wrap_type<ov::op::v8::Gather>({dicts_input_m, any_input(), wrap_type<ov::op::v0::Constant>()});
|
||||
|
||||
ov::matcher_pass_callback callback = [=](ov::pass::pattern::Matcher& m) {
|
||||
const auto& pattern_map = m.get_pattern_value_map();
|
||||
|
|
@ -63,7 +63,7 @@ ov::pass::ConvertGatherToGatherCompressed::ConvertGatherToGatherCompressed() {
|
|||
OPENVINO_ASSERT(pattern_map.count(convert_m));
|
||||
ov::Shape dicts_shape = pattern_map.at(dicts_m).get_node_shared_ptr()->get_shape();
|
||||
auto gather_node =
|
||||
std::dynamic_pointer_cast<ov::opset10::Gather>(pattern_map.at(gather_m).get_node_shared_ptr());
|
||||
std::dynamic_pointer_cast<ov::op::v8::Gather>(pattern_map.at(gather_m).get_node_shared_ptr());
|
||||
if (!gather_node || transformation_callback(gather_node)) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
#include "openvino/core/rt_info.hpp"
|
||||
#include "openvino/op/constant.hpp"
|
||||
#include "openvino/op/convert.hpp"
|
||||
#include "openvino/op/nms_rotated.hpp"
|
||||
#include "openvino/op/non_max_suppression.hpp"
|
||||
#include "openvino/op/reshape.hpp"
|
||||
#include "openvino/pass/pattern/op/wrap_type.hpp"
|
||||
|
|
|
|||
|
|
@ -5,6 +5,13 @@
|
|||
#include "transformations/op_conversions/convert_reduce_to_reshape.hpp"
|
||||
|
||||
#include "itt.hpp"
|
||||
#include "openvino/op/reduce_logical_and.hpp"
|
||||
#include "openvino/op/reduce_logical_or.hpp"
|
||||
#include "openvino/op/reduce_max.hpp"
|
||||
#include "openvino/op/reduce_mean.hpp"
|
||||
#include "openvino/op/reduce_min.hpp"
|
||||
#include "openvino/op/reduce_prod.hpp"
|
||||
#include "openvino/op/reduce_sum.hpp"
|
||||
#include "openvino/pass/pattern/op/wrap_type.hpp"
|
||||
|
||||
bool CvtReduceBase::is_redundant(ov::Shape input, ov::Shape output) {
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
#include "openvino/core/validation_util.hpp"
|
||||
#include "openvino/op/add.hpp"
|
||||
#include "openvino/op/broadcast.hpp"
|
||||
#include "openvino/op/concat.hpp"
|
||||
#include "openvino/op/constant.hpp"
|
||||
#include "openvino/op/gather.hpp"
|
||||
#include "openvino/op/gru_cell.hpp"
|
||||
|
|
@ -24,12 +25,16 @@
|
|||
#include "openvino/op/lstm_cell.hpp"
|
||||
#include "openvino/op/lstm_sequence.hpp"
|
||||
#include "openvino/op/parameter.hpp"
|
||||
#include "openvino/op/range.hpp"
|
||||
#include "openvino/op/reshape.hpp"
|
||||
#include "openvino/op/result.hpp"
|
||||
#include "openvino/op/reverse_sequence.hpp"
|
||||
#include "openvino/op/rnn_cell.hpp"
|
||||
#include "openvino/op/rnn_sequence.hpp"
|
||||
#include "openvino/op/scatter_nd_update.hpp"
|
||||
#include "openvino/op/scatter_update.hpp"
|
||||
#include "openvino/op/shape_of.hpp"
|
||||
#include "openvino/op/squeeze.hpp"
|
||||
#include "openvino/op/tensor_iterator.hpp"
|
||||
#include "openvino/op/transpose.hpp"
|
||||
#include "openvino/op/unsqueeze.hpp"
|
||||
|
|
@ -559,12 +564,12 @@ ov::pass::ConvertLoopToLSTMSequence::ConvertLoopToLSTMSequence() {
|
|||
auto sequence_index_or_label =
|
||||
std::make_shared<pattern::op::Or>(OutputVector{sequence_index_label, sequence_index_reshaped_label});
|
||||
auto gather_body_label =
|
||||
pattern::wrap_type<opset8::Gather>({X_body_label, sequence_index_or_label, gather_axis_label},
|
||||
pattern::rank_equals(2));
|
||||
pattern::wrap_type<ov::op::v8::Gather>({X_body_label, sequence_index_or_label, gather_axis_label},
|
||||
pattern::rank_equals(2));
|
||||
auto W_label = pattern::any_input();
|
||||
auto R_label = pattern::any_input();
|
||||
auto B_label = pattern::wrap_type<op::v0::Constant>();
|
||||
auto lstm_cell_label = pattern::wrap_type<opset4::LSTMCell>(
|
||||
auto lstm_cell_label = pattern::wrap_type<ov::op::v4::LSTMCell>(
|
||||
{gather_body_label, H_body_label, C_body_label, W_label, R_label, B_label});
|
||||
auto scatter_index_new_shape_label = pattern::wrap_type<op::v0::Constant>();
|
||||
auto scatter_index_body_label =
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
#include "openvino/op/concat.hpp"
|
||||
#include "openvino/op/constant.hpp"
|
||||
#include "openvino/op/divide.hpp"
|
||||
#include "openvino/op/group_normalization.hpp"
|
||||
#include "openvino/op/multiply.hpp"
|
||||
#include "openvino/op/mvn.hpp"
|
||||
#include "openvino/op/parameter.hpp"
|
||||
|
|
|
|||
|
|
@ -12,7 +12,9 @@
|
|||
#include <ostream>
|
||||
|
||||
#include "openvino/core/node.hpp"
|
||||
#include "openvino/opsets/opset1.hpp"
|
||||
#include "openvino/op/convolution.hpp"
|
||||
#include "openvino/op/group_conv.hpp"
|
||||
#include "openvino/op/matmul.hpp"
|
||||
|
||||
using namespace ov;
|
||||
|
||||
|
|
@ -31,11 +33,11 @@ std::string ov::getPrimitivesPriority(const std::shared_ptr<ov::Node>& node) {
|
|||
|
||||
Any PrimitivesPriority::merge(const ov::NodeVector& nodes) const {
|
||||
auto canBeMerged = [](const std::shared_ptr<Node>& node) -> bool {
|
||||
if (std::dynamic_pointer_cast<ov::opset1::Convolution>(node) ||
|
||||
std::dynamic_pointer_cast<ov::opset1::GroupConvolution>(node) ||
|
||||
std::dynamic_pointer_cast<ov::opset1::GroupConvolutionBackpropData>(node) ||
|
||||
std::dynamic_pointer_cast<ov::opset1::ConvolutionBackpropData>(node) ||
|
||||
std::dynamic_pointer_cast<ov::opset1::MatMul>(node)) {
|
||||
if (std::dynamic_pointer_cast<ov::op::v1::Convolution>(node) ||
|
||||
std::dynamic_pointer_cast<ov::op::v1::GroupConvolution>(node) ||
|
||||
std::dynamic_pointer_cast<ov::op::v1::GroupConvolutionBackpropData>(node) ||
|
||||
std::dynamic_pointer_cast<ov::op::v1::ConvolutionBackpropData>(node) ||
|
||||
std::dynamic_pointer_cast<ov::op::v0::MatMul>(node)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -9,9 +9,11 @@
|
|||
#include "openvino/core/validation_util.hpp"
|
||||
#include "openvino/op/concat.hpp"
|
||||
#include "openvino/op/convert.hpp"
|
||||
#include "openvino/op/divide.hpp"
|
||||
#include "openvino/op/matmul.hpp"
|
||||
#include "openvino/op/reshape.hpp"
|
||||
#include "openvino/op/util/binary_elementwise_arithmetic.hpp"
|
||||
#include "openvino/op/util/op_types.hpp"
|
||||
#include "openvino/pass/pattern/op/or.hpp"
|
||||
#include "openvino/pass/pattern/op/wrap_type.hpp"
|
||||
#include "transformations/symbolic_transformations/utils.hpp"
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include "compare.hpp"
|
||||
#include "itt.hpp"
|
||||
#include "openvino/op/reshape.hpp"
|
||||
#include "openvino/pass/pattern/op/wrap_type.hpp"
|
||||
#include "transformations/symbolic_transformations/utils.hpp"
|
||||
#include "transformations/utils/utils.hpp"
|
||||
|
|
|
|||
|
|
@ -7,7 +7,11 @@
|
|||
#include "itt.hpp"
|
||||
#include "openvino/core/descriptor_tensor.hpp"
|
||||
#include "openvino/core/validation_util.hpp"
|
||||
#include "openvino/op/add.hpp"
|
||||
#include "openvino/op/range.hpp"
|
||||
#include "openvino/op/reshape.hpp"
|
||||
#include "openvino/op/select.hpp"
|
||||
#include "openvino/op/softmax.hpp"
|
||||
#include "openvino/op/util/symbolic_info.hpp"
|
||||
#include "openvino/pass/manager.hpp"
|
||||
#include "openvino/pass/pattern/op/or.hpp"
|
||||
|
|
|
|||
|
|
@ -9,6 +9,10 @@
|
|||
#include "openvino/op/fake_quantize.hpp"
|
||||
#include "openvino/op/prelu.hpp"
|
||||
#include "openvino/op/transpose.hpp"
|
||||
#include "openvino/op/unsqueeze.hpp"
|
||||
#include "openvino/op/util/binary_elementwise_arithmetic.hpp"
|
||||
#include "openvino/op/util/binary_elementwise_comparison.hpp"
|
||||
#include "openvino/op/util/binary_elementwise_logical.hpp"
|
||||
#include "openvino/op/util/op_types.hpp"
|
||||
#include "openvino/pass/pattern/op/or.hpp"
|
||||
#include "openvino/pass/pattern/op/wrap_type.hpp"
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
#include "transformations/transpose_sinking/ts_shape_of.hpp"
|
||||
|
||||
#include "itt.hpp"
|
||||
#include "openvino/op/gather.hpp"
|
||||
#include "openvino/op/util/shape_of_base.hpp"
|
||||
#include "transformations/transpose_sinking/ts_utils.hpp"
|
||||
|
||||
|
|
|
|||
|
|
@ -10,11 +10,17 @@
|
|||
#include "openvino/op/clamp.hpp"
|
||||
#include "openvino/op/constant.hpp"
|
||||
#include "openvino/op/convert.hpp"
|
||||
#include "openvino/op/convert_like.hpp"
|
||||
#include "openvino/op/elu.hpp"
|
||||
#include "openvino/op/hard_sigmoid.hpp"
|
||||
#include "openvino/op/is_finite.hpp"
|
||||
#include "openvino/op/is_inf.hpp"
|
||||
#include "openvino/op/is_nan.hpp"
|
||||
#include "openvino/op/log_softmax.hpp"
|
||||
#include "openvino/op/logical_not.hpp"
|
||||
#include "openvino/op/selu.hpp"
|
||||
#include "openvino/op/softplus.hpp"
|
||||
#include "openvino/op/swish.hpp"
|
||||
#include "openvino/op/transpose.hpp"
|
||||
#include "openvino/pass/pattern/op/or.hpp"
|
||||
#include "openvino/pass/pattern/op/wrap_type.hpp"
|
||||
|
|
|
|||
|
|
@ -10,13 +10,21 @@
|
|||
#include <memory>
|
||||
|
||||
#include "openvino/core/validation_util.hpp"
|
||||
#include "openvino/op/add.hpp"
|
||||
#include "openvino/op/broadcast.hpp"
|
||||
#include "openvino/op/constant.hpp"
|
||||
#include "openvino/op/divide.hpp"
|
||||
#include "openvino/op/gather.hpp"
|
||||
#include "openvino/op/multiply.hpp"
|
||||
#include "openvino/op/parameter.hpp"
|
||||
#include "openvino/op/relu.hpp"
|
||||
#include "openvino/op/reshape.hpp"
|
||||
#include "openvino/op/shape_of.hpp"
|
||||
#include "openvino/op/sigmoid.hpp"
|
||||
#include "openvino/op/subtract.hpp"
|
||||
#include "openvino/op/tanh.hpp"
|
||||
#include "openvino/op/util/multi_subgraph_base.hpp"
|
||||
#include "openvino/opsets/opset1.hpp"
|
||||
#include "openvino/opsets/opset3.hpp"
|
||||
#include "openvino/op/util/shape_of_base.hpp"
|
||||
|
||||
namespace ov {
|
||||
namespace op {
|
||||
|
|
@ -151,11 +159,11 @@ bool check_for_broadcast(const ov::PartialShape& ref_shape, const ov::PartialSha
|
|||
|
||||
std::shared_ptr<ov::Node> activation(const std::string& activation_name, const ov::Output<ov::Node>& apply_to) {
|
||||
if (activation_name == "relu") {
|
||||
return std::make_shared<opset4::Relu>(apply_to);
|
||||
return std::make_shared<ov::op::v0::Relu>(apply_to);
|
||||
} else if (activation_name == "sigmoid") {
|
||||
return std::make_shared<opset4::Sigmoid>(apply_to);
|
||||
return std::make_shared<ov::op::v0::Sigmoid>(apply_to);
|
||||
} else if (activation_name == "tanh") {
|
||||
return std::make_shared<opset4::Tanh>(apply_to);
|
||||
return std::make_shared<ov::op::v0::Tanh>(apply_to);
|
||||
} else {
|
||||
OPENVINO_THROW("Unsupported activation function");
|
||||
}
|
||||
|
|
@ -277,21 +285,22 @@ bool shapes_equal_except_dynamic_expected_batch(const ov::PartialShape& expected
|
|||
|
||||
void visit_shape_path(Node* node, std::unordered_set<ov::Node*>& visited, std::function<void(ov::Node*)> func) {
|
||||
auto is_shapeof = [](ov::Node* node) {
|
||||
return ov::is_type<opset1::ShapeOf>(node) || ov::is_type<opset3::ShapeOf>(node);
|
||||
return ov::is_type<ov::op::v0::ShapeOf>(node) || ov::is_type<ov::op::v3::ShapeOf>(node);
|
||||
};
|
||||
visit_path_impl(node, visited, func, is_shapeof);
|
||||
}
|
||||
|
||||
void visit_constant_path(ov::Node* node, std::unordered_set<ov::Node*>& visited, std::function<void(ov::Node*)> func) {
|
||||
auto check_parameter = [](ov::Node* node) {
|
||||
OPENVINO_ASSERT(!ov::is_type<opset1::Parameter>(node), "visit_constant_path is called for non-constant path.");
|
||||
OPENVINO_ASSERT(!ov::is_type<ov::op::v0::Parameter>(node),
|
||||
"visit_constant_path is called for non-constant path.");
|
||||
return false;
|
||||
};
|
||||
visit_path_impl(node, visited, func, check_parameter);
|
||||
}
|
||||
|
||||
bool is_dequantization_subgraph(const Output<Node>& node) {
|
||||
if (!is_type<opset8::Multiply>(node.get_node())) {
|
||||
if (!is_type<ov::op::v1::Multiply>(node.get_node())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -299,9 +308,9 @@ bool is_dequantization_subgraph(const Output<Node>& node) {
|
|||
Node* sub = nullptr;
|
||||
Node* convert = nullptr;
|
||||
|
||||
if (is_type<opset8::Subtract>(mul_inputs[0].get_node())) {
|
||||
if (is_type<ov::op::v1::Subtract>(mul_inputs[0].get_node())) {
|
||||
sub = mul_inputs[0].get_node();
|
||||
} else if (is_type<opset8::Convert>(mul_inputs[0].get_node())) {
|
||||
} else if (is_type<ov::op::v0::Convert>(mul_inputs[0].get_node())) {
|
||||
convert = mul_inputs[0].get_node();
|
||||
} else {
|
||||
return false;
|
||||
|
|
@ -309,7 +318,7 @@ bool is_dequantization_subgraph(const Output<Node>& node) {
|
|||
|
||||
if (sub) {
|
||||
auto sub_inputs = sub->input_values();
|
||||
if (is_type<opset8::Convert>(sub_inputs[0].get_node())) {
|
||||
if (is_type<ov::op::v0::Convert>(sub_inputs[0].get_node())) {
|
||||
convert = sub_inputs[0].get_node();
|
||||
}
|
||||
}
|
||||
|
|
@ -326,8 +335,8 @@ bool is_dequantization_subgraph(const Output<Node>& node) {
|
|||
bool can_eliminate_eltwise_node(const std::shared_ptr<Node>& eltwise,
|
||||
const Output<Node>& constant,
|
||||
const Output<Node>& non_constant_input) {
|
||||
if (!is_type<opset8::Add>(eltwise) && !is_type<opset8::Subtract>(eltwise) && !is_type<opset8::Multiply>(eltwise) &&
|
||||
!is_type<opset8::Divide>(eltwise)) {
|
||||
if (!is_type<ov::op::v1::Add>(eltwise) && !is_type<ov::op::v1::Subtract>(eltwise) &&
|
||||
!is_type<ov::op::v1::Multiply>(eltwise) && !is_type<ov::op::v1::Divide>(eltwise)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -336,7 +345,7 @@ bool can_eliminate_eltwise_node(const std::shared_ptr<Node>& eltwise,
|
|||
}
|
||||
|
||||
// check if constant has a single value with either 0 (for Add, Subtract) or 1 (for Multiply, Divide)
|
||||
auto constant_ptr = std::dynamic_pointer_cast<opset8::Constant>(constant.get_node_shared_ptr());
|
||||
auto constant_ptr = std::dynamic_pointer_cast<ov::op::v0::Constant>(constant.get_node_shared_ptr());
|
||||
if (!constant_ptr) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -383,7 +392,7 @@ bool can_eliminate_eltwise_node(const std::shared_ptr<Node>& eltwise,
|
|||
return false;
|
||||
}
|
||||
float expected_const = 0;
|
||||
if (is_type<opset8::Multiply>(eltwise) || is_type<opset8::Divide>(eltwise)) {
|
||||
if (is_type<ov::op::v1::Multiply>(eltwise) || is_type<ov::op::v1::Divide>(eltwise)) {
|
||||
expected_const = 1;
|
||||
}
|
||||
if (actual_const != expected_const) {
|
||||
|
|
|
|||
|
|
@ -7,7 +7,11 @@
|
|||
#include <gtest/gtest.h>
|
||||
|
||||
#include "common_test_utils/ov_test_utils.hpp"
|
||||
#include "openvino/op/add.hpp"
|
||||
#include "openvino/op/concat.hpp"
|
||||
#include "openvino/op/multiply.hpp"
|
||||
#include "openvino/op/parameter.hpp"
|
||||
#include "openvino/op/split.hpp"
|
||||
#include "openvino/op/variadic_split.hpp"
|
||||
#include "ov_ops/rotary_positional_embeddings.hpp"
|
||||
#include "transformations/utils/utils.hpp"
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
#include "openvino/op/constant.hpp"
|
||||
#include "openvino/op/divide.hpp"
|
||||
#include "openvino/op/erf.hpp"
|
||||
#include "openvino/op/gelu.hpp"
|
||||
#include "openvino/op/multiply.hpp"
|
||||
#include "openvino/op/parameter.hpp"
|
||||
#include "openvino/op/power.hpp"
|
||||
|
|
|
|||
|
|
@ -16,9 +16,7 @@
|
|||
#include "common_test_utils/ov_test_utils.hpp"
|
||||
#include "common_test_utils/test_common.hpp"
|
||||
#include "openvino/core/model.hpp"
|
||||
#include "openvino/opsets/opset1.hpp"
|
||||
#include "openvino/opsets/opset10.hpp"
|
||||
#include "openvino/opsets/opset9.hpp"
|
||||
#include "openvino/op/ops.hpp"
|
||||
#include "openvino/pass/constant_folding.hpp"
|
||||
#include "openvino/pass/manager.hpp"
|
||||
#include "transformations/init_node_info.hpp"
|
||||
|
|
@ -147,20 +145,20 @@ TEST(nop_elimination, reshape_v1_1D) {
|
|||
TEST(nop_elimination, squeeze_reshape_elimination_check_info) {
|
||||
std::shared_ptr<ov::Model> f;
|
||||
{
|
||||
auto arg = std::make_shared<opset4::Parameter>(element::f32, PartialShape{8, 16, 1, 3});
|
||||
auto arg = std::make_shared<ov::op::v0::Parameter>(element::f32, PartialShape{8, 16, 1, 3});
|
||||
|
||||
auto relu = std::make_shared<opset4::Relu>(arg);
|
||||
auto relu = std::make_shared<ov::op::v0::Relu>(arg);
|
||||
relu->set_friendly_name("relu");
|
||||
|
||||
auto squeeze_axes = opset4::Constant::create(element::i64, Shape{1}, {2});
|
||||
auto squeeze = std::make_shared<opset4::Squeeze>(relu, squeeze_axes);
|
||||
auto squeeze_axes = ov::op::v0::Constant::create(element::i64, Shape{1}, {2});
|
||||
auto squeeze = std::make_shared<ov::op::v0::Squeeze>(relu, squeeze_axes);
|
||||
squeeze->set_friendly_name("squeeze");
|
||||
|
||||
auto reshape_shape = opset4::Constant::create(element::i64, Shape{4}, {8, 16, 1, 3});
|
||||
auto reshape = std::make_shared<opset4::Reshape>(squeeze, reshape_shape, false);
|
||||
auto reshape_shape = ov::op::v0::Constant::create(element::i64, Shape{4}, {8, 16, 1, 3});
|
||||
auto reshape = std::make_shared<ov::op::v1::Reshape>(squeeze, reshape_shape, false);
|
||||
reshape->set_friendly_name("reshape");
|
||||
|
||||
auto abs = std::make_shared<opset4::Abs>(reshape);
|
||||
auto abs = std::make_shared<ov::op::v0::Abs>(reshape);
|
||||
|
||||
f = std::make_shared<ov::Model>(NodeVector{abs}, ParameterVector{arg});
|
||||
}
|
||||
|
|
@ -182,20 +180,20 @@ TEST(nop_elimination, squeeze_reshape_elimination_check_info) {
|
|||
TEST(nop_elimination, squeeze_unsqueeze_elimination) {
|
||||
std::shared_ptr<ov::Model> f;
|
||||
{
|
||||
auto arg = std::make_shared<opset4::Parameter>(element::f32, PartialShape{8, 16, 1, 3});
|
||||
auto arg = std::make_shared<ov::op::v0::Parameter>(element::f32, PartialShape{8, 16, 1, 3});
|
||||
|
||||
auto relu = std::make_shared<opset4::Relu>(arg);
|
||||
auto relu = std::make_shared<ov::op::v0::Relu>(arg);
|
||||
relu->set_friendly_name("relu");
|
||||
|
||||
auto squeeze_axes = opset4::Constant::create(element::i64, Shape{1}, {2});
|
||||
auto squeeze = std::make_shared<opset4::Squeeze>(relu, squeeze_axes);
|
||||
auto squeeze_axes = ov::op::v0::Constant::create(element::i64, Shape{1}, {2});
|
||||
auto squeeze = std::make_shared<ov::op::v0::Squeeze>(relu, squeeze_axes);
|
||||
squeeze->set_friendly_name("squeeze");
|
||||
|
||||
auto unsqueeze_axes = opset4::Constant::create(element::i64, Shape{1}, {2});
|
||||
auto unsqueeze = std::make_shared<opset4::Unsqueeze>(squeeze, unsqueeze_axes);
|
||||
auto unsqueeze_axes = ov::op::v0::Constant::create(element::i64, Shape{1}, {2});
|
||||
auto unsqueeze = std::make_shared<ov::op::v0::Unsqueeze>(squeeze, unsqueeze_axes);
|
||||
unsqueeze->set_friendly_name("unsqueeze");
|
||||
|
||||
auto abs = std::make_shared<opset4::Abs>(unsqueeze);
|
||||
auto abs = std::make_shared<ov::op::v0::Abs>(unsqueeze);
|
||||
|
||||
f = std::make_shared<ov::Model>(NodeVector{abs}, ParameterVector{arg});
|
||||
}
|
||||
|
|
@ -217,13 +215,13 @@ TEST(nop_elimination, squeeze_unsqueeze_elimination) {
|
|||
TEST(nop_elimination, squeeze_unsqueeze_elimination_dynamic_without_squeeze_axis) {
|
||||
std::shared_ptr<ov::Model> f;
|
||||
{
|
||||
auto arg = std::make_shared<opset4::Parameter>(element::f32, PartialShape{-1, 16, 1, 3});
|
||||
auto arg = std::make_shared<ov::op::v0::Parameter>(element::f32, PartialShape{-1, 16, 1, 3});
|
||||
|
||||
auto squeeze = std::make_shared<opset4::Squeeze>(arg);
|
||||
auto squeeze = std::make_shared<ov::op::v0::Squeeze>(arg);
|
||||
squeeze->set_friendly_name("squeeze");
|
||||
|
||||
auto unsqueeze_axes = opset4::Constant::create(element::i64, Shape{1}, {2});
|
||||
auto unsqueeze = std::make_shared<opset4::Unsqueeze>(squeeze, unsqueeze_axes);
|
||||
auto unsqueeze_axes = ov::op::v0::Constant::create(element::i64, Shape{1}, {2});
|
||||
auto unsqueeze = std::make_shared<ov::op::v0::Unsqueeze>(squeeze, unsqueeze_axes);
|
||||
unsqueeze->set_friendly_name("unsqueeze");
|
||||
|
||||
f = std::make_shared<ov::Model>(NodeVector{unsqueeze}, ParameterVector{arg});
|
||||
|
|
@ -250,17 +248,17 @@ TEST(nop_elimination, reshape_elimination_v1_dynamic) {
|
|||
TEST(nop_elimination, reshape_elimination_v1_check_consumer_count) {
|
||||
std::shared_ptr<ov::Model> f;
|
||||
{
|
||||
auto arg = std::make_shared<opset4::Parameter>(element::f32, PartialShape{8, 16, 1, 3});
|
||||
auto arg = std::make_shared<ov::op::v0::Parameter>(element::f32, PartialShape{8, 16, 1, 3});
|
||||
|
||||
auto reshape_1_shape = opset4::Constant::create(element::i64, Shape{2}, {128, 3});
|
||||
auto reshape_1 = std::make_shared<opset4::Reshape>(arg, reshape_1_shape, false);
|
||||
auto reshape_1_shape = ov::op::v0::Constant::create(element::i64, Shape{2}, {128, 3});
|
||||
auto reshape_1 = std::make_shared<ov::op::v1::Reshape>(arg, reshape_1_shape, false);
|
||||
reshape_1->set_friendly_name("reshape_1");
|
||||
|
||||
auto reshape_2_shape = opset4::Constant::create(element::i64, Shape{4}, {8, 16, 1, 3});
|
||||
auto reshape_2 = std::make_shared<opset4::Reshape>(reshape_1, reshape_2_shape, false);
|
||||
auto reshape_2_shape = ov::op::v0::Constant::create(element::i64, Shape{4}, {8, 16, 1, 3});
|
||||
auto reshape_2 = std::make_shared<ov::op::v1::Reshape>(reshape_1, reshape_2_shape, false);
|
||||
reshape_2->set_friendly_name("reshape_2");
|
||||
|
||||
auto relu = std::make_shared<opset4::Relu>(reshape_1);
|
||||
auto relu = std::make_shared<ov::op::v0::Relu>(reshape_1);
|
||||
relu->set_friendly_name("relu");
|
||||
|
||||
f = std::make_shared<ov::Model>(NodeVector{reshape_2, relu}, ParameterVector{arg});
|
||||
|
|
@ -809,14 +807,14 @@ TEST(nop_elimination, squeeze_unsqueeze_elimination_negative) {
|
|||
auto check_usecase = [](const Shape& shape, const std::vector<int64_t>& indices_val) {
|
||||
auto indices = op::v0::Constant::create(element::i64, Shape{indices_val.size()}, indices_val);
|
||||
auto input = make_shared<op::v0::Parameter>(element::f32, shape);
|
||||
auto squeeze = make_shared<opset1::Squeeze>(input, indices);
|
||||
auto squeeze = make_shared<ov::op::v0::Squeeze>(input, indices);
|
||||
auto baseline_f = make_shared<ov::Model>(squeeze, ParameterVector{input});
|
||||
auto optimized_f = baseline_f->clone();
|
||||
pass::Manager manager;
|
||||
manager.register_pass<ov::pass::NopElimination>();
|
||||
manager.run_passes(optimized_f);
|
||||
ASSERT_EQ(count_ops_of_type<opset1::Squeeze>(baseline_f), 1);
|
||||
ASSERT_EQ(count_ops_of_type<opset1::Squeeze>(optimized_f), 1);
|
||||
ASSERT_EQ(count_ops_of_type<ov::op::v0::Squeeze>(baseline_f), 1);
|
||||
ASSERT_EQ(count_ops_of_type<ov::op::v0::Squeeze>(optimized_f), 1);
|
||||
};
|
||||
|
||||
check_usecase(Shape{1, 1, 1}, std::vector<int64_t>{0, 1, 2});
|
||||
|
|
@ -1043,7 +1041,7 @@ TEST_P(EliminateEltwiseTests, eliminate_eltwise) {
|
|||
}
|
||||
|
||||
if (type_params.op_type == OpType::SUBTRACT_WITH_CONVERT) {
|
||||
constant = std::make_shared<opset8::Convert>(constant, type);
|
||||
constant = std::make_shared<ov::op::v0::Convert>(constant, type);
|
||||
}
|
||||
|
||||
shared_ptr<Node> A = parameter;
|
||||
|
|
@ -1059,28 +1057,28 @@ TEST_P(EliminateEltwiseTests, eliminate_eltwise) {
|
|||
shared_ptr<Node> node;
|
||||
switch (type_params.op_type) {
|
||||
case OpType::ADD:
|
||||
node = make_shared<opset8::Add>(A, B);
|
||||
node = make_shared<ov::op::v1::Add>(A, B);
|
||||
break;
|
||||
case OpType::SUBTRACT:
|
||||
case OpType::SUBTRACT_WITH_CONVERT:
|
||||
node = make_shared<opset8::Subtract>(A, B);
|
||||
node = make_shared<ov::op::v1::Subtract>(A, B);
|
||||
break;
|
||||
case OpType::MULTIPLY:
|
||||
node = make_shared<opset8::Multiply>(A, B);
|
||||
node = make_shared<ov::op::v1::Multiply>(A, B);
|
||||
break;
|
||||
case OpType::DIVIDE:
|
||||
node = make_shared<opset8::Divide>(A, B);
|
||||
node = make_shared<ov::op::v1::Divide>(A, B);
|
||||
break;
|
||||
default:
|
||||
ASSERT_FALSE(true) << "Invalid OpType";
|
||||
}
|
||||
auto abs = make_shared<opset8::Abs>(node);
|
||||
auto abs = make_shared<ov::op::v0::Abs>(node);
|
||||
model = make_shared<ov::Model>(abs, ParameterVector{parameter});
|
||||
|
||||
manager.register_pass<ov::pass::NopElimination>();
|
||||
|
||||
if (can_fuse) {
|
||||
auto abs = make_shared<opset8::Abs>(parameter);
|
||||
auto abs = make_shared<ov::op::v0::Abs>(parameter);
|
||||
model_ref = make_shared<ov::Model>(abs, ParameterVector{parameter});
|
||||
}
|
||||
|
||||
|
|
@ -1153,16 +1151,16 @@ INSTANTIATE_TEST_SUITE_P(EliminateEltwise,
|
|||
|
||||
TEST_F(TransformationTestsF, eliminate_eltwise_dequantization_subgraph) {
|
||||
{
|
||||
auto constant = opset8::Constant::create(element::i8, Shape{}, {2});
|
||||
auto convert = make_shared<opset8::Convert>(constant, element::f32);
|
||||
auto sub = make_shared<opset8::Subtract>(convert, opset8::Constant::create(element::f32, Shape{}, {0}));
|
||||
auto mul = make_shared<opset8::Multiply>(sub, opset8::Constant::create(element::f32, Shape{}, {1}));
|
||||
auto constant = ov::op::v0::Constant::create(element::i8, Shape{}, {2});
|
||||
auto convert = make_shared<ov::op::v0::Convert>(constant, element::f32);
|
||||
auto sub = make_shared<ov::op::v1::Subtract>(convert, ov::op::v0::Constant::create(element::f32, Shape{}, {0}));
|
||||
auto mul = make_shared<ov::op::v1::Multiply>(sub, ov::op::v0::Constant::create(element::f32, Shape{}, {1}));
|
||||
model = make_shared<ov::Model>(mul, ParameterVector{});
|
||||
}
|
||||
{
|
||||
auto constant = opset8::Constant::create(element::i8, Shape{}, {2});
|
||||
auto convert = make_shared<opset8::Convert>(constant, element::f32);
|
||||
auto mul = make_shared<opset8::Multiply>(convert, opset8::Constant::create(element::f32, Shape{}, {1}));
|
||||
auto constant = ov::op::v0::Constant::create(element::i8, Shape{}, {2});
|
||||
auto convert = make_shared<ov::op::v0::Convert>(constant, element::f32);
|
||||
auto mul = make_shared<ov::op::v1::Multiply>(convert, ov::op::v0::Constant::create(element::f32, Shape{}, {1}));
|
||||
model_ref = make_shared<ov::Model>(mul, ParameterVector{});
|
||||
}
|
||||
|
||||
|
|
@ -1204,51 +1202,51 @@ TEST_P(SplitConcatElimination, eliminate_split_concat_subgraph) {
|
|||
EXPECT_TRUE(seq_len % p.split_len == 0) << "Seq_len must be divisible by split_len.";
|
||||
|
||||
ParameterVector params;
|
||||
auto param = make_shared<ov::opset9::Parameter>(element::f32, Shape{batch, seq_len, input_size});
|
||||
auto param = make_shared<ov::op::v0::Parameter>(element::f32, Shape{batch, seq_len, input_size});
|
||||
|
||||
shared_ptr<Node> data = param;
|
||||
shared_ptr<Node> sequence;
|
||||
auto gate = static_cast<size_t>(p.rnn_type);
|
||||
auto axis_const = make_shared<ov::opset9::Constant>(element::i64, Shape{}, p.split_axis);
|
||||
auto H = make_shared<ov::opset9::Parameter>(element::f32, Shape{batch, num_dir, hidden_size});
|
||||
auto C = make_shared<ov::opset9::Parameter>(element::f32, Shape{batch, num_dir, hidden_size});
|
||||
auto seq_lengths = make_shared<ov::opset9::Parameter>(element::i64, Shape{batch});
|
||||
auto W = make_shared<ov::opset9::Parameter>(element::f32, Shape{num_dir, gate * hidden_size, input_size});
|
||||
auto R = make_shared<ov::opset9::Parameter>(element::f32, Shape{num_dir, gate * hidden_size, hidden_size});
|
||||
auto B = make_shared<ov::opset9::Parameter>(element::f32, Shape{num_dir, gate * hidden_size});
|
||||
auto axis_const = make_shared<ov::op::v0::Constant>(element::i64, Shape{}, p.split_axis);
|
||||
auto H = make_shared<ov::op::v0::Parameter>(element::f32, Shape{batch, num_dir, hidden_size});
|
||||
auto C = make_shared<ov::op::v0::Parameter>(element::f32, Shape{batch, num_dir, hidden_size});
|
||||
auto seq_lengths = make_shared<ov::op::v0::Parameter>(element::i64, Shape{batch});
|
||||
auto W = make_shared<ov::op::v0::Parameter>(element::f32, Shape{num_dir, gate * hidden_size, input_size});
|
||||
auto R = make_shared<ov::op::v0::Parameter>(element::f32, Shape{num_dir, gate * hidden_size, hidden_size});
|
||||
auto B = make_shared<ov::op::v0::Parameter>(element::f32, Shape{num_dir, gate * hidden_size});
|
||||
auto direction = op::RecurrentSequenceDirection::FORWARD;
|
||||
if (p.rnn_type == RNNType::RNN) {
|
||||
sequence = make_shared<ov::opset9::RNNSequence>(data, H, seq_lengths, W, R, B, hidden_size, direction);
|
||||
data = make_shared<ov::opset9::Squeeze>(sequence->output(0), axis_const);
|
||||
sequence = make_shared<ov::op::v5::RNNSequence>(data, H, seq_lengths, W, R, B, hidden_size, direction);
|
||||
data = make_shared<ov::op::v0::Squeeze>(sequence->output(0), axis_const);
|
||||
params = {H, seq_lengths, W, R, B};
|
||||
} else if (p.rnn_type == RNNType::GRU) {
|
||||
sequence = make_shared<ov::opset9::GRUSequence>(data, H, seq_lengths, W, R, B, hidden_size, direction);
|
||||
data = make_shared<ov::opset9::Squeeze>(sequence->output(0), axis_const);
|
||||
sequence = make_shared<ov::op::v5::GRUSequence>(data, H, seq_lengths, W, R, B, hidden_size, direction);
|
||||
data = make_shared<ov::op::v0::Squeeze>(sequence->output(0), axis_const);
|
||||
params = {H, seq_lengths, W, R, B};
|
||||
} else if (p.rnn_type == RNNType::LSTM) {
|
||||
sequence = make_shared<ov::opset9::LSTMSequence>(data, H, C, seq_lengths, W, R, B, hidden_size, direction);
|
||||
data = make_shared<ov::opset9::Squeeze>(sequence->output(0), axis_const);
|
||||
sequence = make_shared<ov::op::v5::LSTMSequence>(data, H, C, seq_lengths, W, R, B, hidden_size, direction);
|
||||
data = make_shared<ov::op::v0::Squeeze>(sequence->output(0), axis_const);
|
||||
params = {H, C, seq_lengths, W, R, B};
|
||||
}
|
||||
params.push_back(param);
|
||||
|
||||
shared_ptr<ov::Node> split;
|
||||
if (p.split_type == SplitType::Split) {
|
||||
split = make_shared<ov::opset9::Split>(data->output(0), axis_const, p.seq_len / p.split_len);
|
||||
split = make_shared<ov::op::v1::Split>(data->output(0), axis_const, p.seq_len / p.split_len);
|
||||
} else if (p.split_type == SplitType::VariadicSplit) {
|
||||
auto split_lengths = make_shared<ov::opset9::Constant>(element::i64,
|
||||
auto split_lengths = make_shared<ov::op::v0::Constant>(element::i64,
|
||||
Shape{seq_len / p.split_len},
|
||||
std::vector<size_t>(seq_len / p.split_len, p.split_len));
|
||||
split = make_shared<ov::opset9::VariadicSplit>(data->output(0), axis_const, split_lengths);
|
||||
split = make_shared<ov::op::v1::VariadicSplit>(data->output(0), axis_const, split_lengths);
|
||||
}
|
||||
|
||||
auto outputs_to_concat = split->outputs();
|
||||
if (sequence) {
|
||||
outputs_to_concat[outputs_to_concat.size() - 1] = sequence->output(1);
|
||||
}
|
||||
auto concat = make_shared<ov::opset9::Concat>(outputs_to_concat, p.concat_axis);
|
||||
auto sigmoid = make_shared<ov::opset9::Sigmoid>(concat);
|
||||
auto res = make_shared<ov::opset9::Result>(sigmoid);
|
||||
auto concat = make_shared<ov::op::v0::Concat>(outputs_to_concat, p.concat_axis);
|
||||
auto sigmoid = make_shared<ov::op::v0::Sigmoid>(concat);
|
||||
auto res = make_shared<ov::op::v0::Result>(sigmoid);
|
||||
auto model = make_shared<ov::Model>(ResultVector{res}, ParameterVector{params});
|
||||
|
||||
pass::Manager pass_manager;
|
||||
|
|
@ -1259,11 +1257,11 @@ TEST_P(SplitConcatElimination, eliminate_split_concat_subgraph) {
|
|||
// the transformation won't be applied if split_len is not equal to 1
|
||||
size_t expect_concat = p.split_len == 1 ? 0 : 1;
|
||||
size_t expect_split = p.split_len == 1 ? 0 : 1;
|
||||
EXPECT_EQ(count_ops_of_type<ov::opset9::Concat>(model), expect_concat)
|
||||
EXPECT_EQ(count_ops_of_type<ov::op::v0::Concat>(model), expect_concat)
|
||||
<< "SplitConcatElimination transformation has failed. "
|
||||
"The number of Concat ops is not " +
|
||||
to_string(expect_concat);
|
||||
EXPECT_EQ(count_ops_of_type<ov::opset9::Split>(model) + count_ops_of_type<ov::opset9::VariadicSplit>(model),
|
||||
EXPECT_EQ(count_ops_of_type<ov::op::v1::Split>(model) + count_ops_of_type<ov::op::v1::VariadicSplit>(model),
|
||||
expect_split)
|
||||
<< "SplitConcatElimination transformation has failed. "
|
||||
"The number of Split/VariadicSplit ops is not " +
|
||||
|
|
@ -1288,17 +1286,17 @@ INSTANTIATE_TEST_SUITE_P(SplitConcatElimination, SplitConcatElimination, testing
|
|||
|
||||
TEST(SplitConcatElimination, split_inputs_not_in_order) {
|
||||
int64_t axis = 1;
|
||||
auto axis_const = make_shared<ov::opset9::Constant>(element::i64, Shape{}, axis);
|
||||
auto axis_const = make_shared<ov::op::v0::Constant>(element::i64, Shape{}, axis);
|
||||
|
||||
auto param = make_shared<ov::opset9::Parameter>(element::f32, Shape{2, 10});
|
||||
auto split = make_shared<ov::opset9::Split>(param->output(0), axis_const, 10);
|
||||
auto param = make_shared<ov::op::v0::Parameter>(element::f32, Shape{2, 10});
|
||||
auto split = make_shared<ov::op::v1::Split>(param->output(0), axis_const, 10);
|
||||
OutputVector outputs_to_concat = split->outputs();
|
||||
|
||||
// change order of inputs to Concat, in this case the transformation won't be applied
|
||||
std::reverse(outputs_to_concat.begin(), outputs_to_concat.end());
|
||||
auto concat = make_shared<ov::opset9::Concat>(outputs_to_concat, axis);
|
||||
auto sigmoid = make_shared<ov::opset9::Sigmoid>(concat);
|
||||
auto res = make_shared<ov::opset9::Result>(sigmoid);
|
||||
auto concat = make_shared<ov::op::v0::Concat>(outputs_to_concat, axis);
|
||||
auto sigmoid = make_shared<ov::op::v0::Sigmoid>(concat);
|
||||
auto res = make_shared<ov::op::v0::Result>(sigmoid);
|
||||
auto model = make_shared<ov::Model>(ResultVector{res}, ParameterVector{param});
|
||||
|
||||
pass::Manager pass_manager;
|
||||
|
|
@ -1306,25 +1304,25 @@ TEST(SplitConcatElimination, split_inputs_not_in_order) {
|
|||
pass_manager.register_pass<ov::pass::NopElimination>();
|
||||
pass_manager.run_passes(model);
|
||||
// the transformation shouldn't be applied
|
||||
EXPECT_EQ(count_ops_of_type<ov::opset9::Concat>(model), 1) << "SplitConcatElimination transformation has failed. "
|
||||
EXPECT_EQ(count_ops_of_type<ov::op::v0::Concat>(model), 1) << "SplitConcatElimination transformation has failed. "
|
||||
"The number of Concat ops is not 1";
|
||||
EXPECT_EQ(count_ops_of_type<ov::opset9::Split>(model), 1) << "SplitConcatElimination transformation has failed. "
|
||||
EXPECT_EQ(count_ops_of_type<ov::op::v1::Split>(model), 1) << "SplitConcatElimination transformation has failed. "
|
||||
"The number of Split ops is not 1";
|
||||
}
|
||||
|
||||
TEST(SplitConcatElimination, no_sequence_found) {
|
||||
int64_t axis = 1;
|
||||
auto axis_const = make_shared<ov::opset9::Constant>(element::i64, Shape{}, axis);
|
||||
auto axis_const = make_shared<ov::op::v0::Constant>(element::i64, Shape{}, axis);
|
||||
|
||||
auto param = make_shared<ov::opset9::Parameter>(element::f32, Shape{2, 10});
|
||||
auto param_2 = make_shared<ov::opset9::Parameter>(element::f32, Shape{2, 1});
|
||||
auto split = make_shared<ov::opset9::Split>(param->output(0), axis_const, 10);
|
||||
auto param = make_shared<ov::op::v0::Parameter>(element::f32, Shape{2, 10});
|
||||
auto param_2 = make_shared<ov::op::v0::Parameter>(element::f32, Shape{2, 1});
|
||||
auto split = make_shared<ov::op::v1::Split>(param->output(0), axis_const, 10);
|
||||
OutputVector outputs_to_concat = split->outputs();
|
||||
|
||||
outputs_to_concat[outputs_to_concat.size() - 1] = param_2;
|
||||
auto concat = make_shared<ov::opset9::Concat>(outputs_to_concat, axis);
|
||||
auto sigmoid = make_shared<ov::opset9::Sigmoid>(concat);
|
||||
auto res = make_shared<ov::opset9::Result>(sigmoid);
|
||||
auto concat = make_shared<ov::op::v0::Concat>(outputs_to_concat, axis);
|
||||
auto sigmoid = make_shared<ov::op::v0::Sigmoid>(concat);
|
||||
auto res = make_shared<ov::op::v0::Result>(sigmoid);
|
||||
auto model = make_shared<ov::Model>(ResultVector{res}, ParameterVector{param, param_2});
|
||||
|
||||
pass::Manager pass_manager;
|
||||
|
|
@ -1332,9 +1330,9 @@ TEST(SplitConcatElimination, no_sequence_found) {
|
|||
pass_manager.register_pass<ov::pass::NopElimination>();
|
||||
pass_manager.run_passes(model);
|
||||
// the transformation shouldn't be applied
|
||||
EXPECT_EQ(count_ops_of_type<ov::opset9::Concat>(model), 1) << "SplitConcatElimination transformation has failed. "
|
||||
EXPECT_EQ(count_ops_of_type<ov::op::v0::Concat>(model), 1) << "SplitConcatElimination transformation has failed. "
|
||||
"The number of Concat ops is not 1";
|
||||
EXPECT_EQ(count_ops_of_type<ov::opset9::Split>(model), 1) << "SplitConcatElimination transformation has failed. "
|
||||
EXPECT_EQ(count_ops_of_type<ov::op::v1::Split>(model), 1) << "SplitConcatElimination transformation has failed. "
|
||||
"The number of Split ops is not 1";
|
||||
}
|
||||
|
||||
|
|
@ -1396,84 +1394,84 @@ TEST(nop_elimination, not_gather_to_squeeze_with_vector_indices) {
|
|||
|
||||
TEST_F(TransformationTestsF, Nopv1Broadcast) {
|
||||
{
|
||||
auto data = std::make_shared<opset10::Parameter>(element::f32, PartialShape{-1, -1, -1, -1});
|
||||
auto broadcast_shape = opset10::Constant::create(element::i32, Shape{4}, {1, 1, 1, 1});
|
||||
auto data = std::make_shared<ov::op::v0::Parameter>(element::f32, PartialShape{-1, -1, -1, -1});
|
||||
auto broadcast_shape = ov::op::v0::Constant::create(element::i32, Shape{4}, {1, 1, 1, 1});
|
||||
auto broadcast = std::make_shared<op::v1::Broadcast>(data, broadcast_shape);
|
||||
auto relu = std::make_shared<op::v0::Relu>(broadcast);
|
||||
auto result = std::make_shared<opset10::Result>(relu);
|
||||
auto result = std::make_shared<ov::op::v0::Result>(relu);
|
||||
model = std::make_shared<ov::Model>(ResultVector{result}, ParameterVector{data});
|
||||
manager.register_pass<ov::pass::EliminateNopBroadcast>();
|
||||
}
|
||||
{
|
||||
auto data = std::make_shared<opset10::Parameter>(element::f32, PartialShape{-1, -1, -1, -1});
|
||||
auto data = std::make_shared<ov::op::v0::Parameter>(element::f32, PartialShape{-1, -1, -1, -1});
|
||||
auto relu = std::make_shared<op::v0::Relu>(data);
|
||||
auto result = std::make_shared<opset10::Result>(relu);
|
||||
auto result = std::make_shared<ov::op::v0::Result>(relu);
|
||||
model_ref = std::make_shared<ov::Model>(ResultVector{result}, ParameterVector{data});
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(TransformationTestsF, Nopv3Broadcast) {
|
||||
{
|
||||
auto data = std::make_shared<opset10::Parameter>(element::f32, PartialShape{-1, -1, -1, -1});
|
||||
auto broadcast_shape = opset10::Constant::create(element::i32, Shape{4}, {1, 1, 1, 1});
|
||||
auto data = std::make_shared<ov::op::v0::Parameter>(element::f32, PartialShape{-1, -1, -1, -1});
|
||||
auto broadcast_shape = ov::op::v0::Constant::create(element::i32, Shape{4}, {1, 1, 1, 1});
|
||||
auto broadcast = std::make_shared<op::v3::Broadcast>(data, broadcast_shape);
|
||||
auto relu = std::make_shared<op::v0::Relu>(broadcast);
|
||||
auto result = std::make_shared<opset10::Result>(relu);
|
||||
auto result = std::make_shared<ov::op::v0::Result>(relu);
|
||||
model = std::make_shared<ov::Model>(ResultVector{result}, ParameterVector{data});
|
||||
manager.register_pass<ov::pass::EliminateNopBroadcast>();
|
||||
}
|
||||
{
|
||||
auto data = std::make_shared<opset10::Parameter>(element::f32, PartialShape{-1, -1, -1, -1});
|
||||
auto data = std::make_shared<ov::op::v0::Parameter>(element::f32, PartialShape{-1, -1, -1, -1});
|
||||
auto relu = std::make_shared<op::v0::Relu>(data);
|
||||
auto result = std::make_shared<opset10::Result>(relu);
|
||||
auto result = std::make_shared<ov::op::v0::Result>(relu);
|
||||
model_ref = std::make_shared<ov::Model>(ResultVector{result}, ParameterVector{data});
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(TransformationTestsF, NopTile) {
|
||||
{
|
||||
auto data = std::make_shared<opset10::Parameter>(element::f32, PartialShape{-1, -1, -1, -1});
|
||||
auto repeats = opset10::Constant::create(element::i32, Shape{4}, {1, 1, 1, 1});
|
||||
auto data = std::make_shared<ov::op::v0::Parameter>(element::f32, PartialShape{-1, -1, -1, -1});
|
||||
auto repeats = ov::op::v0::Constant::create(element::i32, Shape{4}, {1, 1, 1, 1});
|
||||
auto tile = std::make_shared<op::v0::Tile>(data, repeats);
|
||||
auto relu = std::make_shared<op::v0::Relu>(tile);
|
||||
auto result = std::make_shared<opset10::Result>(relu);
|
||||
auto result = std::make_shared<ov::op::v0::Result>(relu);
|
||||
model = std::make_shared<ov::Model>(ResultVector{result}, ParameterVector{data});
|
||||
manager.register_pass<ov::pass::EliminateNopBroadcast>();
|
||||
}
|
||||
{
|
||||
auto data = std::make_shared<opset10::Parameter>(element::f32, PartialShape{-1, -1, -1, -1});
|
||||
auto data = std::make_shared<ov::op::v0::Parameter>(element::f32, PartialShape{-1, -1, -1, -1});
|
||||
auto relu = std::make_shared<op::v0::Relu>(data);
|
||||
auto result = std::make_shared<opset10::Result>(relu);
|
||||
auto result = std::make_shared<ov::op::v0::Result>(relu);
|
||||
model_ref = std::make_shared<ov::Model>(ResultVector{result}, ParameterVector{data});
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(TransformationTestsF, NopSliceBeforeGatherElements) {
|
||||
{
|
||||
auto data = std::make_shared<opset10::Parameter>(element::f32, PartialShape{-1, -1, -1, -1});
|
||||
auto data = std::make_shared<ov::op::v0::Parameter>(element::f32, PartialShape{-1, -1, -1, -1});
|
||||
|
||||
auto start = opset10::Constant::create(element::i32, Shape{1}, {0});
|
||||
auto stop = opset10::Constant::create(element::i32, Shape{1}, {2});
|
||||
auto step = opset10::Constant::create(element::i32, Shape{1}, {1});
|
||||
auto axis = opset10::Constant::create(element::i32, Shape{1}, {-1});
|
||||
auto start = ov::op::v0::Constant::create(element::i32, Shape{1}, {0});
|
||||
auto stop = ov::op::v0::Constant::create(element::i32, Shape{1}, {2});
|
||||
auto step = ov::op::v0::Constant::create(element::i32, Shape{1}, {1});
|
||||
auto axis = ov::op::v0::Constant::create(element::i32, Shape{1}, {-1});
|
||||
auto slice = std::make_shared<op::v8::Slice>(data, start, stop, step, axis);
|
||||
|
||||
auto indices = std::make_shared<opset10::Parameter>(element::i64, PartialShape{-1, -1, -1, -1});
|
||||
auto indices = std::make_shared<ov::op::v0::Parameter>(element::i64, PartialShape{-1, -1, -1, -1});
|
||||
auto gather_elements = std::make_shared<op::v6::GatherElements>(slice, indices, 2);
|
||||
|
||||
auto relu = std::make_shared<op::v0::Relu>(gather_elements);
|
||||
auto result = std::make_shared<opset10::Result>(relu);
|
||||
auto result = std::make_shared<ov::op::v0::Result>(relu);
|
||||
model = std::make_shared<ov::Model>(ResultVector{result}, ParameterVector{data, indices});
|
||||
manager.register_pass<ov::pass::NopSliceBeforeGatherElements>();
|
||||
}
|
||||
{
|
||||
auto data = std::make_shared<opset10::Parameter>(element::f32, PartialShape{-1, -1, -1, -1});
|
||||
auto indices = std::make_shared<opset10::Parameter>(element::i64, PartialShape{-1, -1, -1, -1});
|
||||
auto data = std::make_shared<ov::op::v0::Parameter>(element::f32, PartialShape{-1, -1, -1, -1});
|
||||
auto indices = std::make_shared<ov::op::v0::Parameter>(element::i64, PartialShape{-1, -1, -1, -1});
|
||||
|
||||
auto gather_elements = std::make_shared<op::v6::GatherElements>(data, indices, 2);
|
||||
|
||||
auto relu = std::make_shared<op::v0::Relu>(gather_elements);
|
||||
auto result = std::make_shared<opset10::Result>(relu);
|
||||
auto result = std::make_shared<ov::op::v0::Result>(relu);
|
||||
model_ref = std::make_shared<ov::Model>(ResultVector{result}, ParameterVector{data, indices});
|
||||
}
|
||||
}
|
||||
|
|
@ -1628,7 +1626,7 @@ TEST_F(TransformationTestsF, SqueezeBinaryReshape) {
|
|||
manager.register_pass<ov::pass::NopElimination>();
|
||||
}
|
||||
{
|
||||
auto data = std::make_shared<opset10::Parameter>(element::f32, PartialShape{1});
|
||||
auto data = std::make_shared<ov::op::v0::Parameter>(element::f32, PartialShape{1});
|
||||
auto binary = std::make_shared<op::v1::Multiply>(data, op::v0::Constant::create(element::f32, Shape{1}, {0.2}));
|
||||
auto relu = std::make_shared<op::v0::Relu>(binary);
|
||||
model_ref = std::make_shared<ov::Model>(OutputVector{relu}, ParameterVector{data});
|
||||
|
|
|
|||
|
|
@ -7,6 +7,13 @@
|
|||
#include <gtest/gtest.h>
|
||||
|
||||
#include "common_test_utils/ov_test_utils.hpp"
|
||||
#include "openvino/op/reduce_logical_and.hpp"
|
||||
#include "openvino/op/reduce_logical_or.hpp"
|
||||
#include "openvino/op/reduce_max.hpp"
|
||||
#include "openvino/op/reduce_mean.hpp"
|
||||
#include "openvino/op/reduce_min.hpp"
|
||||
#include "openvino/op/reduce_prod.hpp"
|
||||
#include "openvino/op/reduce_sum.hpp"
|
||||
#include "openvino/opsets/opset.hpp"
|
||||
#include "transformations/utils/utils.hpp"
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
#include <gtest/gtest.h>
|
||||
|
||||
#include "common_test_utils/ov_test_utils.hpp"
|
||||
#include "openvino/opsets/opset8.hpp"
|
||||
#include "transformations/low_precision/mark_dequantization_subgraph.hpp"
|
||||
#include "transformations/utils/utils.hpp"
|
||||
|
||||
|
|
|
|||
|
|
@ -10,9 +10,14 @@
|
|||
#include "common_test_utils/type_prop.hpp"
|
||||
#include "openvino/core/model.hpp"
|
||||
#include "openvino/core/validation_util.hpp"
|
||||
#include "openvino/op/add.hpp"
|
||||
#include "openvino/op/concat.hpp"
|
||||
#include "openvino/op/divide.hpp"
|
||||
#include "openvino/op/matmul.hpp"
|
||||
#include "openvino/op/multiply.hpp"
|
||||
#include "openvino/op/parameter.hpp"
|
||||
#include "openvino/op/reshape.hpp"
|
||||
#include "openvino/op/util/op_types.hpp"
|
||||
#include "transformations/utils/utils.hpp"
|
||||
|
||||
using namespace ov;
|
||||
|
|
|
|||
|
|
@ -10,6 +10,9 @@
|
|||
#include <string>
|
||||
|
||||
#include "common_test_utils/ov_test_utils.hpp"
|
||||
#include "openvino/op/add.hpp"
|
||||
#include "openvino/op/parameter.hpp"
|
||||
#include "openvino/op/transpose.hpp"
|
||||
#include "transformations/rt_info/transpose_sinking_attr.hpp"
|
||||
#include "transformations/utils/utils.hpp"
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,9 @@
|
|||
#include "transformations/transpose_sinking/ts_shape_of.hpp"
|
||||
|
||||
#include "common_test_utils/ov_test_utils.hpp"
|
||||
#include "openvino/op/abs.hpp"
|
||||
#include "openvino/op/gather.hpp"
|
||||
#include "openvino/op/shape_of.hpp"
|
||||
#include "transformations/transpose_sinking/ts_fuse.hpp"
|
||||
|
||||
using namespace ov;
|
||||
|
|
|
|||
|
|
@ -10,12 +10,7 @@
|
|||
#include "common_test_utils/ov_test_utils.hpp"
|
||||
#include "common_test_utils/test_tools.hpp"
|
||||
#include "openvino/core/constant_fold_utils.hpp"
|
||||
#include "openvino/op/acosh.hpp"
|
||||
#include "openvino/op/add.hpp"
|
||||
#include "openvino/op/constant.hpp"
|
||||
#include "openvino/op/convert_like.hpp"
|
||||
#include "openvino/op/loop.hpp"
|
||||
#include "openvino/op/multiply.hpp"
|
||||
#include "openvino/op/ops.hpp"
|
||||
#include "ov_ops/type_relaxed.hpp"
|
||||
#include "transformations/common_optimizations/disable_shapeof_constant_folding.hpp"
|
||||
#include "transformations/utils/utils.hpp"
|
||||
|
|
|
|||
|
|
@ -19,8 +19,11 @@
|
|||
#include "openvino/op/broadcast.hpp"
|
||||
#include "openvino/op/constant.hpp"
|
||||
#include "openvino/op/cos.hpp"
|
||||
#include "openvino/op/cosh.hpp"
|
||||
#include "openvino/op/divide.hpp"
|
||||
#include "openvino/op/equal.hpp"
|
||||
#include "openvino/op/exp.hpp"
|
||||
#include "openvino/op/greater.hpp"
|
||||
#include "openvino/op/multiply.hpp"
|
||||
#include "openvino/op/parameter.hpp"
|
||||
#include "openvino/op/reduce_sum.hpp"
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
#include "helper_ops/sparse_fill_empty_rows.hpp"
|
||||
#include "helper_ops/sparse_segment_ops.hpp"
|
||||
#include "openvino/op/broadcast.hpp"
|
||||
#include "openvino/op/concat.hpp"
|
||||
#include "openvino/op/constant.hpp"
|
||||
#include "openvino/op/convert.hpp"
|
||||
#include "openvino/op/embedding_segments_sum.hpp"
|
||||
|
|
@ -17,6 +18,8 @@
|
|||
#include "openvino/op/greater_eq.hpp"
|
||||
#include "openvino/op/non_zero.hpp"
|
||||
#include "openvino/op/reshape.hpp"
|
||||
#include "openvino/op/select.hpp"
|
||||
#include "openvino/op/shape_of.hpp"
|
||||
#include "openvino/op/split.hpp"
|
||||
#include "openvino/op/squeeze.hpp"
|
||||
#include "openvino/op/strided_slice.hpp"
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
#include "openvino/op/constant.hpp"
|
||||
#include "openvino/op/gru_cell.hpp"
|
||||
#include "openvino/op/shape_of.hpp"
|
||||
#include "openvino/op/slice.hpp"
|
||||
#include "openvino/op/split.hpp"
|
||||
#include "openvino/op/transpose.hpp"
|
||||
#include "openvino/op/variadic_split.hpp"
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ bool model_has_suitable_do(const std::shared_ptr<const ov::Model>& model) {
|
|||
for (auto& result_node : model->get_results()) {
|
||||
auto do_node = result_node->input_value(0).get_node_shared_ptr();
|
||||
std::shared_ptr<ov::Node> convert_node;
|
||||
if (ov::is_type<ov::opset1::Convert>(do_node)) { // cases with do->convert->result
|
||||
if (ov::is_type<ov::op::v0::Convert>(do_node)) { // cases with do->convert->result
|
||||
convert_node = do_node;
|
||||
do_node = convert_node->get_input_node_shared_ptr(0);
|
||||
}
|
||||
|
|
@ -77,7 +77,7 @@ std::shared_ptr<const ov::Model> apply_batch_affinity(const std::shared_ptr<cons
|
|||
for (auto& result_node : model->get_results()) {
|
||||
auto do_node = result_node->input_value(0).get_node_shared_ptr();
|
||||
std::shared_ptr<ov::Node> convert_node;
|
||||
if (ov::is_type<ov::opset1::Convert>(do_node)) { // cases with do->convert->result
|
||||
if (ov::is_type<ov::op::v0::Convert>(do_node)) { // cases with do->convert->result
|
||||
convert_node = do_node;
|
||||
do_node = convert_node->get_input_node_shared_ptr(0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,13 +7,24 @@
|
|||
|
||||
#include "openvino/core/rt_info.hpp"
|
||||
#include "openvino/op/add.hpp"
|
||||
#include "openvino/op/concat.hpp"
|
||||
#include "openvino/op/constant.hpp"
|
||||
#include "openvino/op/convert.hpp"
|
||||
#include "openvino/op/divide.hpp"
|
||||
#include "openvino/op/gather.hpp"
|
||||
#include "openvino/op/interpolate.hpp"
|
||||
#include "openvino/op/log.hpp"
|
||||
#include "openvino/op/log_softmax.hpp"
|
||||
#include "openvino/op/matmul.hpp"
|
||||
#include "openvino/op/parameter.hpp"
|
||||
#include "openvino/op/prelu.hpp"
|
||||
#include "openvino/op/reduce_l2.hpp"
|
||||
#include "openvino/op/reshape.hpp"
|
||||
#include "openvino/op/result.hpp"
|
||||
#include "openvino/op/shape_of.hpp"
|
||||
#include "openvino/op/subtract.hpp"
|
||||
#include "openvino/op/transpose.hpp"
|
||||
#include "openvino/op/util/op_types.hpp"
|
||||
#include "openvino/pass/constant_folding.hpp"
|
||||
#include "openvino/pass/manager.hpp"
|
||||
#include "openvino/runtime/iplugin.hpp"
|
||||
|
|
|
|||
|
|
@ -12,6 +12,9 @@
|
|||
|
||||
#include <transformations/utils/utils.hpp>
|
||||
|
||||
#include "openvino/op/convolution.hpp"
|
||||
#include "openvino/op/fake_quantize.hpp"
|
||||
#include "openvino/op/group_conv.hpp"
|
||||
#include "openvino/runtime/auto/properties.hpp"
|
||||
#include "openvino/runtime/device_id_parser.hpp"
|
||||
#include "openvino/runtime/internal_properties.hpp"
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include "cpu_map_scheduling.hpp"
|
||||
#include "graph.h"
|
||||
#include "openvino/op/fake_quantize.hpp"
|
||||
#include "openvino/runtime/performance_heuristics.hpp"
|
||||
#include "openvino/runtime/threading/cpu_streams_info.hpp"
|
||||
#include "openvino/runtime/threading/istreams_executor.hpp"
|
||||
|
|
|
|||
|
|
@ -18,6 +18,11 @@
|
|||
#include "ov_ops/augru_cell.hpp"
|
||||
#include "ov_ops/augru_sequence.hpp"
|
||||
|
||||
#include "openvino/op/gru_cell.hpp"
|
||||
#include "openvino/op/gru_sequence.hpp"
|
||||
#include "openvino/op/lstm_sequence.hpp"
|
||||
#include "openvino/op/rnn_cell.hpp"
|
||||
#include "openvino/op/rnn_sequence.hpp"
|
||||
#include "openvino/core/node.hpp"
|
||||
|
||||
#include <oneapi/dnnl/dnnl.hpp>
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@
|
|||
#include <memory_desc/cpu_memory_desc_utils.h>
|
||||
#include "utils/ngraph_utils.hpp"
|
||||
#include <partitioned_mem_mgr.h>
|
||||
#include "openvino/op/split.hpp"
|
||||
#include "openvino/op/variadic_split.hpp"
|
||||
|
||||
#define THROW_ERROR(...) OPENVINO_THROW("Split layer with name '", getName(), "' ", __VA_ARGS__)
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,8 @@
|
|||
#include "transformations/utils/utils.hpp"
|
||||
#include "utils/general_utils.h"
|
||||
#include "utils/debug_capabilities.h"
|
||||
#include "openvino/op/tensor_iterator.hpp"
|
||||
#include "openvino/op/loop.hpp"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
#include "openvino/op/multiply.hpp"
|
||||
#include "openvino/op/reshape.hpp"
|
||||
#include "openvino/op/subtract.hpp"
|
||||
#include "openvino/op/transpose.hpp"
|
||||
#include "openvino/op/variadic_split.hpp"
|
||||
#include "transformations/cpu_opset/common/op/fully_connected.hpp"
|
||||
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ TEST(TransformationTests, CheckConvertGroupConvIsApplied) {
|
|||
ov::Strides{1});
|
||||
concat_inputs.push_back(conv);
|
||||
}
|
||||
auto concat = std::make_shared<ov::opset8::Concat>(concat_inputs, 1);
|
||||
auto concat = std::make_shared<ov::op::v0::Concat>(concat_inputs, 1);
|
||||
model_ref = std::make_shared<ov::Model>(ov::NodeVector{ concat }, ov::ParameterVector{ param });
|
||||
}
|
||||
auto res = compare_functions(model, model_ref);
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ template <class T>
|
|||
static std::shared_ptr<ov::Model> createTransformedGraph(ov::Shape param_shape, ov::Shape weights_shape) {
|
||||
auto getUnsqueeze = [&](const ov::Output<ov::Node>& node) {
|
||||
auto rank = node.get_partial_shape().rank().get_length();
|
||||
return std::make_shared<ov::opset8::Unsqueeze>(node,
|
||||
return std::make_shared<ov::op::v0::Unsqueeze>(node,
|
||||
ov::opset1::Constant::create(ov::element::i64, ov::Shape{1}, {rank}));
|
||||
};
|
||||
auto type = ov::element::f32;
|
||||
|
|
|
|||
|
|
@ -15,12 +15,17 @@
|
|||
#include "openvino/op/squared_difference.hpp"
|
||||
#include "openvino/op/equal.hpp"
|
||||
#include "openvino/op/not_equal.hpp"
|
||||
#include "openvino/op/is_finite.hpp"
|
||||
#include "openvino/op/is_inf.hpp"
|
||||
#include "openvino/op/is_nan.hpp"
|
||||
#include "openvino/op/less.hpp"
|
||||
#include "openvino/op/less_eq.hpp"
|
||||
#include "openvino/op/mod.hpp"
|
||||
#include "openvino/op/greater.hpp"
|
||||
#include "openvino/op/greater_eq.hpp"
|
||||
#include "openvino/op/logical_and.hpp"
|
||||
#include "openvino/op/logical_or.hpp"
|
||||
#include "openvino/op/logical_xor.hpp"
|
||||
#include "openvino/op/xor.hpp"
|
||||
#include "openvino/op/power.hpp"
|
||||
#include "openvino/op/floor_mod.hpp"
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
#include "intel_gpu/plugin/common_utils.hpp"
|
||||
#include "intel_gpu/plugin/plugin.hpp"
|
||||
|
||||
#include "openvino/op/add.hpp"
|
||||
#include "openvino/op/tensor_iterator.hpp"
|
||||
#include "openvino/op/loop.hpp"
|
||||
#include "openvino/op/constant.hpp"
|
||||
|
|
|
|||
|
|
@ -33,7 +33,9 @@
|
|||
#include "openvino/op/sinh.hpp"
|
||||
#include "openvino/op/cos.hpp"
|
||||
#include "openvino/op/cosh.hpp"
|
||||
#include "openvino/op/softsign.hpp"
|
||||
#include "openvino/op/swish.hpp"
|
||||
#include "openvino/op/sqrt.hpp"
|
||||
#include "openvino/op/hswish.hpp"
|
||||
#include "openvino/op/mish.hpp"
|
||||
#include "openvino/op/gelu.hpp"
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
#include "openvino/op/constant.hpp"
|
||||
#include "openvino/op/subtract.hpp"
|
||||
#include "openvino/op/matmul.hpp"
|
||||
#include "openvino/op/multiply.hpp"
|
||||
#include "openvino/op/convert.hpp"
|
||||
#include "openvino/op/transpose.hpp"
|
||||
#include "openvino/op/reshape.hpp"
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
#include "openvino/op/gather.hpp"
|
||||
#include "openvino/op/matmul.hpp"
|
||||
#include "openvino/op/read_value.hpp"
|
||||
#include "openvino/op/util/op_types.hpp"
|
||||
#include "openvino/pass/pattern/op/wrap_type.hpp"
|
||||
#include "openvino/pass/pattern/op/or.hpp"
|
||||
#include "transformations/utils/utils.hpp"
|
||||
|
|
|
|||
|
|
@ -11,8 +11,10 @@
|
|||
#include "intel_gpu/plugin/common_utils.hpp"
|
||||
#include "openvino/core/node_vector.hpp"
|
||||
#include "openvino/core/rt_info.hpp"
|
||||
#include "openvino/op/concat.hpp"
|
||||
#include "openvino/op/constant.hpp"
|
||||
#include "openvino/op/convert.hpp"
|
||||
#include "openvino/op/gather.hpp"
|
||||
#include "openvino/op/parameter.hpp"
|
||||
#include "openvino/op/read_value.hpp"
|
||||
#include "openvino/op/sink.hpp"
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@
|
|||
#include "openvino/op/reshape.hpp"
|
||||
#include "openvino/op/add.hpp"
|
||||
#include "openvino/op/maximum.hpp"
|
||||
#include "openvino/op/matmul.hpp"
|
||||
#include "openvino/op/softmax.hpp"
|
||||
#include <plugin/transformations/clamp_fp16_output.hpp>
|
||||
#include <transformations/init_node_info.hpp>
|
||||
#include <transformations/utils/utils.hpp>
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
#include <openvino/op/fake_quantize.hpp>
|
||||
#include <openvino/op/binary_convolution.hpp>
|
||||
#include <openvino/op/convolution.hpp>
|
||||
#include <openvino/op/pad.hpp>
|
||||
#include <plugin/transformations/binary_conv_to_conv.hpp>
|
||||
#include <transformations/init_node_info.hpp>
|
||||
#include <transformations/utils/utils.hpp>
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
#include "openvino/core/partial_shape.hpp"
|
||||
#include "openvino/op/parameter.hpp"
|
||||
#include "openvino/op/result.hpp"
|
||||
#include "openvino/op/gather.hpp"
|
||||
#include "openvino/pass/manager.hpp"
|
||||
|
||||
#include <transformations/utils/utils.hpp>
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@
|
|||
#include "intel_gpu/op/read_value.hpp"
|
||||
#include "openvino/core/node_vector.hpp"
|
||||
#include "openvino/core/partial_shape.hpp"
|
||||
#include "openvino/op/concat.hpp"
|
||||
#include "openvino/op/gather.hpp"
|
||||
#include "openvino/op/parameter.hpp"
|
||||
#include "openvino/op/result.hpp"
|
||||
#include "openvino/op/sink.hpp"
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
#include "sync_infer_request.hpp"
|
||||
|
||||
#include "intel_npu/al/prefix.hpp"
|
||||
#include "openvino/op/util/op_types.hpp"
|
||||
#include "openvino/runtime/make_tensor.hpp"
|
||||
#include "openvino/runtime/plugin_itt.hpp"
|
||||
#include "transformations/utils/utils.hpp"
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
#include <memory>
|
||||
|
||||
#include "itt.hpp"
|
||||
#include "openvino/op/ops.hpp"
|
||||
#include "openvino/pass/manager.hpp"
|
||||
#include "openvino/runtime/internal_properties.hpp"
|
||||
#include "openvino/runtime/properties.hpp"
|
||||
|
|
|
|||
|
|
@ -509,7 +509,7 @@ std::shared_ptr<ov::Model> MHAWOTransposeOnInputsFunction::initOriginal() const
|
|||
const auto mulConst = ov::test::utils::deprecated::make_constant(precision, ov::Shape({1}), std::vector<float>{1}, true);
|
||||
const auto mul = std::make_shared<ov::op::v1::Multiply>(param1, mulConst);
|
||||
const auto matMul0 = std::make_shared<ov::op::v0::MatMul>(param0, mul, transA, transB);
|
||||
const auto softmax = std::make_shared<ov::opset8::Softmax>(matMul0, -1);
|
||||
const auto softmax = std::make_shared<ov::op::v8::Softmax>(matMul0, -1);
|
||||
const auto matMul1 = std::make_shared<ov::op::v0::MatMul>(softmax, param2, transA, transB);
|
||||
const auto transpose3 = std::make_shared<ov::op::v1::Transpose>(matMul1, transpose3Const);
|
||||
|
||||
|
|
@ -526,7 +526,7 @@ std::shared_ptr<ov::Model> MHAWOTransposeFunction::initOriginal() const {
|
|||
float transA = false;
|
||||
float transB = false;
|
||||
const auto matMul0 = std::make_shared<ov::op::v0::MatMul>(param0, param1, transA, transB);
|
||||
const auto softmax = std::make_shared<ov::opset8::Softmax>(matMul0, -1);
|
||||
const auto softmax = std::make_shared<ov::op::v8::Softmax>(matMul0, -1);
|
||||
const auto matMul1 = std::make_shared<ov::op::v0::MatMul>(softmax, param2, transA, transB);
|
||||
|
||||
ov::ResultVector results{std::make_shared<ov::opset1::Result>(matMul1)};
|
||||
|
|
@ -553,7 +553,7 @@ std::shared_ptr<ov::Model> MHAWOTransposeSplitMFunction::initReference() const {
|
|||
auto data2 = std::make_shared<ov::opset1::Parameter>(precisions[2], reshape2->get_shape());
|
||||
|
||||
const auto matMul0 = std::make_shared<ov::op::v0::MatMul>(data0, data1);
|
||||
const auto softmax = std::make_shared<ov::opset8::Softmax>(matMul0, -1);
|
||||
const auto softmax = std::make_shared<ov::op::v8::Softmax>(matMul0, -1);
|
||||
const auto matMul1 = std::make_shared<ov::op::v0::MatMul>(softmax, data2);
|
||||
|
||||
const auto subgraph = std::make_shared<ov::snippets::op::Subgraph>(ov::NodeVector{reshape0, reshape1, reshape2},
|
||||
|
|
@ -698,7 +698,7 @@ std::shared_ptr<ov::Model> MHAQuantMatMul0Function::initOriginal() const {
|
|||
|
||||
const auto matMul0 = std::make_shared<ov::op::v0::MatMul>(transpose0, fq1);
|
||||
const auto add = std::make_shared<ov::op::v1::Add>(matMul0, addParam);
|
||||
const auto softMax = std::make_shared<ov::opset8::Softmax>(add, -1);
|
||||
const auto softMax = std::make_shared<ov::op::v8::Softmax>(add, -1);
|
||||
|
||||
const auto matMul1 = std::make_shared<ov::op::v0::MatMul>(softMax, transpose2);
|
||||
auto fq2 = ov::test::utils::make_fake_quantize(matMul1, ov::element::f32, 256, {1},
|
||||
|
|
@ -950,7 +950,7 @@ std::shared_ptr<ov::Model> MHATransposedInputFunction::initOriginal() const {
|
|||
}
|
||||
|
||||
const auto matMul0 = std::make_shared<ov::op::v0::MatMul>(param0, matmul0_in1, false, m_transposed_b);
|
||||
const auto softmax = std::make_shared<ov::opset8::Softmax>(matMul0, -1);
|
||||
const auto softmax = std::make_shared<ov::op::v8::Softmax>(matMul0, -1);
|
||||
const auto matMul1 = std::make_shared<ov::op::v0::MatMul>(softmax, param2);
|
||||
|
||||
ov::ResultVector results{std::make_shared<ov::opset1::Result>(matMul1)};
|
||||
|
|
@ -993,7 +993,7 @@ std::shared_ptr<ov::Model> MHATransposedInputFunction::initReference() const {
|
|||
}
|
||||
|
||||
const auto matMul0 = std::make_shared<ov::op::v0::MatMul>(param0, matmul0_in1);
|
||||
const auto softmax = std::make_shared<ov::opset8::Softmax>(matMul0, -1);
|
||||
const auto softmax = std::make_shared<ov::op::v8::Softmax>(matMul0, -1);
|
||||
const auto matMul1 = std::make_shared<ov::op::v0::MatMul>(softmax, param2);
|
||||
|
||||
auto subgraph = std::make_shared<ov::snippets::op::Subgraph>(ov::NodeVector{data0, in1, data2},
|
||||
|
|
@ -1036,7 +1036,7 @@ std::shared_ptr<ov::Model> MHAWithExtractedReshapeFunction::initOriginal() const
|
|||
const auto target_shape_const_2 = ov::opset1::Constant::create(ov::element::i32, ov::Shape{mm_out_shape.size()}, mm_out_shape);
|
||||
const auto reshape_2 = std::make_shared<ov::opset1::Reshape>(add_2, target_shape_const_2, false);
|
||||
|
||||
const auto softmax = std::make_shared<ov::opset8::Softmax>(reshape_2, -1);
|
||||
const auto softmax = std::make_shared<ov::op::v8::Softmax>(reshape_2, -1);
|
||||
const auto matmul_1 = std::make_shared<ov::opset1::MatMul>(softmax, param_4);
|
||||
|
||||
ov::ResultVector results{std::make_shared<ov::opset1::Result>(matmul_1)};
|
||||
|
|
@ -1074,7 +1074,7 @@ std::shared_ptr<ov::Model> MHAWithExtractedReshapeFunction::initReference() cons
|
|||
|
||||
const auto matmul_0 = std::make_shared<ov::op::v0::MatMul>(param_0, param_1);
|
||||
const auto add_internal = std::make_shared<ov::opset1::Add>(matmul_0, param_2);
|
||||
const auto softmax = std::make_shared<ov::opset8::Softmax>(add_internal, -1);
|
||||
const auto softmax = std::make_shared<ov::op::v8::Softmax>(add_internal, -1);
|
||||
const auto matmul_1 = std::make_shared<ov::op::v0::MatMul>(softmax, param_3);
|
||||
|
||||
auto subgraph_model = std::make_shared<ov::Model>(NodeVector{matmul_1}, ov::ParameterVector{param_0, param_1, param_2, param_3});
|
||||
|
|
|
|||
Loading…
Reference in New Issue