Mojo trait
DeviceBuffer
Implemented traits
AnyType
Methods
copy_to
copy_to(self: T, dev: Device, name: Optional[String]) -> T
Copies the contents of self into DeviceBuffer allocated on dev. Note: this function allocates memory on dev.
Args:
- dev (
Device
): The Device on which to allocate the new DeviceBuffer. - name (
Optional[String]
): Optional name of the new DeviceBuffer.
Returns:
Newly allocated DeviceBuffer containing a copy of self's contents.
Raises:
If the DeviceBuffer is backed by the same Device object as dev.
copy_into
copy_into(self: T, inout dst_memory: T)
Copies the contents of self into a preallocated DeviceBuffer.
Args:
- dst_memory (
T
): The destination DeviceBuffer of the copy.
move_to
move_to(owned self: T, dev: Device) -> T
Returns self if already allocated on dev, otherwise copy the contents of self to dev.
Args:
- dev (
Device
): The Device of the returned buffer.
Returns:
A DeviceBuffer located in dev's address space.
unsafe_ptr
unsafe_ptr(self: T) -> UnsafePointer[SIMD[uint8, 1], 0, 0, alignof[::AnyType,__mlir_type.!kgen.target]() if triple_is_nvidia_cuda() else 1]
Returns a pointer to the DeviceBuffer's storage in device memory.
device
device(self: T) -> Device
Returns the Device on which the DeviceBuffer was allocated.
bytecount
bytecount(self: T) -> Int
Returns the size of the DeviceBuffer in bytes.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!