Skip to content
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

Improve performance of color distance calculations by kernel fusion #809

Merged
merged 2 commits into from
Jan 10, 2025

Conversation

grlee77
Copy link
Contributor

@grlee77 grlee77 commented Jan 9, 2025

Description

This MR is purely to fuse many separate kernels into a single elementwise kernel for each of the "color distance" functions. This is expected to result in substantial performance improvement by reduced kernel launch overhead and because a single pass through the image is much more memory efficient than many separate kernel calls.

There is not expected to be any change in behavior (existing tests must continue to pass)

Benchmark Results

I added benchmarks for these functions and compared the results before and after this change.

The acceleration values are the relative speedup as compared to the scikit-image implementation

For a pair of 32-bit LAB images of shape: (512, 512, 3)

function acceleration (old) acceleration (new)
deltaE_cie76 5.49 21.85
deltaE_ciede94 37.60 65.09
deltaE_ciede2000 12.54 109.71
deltaE_cmc 27.18 89.23

For a pair of 32-bit LAB images of shape: (3840, 2160, 3)

function acceleration (old) acceleration (new)
deltaE_cie76 31.12 250.74
deltaE_ciede94 79.15 117.50
deltaE_ciede2000 71.36 132.73
deltaE_cmc 70.65 154.83

@grlee77 grlee77 added improvement Improves an existing functionality non-breaking Introduces a non-breaking change labels Jan 9, 2025
@grlee77 grlee77 added this to the v25.02.00 milestone Jan 9, 2025
@grlee77 grlee77 requested a review from a team as a code owner January 9, 2025 19:16
Copy link
Contributor

@gigony gigony left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @grlee77 !
I don't understand the internal algorithm but this looks good to me!

@grlee77
Copy link
Contributor Author

grlee77 commented Jan 10, 2025

Not sure that there is a common use case for actually running these on full images or if it is most commonly used just to compare the perceptual difference of single pairs of colors. If the later, then the CPU will be better for running that case.

I think perhaps there could be use cases like comparing perceptual differences among all pairs of colors in a categorical colormap, etc.

@grlee77
Copy link
Contributor Author

grlee77 commented Jan 10, 2025

/merge

@rapids-bot rapids-bot bot merged commit 8fe097e into rapidsai:branch-25.02 Jan 10, 2025
47 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement Improves an existing functionality non-breaking Introduces a non-breaking change
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants