Skip to main content

rlx_model

Attribute Macro rlx_model 

Source
#[rlx_model]
Expand description

AOT compilation macro for RLX models.

Wraps a tracing function with a static OnceCell cache that:

  1. On first call: traces the function → builds IR graph → fuses → compiles thunks
  2. On subsequent calls: executes pre-compiled thunks (zero overhead)

The original function becomes the “graph builder”. A new _compiled function is generated that manages the cache and execution.

§Opt-in self-check

#[rlx_model(check)] injects a call to [rlx_runtime::check::model_self_check] right after the graph is traced, so building the model surfaces shape/dtype, backend-dispatch, missed-fusion and numeric findings on stderr. It runs on the CPU reference backend by default; tune with RLX_CHECK (off / all / strict). No extra dependency — the generated code already routes through ::rlx_runtime.