Skip to main content

Module rules

Module rules 

Source
Expand description

Metadata-only rewrite rules for the optimizer (Layers 1 and 2 of the execution model).

Reduce rules are the cheapest transformations in the execution pipeline: they operate purely on array structure and metadata without reading any data buffers.

There are two kinds of reduce rules:

  • ArrayReduceRule (Layer 1) – a self-rewrite where an array simplifies itself. Example: a FilterArray with an all-true mask removes the filter wrapper.

  • ArrayParentReduceRule (Layer 2) – a child-driven rewrite where a child rewrites its parent. Example: a DictArray child of a ScalarFnArray pushes the scalar function into the dictionary values.

Reduce rules are collected into a ReduceRuleSet per encoding. Parent-reduce rules are registered with the session’s ArrayKernels for each (parent, child) pair they apply to. The optimizer evaluates both in a fixpoint loop until no more rules apply.

Structs§

ReduceRuleSet
A collection of ArrayReduceRules registered for a specific encoding.

Traits§

ArrayParentReduceRule
A metadata-only rewrite rule where a child encoding rewrites its parent (Layer 2).
ArrayReduceRule
A metadata-only rewrite rule that transforms an array based on its own structure (Layer 1).