Skip to content

[OpenVINO backend] Support numpy.empty #21010

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion keras/src/backend/openvino/excluded_concrete_tests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ NumpyDtypeTest::test_diag
NumpyDtypeTest::test_diff
NumpyDtypeTest::test_digitize
NumpyDtypeTest::test_einsum
NumpyDtypeTest::test_empty
NumpyDtypeTest::test_exp2
NumpyDtypeTest::test_expm1
NumpyDtypeTest::test_eye
Expand Down
11 changes: 10 additions & 1 deletion keras/src/backend/openvino/numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,16 @@ def dot(x, y):


def empty(shape, dtype=None):
raise NotImplementedError("`empty` is not supported with openvino backend")
dtype = standardize_dtype(dtype) or config.floatx()
ov_type = OPENVINO_DTYPES[dtype]
if isinstance(shape, tuple):
shape = list(shape)
elif isinstance(shape, int):
shape = [shape]
shape_node = ov_opset.constant(shape, Type.i32).output(0)
const_zero = ov_opset.constant(0, dtype=ov_type).output(0)
empty_tensor = ov_opset.broadcast(const_zero, shape_node).output(0)
return OpenVINOKerasTensor(empty_tensor)


def equal(x1, x2):
Expand Down