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
- outputBuffer. Defaults to None.
Buffer where the content of this buffer will be copied to. Its size must be equal as this buffer.
Returns
- outputBuffer.
If output parameter is None, returns a new Buffer object, otherwise returns the same output object.
- fromHost(self, ndarray input)
Copies the content of a Numpy array to this buffer.
Parameters
- inputnumpy.ndarray.
Input array. Its size in bytes (input.nbytes) must be equal to this buffer size.
Raises
- ValueErrorif 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
- outputnumpy.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.
- dtypenumpy.dtype. Defaults to numpy.uint8.
Data type of the returned array.
Returns
- outputa new numpy array if input parameter output was None
or the same output object otherwise.
Raises
- RuntimeErrorif 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.
- ValueErrorif output is different than None but its size in bytes
output.nbytes is different than this buffer’s size.
- usageFlags