From b6b4bda07a71a4634d369987c177eac5fb7f1565 Mon Sep 17 00:00:00 2001 From: Ivan Tikhonov Date: Tue, 5 Mar 2024 19:46:34 +0400 Subject: [PATCH] Delete check that ReadValue/Assign operations have to be in pair in ov::Model (#23051) ### Details: If ReadValue and Assign are not paired in model topology we have "Model is incorrect. Assign and ReadValue operations must be in pairs on the network." Check for ReadValue-Assign pairs is useless and it is an obstacle for model transformation debugging. Moreover, with more advanced techniques of state modification there can be other ops (custom ones) that modify state in place. ### Tickets: - *CVS-133159* --- src/core/src/model.cpp | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/src/core/src/model.cpp b/src/core/src/model.cpp index 334e9fe224146a..315c3ab870f6e0 100644 --- a/src/core/src/model.cpp +++ b/src/core/src/model.cpp @@ -220,11 +220,6 @@ void ov::Model::prerequirements(bool detect_variables, bool detect_parameters) { void ov::Model::validate_nodes_and_infer_types() const { OV_ITT_SCOPED_TASK(ov::itt::domains::core, "Model::validate_nodes_and_infer_types"); - struct Counter { - int cnt_assign = 0; - int cnt_read_val = 0; - }; - std::map pair_checker; std::stringstream unregistered_parameters; std::stringstream unregistered_variables; std::unordered_set tensors; @@ -246,12 +241,6 @@ void ov::Model::validate_nodes_and_infer_types() const { if (variable_op && std::find(m_variables.begin(), m_variables.end(), variable_op->get_variable()) == m_variables.end()) unregistered_variables << variable_op->get_variable_id() << std::endl; - - if (const auto& assign = std::dynamic_pointer_cast(node)) { - pair_checker[assign->get_variable().get()].cnt_assign++; - } else if (const auto& read_value = std::dynamic_pointer_cast(node)) { - pair_checker[read_value->get_variable().get()].cnt_read_val++; - } } OPENVINO_ASSERT(unregistered_parameters.str().empty(), @@ -261,13 +250,7 @@ void ov::Model::validate_nodes_and_infer_types() const { OPENVINO_ASSERT(unregistered_variables.str().empty(), "Model references undeclared Variables: ", unregistered_variables.str()); - bool only_pairs = - std::all_of(pair_checker.begin(), pair_checker.end(), [](const std::pair& val) { - return val.second.cnt_assign == 1 && val.second.cnt_read_val == 1; - }); - OPENVINO_ASSERT(only_pairs, - "Model is incorrect. Assign and ReadValue operations must be in pairs on the " - "network."); + for (const auto& output : outputs()) { OPENVINO_ASSERT(ov::layout::utils::is_compatible(ov::layout::get_layout(output), output.get_partial_shape()), "Result '",