Abstract Helpers¶
- autoform.extend.avalof(x, /)[source]¶
Return the abstract value for a traceable leaf.
avalofapplies the registered aval rule fortype(x). It is the concrete-to-abstract direction used byautoform.trace(), zeros, and extension code that needs to inspect a value domain.
- autoform.extend.zeroof(v, /)[source]¶
Return a symbolic zero with the same aval as
v.If
vis already a symbolic zero, it is returned unchanged.- Parameters:
v – Concrete value, IR value, or symbolic zero.
- Returns:
A
Zerocarryingavalof(v).- Return type:
- autoform.extend.materialize(x, /)[source]¶
Replace each Zero leaf in a pytree with its concrete zero value.
materializeis useful inside transform rules before calling primitives that expect real runtime values instead of symbolic zeros.- Parameters:
x (Tree) – Pytree that may contain
Zeroleaves.- Returns:
A pytree with the same structure as
xwhere each symbolic zero has been replaced by its registered concrete zero value.- Raises:
TypeError – If a
Zerohas a type with no registered concrete zero (e.g.Zero(BoolAVal())). This indicates an invalid gradient path through a non-differentiable type.- Return type:
Tree