@enigma.kernel
Marks a function as a GPU compute kernel. The body is traced once at compile
time, producing an IR graph that is lowered to Metal Shading Language.
Parameter types
Each parameter must have a type annotation:
Parameters map to MSL
[[buffer(N)]] bindings in declaration order, starting
at index 0.
See Data Types for the full type table.
Returns
AKernelDef object. Do not call directly — pass to enigma.compile().
@enigma.jit
Marks a host-side function that runs at compile time. Use for layout algebra,
tile partitioning, and multi-kernel orchestration.
Tensor arguments to enigma.compile():
Thread & grid queries
These return anIRValue of dtype "uint" representing a thread or group
index. They are valid only inside @enigma.kernel bodies.
Shorthand (x dimension)
Per-dimension queries
Each query takes an optionaldim argument: "x" (default), "y", or "z".
Flat queries (no dim parameter)
Example: 2D grid
Function constants
Metal specialization constants bound at pipeline creation time. Use these for values that should be compile-time-constant in the pipeline but selectable per dispatch (e.g. tile sizes, fusion flags).enigma.function_constant(dtype, index) -> IRValue
arch namespace
Hardware-feature gating helpers. Use these to write kernels that adapt to
the active GPU family.
These are host-side helpers (not callable inside
@enigma.kernel). For the
runtime-side equivalent, see MetalRuntime.device_capabilities() in
Runtime.