-
Notifications
You must be signed in to change notification settings - Fork 19.6k
Added openvino backend support for numpy.median (Issue #30115) #21379
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #21379 +/- ##
=======================================
Coverage 82.54% 82.54%
=======================================
Files 571 571
Lines 57584 57639 +55
Branches 8994 9002 +8
=======================================
+ Hits 47531 47577 +46
- Misses 7760 7766 +6
- Partials 2293 2296 +3
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:
|
43ac109
to
d92b60a
Compare
@rkazants PR is ready for review. Apologies for all the commits, it took me a second to fix my local testing to run on openvino backend on macOS. |
/gemini review |
There was a problem hiding this 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 adds support for numpy.median
to the OpenVINO backend. The implementation handles scenarios for the axis
and keepdims
parameters. A critical bug was identified in the logic for handling multiple reduction axes, making that code path unreachable. Additionally, high-severity issues were found where the code relies on static shape information, leading to failures with dynamic input shapes. Suggestions have been provided to address these points and improve robustness.
/gemini review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
The code changes introduce OpenVINO backend support for numpy.median. There is a high severity issue in the logic for flattening axes within the median
function that needs to be addressed, as well as a medium-severity suggestion to improve the code's correctness.
/gemini review |
There was a problem hiding this 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 adds support for numpy.median
for the OpenVINO backend. The implementation is comprehensive, handling various cases for axis
and keepdims
. I've made a few suggestions to improve maintainability by adding comments to complex parts of the logic, and fixed a correctness issue in the ndim
function.
/gemini review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
The pull request adds OpenVINO backend support for the numpy.median function. The implementation involves a complex series of OpenVINO operations to handle different input scenarios and calculate the median. I've suggested adding more comments to improve the code's readability and maintainability, especially around the tensor manipulations and specific OpenVINO operations used.
@mattdangerw PR is ready for review. Gemini's raised concerns have been addressed, I believe it might be going over old ground with the latest suggestions but I'm happy to add more comments if needed. The torch test is failing in today's commits but I don't think this is due to my median function updates. |
@rkazants updated with comments and better clarity, ready for review. |
Is this ready to merge? @alungriffith @rkazants |
@hertschuh I believe so, just waiting for a review to approve. |
@rkazants @mattdangerw @hertschuh all tests pass, all comments are addressed, please review and close. |
flatten_shape = ov_opset.constant([-1], Type.i32).output(0) | ||
x = ov_opset.reshape(x, flatten_shape, False).output(0) | ||
flattened = True | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this blank line
@@ -1105,7 +1105,173 @@ def maximum(x1, x2): | |||
|
|||
|
|||
def median(x, axis=None, keepdims=False): | |||
raise NotImplementedError("`median` is not supported with openvino backend") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please this comment here:
"""
The median algorithm follows numpy's method;
if axis is None, flatten all dimensions of the array and find the
median value.
if axis is single int or list/tuple of multiple values, re-order x array
to move those axis dims to the right, flatten the multiple axis dims
then calculate median values along the flattened axis.
"""
Added decomposition for numpy.median using OpenVINO backend.