Skip to content

[OpenVINO] Implement nanmedian and nanpercentile ops#22762

Merged
hertschuh merged 3 commits intokeras-team:masterfrom
goyaladitya05:openvino/nanmedian
Apr 24, 2026
Merged

[OpenVINO] Implement nanmedian and nanpercentile ops#22762
hertschuh merged 3 commits intokeras-team:masterfrom
goyaladitya05:openvino/nanmedian

Conversation

@goyaladitya05
Copy link
Copy Markdown
Contributor

Description

ops nanmedian and nanpercentile were added to keras.ops in #22585 and #22679. This PR implements both for the OpenVINO backend.

Closes: openvinotoolkit/openvino/issues/35502

Contributor Agreement

Please check all boxes below before submitting your PR for review:

  • I am a human, and not a bot.
  • I will be responsible for responding to review comments in a timely manner.
  • I will work with the maintainers to push this PR forward until submission.

Note: Failing to adhere to this agreement may result in your future PRs no longer being reviewed.

Copy link
Copy Markdown
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 nanmedian and nanpercentile for the OpenVINO backend and enables the corresponding tests. The current implementation of nanmedian is overly complex and contains a bug where keepdims=True does not correctly restore the original rank for multi-axis reductions. Additionally, it fails to cast integer or boolean scalars to float, which is inconsistent with NumPy's behavior. It is recommended to simplify the logic by using the existing nanquantile function.

Comment thread keras/src/backend/openvino/numpy.py Outdated
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.03%. Comparing base (0dd8a15) to head (9dad42a).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff             @@
##           master   #22762       +/-   ##
===========================================
+ Coverage   59.77%   83.03%   +23.25%     
===========================================
  Files         596      596               
  Lines       69820    69822        +2     
  Branches    10883    10883               
===========================================
+ Hits        41737    57976    +16239     
+ Misses      25575     8998    -16577     
- Partials     2508     2848      +340     
Flag Coverage Δ
keras 82.85% <100.00%> (+23.07%) ⬆️
keras-jax 58.36% <0.00%> (?)
keras-numpy 54.23% <0.00%> (?)
keras-openvino 59.79% <100.00%> (+0.01%) ⬆️
keras-tensorflow 59.92% <0.00%> (?)
keras-torch 58.70% <0.00%> (?)

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.

Copy link
Copy Markdown
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 implementing those.

@google-ml-butler google-ml-butler Bot added kokoro:force-run ready to pull Ready to be merged into the codebase labels Apr 24, 2026
@google-ml-butler google-ml-butler Bot removed the ready to pull Ready to be merged into the codebase label Apr 24, 2026
@hertschuh hertschuh merged commit 7a2fbd2 into keras-team:master Apr 24, 2026
11 checks passed
@goyaladitya05 goyaladitya05 deleted the openvino/nanmedian branch April 24, 2026 02:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Keras 3 OpenVINO backend] Support nanmedian and nanpercentile ops

4 participants