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
Fix: Defer axis validation in reduce operations to compile/runtime (#33450)
Siddhant Shekharc373dcf7490b
diff --git a/src/bindings/python/tests/test_graph/test_reduction.py b/src/bindings/python/tests/test_graph/test_reduction.pyindex ae468fc652b..2c0d270b4ee 100644--- a/src/bindings/python/tests/test_graph/test_reduction.py+++ b/src/bindings/python/tests/test_graph/test_reduction.py@@ -160,3 +160,42 @@ def test_reduce_with_keywork():const = ov.constant([-1], np.int64)min_op = ov.reduce_min(node=const, reduction_axes=0)assert min_op.get_output_size() == 1+++ "graph_api_helper",+ [+ ov.reduce_mean,+ ov.reduce_max,+ ov.reduce_min,+ ov.reduce_sum,+ ov.reduce_prod,+ ],+)+def test_reduce_invalid_axis_raises_immediately(graph_api_helper):+ shape = [2] # 1D tensor, rank=1+ input_data = np.random.randn(*shape).astype(np.float32)+ invalid_axes = np.array([1]) # axis 1 is out of range for rank 1 (valid: -1, 0)++ with pytest.raises(RuntimeError) as exc_info:+ graph_api_helper(input_data, invalid_axes)++ assert "out of the tensor rank range" in str(exc_info.value)+++ "graph_api_helper",+ [+ ov.reduce_logical_and,+ ov.reduce_logical_or,+ ],+)+def test_reduce_logical_invalid_axis_raises_immediately(graph_api_helper):+ shape = [2] # 1D tensor, rank=1+ input_data = np.random.randn(*shape).astype(bool)+ invalid_axes = np.array([1]) # axis 1 is out of range for rank 1 (valid: -1, 0)++ with pytest.raises(RuntimeError) as exc_info:+ graph_api_helper(input_data, invalid_axes)++ assert "out of the tensor rank range" in str(exc_info.value)