OpenVINO™ is an open source toolkit for optimizing and deploying AI inference
C++ aicomputer-visiondeep-learningdeploy-aidiffusion-modelsgenerative-aigood-first-issueinferencellm-inferencenatural-language-processingnlpopenvinooptimize-aiperformance-boostrecommendation-systemspeech-recognitionstable-diffusiontransformersyolo
Extend UnrollIf to handle self-comparison conditions (x != x, x == x, etc.) (#33155)
Evgeny Kotov4568318f9ab6
diff --git a/src/common/transformations/src/transformations/control_flow/unroll_if.cpp b/src/common/transformations/src/transformations/control_flow/unroll_if.cppindex 986a176421b..fcd002abce7 100644--- a/src/common/transformations/src/transformations/control_flow/unroll_if.cpp+++ b/src/common/transformations/src/transformations/control_flow/unroll_if.cpp@@ -5,17 +5,75 @@#include "transformations/control_flow/unroll_if.hpp"#include <memory>+#include <utility>#include "itt.hpp"#include "openvino/core/descriptor/tensor.hpp"#include "openvino/core/graph_util.hpp"#include "openvino/core/rt_info.hpp"#include "openvino/core/validation_util.hpp"+#include "openvino/op/equal.hpp"+#include "openvino/op/greater.hpp"+#include "openvino/op/greater_eq.hpp"#include "openvino/op/if.hpp"+#include "openvino/op/less.hpp"+#include "openvino/op/less_eq.hpp"+#include "openvino/op/not_equal.hpp"#include "openvino/op/result.hpp"+#include "openvino/op/util/binary_elementwise_comparison.hpp"#include "openvino/pass/pattern/op/wrap_type.hpp"#include "transformations/utils/utils.hpp"+namespace {+// Evaluates self-comparison (x op x) where both inputs are identical.+// Returns {is_self_comparison, result}.+// Self-comparison semantics (for non-NaN values):+// x == x -> true x != x -> false+// x <= x -> true x < x -> false+// x >= x -> true x > x -> false+//+// NOTE: For floating-point types, IEEE 754 specifies that NaN != NaN is TRUE.+// To ensure IEEE 754 compliance, this optimization is only applied to integer types+// where NaN values are impossible. For float types, we skip the optimization to+// preserve correct NaN semantics if the runtime values happen to contain NaN.+std::pair<bool, bool> evaluate_self_comparison(const std::shared_ptr<ov::Node>& cond_node) {+ auto comparison = ov::as_type_ptr<ov::op::util::BinaryElementwiseComparison>(cond_node);+ if (!comparison) {+ return {false, false};+ }++ const auto& input0 = comparison->input_value(0);+ const auto& input1 = comparison->input_value(1);++ // Check if both inputs come from the same source (same node and same output index)+ if (input0 != input1) {+ return {false, false};+ }++ // For floating-point types, skip optimization to preserve IEEE 754 NaN semantics.+ // NaN != NaN is TRUE per IEEE 754, so we cannot assume x != x is always false for floats.+ // Integer types cannot contain NaN, so the optimization is safe for them.+ auto input_type = comparison->get_input_element_type(0);+ if (input_type.is_real()) {+ return {false, false};+ }++ // For integer types: reflexive comparisons (==, <=, >=) return true;+ // irreflexive (!=, <, >) return false+ if (ov::is_type<ov::op::v1::Equal>(cond_node) || ov::is_type<ov::op::v1::LessEqual>(cond_node) ||+ ov::is_type<ov::op::v1::GreaterEqual>(cond_node)) {+ return {true, true};+ }++ if (ov::is_type<ov::op::v1::NotEqual>(cond_node) || ov::is_type<ov::op::v1::Less>(cond_node) ||+ ov::is_type<ov::op::v1::Greater>(cond_node)) {+ return {true, false};+ }++ return {false, false};+}+} // namespace+bool ov::pass::UnrollIf::run_on_model(const std::shared_ptr<ov::Model>& f) {RUN_ON_FUNCTION_SCOPE(UnrollIf);bool is_applicable = false;@@ -31,15 +89,25 @@ bool ov::pass::UnrollIf::run_on_model(const std::shared_ptr<ov::Model>& f) {continue;}Output<Node> cond = if_node->input_value(0);++ // First, try to get condition as a constant (existing logic)const auto cond_is_const = ov::util::get_constant_from_source(cond);++ bool cond_value_bool = false;if (!cond_is_const) {- continue;+ // If not a constant, check for self-comparison pattern (x op x)+ auto [is_self_cmp, result] = evaluate_self_comparison(cond.get_node_shared_ptr());+ if (!is_self_cmp) {+ continue;+ }+ cond_value_bool = result;+ } else {+ cond_value_bool = cond_is_const->cast_vector<bool>()[0];}- auto cond_value = cond_is_const->cast_vector<bool>();- auto body = (cond_value[0]) ? if_node->get_then_body() : if_node->get_else_body();- auto input_descriptions = if_node->get_input_descriptions(static_cast<int>(!cond_value[0]));- auto output_descriptions = if_node->get_output_descriptions(static_cast<int>(!cond_value[0]));+ auto body = cond_value_bool ? if_node->get_then_body() : if_node->get_else_body();+ auto input_descriptions = if_node->get_input_descriptions(static_cast<int>(!cond_value_bool));+ auto output_descriptions = if_node->get_output_descriptions(static_cast<int>(!cond_value_bool));// copy rt info before reconnectionfor (auto& op : body->get_ops())copy_runtime_info({op, if_node}, op);diff --git a/src/common/transformations/tests/control_flow/unroll_if_test.cpp b/src/common/transformations/tests/control_flow/unroll_if_test.cppindex 62d1088bb3d..97fe8920054 100644--- a/src/common/transformations/tests/control_flow/unroll_if_test.cpp+++ b/src/common/transformations/tests/control_flow/unroll_if_test.cpp@@ -6,13 +6,21 @@#include <gtest/gtest.h>+#include <limits>#include <memory>+#include <sstream>#include "common_test_utils/ov_test_utils.hpp"#include "openvino/op/add.hpp"+#include "openvino/op/equal.hpp"+#include "openvino/op/greater.hpp"+#include "openvino/op/greater_eq.hpp"#include "openvino/op/if.hpp"+#include "openvino/op/less.hpp"+#include "openvino/op/less_eq.hpp"#include "openvino/op/logical_not.hpp"#include "openvino/op/multiply.hpp"+#include "openvino/op/not_equal.hpp"#include "openvino/op/split.hpp"#include "openvino/op/subtract.hpp"#include "openvino/op/variadic_split.hpp"@@ -60,6 +68,44 @@ std::shared_ptr<ov::Model> get_else_body() {return else_body;}+// Generic helper functions for self-comparison tests with configurable element type and shape+std::shared_ptr<ov::Model> get_then_body_generic(ov::element::Type et, const ov::PartialShape& shape) {+ auto Xt = std::make_shared<ov::op::v0::Parameter>(et, shape);+ Xt->set_friendly_name("Xt");+ auto Yt = std::make_shared<ov::op::v0::Parameter>(et, shape);+ Yt->set_friendly_name("Yt");+ auto add_op = std::make_shared<ov::op::v1::Add>(Xt, Yt);+ add_op->set_friendly_name("add_op");+ auto then_op_result = std::make_shared<ov::op::v0::Result>(add_op);+ then_op_result->set_friendly_name("then_op_result");+ auto then_body = std::make_shared<ov::Model>(ov::OutputVector{then_op_result}, ov::ParameterVector{Xt, Yt});+ ov::pass::InitNodeInfo().run_on_model(then_body);+ return then_body;+}++std::shared_ptr<ov::Model> get_else_body_generic(ov::element::Type et, const ov::PartialShape& shape) {+ auto Xe = std::make_shared<ov::op::v0::Parameter>(et, shape);+ Xe->set_friendly_name("Xe");+ auto Ye = std::make_shared<ov::op::v0::Parameter>(et, shape);+ Ye->set_friendly_name("Ye");+ auto mul_op = std::make_shared<ov::op::v1::Multiply>(Xe, Ye);+ mul_op->set_friendly_name("mul_op");+ auto else_op_result = std::make_shared<ov::op::v0::Result>(mul_op);+ else_op_result->set_friendly_name("else_op_result");+ auto else_body = std::make_shared<ov::Model>(ov::OutputVector{else_op_result}, ov::ParameterVector{Xe, Ye});+ ov::pass::InitNodeInfo().run_on_model(else_body);+ return else_body;+}++// Backwards-compatible wrappers for i64 with Shape{3}+std::shared_ptr<ov::Model> get_then_body_i64() {+ return get_then_body_generic(ov::element::i64, ov::Shape{3});+}++std::shared_ptr<ov::Model> get_else_body_i64() {+ return get_else_body_generic(ov::element::i64, ov::Shape{3});+}+std::shared_ptr<ov::Model> create_if_model(bool condition) {auto X = std::make_shared<ov::op::v0::Parameter>(ov::element::f32, ov::Shape{3});X->set_friendly_name("X");@@ -411,5 +457,358 @@ TEST(TransformationTests, UnrollIfToParameterResultModel) {EXPECT_THAT(model->output(0).get_names(), UnorderedElementsAre("Output"));}+// Enum for comparison operations in parameterized tests+enum class ComparisonType { Equal, NotEqual, Less, LessEqual, Greater, GreaterEqual };++// Parameters for self-comparison tests+struct UnrollIfSelfComparisonParams {+ ov::element::Type element_type;+ ov::PartialShape shape;+ ComparisonType comparison_type;+ bool expected_result; // true -> then_body (Add), false -> else_body (Multiply)+};++// Helper to create comparison node based on ComparisonType+std::shared_ptr<ov::Node> create_comparison(ComparisonType type,+ const ov::Output<ov::Node>& lhs,+ const ov::Output<ov::Node>& rhs) {+ switch (type) {+ case ComparisonType::Equal:+ return std::make_shared<ov::op::v1::Equal>(lhs, rhs);+ case ComparisonType::NotEqual:+ return std::make_shared<ov::op::v1::NotEqual>(lhs, rhs);+ case ComparisonType::Less:+ return std::make_shared<ov::op::v1::Less>(lhs, rhs);+ case ComparisonType::LessEqual:+ return std::make_shared<ov::op::v1::LessEqual>(lhs, rhs);+ case ComparisonType::Greater:+ return std::make_shared<ov::op::v1::Greater>(lhs, rhs);+ case ComparisonType::GreaterEqual:+ return std::make_shared<ov::op::v1::GreaterEqual>(lhs, rhs);+ default:+ return nullptr;+ }+}++// String conversion for test naming+std::string comparison_type_to_string(ComparisonType type) {+ switch (type) {+ case ComparisonType::Equal:+ return "Equal";+ case ComparisonType::NotEqual:+ return "NotEqual";+ case ComparisonType::Less:+ return "Less";+ case ComparisonType::LessEqual:+ return "LessEqual";+ case ComparisonType::Greater:+ return "Greater";+ case ComparisonType::GreaterEqual:+ return "GreaterEqual";+ default:+ return "Unknown";+ }+}++// Parameterized test class for self-comparison tests+class UnrollIfSelfComparisonTest : public ::testing::TestWithParam<UnrollIfSelfComparisonParams> {};++TEST_P(UnrollIfSelfComparisonTest, SelfComparisonOptimization) {+ const auto& p = GetParam();++ // Create model with self-comparison condition+ auto X = std::make_shared<ov::op::v0::Parameter>(p.element_type, p.shape);+ X->set_friendly_name("X");+ auto Y = std::make_shared<ov::op::v0::Parameter>(p.element_type, p.shape);+ Y->set_friendly_name("Y");++ // Create comparison with identical inputs: X op X+ auto cond = create_comparison(p.comparison_type, X, X);+ cond->set_friendly_name("cond");++ auto if_op = std::make_shared<ov::op::v8::If>(cond);+ if_op->set_friendly_name("if_op");++ const auto& then_body = get_then_body_generic(p.element_type, p.shape);+ const auto& else_body = get_else_body_generic(p.element_type, p.shape);++ if_op->set_then_body(then_body);+ if_op->set_else_body(else_body);+ auto then_p = then_body->get_parameters();+ auto else_p = else_body->get_parameters();+ if_op->set_input(X, then_p[0], else_p[0]);+ if_op->set_input(Y, then_p[1], else_p[1]);+ if_op->set_output(then_body->get_results()[0], else_body->get_results()[0]);+ auto if_result = std::make_shared<ov::op::v0::Result>(if_op);+ if_result->set_friendly_name("if_result");++ auto f = std::make_shared<ov::Model>(ov::OutputVector{if_result}, ov::ParameterVector{X, Y});++ ov::pass::Manager manager;+ manager.register_pass<ov::pass::InitNodeInfo>();+ manager.register_pass<ov::pass::UnrollIf>();+ manager.run_passes(f);++ OV_ASSERT_NO_THROW(check_rt_info(f));++ // Create reference model+ auto f_ref = p.expected_result ? get_then_body_generic(p.element_type, p.shape)+ : get_else_body_generic(p.element_type, p.shape);++ auto res = compare_functions(f, f_ref);+ ASSERT_TRUE(res.first) << res.second;+}++// Test name generator for better readability+std::string self_comparison_test_name(const ::testing::TestParamInfo<UnrollIfSelfComparisonParams>& info) {+ const auto& p = info.param;+ std::ostringstream name;+ name << p.element_type.get_type_name() << "_";++ // Convert shape to string+ if (p.shape.is_static()) {+ name << "shape";+ for (auto dim : p.shape.get_shape()) {+ name << "_" << dim;+ }+ } else {+ name << "dynamic";+ }++ name << "_" << comparison_type_to_string(p.comparison_type);+ return name.str();+}++// Test parameters covering different element types, shapes, and comparison operations+// Self-comparison semantics (for integer types where NaN is impossible):+// x == x -> true x != x -> false+// x <= x -> true x < x -> false+// x >= x -> true x > x -> false+// NOTE: If condition input must have rank 0 or 1, so we test with 1D shapes only+static const std::vector<UnrollIfSelfComparisonParams> self_comparison_params = {+ // Integer types with different 1D shapes - Equal (x == x -> true)+ {ov::element::i8, ov::Shape{1}, ComparisonType::Equal, true},+ {ov::element::i16, ov::Shape{3}, ComparisonType::Equal, true},+ {ov::element::i32, ov::Shape{5}, ComparisonType::Equal, true},+ {ov::element::i64, ov::Shape{3}, ComparisonType::Equal, true},+ {ov::element::u8, ov::Shape{1}, ComparisonType::Equal, true},+ {ov::element::u16, ov::Shape{3}, ComparisonType::Equal, true},+ {ov::element::u32, ov::Shape{7}, ComparisonType::Equal, true},+ {ov::element::u64, ov::Shape{3}, ComparisonType::Equal, true},++ // NotEqual (x != x -> false)+ {ov::element::i8, ov::Shape{1}, ComparisonType::NotEqual, false},+ {ov::element::i16, ov::Shape{3}, ComparisonType::NotEqual, false},+ {ov::element::i32, ov::Shape{5}, ComparisonType::NotEqual, false},+ {ov::element::i64, ov::Shape{3}, ComparisonType::NotEqual, false},+ {ov::element::u8, ov::Shape{1}, ComparisonType::NotEqual, false},+ {ov::element::u16, ov::Shape{3}, ComparisonType::NotEqual, false},+ {ov::element::u32, ov::Shape{7}, ComparisonType::NotEqual, false},+ {ov::element::u64, ov::Shape{3}, ComparisonType::NotEqual, false},++ // Less (x < x -> false)+ {ov::element::i8, ov::Shape{1}, ComparisonType::Less, false},+ {ov::element::i32, ov::Shape{3}, ComparisonType::Less, false},+ {ov::element::i64, ov::Shape{5}, ComparisonType::Less, false},+ {ov::element::u32, ov::Shape{3}, ComparisonType::Less, false},++ // LessEqual (x <= x -> true)+ {ov::element::i8, ov::Shape{1}, ComparisonType::LessEqual, true},+ {ov::element::i32, ov::Shape{3}, ComparisonType::LessEqual, true},+ {ov::element::i64, ov::Shape{5}, ComparisonType::LessEqual, true},+ {ov::element::u32, ov::Shape{3}, ComparisonType::LessEqual, true},++ // Greater (x > x -> false)+ {ov::element::i8, ov::Shape{1}, ComparisonType::Greater, false},+ {ov::element::i32, ov::Shape{3}, ComparisonType::Greater, false},+ {ov::element::i64, ov::Shape{5}, ComparisonType::Greater, false},+ {ov::element::u32, ov::Shape{3}, ComparisonType::Greater, false},++ // GreaterEqual (x >= x -> true)+ {ov::element::i8, ov::Shape{1}, ComparisonType::GreaterEqual, true},+ {ov::element::i32, ov::Shape{3}, ComparisonType::GreaterEqual, true},+ {ov::element::i64, ov::Shape{5}, ComparisonType::GreaterEqual, true},+ {ov::element::u32, ov::Shape{3}, ComparisonType::GreaterEqual, true},+};++INSTANTIATE_TEST_SUITE_P(TransformationTests,+ UnrollIfSelfComparisonTest,+ ::testing::ValuesIn(self_comparison_params),+ self_comparison_test_name);++// Test: NaN behavior - Constant with NaN values+// Per IEEE 754: NaN != NaN should be true+// When inputs are constants, the existing constant folding path (get_constant_from_source)+// correctly evaluates NaN != NaN to true per IEEE 754.+// Our self-comparison optimization is NOT triggered for constants (constant folding is used instead).+TEST(TransformationTests, UnrollIfSelfComparisonWithNaNConstant) {+ // Create a constant containing NaN+ auto nan_val = std::numeric_limits<float>::quiet_NaN();+ auto nan_const =+ std::make_shared<ov::op::v0::Constant>(ov::element::f32, ov::Shape{1}, std::vector<float>{nan_val});+ nan_const->set_friendly_name("nan_const");++ auto Y = std::make_shared<ov::op::v0::Parameter>(ov::element::f32, ov::Shape{1});+ Y->set_friendly_name("Y");++ // NotEqual(nan_const, nan_const) - same constant source+ // Per IEEE 754: NaN != NaN -> true (should select then_body)+ // Constant folding path handles this correctly!+ auto cond = std::make_shared<ov::op::v1::NotEqual>(nan_const, nan_const);+ cond->set_friendly_name("cond");++ // Then body: output Y + 1+ std::shared_ptr<ov::Model> then_body;+ {+ auto Yt = std::make_shared<ov::op::v0::Parameter>(ov::element::f32, ov::Shape{1});+ auto one = std::make_shared<ov::op::v0::Constant>(ov::element::f32, ov::Shape{1}, std::vector<float>{1.0f});+ auto add = std::make_shared<ov::op::v1::Add>(Yt, one);+ then_body = std::make_shared<ov::Model>(ov::OutputVector{add}, ov::ParameterVector{Yt});+ }++ // Else body: output Y * 2+ std::shared_ptr<ov::Model> else_body;+ {+ auto Ye = std::make_shared<ov::op::v0::Parameter>(ov::element::f32, ov::Shape{1});+ auto two = std::make_shared<ov::op::v0::Constant>(ov::element::f32, ov::Shape{1}, std::vector<float>{2.0f});+ auto mul = std::make_shared<ov::op::v1::Multiply>(Ye, two);+ else_body = std::make_shared<ov::Model>(ov::OutputVector{mul}, ov::ParameterVector{Ye});+ }++ auto if_op = std::make_shared<ov::op::v8::If>(cond);+ if_op->set_friendly_name("if_op");+ if_op->set_then_body(then_body);+ if_op->set_else_body(else_body);++ auto then_p = then_body->get_parameters();+ auto else_p = else_body->get_parameters();+ if_op->set_input(Y, then_p[0], else_p[0]);+ if_op->set_output(then_body->get_results()[0], else_body->get_results()[0]);++ auto if_result = std::make_shared<ov::op::v0::Result>(if_op);+ auto f = std::make_shared<ov::Model>(ov::OutputVector{if_result}, ov::ParameterVector{Y});++ ov::pass::Manager manager;+ manager.register_pass<ov::pass::InitNodeInfo>();+ manager.register_pass<ov::pass::UnrollIf>();+ manager.run_passes(f);++ // The If node should be removed (constant folding path evaluates condition)+ bool if_node_exists = false;+ for (const auto& op : f->get_ordered_ops()) {+ if (ov::as_type_ptr<ov::op::v8::If>(op)) {+ if_node_exists = true;+ break;+ }+ }+ ASSERT_FALSE(if_node_exists) << "If node should be removed";++ // Per IEEE 754, NaN != NaN is TRUE, so then_body (Add) should be selected+ bool has_add = false;+ for (const auto& op : f->get_ordered_ops()) {+ if (ov::as_type_ptr<ov::op::v1::Add>(op)) {+ has_add = true;+ break;+ }+ }+ ASSERT_TRUE(has_add) << "Then body (Add) should be selected since NaN != NaN is TRUE per IEEE 754";+}++// Test: Self-comparison with float Parameter is NOT optimized (IEEE 754 NaN compliance)+// Per IEEE 754: NaN != NaN is TRUE, so we cannot assume x != x is always false for floats.+// The optimization is skipped for floating-point types to preserve correct NaN semantics.+TEST(TransformationTests, UnrollIfSelfComparisonFloatParameterNotOptimized) {+ // X is a float Parameter - at runtime it COULD contain NaN+ auto X = std::make_shared<ov::op::v0::Parameter>(ov::element::f32, ov::Shape{3});+ X->set_friendly_name("X");+ auto Y = std::make_shared<ov::op::v0::Parameter>(ov::element::f32, ov::Shape{3});+ Y->set_friendly_name("Y");++ // NotEqual(X, X) - same Parameter, but float type+ // IEEE 754: if X contains NaN, result should be TRUE+ // Our optimization: SKIP for float types to preserve IEEE 754 compliance+ auto cond = std::make_shared<ov::op::v1::NotEqual>(X, X);+ cond->set_friendly_name("cond");++ auto if_op = std::make_shared<ov::op::v8::If>(cond);+ if_op->set_friendly_name("if_op");+ const auto& then_body = get_then_body();+ const auto& else_body = get_else_body();++ if_op->set_then_body(then_body);+ if_op->set_else_body(else_body);+ auto then_p = then_body->get_parameters();+ auto else_p = else_body->get_parameters();+ if_op->set_input(X, then_p[0], else_p[0]);+ if_op->set_input(Y, then_p[1], else_p[1]);+ if_op->set_output(then_body->get_results()[0], else_body->get_results()[0]);+ auto if_result = std::make_shared<ov::op::v0::Result>(if_op);+ if_result->set_friendly_name("if_result");++ auto f = std::make_shared<ov::Model>(ov::OutputVector{if_result}, ov::ParameterVector{X, Y});++ ov::pass::Manager manager;+ manager.register_pass<ov::pass::InitNodeInfo>();+ manager.register_pass<ov::pass::UnrollIf>();+ manager.run_passes(f);++ OV_ASSERT_NO_THROW(check_rt_info(f));++ // Verify the transformation is NOT applied for float types (If node should remain)+ bool if_node_exists = false;+ for (const auto& op : f->get_ordered_ops()) {+ if (ov::as_type_ptr<ov::op::v8::If>(op)) {+ if_node_exists = true;+ break;+ }+ }+ ASSERT_TRUE(if_node_exists) << "If node should NOT be removed for float self-comparison (IEEE 754 NaN safety)";+}++// Negative test: x != y should NOT be unrolled (different inputs)+TEST(TransformationTests, UnrollIfDifferentInputsNoChange) {+ auto X = std::make_shared<ov::op::v0::Parameter>(ov::element::f32, ov::Shape{3});+ X->set_friendly_name("X");+ auto Y = std::make_shared<ov::op::v0::Parameter>(ov::element::f32, ov::Shape{3});+ Y->set_friendly_name("Y");++ // Different inputs - should NOT be detected as self-comparison+ auto cond = std::make_shared<ov::op::v1::NotEqual>(X, Y);+ cond->set_friendly_name("cond");++ auto if_op = std::make_shared<ov::op::v8::If>(cond);+ if_op->set_friendly_name("if_op");+ const auto& then_body = get_then_body();+ const auto& else_body = get_else_body();++ if_op->set_then_body(then_body);+ if_op->set_else_body(else_body);+ auto then_p = then_body->get_parameters();+ auto else_p = else_body->get_parameters();+ if_op->set_input(X, then_p[0], else_p[0]);+ if_op->set_input(Y, then_p[1], else_p[1]);+ if_op->set_output(then_body->get_results()[0], else_body->get_results()[0]);+ auto if_result = std::make_shared<ov::op::v0::Result>(if_op);+ if_result->set_friendly_name("if_result");++ auto f = std::make_shared<ov::Model>(ov::OutputVector{if_result}, ov::ParameterVector{X, Y});++ ov::pass::Manager manager;+ manager.register_pass<ov::pass::InitNodeInfo>();+ manager.register_pass<ov::pass::UnrollIf>();+ manager.run_passes(f);++ // The If node should still exist since the condition is not constant+ // and not a self-comparison+ bool if_node_exists = false;+ for (const auto& op : f->get_ordered_ops()) {+ if (ov::as_type_ptr<ov::op::v8::If>(op)) {+ if_node_exists = true;+ break;+ }+ }+ ASSERT_TRUE(if_node_exists) << "If node should not be removed when inputs are different";+}+} // namespace test} // namespace ov