Skip to content

Commit 7c6facd

Browse files
authored
Update numpy.py
1 parent eb1f844 commit 7c6facd

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

keras/src/backend/openvino/numpy.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,17 @@
1313
from keras.src.backend.openvino.core import get_ov_output
1414
from keras.src.backend.openvino.core import ov_to_keras_type
1515

16+
def dot(x, y):
17+
"""
18+
OpenVINO implementation of numpy.dot using MatMul and element-wise multiplication.
19+
"""
20+
x, y = _align_operand_types(x, y)
21+
if len(x.shape) == 1 and len(y.shape) == 1:
22+
return ov_to_keras_type(ov_opset.reduce_sum(ov_opset.multiply(x, y), axes=[0]))
23+
if len(x.shape) == 2 and len(y.shape) == 1:
24+
y = ov_opset.unsqueeze(y, [1])
25+
return ov_to_keras_type(ov_opset.squeeze(ov_opset.matmul(x, y), [1]))
26+
return ov_to_keras_type(ov_opset.matmul(x, y))
1627

1728
def add(x1, x2):
1829
element_type = None

0 commit comments

Comments
 (0)