quadrants.lang.buffer_view#
Classes#
A view into a sub-range [offset, offset+size) of an ndarray. |
Module Contents#
- class quadrants.lang.buffer_view.BufferView(arr, offset, size)[source]#
A view into a sub-range [offset, offset+size) of an ndarray.
Create via slice syntax:
view = data[:16] # offset=0, size=16 view = data[8:24] # offset=8, size=16
Or construct directly:
view = qd.BufferView(data, offset=16, size=32)
Subviews can be created from an existing view:
sub = view.subview(offset=4, size=8)
Annotate kernel/func parameters with
BufferView[dtype]or plainBufferView:@qd.kernel def k(v: BufferView[qd.f32]): for i in range(v.size): v[i] *= 2.0