IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /get-started.md). For the complete documentation index, see llms.txt.
Skip to main content
For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /get-started.md).

Mojo struct

OwnedGPUStorage

struct OwnedGPUStorage[dtype: DType, address_space: AddressSpace, LayoutType: TensorLayout, alignment: Int = align_of[dtype]()]

Holds the elements of a compact layout in a GPU stack allocation.

The memory comes from stack_allocation in a constructor that is always inlined, so a LOCAL or host allocation lives in the frame of the function that builds the tensor, and is valid until that function returns. A SHARED allocation is shared by every instance in a block.

Parameters​

  • ​dtype (DType): The element data type.
  • ​address_space (AddressSpace): The address space to allocate in.
  • ​LayoutType (TensorLayout): The layout of the tensor the storage backs. Constrained to compact layouts, whose offsets cover exactly one slot per element.
  • ​alignment (Int): The alignment of the underlying memory.

Implemented traits​

AnyType, Defaultable, Deinitable

Methods​

__init__​

def __init__(out self)

Allocates one uninitialized slot per element of LayoutType.

Constraints:

LayoutType must be compact: its cosize must equal its number of elements.

unsafe_ptr​

def unsafe_ptr(ref self) -> Pointer[Scalar[dtype], origin_of(self), address_space=address_space]

Returns a pointer to the first element.

Returns:

Pointer[Scalar[dtype], origin_of(self), address_space=address_space]: A pointer whose origin and mutability are those of self.

Was this page helpful?