Skip to content

Commit

Permalink
[Transformations] Fix vector subscript out of range in transformations (
Browse files Browse the repository at this point in the history
openvinotoolkit#27180)

### Details:
- Fix issue reported by MSVC `Assertion failed: vector subscript out of
range` by skip accessing not existing parameters in
`RemoveMultiSubGraphOpDanglingParamsResults` transformation.

### Tickets:
 - CVS-155258
  • Loading branch information
praasz authored and CuriousPanCake committed Nov 6, 2024
1 parent 1f6700f commit 167530a
Showing 1 changed file with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -178,19 +178,21 @@ bool ov::pass::RemoveMultiSubGraphOpDanglingParamsResults::run_on_model(const st
if (std::count(std::begin(to_remove_descriptors_indexes[body_idx]),
std::end(to_remove_descriptors_indexes[body_idx]),
desc_idx) > 0) {
auto& body_param = body_params[body_in_descriptors[desc_idx]->m_body_parameter_index];
body_func->remove_parameter(body_param);
// Move all body indexes which are after these indicated by to_remove_descriptors_indexes
update_body_param_desc(body_in_descriptors,
body_in_descriptors[desc_idx]->m_body_parameter_index);
if (body_in_descriptors[desc_idx]->m_body_parameter_index < body_params.size()) {
auto& body_param = body_params[body_in_descriptors[desc_idx]->m_body_parameter_index];
body_func->remove_parameter(body_param);
// Move all body indexes which are after these indicated by to_remove_descriptors_indexes
update_body_param_desc(body_in_descriptors,
body_in_descriptors[desc_idx]->m_body_parameter_index);
}
// remove dangling input of MultiSubGraphOp which was not removed earlier
auto current_input_idx = body_in_descriptors[desc_idx]->m_input_index;
auto& current_input = op_inputs[current_input_idx];
// the same input tensor can go to different input ports
if (std::count(std::begin(required_inputs_indices),
if (current_input_idx < op_inputs.size() &&
std::count(std::begin(required_inputs_indices),
std::end(required_inputs_indices),
current_input_idx) == 0 &&
std::count(std::begin(op_inputs), std::end(op_inputs), current_input) > 0) {
std::count(std::begin(op_inputs), std::end(op_inputs), op_inputs[current_input_idx]) > 0) {
op_inputs.erase(std::next(op_inputs.begin(), current_input_idx));
// Move all input indexes (in all bodies) which are after these indicated by
// to_remove_descriptors_indexes and are not used in any body
Expand Down

0 comments on commit 167530a

Please sign in to comment.