Buffer

class lluvia.core.Buffer
allocationInfo
copy(self, Buffer output=None)

Copies the content of this buffer into output.

If output is None, a new buffer is created in the same memory as this one and with the same usage flags.

Parameters

output (Buffer. Defaults to None.) – Buffer where the content of this buffer will be copied to. Its size must be equal as this buffer.

Returns

output – If output parameter is None, returns a new Buffer object, otherwise returns the same output object.

Return type

Buffer.

fromHost(self, ndarray input)

Copies the content of a Numpy array to this buffer.

Parameters

input (numpy.ndarray.) – Input array. Its size in bytes (input.nbytes) must be equal to this buffer size.

:raises ValueError : if the size of the input array in bytes is different: to this buffer size.

isMappable
memory
session
size
toHost(self, ndarray output=None, dtype=np.uint8)

Copies the content of this buffer into a numpy host array.

Parameters
  • output (numpy.ndarray. Defaults to None.) – Numpy array where the memory content of this buffer will be copied to. If None, a new Numpy array will be created with the same size in bytes as this buffer.

  • dtype (numpy.dtype. Defaults to numpy.uint8.) – Data type of the returned array.

Returns

output – or the same output object otherwise.

Return type

a new numpy array if input parameter output was None

:raises RuntimeError : if the buffer is not mappable to host-visible memory.: This might be caused by another object mapping the same memory page as this one or because the memory this buffer was created from is not mappable to host-visible memory, e.g., memories created with ‘DeviceLocal’ flag. :raises ValueError : if output is different than None but its size in bytes: output.nbytes is different than this buffer’s size.

usageFlags