Skip to content

[OpenVINO backend] Implements extract_sequences, erfinv, and solve in the math suite#22320

Open
goyaladitya05 wants to merge 2 commits intokeras-team:masterfrom
goyaladitya05:openvino/implement-math-logdet-solve
Open

[OpenVINO backend] Implements extract_sequences, erfinv, and solve in the math suite#22320
goyaladitya05 wants to merge 2 commits intokeras-team:masterfrom
goyaladitya05:openvino/implement-math-logdet-solve

Conversation

@goyaladitya05
Copy link
Contributor

@goyaladitya05 goyaladitya05 commented Mar 1, 2026

This PR implements the following ops for the math suite of the OpenVINO backend.

  • extract_sequences using a gather based sliding window approach.
  • erfinv via Winitzki approximation + one Newton-Raphson refinement step using the native erf op
  • math.solve by delegating to the already implemented linalg.solve
  • Removed relevent tests from excluded_concrete_tests.txt

Closes: openvinotoolkit/openvino/issues/34412

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, 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's mathematical capabilities by adding support for several key operations: extract_sequences, erfinv, and math.solve. These additions allow for more complex numerical computations to be performed efficiently using OpenVINO, thereby improving the backend's overall functionality and compatibility with Keras's math suite. The implementation details involve using native OpenVINO operations for sequence extraction and a robust approximation method for the inverse error function, while solve is delegated to an existing linear algebra function.

Highlights

  • New Math Operations: Implemented extract_sequences, erfinv, and math.solve for the OpenVINO backend, expanding the range of supported mathematical computations.
  • extract_sequences Implementation: The extract_sequences operation was implemented using a gather-based sliding-window approach with OpenVINO operations.
  • erfinv Implementation: The erfinv (inverse error function) was implemented using the Winitzki approximation combined with a single Newton-Raphson refinement step, leveraging the native erf operation.
  • math.solve Delegation: The math.solve function now delegates its implementation to the already existing linalg.solve function within the OpenVINO backend.
  • Test Unblocking: Removed previously excluded tests for extract_sequences and erfinv from excluded_concrete_tests.txt, indicating these operations are now functional and tested.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • keras/src/backend/openvino/excluded_concrete_tests.txt
    • Removed ExtractSequencesOpTest::test_extract_sequences_call from the exclusion list.
    • Removed MathOpsCorrectnessTest::test_erfinv_operation_basic from the exclusion list.
    • Removed MathOpsCorrectnessTest::test_erfinv_operation_dtype from the exclusion list.
    • Removed MathOpsCorrectnessTest::test_erfinv_operation_edge_cases from the exclusion list.
    • Removed MathOpsCorrectnessTest::test_extract_sequences from the exclusion list.
  • keras/src/backend/openvino/math.py
    • Implemented the extract_sequences function using OpenVINO ops for shape manipulation, indexing, and gathering.
    • Implemented the erfinv function using a Winitzki approximation and Newton-Raphson refinement.
    • Implemented the solve function by importing and delegating to linalg.solve.
Activity
  • No human activity has been recorded on this pull request yet.
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 implements extract_sequences, erfinv, and solve for the OpenVINO backend. No security vulnerabilities were found. The implementations are functionally correct, and suggestions have been provided to improve the readability and maintainability of extract_sequences and erfinv by refactoring them to use more constants and intermediate variables.

@codecov-commenter
Copy link

codecov-commenter commented Mar 1, 2026

Codecov Report

❌ Patch coverage is 0% with 61 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.62%. Comparing base (4f85917) to head (df9f1ef).

Files with missing lines Patch % Lines
keras/src/backend/openvino/math.py 0.00% 61 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (4f85917) and HEAD (df9f1ef). Click for more details.

HEAD has 2 uploads less than BASE
Flag BASE (4f85917) HEAD (df9f1ef)
keras 5 4
keras-openvino 1 0
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #22320      +/-   ##
==========================================
- Coverage   82.73%   76.62%   -6.12%     
==========================================
  Files         594      594              
  Lines       65732    65793      +61     
  Branches    10266    10266              
==========================================
- Hits        54385    50413    -3972     
- Misses       8711    12947    +4236     
+ Partials     2636     2433     -203     
Flag Coverage Δ
keras 76.45% <0.00%> (-6.11%) ⬇️
keras-jax 60.86% <0.00%> (-0.06%) ⬇️
keras-numpy 55.06% <0.00%> (-0.06%) ⬇️
keras-openvino ?
keras-tensorflow 62.10% <0.00%> (-0.06%) ⬇️
keras-torch 60.96% <0.00%> (-0.06%) ⬇️

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.

@goyaladitya05 goyaladitya05 force-pushed the openvino/implement-math-logdet-solve branch from b4d0a48 to 40ac7cb Compare March 1, 2026 11:40
@goyaladitya05 goyaladitya05 force-pushed the openvino/implement-math-logdet-solve branch from 40ac7cb to df9f1ef Compare March 1, 2026 12:05
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.

[Keras 3 OpenVINO backend]: Implement support for extract_sequences, erfinv, solve operations

3 participants