Skip to content

Instantly share code, notes, and snippets.

@rvaghefi
Created January 13, 2021 22:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rvaghefi/705cdae5c4e6d5bebe4923497e09d277 to your computer and use it in GitHub Desktop.
Save rvaghefi/705cdae5c4e6d5bebe4923497e09d277 to your computer and use it in GitHub Desktop.
cupy_vectorized.py
import cupy as cp
def cupy_vectorized(X,Y):
X_gpu = cp.asarray(X)
Y_gpu = cp.asarray(Y)
D = cp.sum((X_gpu[:,None,:] - Y_gpu[None,:,:])**2, axis=2)**0.5
return cp.asnumpy(D)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment