Skip to content

Commit 24fc3aa

Browse files
leofangclaude
andcommitted
Fix torch-incompatible assertions in TestViewCudaArrayInterfaceGPU
The _check_view method in TestViewCudaArrayInterfaceGPU was missed during the tensor bridge refactor (#1894) and still used raw numpy attributes (in_arr.size, in_arr.strides, in_arr.flags, etc.) that don't work with torch tensors. Use the _arr_* helpers that #1894 added for torch/numpy compatibility. Caught by the nightly optional-dependency CI (#1987). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent f77e0c8 commit 24fc3aa

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

cuda_core/tests/test_utils.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -343,15 +343,15 @@ def test_cuda_array_interface_gpu(self, in_arr, use_stream):
343343

344344
def _check_view(self, view, in_arr, dev):
345345
assert isinstance(view, StridedMemoryView)
346-
assert view.ptr == gpu_array_ptr(in_arr)
347-
assert view.shape == in_arr.shape
348-
assert view.size == in_arr.size
349-
strides_in_counts = convert_strides_to_counts(in_arr.strides, in_arr.dtype.itemsize)
350-
if in_arr.flags["C_CONTIGUOUS"]:
346+
assert view.ptr == _arr_ptr(in_arr)
347+
expected_shape = tuple(in_arr.shape)
348+
assert view.shape == expected_shape
349+
assert view.size == _arr_size(in_arr)
350+
strides_in_counts = _arr_strides_in_counts(in_arr)
351+
if _arr_is_c_contiguous(in_arr):
351352
assert view.strides is None
352353
else:
353354
assert view.strides == strides_in_counts
354-
assert view.dtype == in_arr.dtype
355355
assert view.device_id == dev.device_id
356356
assert view.is_device_accessible is True
357357
assert view.exporting_obj is in_arr

0 commit comments

Comments
 (0)