Skip to content

Commit 8e4b4ab

Browse files
authored
[OpenVINO Backend]: support numpy.ndim (#21176)
* feat: support numpy.ndim Signed-off-by: 11happy <soni5happy@gmail.com> * use shapeof shapeof method Signed-off-by: 11happy <soni5happy@gmail.com> --------- Signed-off-by: 11happy <soni5happy@gmail.com>
1 parent 1ea81a1 commit 8e4b4ab

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

keras/src/backend/openvino/excluded_concrete_tests.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ NumpyOneInputOpsCorrectnessTest::test_meshgrid
9898
NumpyOneInputOpsCorrectnessTest::test_min
9999
NumpyOneInputOpsCorrectnessTest::test_moveaxis
100100
NumpyOneInputOpsCorrectnessTest::test_nan_to_num
101-
NumpyOneInputOpsCorrectnessTest::test_ndim
102101
NumpyOneInputOpsCorrectnessTest::test_nonzero
103102
NumpyOneInputOpsCorrectnessTest::test_pad_float16_constant_2
104103
NumpyOneInputOpsCorrectnessTest::test_pad_float32_constant_2

keras/src/backend/openvino/numpy.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1036,7 +1036,10 @@ def nan_to_num(x, nan=0.0, posinf=None, neginf=None):
10361036

10371037

10381038
def ndim(x):
1039-
raise NotImplementedError("`ndim` is not supported with openvino backend")
1039+
x = get_ov_output(x)
1040+
x_shape = ov_opset.shape_of(x).output(0)
1041+
x_dim = ov_opset.shape_of(x_shape, "i64")
1042+
return x_dim
10401043

10411044

10421045
def nonzero(x):

0 commit comments

Comments
 (0)