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 trait

OwnedTensorEngine

Supplies the storage behind an OwnedTensor and views of that storage.

A conforming engine names the owning storage an OwnedTensor holds and the TensorEngine of the TileTensor views built from that tensor. get_storage_view turns the owned storage into that engine's storage handle.

Implemented traits​

AnyType

comptime members​

StorageType​

comptime StorageType[dtype: DType, address_space: AddressSpace, LayoutType: TensorLayout]

The owning storage for a tensor with the given element type and layout.

OwnedTensor default-constructs this type to allocate its elements, so the layout must be enough to size the storage.

Parameters​

  • ​dtype (DType): The element data type of the storage.
  • ​address_space (AddressSpace): The address space the storage resides in.
  • ​LayoutType (TensorLayout): The layout of the tensor the storage backs.

ViewEngine​

comptime ViewEngine

The engine of a TileTensor built from an OwnedTensor.

Required methods​

get_storage_view​

static def get_storage_view[result_mut: Bool, dtype: DType, address_space: AddressSpace, result_origin: Origin[mut=result_mut], //](ref storage: Self.StorageType[dtype, address_space, LayoutType]) -> Self.ViewEngine.StorageType[dtype, result_origin, address_space]

Returns a ViewEngine storage handle to owned storage.

The caller chooses result_origin, either through the return type it expects or by passing it by keyword. It should be the origin of the OwnedTensor holding storage, so the view can't outlive the owner.

Parameters:

  • ​result_mut (Bool): The mutability of the view, inferred from result_origin.
  • ​dtype (DType): The element data type of the storage.
  • ​address_space (AddressSpace): The address space the storage resides in.
  • ​result_origin (Origin[mut=result_mut]): The origin the view borrows from.

Args:

  • ​storage (Self.StorageType[dtype, address_space, LayoutType]): The owned storage to view.

Returns:

_Self.ViewEngine.StorageType[dtype, result_origin, address_space]: A handle to storage with origin result_origin.

Was this page helpful?