Nx.Defn.Evaluator (Nx v1.1.0)

Copy Markdown View Source

The default implementation of a Nx.Defn.Compiler that evaluates the expression tree against the tensor backend.

Buffer donation

The evaluator counts how many times each node is used. When a node is passed to an operation for the last time, the evaluator marks that argument with Nx.donatable/1, so backends that run operations eagerly may reuse its buffer. Similarly, a user argument marked as donatable is only handed over at its last use. Nodes that may still be reachable through another node's result (such as values returned by a cond branch) and results of the function are never marked due to runtime-value constraints.

Options

The following options are specific to this compiler:

  • :hooks - a map of callbacks to override named io_call side effects. This allows overriding named io_calls at JIT time without recompiling the graph.

  • :garbage_collect - when true, garbage collects after evaluating each node

  • :max_concurrency - the number of partitions to start when running a Nx.Serving with this compiler