MCPcopy Create free account
hub / github.com/apache/arrow / test_CudaBuffer

Function test_CudaBuffer

python/pyarrow/tests/test_cuda.py:302–326  ·  view source on GitHub ↗
(size)

Source from the content-addressed store, hash-verified

300
301@pytest.mark.parametrize("size", [0, 1, 1000])
302def test_CudaBuffer(size):
303 arr, buf = make_random_buffer(size)
304 assert arr.tobytes() == buf.to_pybytes()
305 cbuf = global_context.buffer_from_data(buf)
306 assert cbuf.size == size
307 assert not cbuf.is_cpu
308 assert arr.tobytes() == cbuf.to_pybytes()
309 if size > 0:
310 assert cbuf.address > 0
311
312 for i in range(size):
313 assert cbuf[i] == arr[i]
314
315 for s in [
316 slice(None),
317 slice(size//4, size//2),
318 ]:
319 assert cbuf[s].to_pybytes() == arr[s].tobytes()
320
321 sbuf = cbuf.slice(size//4, size//2)
322 assert sbuf.parent == cbuf
323
324 with pytest.raises(TypeError,
325 match="Do not call CudaBuffer's constructor directly"):
326 cuda.CudaBuffer()
327
328
329@pytest.mark.parametrize("size", [0, 1, 1000])

Callers

nothing calls this directly

Calls 4

sliceFunction · 0.85
CudaBufferMethod · 0.80
make_random_bufferFunction · 0.70
sliceMethod · 0.45

Tested by

no test coverage detected