Skip to content

Commit 3969657

Browse files
leofangclaude
andcommitted
Fix strides assertion for torch CAI: allow explicit C-contiguous strides
torch's __cuda_array_interface__ always reports strides, even for C-contiguous tensors. Use the same assertion pattern as the other _check_view methods: allow strides to equal the C-contiguous values instead of requiring None. Verified locally: 7/7 torch CAI tests pass. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 24fc3aa commit 3969657

1 file changed

Lines changed: 1 addition & 4 deletions

File tree

cuda_core/tests/test_utils.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -348,10 +348,7 @@ def _check_view(self, view, in_arr, dev):
348348
assert view.shape == expected_shape
349349
assert view.size == _arr_size(in_arr)
350350
strides_in_counts = _arr_strides_in_counts(in_arr)
351-
if _arr_is_c_contiguous(in_arr):
352-
assert view.strides is None
353-
else:
354-
assert view.strides == strides_in_counts
351+
assert (_arr_is_c_contiguous(in_arr) and view.strides is None) or view.strides == strides_in_counts
355352
assert view.device_id == dev.device_id
356353
assert view.is_device_accessible is True
357354
assert view.exporting_obj is in_arr

0 commit comments

Comments
 (0)