Pool of pinned CPU memory buffers for efficient GPU-to-CPU transfers
Source:R/inference.R
pinned_buffer_pool.RdPinned (page-locked) memory enables faster async GPU-to-CPU data transfers by allowing the GPU to directly access the CPU memory without involving the CPU. This class maintains a pool of such buffers to avoid the overhead of repeated allocation and deallocation.
Examples
if (FALSE) { # \dontrun{
pool <- pinned_buffer_pool$new(max_buffers_per_shape = 8L)
buf <- pool$get(c(100L, 128L), torch_float())
# ... use buffer ...
pool$put(buf) # Return to pool for reuse
} # }