Skip to content

Commit

Permalink
Disable custom 2D separable filtering kernels on windows (#770)
Browse files Browse the repository at this point in the history
We currently bundle some custom 2D convolution kernels not present in CuPy. We have additional testing of these internel kernels, but I found that on the Windows platform a subset of these tests currently fail.

This MR disables auto-selection of these kernels on the Windows platform (will always fall back to CuPy's `cupyx.scipy.ndimage` kernels in this case). The test cases that are currently known to fail are skipped for now on Windows. Longer term it would be good to resolve the issues with the kernels, restore the test cases and enable use of these kernels on Windows.

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

Approvers:
  - https://github.com/jakirkham

URL: #770
  • Loading branch information
grlee77 committed Sep 1, 2024
1 parent 4da46b0 commit d66fcd0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
5 changes: 4 additions & 1 deletion python/cucim/src/cucim/skimage/_vendored/_ndimage_filters.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""A vendored subset of cupyx.scipy.ndimage._filters"""
import math
import platform
import warnings

import cupy
Expand All @@ -22,6 +23,8 @@
except ImportError:
compile_errors = (ResourceLimitError,)

_is_not_windows = platform.system() != "Windows"


def correlate(input, weights, output=None, mode="reflect", cval=0.0, origin=0):
"""Multi-dimensional correlate.
Expand Down Expand Up @@ -231,7 +234,7 @@ def _correlate_or_convolve1d(
default_algorithm = False
if algorithm is None:
default_algorithm = True
if input.ndim == 2 and weights.size <= 256:
if _is_not_windows and input.ndim == 2 and weights.size <= 256:
algorithm = "shared_memory"
else:
algorithm = "elementwise"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import platform

import cupy as cp
import pytest

Expand Down Expand Up @@ -227,6 +229,13 @@ def test_separable_image_shapes_and_modes(shape, axis, kernel_size, mode):
)


@pytest.mark.skipif(
platform.system() == "Windows",
reason=(
"custom separable kernels disabled on Windows until dtype-related "
"test failures can be resolved"
),
)
@pytest.mark.parametrize("axis", (0, 1))
@pytest.mark.parametrize("image_dtype", image_dtypes_tested)
@pytest.mark.parametrize(
Expand All @@ -246,6 +255,13 @@ def test_separable_image_and_kernel_dtypes(axis, image_dtype, kernel_dtype):
)


@pytest.mark.skipif(
platform.system() == "Windows",
reason=(
"custom separable kernels disabled on Windows until dtype-related "
"test failures can be resolved"
),
)
@pytest.mark.parametrize("axis", (0, 1))
@pytest.mark.parametrize("image_dtype", image_dtypes_tested)
@pytest.mark.parametrize(
Expand Down

0 comments on commit d66fcd0

Please sign in to comment.