Skip to content

PERF Pass buffers via pointers in PairwiseDistancesReductions routines for sparse data #26765

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

Merged
merged 8 commits into from
Jul 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions doc/whats_new/v1.4.rst
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,13 @@ Changelog
:pr:`13649` by :user:`Samuel Ronsin <samronsin>`, initiated by
:user:`Patrick O'Reilly <pat-oreilly>`.

:mod:`sklearn.metrics`
......................

- |Performance| Computing pairwise distances via :class:`metrics.DistanceMetric`
for CSR × CSR, Dense × CSR, and CSR × Dense datasets is now 1.5x faster.
:pr:`26765` by :user:`Meekail Zain <micky774>`

:mod:`sklearn.utils`
....................

Expand Down
20 changes: 10 additions & 10 deletions sklearn/metrics/_dist_metrics.pxd.tp
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ cdef class DistanceMetric{{name_suffix}}(DistanceMetric):
cdef float64_t dist_csr(
self,
const {{INPUT_DTYPE_t}}* x1_data,
const int32_t[:] x1_indices,
const int32_t* x1_indices,
const {{INPUT_DTYPE_t}}* x2_data,
const int32_t[:] x2_indices,
const int32_t* x2_indices,
const int32_t x1_start,
const int32_t x1_end,
const int32_t x2_start,
Expand All @@ -101,9 +101,9 @@ cdef class DistanceMetric{{name_suffix}}(DistanceMetric):
cdef float64_t rdist_csr(
self,
const {{INPUT_DTYPE_t}}* x1_data,
const int32_t[:] x1_indices,
const int32_t* x1_indices,
const {{INPUT_DTYPE_t}}* x2_data,
const int32_t[:] x2_indices,
const int32_t* x2_indices,
const int32_t x1_start,
const int32_t x1_end,
const int32_t x2_start,
Expand All @@ -127,20 +127,20 @@ cdef class DistanceMetric{{name_suffix}}(DistanceMetric):
cdef int pdist_csr(
self,
const {{INPUT_DTYPE_t}}* x1_data,
const int32_t[:] x1_indices,
const int32_t[:] x1_indptr,
const int32_t[::1] x1_indices,
const int32_t[::1] x1_indptr,
const intp_t size,
float64_t[:, ::1] D,
) except -1 nogil

cdef int cdist_csr(
self,
const {{INPUT_DTYPE_t}}* x1_data,
const int32_t[:] x1_indices,
const int32_t[:] x1_indptr,
const int32_t[::1] x1_indices,
const int32_t[::1] x1_indptr,
const {{INPUT_DTYPE_t}}* x2_data,
const int32_t[:] x2_indices,
const int32_t[:] x2_indptr,
const int32_t[::1] x2_indices,
const int32_t[::1] x2_indptr,
const intp_t size,
float64_t[:, ::1] D,
) except -1 nogil
Expand Down
Loading