[CORE] depracate get/set_concatenation_axis functions (#24737)
### Details: - remove `set_concatenation_axis` function usage - replace `get_concatenation_axis` function usage ### Tickets: - [CVS-94507](https://jira.devtools.intel.com/browse/CVS-94507) ### Related PR: - https://github.com/openvinotoolkit/openvino/pull/24383 --------- Co-authored-by: Michal Lukaszewski <michal.lukaszewski@intel.com>
This commit is contained in:
parent
0cc051debb
commit
416c4ffb7e
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
#include <memory>
|
||||
#include "openvino/core/node.hpp"
|
||||
#include "openvino/core/validation_util.hpp"
|
||||
#include "openvino/opsets/opset1.hpp"
|
||||
#include "openvino/pass/pattern/op/or.hpp"
|
||||
|
||||
|
|
@ -83,10 +84,17 @@ bool MoveFakeQuantize::transform(TransformationContext& context, ov::pass::patte
|
|||
if (concat_node == nullptr) {
|
||||
return false;
|
||||
}
|
||||
const auto concat_axis = concat_node->get_concatenation_axis();
|
||||
|
||||
const auto rank = concat_node->get_output_partial_shape(0).rank();
|
||||
if (rank.is_dynamic()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto concat_axis = ov::util::normalize(concat_node->get_axis(), rank.get_length());
|
||||
|
||||
for (size_t i = 0; i < 4; i++) {
|
||||
curr_constants[i] = as_type_ptr<opset1::Constant>(fq->get_input_node_shared_ptr(i + 1));
|
||||
if (!multi_chanels && concat_axis >= 0 && curr_constants[i]->get_shape().size() > static_cast<size_t>(concat_axis)
|
||||
if (!multi_chanels && curr_constants[i]->get_shape().size() > static_cast<size_t>(concat_axis)
|
||||
&& curr_constants[i]->get_shape()[concat_axis] != 1) {
|
||||
multi_chanels = true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1561,7 +1561,11 @@ NetworkHelper::InsertDequantizationResult NetworkHelper::moveDequantizationBefor
|
|||
std::vector<std::vector<std::shared_ptr<ov::opset1::Constant>>> multiplyConstants, subtractConstants;
|
||||
if (is_type<ov::opset1::Concat>(operation)) {
|
||||
const auto concatNode = as_type_ptr<ov::opset1::Concat>(operation);
|
||||
auto axis = concatNode->get_concatenation_axis();
|
||||
int64_t axis = -1;
|
||||
if (concatNode->get_output_partial_shape(0).rank().is_static()) {
|
||||
const auto rank = concatNode->get_output_partial_shape(0).rank().get_length();
|
||||
axis = ov::util::normalize(concatNode->get_axis(), rank);
|
||||
}
|
||||
if (dequantization.multiply && dequantization.multiplyConstant->get_shape().size() > 1 && dequantization.multiplyConstant->get_shape()[axis] != 1) {
|
||||
multiplyConstants = NetworkHelper::splitConstantsBeforeConcat(operation, { dequantization.multiplyConstant });
|
||||
}
|
||||
|
|
@ -1659,7 +1663,11 @@ std::vector<std::vector<std::shared_ptr<ov::opset1::Constant>>> NetworkHelper::s
|
|||
std::vector<std::vector<std::shared_ptr<ov::opset1::Constant>>> newConstants(currConstants.size());
|
||||
auto number_of_concat_inputs = concat->get_input_size();
|
||||
const auto concatNode = as_type_ptr<ov::opset1::Concat>(concat);
|
||||
const auto concat_axis = concatNode->get_concatenation_axis();
|
||||
int64_t concat_axis = -1;
|
||||
if (concatNode->get_output_partial_shape(0).rank().is_static()) {
|
||||
const auto rank = concatNode->get_output_partial_shape(0).rank().get_length();
|
||||
concat_axis = ov::util::normalize(concatNode->get_axis(), rank);
|
||||
}
|
||||
std::vector<int64_t> shape_axis(number_of_concat_inputs);
|
||||
for (size_t i{ 0 }; i < number_of_concat_inputs; ++i) {
|
||||
auto shape = concat->get_input_partial_shape(i);
|
||||
|
|
|
|||
|
|
@ -765,7 +765,11 @@ public:
|
|||
if (!concat_ptr) {
|
||||
return false;
|
||||
}
|
||||
auto axis = concat_ptr->get_concatenation_axis();
|
||||
int64_t axis = -1;
|
||||
if (concat_ptr->get_output_partial_shape(0).rank().is_static()) {
|
||||
const auto rank = concat_ptr->get_output_partial_shape(0).rank().get_length();
|
||||
axis = ov::util::normalize(concat_ptr->get_axis(), rank);
|
||||
}
|
||||
|
||||
auto inputs = concat_ptr->inputs();
|
||||
std::map<int64_t, ov::Mask::Ptr> input_masks;
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
static bool use_broadcast(const std::shared_ptr<ov::op::v0::Concat>& concat) {
|
||||
const auto& output = concat->output(0);
|
||||
const auto& input = concat->input(0);
|
||||
const auto& input_concat_dim = input.get_partial_shape()[concat->get_concatenation_axis()];
|
||||
const auto& input_concat_dim = input.get_partial_shape()[concat->get_axis()];
|
||||
|
||||
return input_concat_dim.is_static() && input_concat_dim.get_length() == 1 && output.get_partial_shape().is_static();
|
||||
}
|
||||
|
|
@ -87,4 +87,4 @@ ov::pass::ConcatToBroadcast::ConcatToBroadcast() {
|
|||
|
||||
auto m = std::make_shared<pattern::Matcher>(concat_label, matcher_name);
|
||||
this->register_matcher(m, callback);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,9 @@ bool concat_predicate(ov::Output<ov::Node> output) {
|
|||
const auto& concat = ov::as_type_ptr<ov::op::v0::Concat>(output.get_node_shared_ptr());
|
||||
if (!concat)
|
||||
return false;
|
||||
return concat->get_concatenation_axis() >= output_pshape.rank().get_length() - 2;
|
||||
|
||||
const auto norm_axis = ov::util::normalize(concat->get_axis(), output_pshape.rank().get_length());
|
||||
return norm_axis >= output_pshape.rank().get_length() - 2;
|
||||
}
|
||||
|
||||
bool last_two_dims_are_equal(const ov::PartialShape& lhs, const ov::PartialShape& rhs) {
|
||||
|
|
@ -136,7 +138,7 @@ void pull_reshape_through_optional_concat_and_bea(const ov::pass::pattern::Patte
|
|||
OPENVINO_ASSERT(concat_node != nullptr,
|
||||
"DeReshapeMatMul transformation matched operation which should be Concat -- but it is not");
|
||||
auto rank = concat_node->get_output_partial_shape(0).rank().get_length();
|
||||
auto axis = (concat_node->get_concatenation_axis() == (rank - 1)) ? -1 : -2;
|
||||
auto axis = (ov::util::normalize(concat_node->get_axis(), rank) == (rank - 1)) ? -1 : -2;
|
||||
|
||||
auto idx_of_reshape_input = reshape_output == concat_node->input_value(0) ? 0 : 1;
|
||||
auto idx_of_non_reshape_input = static_cast<size_t>(!idx_of_reshape_input);
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
#include "itt.hpp"
|
||||
#include "openvino/core/bound_evaluation_util.hpp"
|
||||
#include "openvino/core/rt_info.hpp"
|
||||
#include "openvino/core/validation_util.hpp"
|
||||
#include "openvino/op/add.hpp"
|
||||
#include "openvino/op/concat.hpp"
|
||||
#include "openvino/op/convert.hpp"
|
||||
|
|
@ -163,7 +164,10 @@ ov::Output<ov::Node> alternative_source_from_concat_input_sources(const STS_map&
|
|||
if (!concat || concat->get_input_size() != 2)
|
||||
return alternative_source;
|
||||
int64_t idx = get_idx_of_symbol_in_source(source, symbol);
|
||||
if (idx == -1 || idx != concat->get_concatenation_axis())
|
||||
if (idx == -1)
|
||||
return alternative_source;
|
||||
const auto rank = source.get_partial_shape().rank().get_length();
|
||||
if (idx != ov::util::normalize(concat->get_axis(), rank))
|
||||
return alternative_source;
|
||||
// optimize using the knowledge of the Concat SI and what happens on the axis
|
||||
const auto& lhs_pshape = concat->get_input_partial_shape(0);
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
#include "transformations/transpose_sinking/ts_concat.hpp"
|
||||
|
||||
#include "itt.hpp"
|
||||
#include "openvino/core/validation_util.hpp"
|
||||
#include "openvino/op/concat.hpp"
|
||||
#include "openvino/op/constant.hpp"
|
||||
#include "openvino/op/transpose.hpp"
|
||||
|
|
@ -35,8 +36,7 @@ TSConcatForward::TSConcatForward() {
|
|||
return false;
|
||||
}
|
||||
|
||||
auto concat_axis = concat_node->get_concatenation_axis();
|
||||
if (concat_axis < 0) {
|
||||
if (concat_node->get_output_partial_shape(0).is_dynamic()) {
|
||||
return false;
|
||||
}
|
||||
// todo: support dyn rank case
|
||||
|
|
@ -45,10 +45,12 @@ TSConcatForward::TSConcatForward() {
|
|||
return false;
|
||||
}
|
||||
|
||||
const auto rank = concat_node->get_output_partial_shape(0).rank().get_length();
|
||||
const auto concat_axis = ov::util::normalize(concat_node->get_axis(), rank);
|
||||
|
||||
const auto transpose_axis_order = transpose_info.transpose_const->get_axis_vector_val();
|
||||
const int64_t transposed_concat_axis = transpose_axis_order[concat_axis];
|
||||
concat_node->set_axis(transposed_concat_axis);
|
||||
concat_node->set_concatenation_axis(-1);
|
||||
|
||||
default_outputs_update(main_node, transpose_info);
|
||||
return true;
|
||||
|
|
@ -81,11 +83,13 @@ TSConcatBackward::TSConcatBackward() {
|
|||
}
|
||||
|
||||
auto concat_node = as_type_ptr<ov::op::v0::Concat>(main_node);
|
||||
auto concat_axis = concat_node->get_concatenation_axis();
|
||||
if (concat_axis < 0) {
|
||||
if (concat_node->get_output_partial_shape(0).is_dynamic()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto rank = concat_node->get_output_partial_shape(0).rank().get_length();
|
||||
auto concat_axis = ov::util::normalize(concat_node->get_axis(), rank);
|
||||
|
||||
const auto transpose_axis_order = transpose_const->get_axis_vector_val();
|
||||
const auto reversed_transpose_axis_order = ReverseTransposeOrder(transpose_axis_order);
|
||||
if (static_cast<int64_t>(reversed_transpose_axis_order.size()) <= concat_axis) {
|
||||
|
|
@ -94,7 +98,6 @@ TSConcatBackward::TSConcatBackward() {
|
|||
|
||||
const auto transposed_concat_axis = reversed_transpose_axis_order[concat_axis];
|
||||
concat_node->set_axis(static_cast<int64_t>(transposed_concat_axis));
|
||||
concat_node->set_concatenation_axis(-1);
|
||||
|
||||
for (auto& new_node : sink_backward::InsertTransposeBeforeNode(main_node, transpose_const)) {
|
||||
register_new_node(new_node);
|
||||
|
|
|
|||
|
|
@ -37,9 +37,13 @@ public:
|
|||
std::shared_ptr<Node> clone_with_new_inputs(const OutputVector& new_args) const override;
|
||||
|
||||
/// \return The concatenation axis.
|
||||
OPENVINO_DEPRECATED("The function get_concatenation_axis() is deprecated. Will be removed in 2025.0 release. Use "
|
||||
"get_axis() instead.")
|
||||
int64_t get_concatenation_axis() const {
|
||||
return m_concat_axis;
|
||||
}
|
||||
OPENVINO_DEPRECATED("The function set_concatenation_axis() is deprecated. Will be removed in 2025.0 release. Use "
|
||||
"set_axis() instead.")
|
||||
void set_concatenation_axis(int64_t concatenation_axis) {
|
||||
m_concat_axis = concatenation_axis;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ std::vector<TRShape> shape_infer(const Concat* op, const std::vector<T>& input_s
|
|||
NODE_VALIDATION_CHECK(op, !input_shapes.empty());
|
||||
using DimType = typename T::value_type;
|
||||
|
||||
auto concat_axis = op->get_concatenation_axis() < 0 ? op->get_axis() : op->get_concatenation_axis();
|
||||
auto concat_axis = op->get_axis();
|
||||
const auto empty_dim = DimType{};
|
||||
|
||||
auto concat_dim = DimType{0};
|
||||
|
|
|
|||
|
|
@ -39,11 +39,7 @@ void Concat::validate_and_infer_types() {
|
|||
input_shapes.push_back(get_input_partial_shape(i));
|
||||
}
|
||||
|
||||
const auto output_shapes = shape_infer(this, input_shapes);
|
||||
const auto& output_shape = output_shapes[0];
|
||||
if (output_shape.rank().is_static() && (get_concatenation_axis() < 0)) {
|
||||
set_concatenation_axis(ov::util::normalize(get_axis(), output_shape.size()));
|
||||
}
|
||||
const auto output_shape = shape_infer(this, input_shapes).front();
|
||||
|
||||
set_output_type(0, inputs_et, output_shape);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -142,7 +142,7 @@ TEST(copy, concat) {
|
|||
|
||||
ASSERT_TRUE(nullptr != new_node);
|
||||
ASSERT_TRUE(new_args == new_node->input_values());
|
||||
ASSERT_TRUE(node_cast->get_concatenation_axis() == axis);
|
||||
ASSERT_TRUE(node_cast->get_axis() == axis);
|
||||
}
|
||||
|
||||
TEST(copy, constant) {
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ std::vector<layout> concatenation_inst::calc_output_layouts(const concatenation_
|
|||
}
|
||||
ov::op::v0::Concat op;
|
||||
op.set_friendly_name(desc->id);
|
||||
op.set_concatenation_axis(axis_index);
|
||||
op.set_axis(axis_index);
|
||||
std::vector<ShapeType> output_shapes = ov::op::v0::shape_infer(&op, input_shapes);
|
||||
return { layout {output_shapes[0], output_dt, output_format} };
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue