Skip to main content
Log in

Mojo struct

DeviceBuffer

struct DeviceBuffer[type: DType]

Implemented traits

AnyType, CollectionElement, Copyable, Movable, Sized, UnknownDestructibility

Methods

__init__

__init__(out self, ctx: DeviceContext, size: Int, sync_mode: _DeviceSyncMode)

This init takes in a constructed DeviceContext and schedules an owned buffer allocation using the stream in the device context.

__init__(out self, handle: UnsafePointer[_DeviceBufferCpp], device_ptr: UnsafePointer[SIMD[type, 1]])

__init__(out self, ctx: DeviceContext, ptr: UnsafePointer[SIMD[type, 1]], size: Int, *, owning: Bool)

__copyinit__

__copyinit__(out self, existing: Self)

__moveinit__

__moveinit__(out self, owned existing: Self)

__del__

__del__(owned self)

This function schedules an owned buffer free using the stream in the device context.

copy

copy(self) -> Self

Explicitly construct a copy of self.

Returns:

A copy of this value.

__len__

__len__(self) -> Int

create_sub_buffer

create_sub_buffer[view_type: DType](self, offset: Int, size: Int) -> DeviceBuffer[view_type]

enqueue_copy_to

enqueue_copy_to(self, dst: Self)

take_ptr

take_ptr(owned self) -> UnsafePointer[SIMD[type, 1]]

get_ptr

get_ptr(self) -> UnsafePointer[SIMD[type, 1]]

__getattr__

__getattr__[name: StringLiteral](self) -> UnsafePointer[SIMD[type, 1]]