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

Adding fused_l2_nn_argmin wrapper to Pylibraft #924

Merged
Merged
Changes from 1 commit
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
Prev Previous commit
Fixing flake8 style
  • Loading branch information
cjnolet committed Oct 19, 2022
commit 6d2b9d0ca34c2c72a9505d0a4465514e9bb7f260
65 changes: 33 additions & 32 deletions python/pylibraft/pylibraft/distance/fused_l2_nn.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -38,26 +38,27 @@ cdef extern from "raft_distance/fused_l2_min_arg.hpp" \
namespace "raft::distance::runtime":

void fused_l2_nn_min_arg(
const handle_t &handle,
int* min,
const float* x,
const float* y,
int m,
int n,
int k,
bool sqrt);
const handle_t &handle,
int* min,
const float* x,
const float* y,
int m,
int n,
int k,
bool sqrt)

void fused_l2_nn_min_arg(
const handle_t &handle,
int* min,
const double* x,
const double* y,
int m,
int n,
int k,
bool sqrt);

def fused_l2_nn_argmin(X, Y, output, sqrt = True):
const handle_t &handle,
int* min,
const double* x,
const double* y,
int m,
int n,
int k,
bool sqrt)


def fused_l2_nn_argmin(X, Y, output, sqrt=True):
"""
Compute the 1-nearest neighbors between X and Y using the L2 distance

Expand Down Expand Up @@ -129,21 +130,21 @@ def fused_l2_nn_argmin(X, Y, output, sqrt = True):

if x_dt == np.float32:
fused_l2_nn_min_arg(deref(h),
<int*> d_ptr,
<float*> x_ptr,
<float*> y_ptr,
<int>m,
<int>n,
<int>x_k,
<bool>sqrt)
<int*> d_ptr,
<float*> x_ptr,
<float*> y_ptr,
<int>m,
<int>n,
<int>x_k,
<bool>sqrt)
elif x_dt == np.float64:
fused_l2_nn_min_arg(deref(h),
<int*> d_ptr,
<double*> x_ptr,
<double*> y_ptr,
<int>m,
<int>n,
<int>x_k,
<bool>sqrt)
<int*> d_ptr,
<double*> x_ptr,
<double*> y_ptr,
<int>m,
<int>n,
<int>x_k,
<bool>sqrt)
else:
raise ValueError("dtype %s not supported" % x_dt)