Expand description
Typed device buffers: sizes come from the element type, never from a literal byte count.
Functions§
- bytes
- Bytes of
lenelements ofE, at least one element (runtimes reject empty allocations). - copy
- Copies the first
lenvalues ofFofsrcintodst, on the device. - download
- Host copy of a device buffer of
E(waits for the queued work that writes it). - download_
prefix - Host copy of the first
lenelements ofEof a device buffer: only those bytes are read, so a buffer sized for the largest batch costs only the current batch’s transfer. - download_
range - Host copy of elements
start .. start + lenofEof a device buffer: only those bytes are read. - empty
- Uninitialized device buffer of
lenelements ofE. - fill
- Sets the first
lenvalues ofhandle(which holds at leastlenvalues ofF) tovalue, on the device. - filled
- Device buffer of
lencopies ofvalue, filled on the device: nothing is uploaded. - truncate
handlewithout its lastunusedelements ofE(a view of a buffer larger than the data).- upload
- Device copy of
data. - write
- Writes
datato the start of the existing device bufferhandle(which holds at leastdata.len()elements ofE): no allocation, enqueued after the work already queued on the client’s stream, so a buffer reused every window is not overwritten before the previous window’s kernels have read it. - write_
bytes - Writes
datato the start ofhandle, narrowed todata’s length: a reused buffer is often larger than the chunk written into it, and the CPU runtime copies the whole bound range (a write shorter than its handle panics there; wgpu and CUDA accept it). - write_
owned writetaking ownership ofdata: the bytes move into the transfer without a copy (useful when the buffer was filled on another thread, e.g. a read-ahead loader).- zeros
- Device buffer of
lenzeros, filled on the device (cubecl-std’s zero kernel): nothing is uploaded.