Custom Nx.Defn.Compiler that compiles defn expressions
to run on the Burn GPU backend via NIF.
This compiler traverses the Nx.Defn.Expr expression tree,
converts it into Burn tensor operations, and executes them
through the Rust NIF layer for GPU acceleration.
Usage
Nx.Defn.global_default_options(compiler: ExBurn.Defn.Compiler)Or per-function:
defn my_fun(x, y, opts \\ []) do
Nx.add(x, y)
end
compiler: ExBurn.Defn.CompilerHow it works
Nx.Defntraces the function body into an expression tree ofNx.Defn.Exprnodes.- The compiler receives the expression tree via
__compile__/4or__jit__/5. - Each expression node is evaluated by converting parameters to Burn tensors, then dispatching the operation to the NIF.
- The result is converted back to
Nx.Tensorfor the caller.
Options
:garbage_collect- whentrue, garbage collects after evaluating each node (default:false)