Skip to content
Open
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
25 changes: 23 additions & 2 deletions keras/src/backend/openvino/numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -848,9 +848,30 @@ def log2(x):

Copy link
Contributor

Choose a reason for hiding this comment

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

please switch on tests for this functionality.

Copy link
Author

Choose a reason for hiding this comment

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

In issue you mentioned ./keras/src/ops/numpy_test.py for testing. I initially thought that tests automatically invoke the numpy from correct backend. But on tracking knp imports in numpy_test file they seem to come from ./keras/src/backend/numpy module instead of openvino. I verify this by executing tests without implementing logaddexp() and they PASSED (a number of other unimplemented functions inside ./keras/src/backend/openvino/numpy.py also pass). What should I change exactly to test the function in current test setup?

Copy link
Contributor

Choose a reason for hiding this comment

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

please rebase to latest master and you will see corresponding lines for logaddexp


def logaddexp(x1, x2):
raise NotImplementedError(
"`logaddexp` is not supported with openvino backend"
element_type = None
if isinstance(x1, OpenVINOKerasTensor):
element_type = x1.output.get_element_type()
if isinstance(x2, OpenVINOKerasTensor):
element_type = x2.output.get_element_type()
x1 = get_ov_output(x1, element_type)
x2 = get_ov_output(x2, element_type)
x1, x2 = _align_operand_types(x1, x2, "logaddexp()")
x_type = x1.get_element_type()
if x_type.is_integral():
ov_type = OPENVINO_DTYPES[config.floatx()]
x1 = ov_opset.convert(x1, ov_type)
x2 = ov_opset.convert(x2, ov_type)
max_element = ov_opset.maximum(x1, x2).output(0)
exp_k = ov_opset.exp(max_element).output(0)
exp_x1 = ov_opset.exp(ov_opset.subtract(x1, max_element).output(0)).output(
0
)
exp_x2 = ov_opset.exp(ov_opset.subtract(x2, max_element).output(0)).output(
0
)
sum_exp = ov_opset.add(exp_x1, exp_x2).output(0)
mul_exp = ov_opset.multiply(exp_k, sum_exp).output(0)
return OpenVINOKerasTensor(ov_opset.log(mul_exp).output(0))


def logical_and(x1, x2):
Expand Down