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 module

tensor_arg_traits

Composable traits for graph-compiler kernel tensor arguments.

A kernel declares each tensor argument by combining small, orthogonal traits with trait composition instead of naming a single monolithic tensor type.

The traits fall into three groups:

  • Role traits (Input, Output, MutableInput) declare how the kernel uses the argument: read-only, write-only destination, or read-write in place. Exactly one role applies to each argument.
  • The Fused marker declares that the operand participates in prologue or epilogue fusion.
  • The Stable marker declares that the argument's storage is a stable address slot, read through StableAddrEngine (device only).
  • Metadata and access traits describe what the kernel can read off the argument (Tensor) and how it touches individual elements. The access markers carry no metadata; bind Tensor alongside them to read the dtype, rank, or shape.

Element access is split into marker / capability pairs. A graph-visible marker (LoadAccess, StoreAccess) records the access form in the distilled contract but adds no method; the matching capability (Loadable, Storable) additionally supplies the method the kernel body calls. A kernel typically binds the marker in its signature and refines to the capability inside its body, so the same argument type works whether it stays on the host or is projected to a device.

_LegacyComputeOutput is the exception: it doesn't guarantee its capability _LegacyComputable, and the graph compiler may deliver Storable instead. It is legacy machinery; read its docstring before using it.

The interim tile epilogue traits live in legacy_tile_traits.

Traits​

  • ​Fused: Marker trait: the operand participates in fusion.
  • ​Input: Tells the graph compiler this argument is a read-only input.
  • ​Loadable: LoadAccess refined with the callable load method.
  • ​LoadAccess: Marker trait: this tensor supports SIMD loads.
  • ​MutableInput: Tells the graph compiler this argument is a mutable input.
  • ​Output: Tells the graph compiler this argument is an output.
  • ​Stable: Marker trait: the argument's data pointer lives in a stable address slot.
  • ​Storable: StoreAccess refined with the callable store method.
  • ​StoreAccess: Marker trait: this tensor supports SIMD stores.
  • ​Tensor: Metadata trait exposing a tensor's element type, known rank, and shape.
  • ​TileTensorable: A Tensor backed by a dense layout that can project to a TileTensor view over its storage.
  • ​UnsafeFusedView: Flags a fused trait argument whose host and device views share a byte-identical layout.

Functions​

Was this page helpful?