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

TargetCostModel

struct TargetCostModel

Maps op tags to hardware cost annotations.

Separates the algorithm (what ops exist) from the target (how much they cost). The algorithm declares logical ops with buffer metadata (tag, stage, subtile, channel, k_offset). The cost model supplies resource kind, latency, and role β€” the constraints that drive scheduling.

Op tags 0-127 are kernel-specific (registered via set_cost). Op tags 128+ are framework infrastructure ops and are not looked up in the cost model β€” they carry their own annotations.

Usage: var model = TargetCostModel() model.set_cost(0, OpCost(ResourceKind.GLOBAL_MEM, 200, OpRole.GLOBAL_LOAD)) var annotated = annotate_ops(logical_ops, model)

Implemented traits​

AnyType, Copyable, ImplicitlyCopyable, ImplicitlyDestructible, Movable

Methods​

__init__​

__init__(out self)

set_cost​

set_cost(mut self, tag: Int, cost: OpCost)

Register a cost annotation for a kernel op tag (0-127).

get_cost​

get_cost(self, tag: Int) -> OpCost

Look up the cost for a kernel op tag.

Returns:

OpCost