Created
January 13, 2021 22:54
-
-
Save rvaghefi/705cdae5c4e6d5bebe4923497e09d277 to your computer and use it in GitHub Desktop.
cupy_vectorized.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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