Skip to content

Conversation

@danielenricocahall
Copy link
Contributor

@danielenricocahall danielenricocahall commented Oct 24, 2025

  • Cleanup axis resolution (centralize to _resolve_axis function)
  • Support heaviside for functionality only (typing still needs work)
  • Remove test_isposinf from exclusion list as we now support that operation
  • Fix pad type tests
  • Fix variance and std implementations

Note: The type tests for var and std are currently omitted because the tests expect f32 and we're returning f64. - however, if we convert to f32, the results for the operation tests are slightly off e.g.,

E ACTUAL: array(0.666504, dtype=float32) 
E DESIRED: array(0.666667)

unsure if the tolerances in the correctness tests themselves need adjustment or if there's some type coercion happening under the hood when the values are being calculated. I tried different implementations for variance but they all arrive at the same result.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @danielenricocahall, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the OpenVINO backend by implementing new operations and refining existing ones. It focuses on improving code structure through axis resolution centralization, expanding functionality with heaviside support, and ensuring the correctness of statistical operations like variance and standard deviation.

Highlights

  • Axis Resolution Centralization: The logic for resolving axes in operations like count_nonzero and cumsum has been centralized into a new _resolve_axis function, reducing code duplication and improving consistency.
  • Heaviside Function Support: The heaviside operation is now implemented for the OpenVINO backend, moving from a NotImplementedError to functional support, though typing still requires further work.
  • Variance and Standard Deviation Fixes: The implementations for var and std have been refactored and corrected. std now leverages the var function, and var includes improved type handling for integral inputs and centralized axis resolution.
  • Test Exclusions Updated: Several tests related to pad, std, var, and heaviside have been removed from the excluded_concrete_tests.txt file, indicating that these operations are now expected to pass or are being re-evaluated.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces several enhancements to the OpenVINO backend, including axis resolution cleanup, heaviside function support, test exclusion list updates, and variance/std implementation fixes. The changes aim to improve code maintainability and extend the functionality of supported operations.

@codecov-commenter
Copy link

codecov-commenter commented Oct 24, 2025

Codecov Report

❌ Patch coverage is 92.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.66%. Comparing base (47fcb39) to head (f55f6a0).
⚠️ Report is 22 commits behind head on master.

Files with missing lines Patch % Lines
keras/src/backend/openvino/numpy.py 92.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #21774      +/-   ##
==========================================
- Coverage   82.69%   82.66%   -0.04%     
==========================================
  Files         573      577       +4     
  Lines       58888    59409     +521     
  Branches     9218     9310      +92     
==========================================
+ Hits        48696    49109     +413     
- Misses       7845     7899      +54     
- Partials     2347     2401      +54     
Flag Coverage Δ
keras 82.48% <92.00%> (-0.02%) ⬇️
keras-jax 63.33% <8.00%> (+0.09%) ⬆️
keras-numpy 57.57% <0.00%> (-0.15%) ⬇️
keras-openvino 34.35% <92.00%> (-0.05%) ⬇️
keras-tensorflow 64.13% <8.00%> (+0.11%) ⬆️
keras-torch 63.63% <8.00%> (+0.07%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

danielenricocahall and others added 2 commits October 24, 2025 13:52
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@danielenricocahall danielenricocahall marked this pull request as draft October 24, 2025 18:33
@hertschuh
Copy link
Collaborator

@danielenricocahall this PR is still in draft. Let us know when it's ready for review.

@danielenricocahall danielenricocahall marked this pull request as ready for review October 30, 2025 19:09
@danielenricocahall
Copy link
Contributor Author

@danielenricocahall this PR is still in draft. Let us know when it's ready for review.

@hertschuh thank you for the reminder! Forgot about this one 😅 I think it's ready for review though, flipping the switch now

Copy link
Collaborator

@hertschuh hertschuh left a comment

Choose a reason for hiding this comment

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

Thanks for all the additions and simplifications!

axis = 0
axis = ov_opset.constant(axis, Type.i32).output(0)
zero = ov_opset.constant(0.0, work_dtype).output(0)
return OpenVINOKerasTensor(ov_opset.multiply(x, zero).output(0))
Copy link
Collaborator

Choose a reason for hiding this comment

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

nitpick: wouldn't a broadcast be faster?

ov_opset.broadcast(const_zero, ov_opset.shape_of(x)).output(0)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes that's much smarter. Updated!

@google-ml-butler google-ml-butler bot added kokoro:force-run ready to pull Ready to be merged into the codebase labels Oct 31, 2025
@fchollet fchollet merged commit 72dfa36 into keras-team:master Oct 31, 2025
11 checks passed
@google-ml-butler google-ml-butler bot removed awaiting review ready to pull Ready to be merged into the codebase labels Oct 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants