diff --git a/src/core/src/op/squared_difference.cpp b/src/core/src/op/squared_difference.cpp index e91c46aace291f..48d0a8f6ae97ae 100644 --- a/src/core/src/op/squared_difference.cpp +++ b/src/core/src/op/squared_difference.cpp @@ -66,10 +66,7 @@ bool ov::op::v0::SquaredDifference::evaluate(TensorVector& outputs, const Tensor bool ov::op::v0::SquaredDifference::has_evaluate() const { OV_OP_SCOPE(v0_SquaredDifference_has_evaluate); - switch (get_input_element_type(0)) { - case element::f32: + if (get_input_element_type(0) == element::f32) return true; - default: - return false; - } + return false; } diff --git a/src/core/tests/pass/constant_folding.cpp b/src/core/tests/pass/constant_folding.cpp index 005d5c4b8bfea0..cc2fae1889890c 100644 --- a/src/core/tests/pass/constant_folding.cpp +++ b/src/core/tests/pass/constant_folding.cpp @@ -3930,3 +3930,21 @@ TEST(constant_folding, parameter_with_unspecified_type_from_host_tensor) { auto model = std::make_shared(ov::ResultVector{res}, ov::ParameterVector{param}); EXPECT_NO_THROW(run_constant_folding(model)); } + +TEST(constant_folding, sq_diff) { + auto const_0 = std::make_shared(element::f32, ov::Shape{1}, std::vector{4}); + auto const_1 = std::make_shared(element::f32, ov::Shape{1}, std::vector{2}); + auto sq_diff = std::make_shared(const_0, const_1); + auto res = std::make_shared(sq_diff); + auto model = std::make_shared(ov::ResultVector{res}, ov::ParameterVector{}); + auto ops = model->get_ops(); + ASSERT_GT(ops.size(), 2); + EXPECT_NO_THROW(run_constant_folding(model)); + ops = model->get_ordered_ops(); + // constant + result + ASSERT_EQ(ops.size(), 2); + auto const_node = std::dynamic_pointer_cast(ops.front()); + ASSERT_NE(const_node, nullptr); + auto res_node = std::dynamic_pointer_cast(ops.back()); + ASSERT_NE(res_node, nullptr); +} \ No newline at end of file