Repository navigation
use vendored version of cupy.pad with added performance optimizations - #482
Merged
Merged
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## branch-23.02 #482 +/- ##
================================================
- Coverage 92.95% 92.89% -0.06%
================================================
Files 130 131 +1
Lines 9775 9905 +130
================================================
+ Hits 9086 9201 +115
- Misses 689 704 +15 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
gigony
approved these changes
Feb 2, 2023
gigony
left a comment
Contributor
There was a problem hiding this comment.
Looks good to me!
There is a typo but I think it can be corrected later if we don't want to spend extra time triggering CI/CD again.
This version provides faster, elementwise kernel implementations for common padding modes. This version should also be submited upstream to CuPy itself.
apply isort fix typo
grlee77
force-pushed
the
pad-elementwise
branch
from
February 2, 2023 06:40
ab5a4db to
b557cf8
Compare
Member
|
/merge |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
This version provides faster, elementwise kernel implementations for common padding modes.
It is under
_vendoredbecause most ofpad.pyis copied from CuPy itself. The only new part there is the_use_elementwise_kernelutility and the conditional branch where it evaluates to True. The newly written code is mostly inpad_elementwise.py.I could potentially further refactor
pad.pyto remove most of the code and just call out tocupy.padinstead whenever we aren't using the elementwise kernels.This version should also be submited upstream to CuPy itself.
Padding performance is substantially improved for modes
edge,symmetric,reflectandwrap. Most places in cuCIM where we use padding, it is not the bottleneck, but it should still provide a small performance improvement in several places. I ran some benchmarks, and the largest impact I saw was around 25% reduction in run-time forchan_vese.Benchmark Results (vs.
cupy.pad)In the following, the next-to-last column is the overall acceleration observed. It is large for small 2D or 3D images (>5x) and becomes relatively small for larger images (e.g. ~10% for 4k images).
The final column only relates to the amount of time spent on the host. That "accel. CPU" number always strongly favors the new implementation. It has lower host overhead because everything is done in a single kernel call rather than potentially using multiple kernels for each axis in turn. This kernel launch overhead explains why the overall benefit is much higher for the smaller image sizes.