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

Function test_copy_to

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

Source from the content-addressed store, hash-verified

825
826
827def test_copy_to():
828 _, buf = make_random_buffer(size=10, target='device')
829 mm_cuda = buf.memory_manager
830
831 for dest in [mm_cuda, mm_cuda.device]:
832 arr = pa.array([0, 1, 2])
833 arr_cuda = arr.copy_to(dest)
834 assert not arr_cuda.buffers()[1].is_cpu
835 assert arr_cuda.buffers()[1].device_type == pa.DeviceAllocationType.CUDA
836 assert arr_cuda.buffers()[1].device == mm_cuda.device
837
838 arr_roundtrip = arr_cuda.copy_to(pa.default_cpu_memory_manager())
839 assert arr_roundtrip.equals(arr)
840
841 batch = pa.record_batch({"col": arr})
842 batch_cuda = batch.copy_to(dest)
843 buf_cuda = batch_cuda["col"].buffers()[1]
844 assert not buf_cuda.is_cpu
845 assert buf_cuda.device_type == pa.DeviceAllocationType.CUDA
846 assert buf_cuda.device == mm_cuda.device
847
848 batch_roundtrip = batch_cuda.copy_to(pa.default_cpu_memory_manager())
849 assert batch_roundtrip.equals(batch)
850
851
852def test_device_interface_array():

Callers

nothing calls this directly

Calls 4

buffersMethod · 0.80
equalsMethod · 0.80
make_random_bufferFunction · 0.70
arrayMethod · 0.45

Tested by

no test coverage detected