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

Function test_foreign_buffer

python/pyarrow/tests/test_cuda.py:282–298  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

280
281
282def test_foreign_buffer():
283 ctx = global_context
284 dtype = np.dtype(np.uint8)
285 size = 10
286 hbuf = cuda.new_host_buffer(size * dtype.itemsize)
287
288 # test host buffer memory reference counting
289 rc = sys.getrefcount(hbuf)
290 fbuf = ctx.foreign_buffer(hbuf.address, hbuf.size, hbuf)
291 assert sys.getrefcount(hbuf) == rc + 1
292 del fbuf
293 assert sys.getrefcount(hbuf) == rc
294
295 # test postponed deallocation of host buffer memory
296 fbuf = ctx.foreign_buffer(hbuf.address, hbuf.size, hbuf)
297 del hbuf
298 fbuf.copy_to_host()
299
300
301@pytest.mark.parametrize("size", [0, 1, 1000])

Callers

nothing calls this directly

Calls 1

dtypeMethod · 0.80

Tested by

no test coverage detected