Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ examples/**/*.jpg
.python-version
.coverage
*coverage.xml
.ruff_cache
.ruff_cache
my_clean_keras_env_py310/
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 @@ -43,7 +43,6 @@ NumpyDtypeTest::test_meshgrid
NumpyDtypeTest::test_minimum_python_types
NumpyDtypeTest::test_multiply
NumpyDtypeTest::test_power
NumpyDtypeTest::test_prod
NumpyDtypeTest::test_quantile
NumpyDtypeTest::test_repeat
NumpyDtypeTest::test_roll
Expand Down Expand Up @@ -104,7 +103,6 @@ NumpyOneInputOpsCorrectnessTest::test_pad_int16_constant_2
NumpyOneInputOpsCorrectnessTest::test_pad_int8_constant_2
NumpyOneInputOpsCorrectnessTest::test_pad_uint8_constant_2
NumpyOneInputOpsCorrectnessTest::test_pad_int32_constant_2
NumpyOneInputOpsCorrectnessTest::test_prod
NumpyOneInputOpsCorrectnessTest::test_real
NumpyOneInputOpsCorrectnessTest::test_repeat
NumpyOneInputOpsCorrectnessTest::test_reshape
Expand Down
46 changes: 45 additions & 1 deletion keras/src/backend/openvino/numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -1262,8 +1262,52 @@ def pad(x, pad_width, mode="constant", constant_values=None):


def prod(x, axis=None, keepdims=False, dtype=None):
raise NotImplementedError("`prod` is not supported with openvino backend")
if axis == () or axis == []:
return x

x = get_ov_output(x)

if axis is None:
flatten_shape = ov_opset.constant([-1], Type.i32).output(0)
x = ov_opset.reshape(x, flatten_shape, False).output(0)
axis = 0
elif isinstance(axis, tuple):
axis = list(axis)

axis = ov_opset.constant(axis, Type.i32).output(0)

x_type = x.get_element_type()

promotion_map = {
Type.bf16: Type.bf16,
Type.f16: Type.f16,
Type.f32: Type.f32,
Type.f64: Type.f64,
Type.i8: Type.i32,
Type.i16: Type.i32,
Type.i32: Type.i32,
Type.i64: Type.i64,
Type.u8: Type.u32,
Type.u16: Type.u32,
Type.u32: Type.u32,
Type.u64: Type.u64,
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use the same dictionary from core.py


if x_type == Type.boolean:
result_node = ov_opset.reduce_logical_and(x, axis, keepdims).output(0)
final_result = ov_opset.convert(result_node, Type.i32).output(0)
return OpenVINOKerasTensor(final_result)

target_type = None
if dtype is None:
target_type = promotion_map.get(x_type, x_type)
else:
dtype_string = standardize_dtype(dtype)
target_type = OPENVINO_DTYPES[dtype_string]

temporary_result = ov_opset.reduce_prod(x, axis, keepdims).output(0)
Copy link
Contributor

@rkazants rkazants Jun 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

name this var prod_result

final_result = ov_opset.convert(temporary_result, target_type).output(0)
return OpenVINOKerasTensor(final_result)

def quantile(x, q, axis=None, method="linear", keepdims=False):
raise NotImplementedError(
Expand Down
Loading