-
Notifications
You must be signed in to change notification settings - Fork 2
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
chore: fix nms & use views instead of owned arrays #53
Conversation
CodSpeed Performance ReportMerging #53 will improve performances by 79.02%Comparing Summary
Benchmarks breakdown
|
Hi @BTOdell I've extended a bit the use of array views and also fixed the python bindings. Overall things are well speed up especially NMS which is really cool ! I've tried a bunch of things but couldn't figure out why things are slowed down there. A theory could be that in the case where our output is significantly bigger than our input (which is the case for ious functions since they return a matrix from 2 1d vectors) it's better to deal with OwneRepr ... do you have any idea ? |
When you pass in an owned ndarray to a function, you give up ownership of that data and the caller won't use it anymore, so when it's converted to a PyArray, the internal data can simply be moved into the PyArray without doing an element-by-element copy. You can see in the new flamegraph, it's called Also, I noticed you added back the |
To overcome the issue with the element-by-element copying, you could try accepting a CowArray instead of an ArrayView. That way, if the user has an owned array that they won't need after calling the function, they can pass in the owned array to regain the original performance. But if they need the array after the call, then they would pass in a view (and incur the cost of copying from the view into the PyArray). |
@Smirkey Can you comment on this? |
yeah sure sorry ! I added it back because it broke the test (division by zero errors), but will look further into what you've done for fixing nms later, my goal at first was to get everything working along with the bindings As for the slow down observed in codspeed benchmarks, it was linked to the fact that I use |
The zero division errors only occur whit integer and unsigned integers |
I believe it's either related to all of the Also, I think it's possible that adding the |
But it looks like everything is passing even with the |
#51