Skip to main content

Module optimizer

Module optimizer 

Source
Expand description

The optimizer applies metadata-only rewrite rules (reduce and reduce_parent) in a fixpoint loop until no more rules apply.

Optimization runs between execution steps. After a child is decoded, reduce_parent rules that did not match before can match.

Parent-reduce rules come from the session’s kernels::ArrayKernels. To optimize, use ArrayOptimizer::optimize_ctx with the session or with an ExecutionCtx created from it.

Array constructors do not optimize. The optimizer works top down: it tries the rules of a node, then optimizes the children that were never optimized, and tries the rules of the node again if a child changed. Thus a rule for a child encoding sees that encoding, not a lazy wrapper around it. The nodes that a rule builds are optimized before the next pass, so two rules that are inverses of each other cannot rewrite a node back and forth.

The optimizer marks the arrays that it returns. Optimizing a marked array again tries no rule.

Modules§

kernels
Session-scoped registry of parent kernels.
rules
Metadata-only rewrite rules for the optimizer (Layers 1 and 2 of the execution model).

Structs§

OptimizerKernels
The parent-reduce kernels ArrayOptimizer optimizes with, from AsOptimizerKernels.

Traits§

ArrayOptimizer
Extension trait for optimizing array trees using reduce/reduce_parent rules.
AsOptimizerKernels
A source of the parent-reduce kernels ArrayOptimizer optimizes with.