Skip to content

Commit

Permalink
[OpenVINO backend] Support numpy.append (#20951)
Browse files Browse the repository at this point in the history
* [OpenVINO backend] Support numpy.append

Signed-off-by: Lim, Kuan Xian <[email protected]>

* Remove NumpyDtype test_append_ from exclude list

Signed-off-by: Lim, Kuan Xian <[email protected]>

* Fix attribute error

Signed-off-by: Lim, Kuan Xian <[email protected]>

* Fix NumpyDtypeTest error

Signed-off-by: Lim, Kuan Xian <[email protected]>

* Update concat to append

Signed-off-by: Lim, Kuan Xian <[email protected]>

---------

Signed-off-by: Lim, Kuan Xian <[email protected]>
  • Loading branch information
kuanxian1 authored Mar 3, 2025
1 parent c356cae commit 7a7bca6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 0 additions & 2 deletions keras/src/backend/openvino/excluded_concrete_tests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ NumpyDtypeTest::test_absolute_bool
NumpyDtypeTest::test_add_
NumpyDtypeTest::test_all
NumpyDtypeTest::test_any
NumpyDtypeTest::test_append_
NumpyDtypeTest::test_argmax
NumpyDtypeTest::test_argmin
NumpyDtypeTest::test_argpartition
Expand Down Expand Up @@ -159,7 +158,6 @@ NumpyOneInputOpsCorrectnessTest::test_unravel_index
NumpyOneInputOpsCorrectnessTest::test_var
NumpyOneInputOpsCorrectnessTest::test_vectorize
NumpyOneInputOpsCorrectnessTest::test_vstack
NumpyTwoInputOpsCorrectnessTest::test_append
NumpyTwoInputOpsCorrectnessTest::test_bitwise_and
NumpyTwoInputOpsCorrectnessTest::test_bitwise_left_shift
NumpyTwoInputOpsCorrectnessTest::test_bitwise_or
Expand Down
9 changes: 8 additions & 1 deletion keras/src/backend/openvino/numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,14 @@ def amin(x, axis=None, keepdims=False):


def append(x1, x2, axis=None):
raise NotImplementedError("`append` is not supported with openvino backend")
x1, x2 = get_ov_output(x1), get_ov_output(x2)
x1, x2 = _align_operand_types(x1, x2, "append()")
if axis is None:
flatten_shape = ov_opset.constant([-1], Type.i32).output(0)
x1 = ov_opset.reshape(x1, flatten_shape, False).output(0)
x2 = ov_opset.reshape(x2, flatten_shape, False).output(0)
axis = 0
return OpenVINOKerasTensor(ov_opset.concat([x1, x2], axis).output(0))


def arange(start, stop=None, step=None, dtype=None):
Expand Down

0 comments on commit 7a7bca6

Please sign in to comment.