-
Notifications
You must be signed in to change notification settings - Fork 60
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
Use linalg & inline _get_manders_overlap_coeff
#578
Conversation
sqrt
in _get_manders_overlap_coeff
norm
in _get_manders_overlap_coeff
norm
in _get_manders_overlap_coeff
_get_manders_overlap_coeff
_get_manders_overlap_coeff
_get_manders_overlap_coeff
@grlee77 would be curious to hear your thoughts on this approach 🙂 |
denom = cp.linalg.norm(image0) * cp.linalg.norm(image1) | ||
return cp.vdot(image0, image1) / denom |
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.
We could go further here and do
1 - cupyx.scipy.spatial.distance.cosine(image0, image1)
This was added in PR ( cupy/cupy#7063 ) and would require CuPy 12.0.0+ & pylibraft from RAPIDS
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.
Looks like we have to ravel to 1D to use the cosine
solution and then do a subtraction to get the equivalent result of the linalg implementation:
1 - cosine(image0.reshape(1, -1), image1.reshape(1, -1))
If the RAFT solution is faster we can provide it with fallback to the linalg one here when unavailable. In my initial testing it was slower than using linalg in this case, so let's just keep the suggested solution here for now.
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.
Sounds good. Thanks Greg! 🙏
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.
Thanks, @jakirkham, looks great!
/merge |
As most of the operations in
_get_manders_overlap_coeff
can be constructed from other linalg operations, use those directly to compute the result. Once this is done, there is less of a need tofuse
it into a kernel. Instead those linalg functions can just be called as-is.Note: This resolves a bug seen with
test_moc
in the CUDA 11.2 CI on the CUDA 12 PR ( #572 (comment) ) ( #572 (comment) )