Skip to content

Commit

Permalink
chan_vese: pass all constants to _fused_variance_kernel2 as device …
Browse files Browse the repository at this point in the history
…scalars (#764)

This change avoids an issue with an internal `numpy.can_cast` call in CuPy's kernel fusion code when using NumPy 2.0. With this change all cuCIM tests passed using NumPy 2.0.1 and the CuPy 13.3dev branch.

Fixes #742

Authors:
  - Gregory Lee (https://github.com/grlee77)

Approvers:
  - https://github.com/jakirkham
  - Gigon Bae (https://github.com/gigony)

URL: #764
  • Loading branch information
grlee77 committed Aug 22, 2024
1 parent ef99071 commit c004b6f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion python/cucim/src/cucim/skimage/segmentation/_chan_vese.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ def _fused_variance_kernel2(
difference_term += term2

new_phi = phi + (dt * delta_phi) * (mu * K + difference_term)
out = new_phi / (1 + mu * dt * delta_phi * Csum)
out_denom = mu * dt * delta_phi * Csum
out_denom += out_denom.dtype.type(1)
out = new_phi / out_denom
return out


Expand Down Expand Up @@ -430,6 +432,9 @@ def chan_vese(
phivar = tol + 1

dt = cp.asarray(dt, dtype=float_dtype)
mu = cp.asarray(mu, dtype=float_dtype)
lambda1 = cp.asarray(lambda1, dtype=float_dtype)
lambda2 = cp.asarray(lambda2, dtype=float_dtype)
while phivar > tol and i < max_num_iter:
# Save old level set values
oldphi = phi
Expand Down

0 comments on commit c004b6f

Please sign in to comment.