Skip to content

Commit 0f85061

Browse files
authored
cuda.core: fix _arr_is_c_contiguous discriminator for numba arrays (#1998)
`_arr_is_c_contiguous` checked `hasattr(arr, "flags")`, which is True for both numpy arrays and numba `DeviceNDArray`. For numba `arr.flags` is a plain dict, so the truthy branch falls into `arr.flags.c_contiguous` and raises `AttributeError: 'dict' object has no attribute 'c_contiguous'`. Discriminate on the flags object instead, mirroring the sibling `_arr_is_writeable` helper. Unblocks six numba-cuda parametrizations: - TestViewGPU::test_args_viewable_as_strided_memory_gpu[numba-cuda-{int8,float32}] - TestViewGPU::test_strided_memory_view_cpu[numba-cuda-{int8,float32}] - TestViewGPU::test_strided_memory_view_init[numba-cuda-{int8,float32}] Made-with: Cursor
1 parent aac5bf5 commit 0f85061

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

cuda_core/tests/test_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def _arr_size(arr):
102102
def _arr_is_c_contiguous(arr):
103103
if torch is not None and isinstance(arr, torch.Tensor):
104104
return arr.is_contiguous()
105-
return arr.flags.c_contiguous if hasattr(arr, "flags") else arr.flags["C_CONTIGUOUS"]
105+
return arr.flags.c_contiguous if hasattr(arr.flags, "c_contiguous") else arr.flags["C_CONTIGUOUS"]
106106

107107

108108
def _arr_is_writeable(arr):

0 commit comments

Comments
 (0)