|
10 | 10 | #include "itt.hpp" |
11 | 11 | #include "openvino/core/graph_util.hpp" |
12 | 12 | #include "openvino/core/rt_info.hpp" |
| 13 | +#include "openvino/core/validation_util.hpp" |
13 | 14 | #include "openvino/op/concat.hpp" |
14 | 15 | #include "openvino/op/constant.hpp" |
15 | 16 | #include "openvino/op/gather.hpp" |
@@ -43,13 +44,6 @@ bool get_vector_i64(const Output<Node>& value, std::vector<int64_t>& out) { |
43 | 44 | return !out.empty(); |
44 | 45 | } |
45 | 46 |
|
46 | | -bool normalize_axis(int64_t& axis, int64_t rank) { |
47 | | - if (axis < 0) { |
48 | | - axis += rank; |
49 | | - } |
50 | | - return axis >= 0 && axis < rank; |
51 | | -} |
52 | | - |
53 | 47 | bool get_mask(const std::vector<int64_t>& mask, size_t idx) { |
54 | 48 | return idx < mask.size() ? mask[idx] != 0 : false; |
55 | 49 | } |
@@ -157,7 +151,13 @@ bool parse_slice_window(const std::shared_ptr<ov::Node>& node, int64_t& start, i |
157 | 151 | return false; |
158 | 152 | } |
159 | 153 |
|
160 | | - if (!normalize_axis(axis, data_rank.get_length()) || axis != 1 || step != 1 || stop <= start) { |
| 154 | + const auto rank = data_rank.get_length(); |
| 155 | + if (!ov::util::is_axis_valid(axis, rank)) { |
| 156 | + return false; |
| 157 | + } |
| 158 | + axis = static_cast<int64_t>(ov::util::normalize_axis(axis, rank)); |
| 159 | + |
| 160 | + if (axis != 1 || step != 1 || stop <= start) { |
161 | 161 | return false; |
162 | 162 | } |
163 | 163 |
|
@@ -211,7 +211,13 @@ StridedSliceReshapeConcatFusion::StridedSliceReshapeConcatFusion() { |
211 | 211 | } |
212 | 212 |
|
213 | 213 | int64_t concat_axis = concat->get_axis(); |
214 | | - if (!normalize_axis(concat_axis, output_rank.get_length()) || concat_axis != 1) { |
| 214 | + const auto rank = output_rank.get_length(); |
| 215 | + if (!ov::util::is_axis_valid(concat_axis, rank)) { |
| 216 | + return false; |
| 217 | + } |
| 218 | + concat_axis = static_cast<int64_t>(ov::util::normalize_axis(concat_axis, rank)); |
| 219 | + |
| 220 | + if (concat_axis != 1) { |
215 | 221 | return false; |
216 | 222 | } |
217 | 223 |
|
|
0 commit comments