-
-
Notifications
You must be signed in to change notification settings - Fork 26k
ENH Add the fused CSR dense case for Euclidean Specializations #25044
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
Changes from all commits
0243c1d
3344567
303bc90
8576390
a874def
12700d6
6563505
ff6d47f
17b6845
22d2cd2
45d425a
b95ca39
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -119,26 +119,7 @@ def is_valid_sparse_matrix(X): | |||||||||||||||||||||||||||||||||||
and metric in cls.valid_metrics() | ||||||||||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
# The other joblib-based back-end might be more efficient on fused sparse-dense | ||||||||||||||||||||||||||||||||||||
# datasets' pairs on metric="(sq)euclidean" for some configurations because it | ||||||||||||||||||||||||||||||||||||
# uses the Squared Euclidean matrix decomposition, i.e.: | ||||||||||||||||||||||||||||||||||||
# | ||||||||||||||||||||||||||||||||||||
# ||X_c_i - Y_c_j||² = ||X_c_i||² - 2 X_c_i.Y_c_j^T + ||Y_c_j||² | ||||||||||||||||||||||||||||||||||||
Comment on lines
-124
to
-126
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this "trick" still documented somewhere in the pairwise distances codebase? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, it is given here: scikit-learn/sklearn/metrics/_pairwise_distances_reduction/_middle_term_computer.pyx.tp Lines 77 to 93 in dfe9e2e
I am thinking of writing a couple of notes for the design of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That would be great. Not too many details, but giving a good overview. |
||||||||||||||||||||||||||||||||||||
# | ||||||||||||||||||||||||||||||||||||
# calling efficient sparse-dense routines for matrix and vectors multiplication | ||||||||||||||||||||||||||||||||||||
# implemented in SciPy we do not use yet here. | ||||||||||||||||||||||||||||||||||||
# See: https://github.com/scikit-learn/scikit-learn/pull/23585#issuecomment-1247996669 # noqa | ||||||||||||||||||||||||||||||||||||
# TODO: implement specialisation for (sq)euclidean on fused sparse-dense | ||||||||||||||||||||||||||||||||||||
# using sparse-dense routines for matrix-vector multiplications. | ||||||||||||||||||||||||||||||||||||
# Currently, only dense-dense and sparse-sparse are optimized for | ||||||||||||||||||||||||||||||||||||
# the Euclidean case. | ||||||||||||||||||||||||||||||||||||
fused_sparse_dense_euclidean_case_guard = not ( | ||||||||||||||||||||||||||||||||||||
(is_valid_sparse_matrix(X) ^ is_valid_sparse_matrix(Y)) # "^" is XOR | ||||||||||||||||||||||||||||||||||||
and isinstance(metric, str) | ||||||||||||||||||||||||||||||||||||
and "euclidean" in metric | ||||||||||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
return is_usable and fused_sparse_dense_euclidean_case_guard | ||||||||||||||||||||||||||||||||||||
return is_usable | ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
@classmethod | ||||||||||||||||||||||||||||||||||||
@abstractmethod | ||||||||||||||||||||||||||||||||||||
|
Uh oh!
There was an error while loading. Please reload this page.