Skip to content

Commit

Permalink
Merge pull request #806 from IntelPython/fix-pairwise-distance-for-si…
Browse files Browse the repository at this point in the history
…ngle-precision

Fixed pairwise_distance.py to run on machine with no FP64 support in HW
  • Loading branch information
diptorupd authored Oct 18, 2022
2 parents 7a94133 + 73daf3f commit 60b1455
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions numba_dpex/examples/pairwise_distance.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
# Local Work size is optional
local_size = args.l

X = np.random.random((args.n, args.d))
D = np.empty((args.n, args.n))
X = np.random.random((args.n, args.d)).astype(np.single)
D = np.empty((args.n, args.n), dtype=np.single)


@dpex.kernel
Expand All @@ -40,9 +40,10 @@ def pairwise_distance(X, D, xshape0, xshape1):
"""
idx = dpex.get_global_id(0)

d0 = X[idx, 0] - X[idx, 0]
# for i in range(xshape0):
for j in range(X.shape[0]):
d = 0.0
d = d0
for k in range(X.shape[1]):
tmp = X[idx, k] - X[j, k]
d += tmp * tmp
Expand Down

0 comments on commit 60b1455

Please sign in to comment.