diff --git a/keras/src/backend/openvino/excluded_concrete_tests.txt b/keras/src/backend/openvino/excluded_concrete_tests.txt index 7371a2b9a5b8..fac4d3f3f70f 100644 --- a/keras/src/backend/openvino/excluded_concrete_tests.txt +++ b/keras/src/backend/openvino/excluded_concrete_tests.txt @@ -38,7 +38,6 @@ NumpyDtypeTest::test_mean NumpyDtypeTest::test_median NumpyDtypeTest::test_meshgrid NumpyDtypeTest::test_minimum_python_types -NumpyDtypeTest::test_moveaxis NumpyDtypeTest::test_multiply NumpyDtypeTest::test_outer_ NumpyDtypeTest::test_power @@ -96,7 +95,6 @@ NumpyOneInputOpsCorrectnessTest::test_max NumpyOneInputOpsCorrectnessTest::test_mean NumpyOneInputOpsCorrectnessTest::test_median NumpyOneInputOpsCorrectnessTest::test_meshgrid -NumpyOneInputOpsCorrectnessTest::test_moveaxis NumpyOneInputOpsCorrectnessTest::test_pad_float16_constant_2 NumpyOneInputOpsCorrectnessTest::test_pad_float32_constant_2 NumpyOneInputOpsCorrectnessTest::test_pad_float64_constant_2 diff --git a/keras/src/backend/openvino/numpy.py b/keras/src/backend/openvino/numpy.py index bbd23c633953..1aebd88a2bdc 100644 --- a/keras/src/backend/openvino/numpy.py +++ b/keras/src/backend/openvino/numpy.py @@ -1109,9 +1109,23 @@ def mod(x1, x2): def moveaxis(x, source, destination): - raise NotImplementedError( - "`moveaxis` is not supported with openvino backend" - ) + x = get_ov_output(x) + if isinstance(source, int): + source = [source] + if isinstance(destination, int): + destination = [destination] + + ndim = x.get_partial_shape().rank.get_length() + source = [axis if axis >= 0 else axis + ndim for axis in source] + destination = [axis if axis >= 0 else axis + ndim for axis in destination] + + axes = list(range(ndim)) + for src, dst in zip(source, destination): + axes.remove(src) + axes.insert(dst, src) + + axes_const = ov_opset.constant(axes, Type.i32).output(0) + return OpenVINOKerasTensor(ov_opset.transpose(x, axes_const).output(0)) def nan_to_num(x, nan=0.0, posinf=None, neginf=None):