Skip to content

Commit 1d31699

Browse files
p-wysockimlukasze
andauthored
[PyOV][25.3] Remove deprecated binary operations Node API (#30636)
### Blocked by: - Currently blocked by the deprecated API usage in OpenVINO Keras backend. This PR needs to be merged first: keras-team/keras#21317 ### Details: - Originally deprecated in #26761 - Fixed a test which before API removal was most likely doing an `assert ops.Equal`, essentially checking `assert True` ### Tickets: - CVS-131039 --------- Signed-off-by: p-wysocki <przemyslaw.wysocki@intel.com> Co-authored-by: Michal Lukaszewski <michal.lukaszewski@intel.com>
1 parent 72f7800 commit 1d31699

File tree

3 files changed

+4
-70
lines changed

3 files changed

+4
-70
lines changed

src/bindings/python/src/openvino/runtime/__init__.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,3 @@
8484
# Helper functions for openvino module
8585
from openvino.runtime.ie_api import tensor_from_file
8686
from openvino.runtime.ie_api import compile_model
87-
88-
from openvino.utils import deprecated
89-
90-
# Extend Node class to support binary operators
91-
Node.__eq__ = deprecated(version="2025.3", message="Use ops.equal instead")(opset13.equal)
92-
Node.__ne__ = deprecated(version="2025.3", message="Use ops.not_equal instead")(opset13.not_equal)
93-
Node.__lt__ = deprecated(version="2025.3", message="Use ops.less instead")(opset13.less)
94-
Node.__le__ = deprecated(version="2025.3", message="Use ops.less_equal instead")(opset13.less_equal)
95-
Node.__gt__ = deprecated(version="2025.3", message="Use ops.greater instead")(opset13.greater)
96-
Node.__ge__ = deprecated(version="2025.3", message="Use ops.greater_equal instead")(opset13.greater_equal)

src/bindings/python/tests/test_runtime/test_deprecated_runtime.py

Lines changed: 0 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -366,62 +366,3 @@ def test_runtime_passes_manager():
366366

367367
assert count_ops_of_type(model, node_ceil) == 0
368368
assert count_ops_of_type(model, node_constant) == 1
369-
370-
371-
# from test_graph/test_ops_binary.py
372-
@pytest.mark.parametrize(
373-
("operator", "expected_type", "warning_type"),
374-
[
375-
(operator.add, Type.f32, warnings.catch_warnings(record=True)),
376-
(operator.sub, Type.f32, warnings.catch_warnings(record=True)),
377-
(operator.mul, Type.f32, warnings.catch_warnings(record=True)),
378-
(operator.truediv, Type.f32, warnings.catch_warnings(record=True)),
379-
(operator.eq, Type.boolean, pytest.warns(DeprecationWarning)),
380-
(operator.ne, Type.boolean, pytest.warns(DeprecationWarning)),
381-
(operator.gt, Type.boolean, pytest.warns(DeprecationWarning)),
382-
(operator.ge, Type.boolean, pytest.warns(DeprecationWarning)),
383-
(operator.lt, Type.boolean, pytest.warns(DeprecationWarning)),
384-
(operator.le, Type.boolean, pytest.warns(DeprecationWarning)),
385-
],
386-
)
387-
def test_binary_operators(operator, expected_type, warning_type):
388-
value_b = np.array([[4, 5], [1, 7]], dtype=np.float32)
389-
390-
shape = [2, 2]
391-
parameter_a = ops.parameter(shape, name="A", dtype=np.float32)
392-
393-
with warning_type:
394-
model = operator(parameter_a, value_b)
395-
396-
assert model.get_output_size() == 1
397-
assert list(model.get_output_shape(0)) == shape
398-
assert model.get_output_element_type(0) == expected_type
399-
400-
401-
@pytest.mark.parametrize(
402-
("operator", "expected_type", "warning_type"),
403-
[
404-
(operator.add, Type.f32, warnings.catch_warnings(record=True)),
405-
(operator.sub, Type.f32, warnings.catch_warnings(record=True)),
406-
(operator.mul, Type.f32, warnings.catch_warnings(record=True)),
407-
(operator.truediv, Type.f32, warnings.catch_warnings(record=True)),
408-
(operator.eq, Type.boolean, pytest.warns(DeprecationWarning)),
409-
(operator.ne, Type.boolean, pytest.warns(DeprecationWarning)),
410-
(operator.gt, Type.boolean, pytest.warns(DeprecationWarning)),
411-
(operator.ge, Type.boolean, pytest.warns(DeprecationWarning)),
412-
(operator.lt, Type.boolean, pytest.warns(DeprecationWarning)),
413-
(operator.le, Type.boolean, pytest.warns(DeprecationWarning)),
414-
],
415-
)
416-
def test_binary_operators_with_scalar(operator, expected_type, warning_type):
417-
value_b = np.array([[5, 6], [7, 8]], dtype=np.float32)
418-
419-
shape = [2, 2]
420-
parameter_a = ops.parameter(shape, name="A", dtype=np.float32)
421-
422-
with warning_type:
423-
model = operator(parameter_a, value_b)
424-
425-
assert model.get_output_size() == 1
426-
assert list(model.get_output_shape(0)) == shape
427-
assert model.get_output_element_type(0) == expected_type

src/bindings/python/tests/test_transformations/test_replacement_api.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,14 @@ def test_replace_node():
5252

5353

5454
def test_replace_output_update_name():
55+
# Before replacement: param -> relu -> exp -> result
56+
# After replacement: param -> relu -> result
5557
param = ops.parameter(PartialShape([1, 3, 22, 22]), name="parameter")
5658
relu = ops.relu(param.output(0))
5759
exp = ops.exp(relu.output(0))
5860
res = ops.result(exp.output(0), name="result")
5961

6062
replace_output_update_name(exp.output(0), exp.input_value(0))
6163

62-
assert res.input_value(0).get_node() == exp
64+
assert res.input_value(0).get_node().get_instance_id() == relu.get_instance_id()
65+
assert res.input_value(0).get_node().get_friendly_name() == exp.get_friendly_name()

0 commit comments

Comments
 (0)