IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /max/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. /max/get-started.md).

Mojo struct

OpCost

struct OpCost

Hardware cost annotation for a single operation kind.

Maps an operation tag to the hardware resource it occupies, its latency in cycles, its data-flow role, and (optionally) the VGPR liveness it induces. Provided by a TargetCostModel.

Fields​

  • ​resource (ResourceKind):
  • ​latency (Int):
  • ​role (OpRole):
  • ​vgpr_def (Int): VGPRs this op brings into scope (new live register values).
  • ​vgpr_kill (Int): VGPRs this op releases (last use of some register buffer).

Implemented traits​

AnyType, Copyable, ImplicitlyCopyable, ImplicitlyDestructible, Movable

Methods​

__init__​

__init__(out self, resource: ResourceKind, latency: Int, role: OpRole, *, vgpr_def: Int = 0, vgpr_kill: Int = 0)

Constructs an OpCost.

Args:

  • ​resource (ResourceKind): Hardware execution unit.
  • ​latency (Int): Latency in cycles.
  • ​role (OpRole): Pipeline data-flow role.
  • ​vgpr_def (Int): VGPRs the op brings into scope.
  • ​vgpr_kill (Int): VGPRs the op releases.

none​

static none() -> Self

Sentinel for unregistered op tags.