Optionalallocate: ((byteLength: number) => Memory) | nullimport {
DeviceMemory,
ManagedMemory,
Float32Buffer,
setDefaultAllocator
} from '@rapidsai/cuda';
// The default allocator creates `DeviceMemory` instances,
// which can only be accessed directly from the GPU device.
// An expensive copy from GPU to CPU memory must be performed
// in order to read the data in JavaScript.
const dbuf = new Float32Buffer([1.0, 2.0, 3.0]);
assert(dbuf.buffer instanceof DeviceMemory);
// Override allocate function to create `ManagedMemory` instances.
setDefaultAllocator((byteLength) => new ManagedMemory(byteLength));
// Now the allocator uses the supplied function to create
// `ManagedMemory` instances. This kind of memory can be accessed
// by both the CPU and GPU, because the CUDA driver automatically
// migrates the data from the CPU <-> GPU as required.
const mbuf = new Float32Buffer([1.0, 2.0, 3.0]);
assert(mbuf.buffer instanceof ManagedMemory);
Function to use for device
Memoryallocations.