Skip to content

Commit 6d4b684

Browse files
authored
[BUGFIX][shapeinference]: Fixed a bug in get_input_bounds with op with no input on specifed port (openvinotoolkit#22885)
### Details: Fixed a bug in get_input_bounds(), where method tries to access input at specified port, but operator does not have anything attached at that port - the result was a crash. This situation was encountered when calling shape_infer() method with slice op, which did not have any attached inputs.
1 parent 6bd4ab7 commit 6d4b684

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/core/shape_inference/include/utils.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ ov::optional<TResult> get_input_bounds(const ov::Node* op, size_t port, const IT
365365
out.emplace();
366366
out->reserve(lowers.size());
367367
std::transform(lowers.cbegin(), lowers.cend(), lowers.cbegin(), std::back_inserter(*out), make_bound(et));
368-
} else {
368+
} else if (port < op->get_input_size()) {
369369
auto bounds = ov::evaluate_both_bounds(op->get_input_source_output(port));
370370

371371
if (bounds.first && bounds.second) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright (C) 2018-2024 Intel Corporation
2+
// SPDX-License-Identifier: Apache-2.0
3+
//
4+
5+
#include <gtest/gtest.h>
6+
7+
#include "openvino/op/reverse.hpp"
8+
#include "utils.hpp"
9+
10+
TEST(shape_inference_utils_test, get_input_bounds_not_valid_port) {
11+
ov::op::v1::Reverse dummy_op;
12+
const size_t not_valid_port = 100;
13+
const ov::ITensorAccessor& ta = ov::make_tensor_accessor();
14+
15+
const auto ret = ov::op::get_input_bounds<ov::PartialShape, int64_t>(&dummy_op, not_valid_port, ta);
16+
ASSERT_FALSE(ret);
17+
}

0 commit comments

Comments
 (0)