Skip to content

Commit

Permalink
dtype fix for temp output array in pdist_max_blockwise
Browse files Browse the repository at this point in the history
  • Loading branch information
grlee77 committed Mar 3, 2025
1 parent ae2d29a commit f73f779
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions python/cucim/src/cucim/skimage/_shared/distance.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,14 @@ def pdist_max_blockwise(
)

blocks_per_dim = math.ceil(num_coords / coords_per_block)
if coords.dtype not in [xp.float32, xp.float64]:
coords = coords.astype(xp.float32, copy=False)
if blocks_per_dim > 1:
# reuse the same temporary storage array for most blocks
# (last block in row and column may be smaller)
temp = xp.zeros((coords_per_block, coords_per_block), dtype=xp.float32)
if coords.dtype not in [xp.float32, xp.float64]:
coords = coords.astype(xp.float32, copy=False)
temp = xp.zeros(
(coords_per_block, coords_per_block), dtype=coords.dtype
)
if not coords.flags.c_contiguous:
coords = xp.ascontiguousarray(coords)
max_dist = 0
Expand Down

0 comments on commit f73f779

Please sign in to comment.