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

Function test_CudaBuffer

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

Source from the content-addressed store, hash-verified

308
309@pytest.mark.parametrize("size", [0, 1, 1000])
310def test_CudaBuffer(size):
311 arr, buf = make_random_buffer(size)
312 assert arr.tobytes() == buf.to_pybytes()
313 cbuf = global_context.buffer_from_data(buf)
314 assert cbuf.size == size
315 assert not cbuf.is_cpu
316 assert arr.tobytes() == cbuf.to_pybytes()
317 if size > 0:
318 assert cbuf.address > 0
319
320 for i in range(size):
321 assert cbuf[i] == arr[i]
322
323 for s in [
324 slice(None),
325 slice(size//4, size//2),
326 ]:
327 assert cbuf[s].to_pybytes() == arr[s].tobytes()
328
329 sbuf = cbuf.slice(size//4, size//2)
330 assert sbuf.parent == cbuf
331
332 with pytest.raises(TypeError,
333 match="Do not call CudaBuffer's constructor directly"):
334 cuda.CudaBuffer()
335
336
337@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