Skip to content

OpenVINO™ is an open source toolkit for optimizing and deploying AI inference

[PyOV][25.3] Remove deprecated binary operations Node API (#30636)

Przemyslaw Wysocki1d3169949b14
diff --git a/src/bindings/python/src/openvino/runtime/__init__.py b/src/bindings/python/src/openvino/runtime/__init__.py
index 6668a99f90e..c0889a3882f 100644
--- a/src/bindings/python/src/openvino/runtime/__init__.py
+++ b/src/bindings/python/src/openvino/runtime/__init__.py
@@ -84,13 +84,3 @@ from openvino.runtime import properties
# Helper functions for openvino module
from openvino.runtime.ie_api import tensor_from_file
from openvino.runtime.ie_api import compile_model
-
-from openvino.utils import deprecated
-
-# Extend Node class to support binary operators
-Node.__eq__ = deprecated(version="2025.3", message="Use ops.equal instead")(opset13.equal)
-Node.__ne__ = deprecated(version="2025.3", message="Use ops.not_equal instead")(opset13.not_equal)
-Node.__lt__ = deprecated(version="2025.3", message="Use ops.less instead")(opset13.less)
-Node.__le__ = deprecated(version="2025.3", message="Use ops.less_equal instead")(opset13.less_equal)
-Node.__gt__ = deprecated(version="2025.3", message="Use ops.greater instead")(opset13.greater)
-Node.__ge__ = deprecated(version="2025.3", message="Use ops.greater_equal instead")(opset13.greater_equal)
diff --git a/src/bindings/python/tests/test_runtime/test_deprecated_runtime.py b/src/bindings/python/tests/test_runtime/test_deprecated_runtime.py
index 845659b17f3..7885268b014 100644
--- a/src/bindings/python/tests/test_runtime/test_deprecated_runtime.py
+++ b/src/bindings/python/tests/test_runtime/test_deprecated_runtime.py
@@ -366,62 +366,3 @@ def test_runtime_passes_manager():
assert count_ops_of_type(model, node_ceil) == 0
assert count_ops_of_type(model, node_constant) == 1
-
-
-# from test_graph/test_ops_binary.py
- ("operator", "expected_type", "warning_type"),
- [
- (operator.add, Type.f32, warnings.catch_warnings(record=True)),
- (operator.sub, Type.f32, warnings.catch_warnings(record=True)),
- (operator.mul, Type.f32, warnings.catch_warnings(record=True)),
- (operator.truediv, Type.f32, warnings.catch_warnings(record=True)),
- (operator.eq, Type.boolean, pytest.warns(DeprecationWarning)),
- (operator.ne, Type.boolean, pytest.warns(DeprecationWarning)),
- (operator.gt, Type.boolean, pytest.warns(DeprecationWarning)),
- (operator.ge, Type.boolean, pytest.warns(DeprecationWarning)),
- (operator.lt, Type.boolean, pytest.warns(DeprecationWarning)),
- (operator.le, Type.boolean, pytest.warns(DeprecationWarning)),
- ],
-)
-def test_binary_operators(operator, expected_type, warning_type):
- value_b = np.array([[4, 5], [1, 7]], dtype=np.float32)
-
- shape = [2, 2]
- parameter_a = ops.parameter(shape, name="A", dtype=np.float32)
-
- with warning_type:
- model = operator(parameter_a, value_b)
-
- assert model.get_output_size() == 1
- assert list(model.get_output_shape(0)) == shape
- assert model.get_output_element_type(0) == expected_type
-
-
- ("operator", "expected_type", "warning_type"),
- [
- (operator.add, Type.f32, warnings.catch_warnings(record=True)),
- (operator.sub, Type.f32, warnings.catch_warnings(record=True)),
- (operator.mul, Type.f32, warnings.catch_warnings(record=True)),
- (operator.truediv, Type.f32, warnings.catch_warnings(record=True)),
- (operator.eq, Type.boolean, pytest.warns(DeprecationWarning)),
- (operator.ne, Type.boolean, pytest.warns(DeprecationWarning)),
- (operator.gt, Type.boolean, pytest.warns(DeprecationWarning)),
- (operator.ge, Type.boolean, pytest.warns(DeprecationWarning)),
- (operator.lt, Type.boolean, pytest.warns(DeprecationWarning)),
- (operator.le, Type.boolean, pytest.warns(DeprecationWarning)),
- ],
-)
-def test_binary_operators_with_scalar(operator, expected_type, warning_type):
- value_b = np.array([[5, 6], [7, 8]], dtype=np.float32)
-
- shape = [2, 2]
- parameter_a = ops.parameter(shape, name="A", dtype=np.float32)
-
- with warning_type:
- model = operator(parameter_a, value_b)
-
- assert model.get_output_size() == 1
- assert list(model.get_output_shape(0)) == shape
- assert model.get_output_element_type(0) == expected_type
diff --git a/src/bindings/python/tests/test_transformations/test_replacement_api.py b/src/bindings/python/tests/test_transformations/test_replacement_api.py
index 692b95060a3..632e244cdad 100644
--- a/src/bindings/python/tests/test_transformations/test_replacement_api.py
+++ b/src/bindings/python/tests/test_transformations/test_replacement_api.py
@@ -52,6 +52,8 @@ def test_replace_node():
def test_replace_output_update_name():
+ # Before replacement: param -> relu -> exp -> result
+ # After replacement: param -> relu -> result
param = ops.parameter(PartialShape([1, 3, 22, 22]), name="parameter")
relu = ops.relu(param.output(0))
exp = ops.exp(relu.output(0))
@@ -59,4 +61,5 @@ def test_replace_output_update_name():
replace_output_update_name(exp.output(0), exp.input_value(0))
- assert res.input_value(0).get_node() == exp
+ assert res.input_value(0).get_node().get_instance_id() == relu.get_instance_id()
+ assert res.input_value(0).get_node().get_friendly_name() == exp.get_friendly_name()