Skip to content

Commit f22ad8e

Browse files
committed
Address cuda.core coverage test review comments
1 parent 73b1f05 commit f22ad8e

3 files changed

Lines changed: 355 additions & 377 deletions

File tree

cuda_core/tests/test_tensor_map.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,27 @@ def test_invalid_data_type(self, dev, skip_if_no_tma):
308308
data_type=42,
309309
)
310310

311+
def test_as_tensor_map_host_view_rejected_without_tma(self):
312+
"""``as_tensor_map`` on a non-device-accessible (host) view fails
313+
gracefully with a clear error, without needing TMA-capable hardware.
314+
315+
This drives the real ``as_tensor_map`` -> ``_from_tiled`` path: every
316+
keyword is assembled and the options are coerced before the
317+
device-accessibility guard rejects the host pointer, so no monkeypatching
318+
is required to cover the forwarding logic.
319+
"""
320+
host = np.zeros((64, 64), dtype=np.float32)
321+
view = StridedMemoryView.from_any_interface(host, stream_ptr=-1)
322+
with pytest.raises(ValueError, match="device-accessible"):
323+
view.as_tensor_map(
324+
box_dim=(32, 32),
325+
data_type=TensorMapDataType.FLOAT32,
326+
element_strides=(1, 1),
327+
swizzle=TensorMapSwizzle.SWIZZLE_128B,
328+
l2_promotion=TensorMapL2Promotion.L2_128B,
329+
oob_fill=TensorMapOOBFill.NAN_REQUEST_ZERO_FMA,
330+
)
331+
311332

312333
class TestTensorMapDtypeMapping:
313334
"""Test automatic dtype inference from numpy dtypes."""

0 commit comments

Comments
 (0)