torch.tx.BufferPool
class BufferPoolnew BufferPool(maxPoolSize: number = 10)
Constructor Parameters
maxPoolSizenumberoptional- Maximum number of buffers to keep per shape/dtype combination
- readonly
stats({ pooled: number; inUse: number; pools: number }) - – Get statistics about the buffer pool.
A pool of reusable tensor buffers.
Buffers are categorized by shape and dtype. When a buffer is requested, a matching buffer from the pool is returned if available, otherwise a new buffer is created. When done, buffers can be returned to the pool for reuse.
Examples
const pool = new BufferPool();
// Get a buffer (creates new or reuses existing)
const buf = pool.acquire([2, 3], 'float32');
// Use the buffer...
result.copy_(buf);
// Return to pool for reuse
pool.release(buf);
// Clear all buffers when done
pool.clear();