[OpenVINO backend] Fix array(), maximum(), minimum(), reshape() and split() ops in the numpy suite#22319
Conversation
…plit() numpy ops - array(): use convert_to_tensor() instead of np.array() so the result is always an OpenVINOKerasTensor rather than a raw NumPy array - maximum() / minimum(): apply the same t1/t2 dtype-extraction pattern used by add() / subtract() / multiply() so that Python int/float literals are promoted according to JAX weak-type semantics - reshape(): wrap a bare integer newshape in a list before passing it to ov_opset.constant(), which requires a 1-D shape tensor - split(): extract constant data from an OpenVINOKerasTensor passed as indices_or_sections (side-effect of the array() fix); also fixes hsplit() and vsplit() which delegate to split()
Summary of ChangesHello, 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 robustness and consistency of several core NumPy operations within the OpenVINO backend. By refining how Highlights
🧠 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
Activity
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
Code Review
This pull request introduces several important fixes for the OpenVINO backend's numpy operations, enhancing correctness and consistency. The changes for array(), reshape(), and split() are well-implemented and address the described issues effectively. The fixes for maximum() and minimum() correctly align their behavior with other binary operations by adding proper type promotion logic. While this follows an existing pattern, it also duplicates a significant block of code. I've added comments suggesting a refactoring to improve maintainability.
…ate binary op type promotion
8da27ad to
80f37e5
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #22319 +/- ##
==========================================
+ Coverage 82.73% 82.75% +0.01%
==========================================
Files 594 594
Lines 65732 65722 -10
Branches 10266 10267 +1
==========================================
+ Hits 54385 54386 +1
+ Misses 8711 8696 -15
- Partials 2636 2640 +4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This PR focuses on improving the implementations for
array(), maximum(), minimum(), reshape() and split()for the OpenVINO Backend in the numpy suite.array()- replacednp.array()withconvert_to_tensor()so the return value is always anOpenVINOKerasTensorinstead of a raw NumPy array, making it consistent with other ops in the backend.maximum()/minimum()- added thet1/t2dtype-extraction step (same pattern asadd(),subtract(),multiply()) so Pythonint/floatliterals are promoted using JAX weak-type semantics instead of being unconditionally cast toint32/float32reshape()- added a guard for integernewshape(e.g.Reshape(-1)), wrapping it in a list before passing toov_opset.constant()which requires a 1-D shape tensorsplit()- handleOpenVINOKerasTensorasindices_or_sectionsby extracting the underlying constant data viaget_node().get_data(); this was a side-effect of thearray()fix and also covershsplit()/vsplit()which delegate tosplit()Included the relevent tests from
excluded_concrete_tests.txt.Closes: openvinotoolkit/openvino/issues/34409