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

DenseTensor

Metadata trait: a Tensor backed by a dense (contiguous) layout.

Adds the layout type, preferred alignment, and engine on top of Tensor, giving the kernel enough to build a TileTensor view over the argument's storage. The dense-vs-plain distinction is invisible to the distilled contract.

Implemented traits​

AnyType, Tensor

comptime members​

alignment​

comptime alignment

Engine​

comptime Engine = DefaultEngine

How the argument's backing memory is referenced.

Per-target instantiation metadata like alignment, not part of the distilled contract: the graph compiler picks it per device label when it instantiates the argument, so a host-pointer argument and a device-pointer argument differ here while sharing one contract.

LayoutType​

comptime LayoutType

Required methods​

layout​

def layout(self) -> Self.LayoutType

Returns the tensor's layout (shape and strides).

Returns:

_Self.LayoutType: The argument's LayoutType instance.

Was this page helpful?