Walk¶
Advanced
Use this when manual equation stepping is needed for debugging, visualization, or a custom runner. For ordinary execution, prefer ir.call(...) or await ir.acall(...).
Manual Execution¶
ir.walk(...) is the manual execution interface on the object returned by trace. It exposes the same equation stream that .call(...) and .acall(...) execute.
Use Cases¶
It is useful for debuggers, visualizers, custom runners, or test harnesses that need to observe or replace individual equation results. For ordinary execution, use ir.call(...) or await ir.acall(...).
Generator Contract¶
ir.walk(*inputs) returns a generator:
Step |
Action |
Result |
|---|---|---|
Start |
|
The first equation and its concrete input values. |
Continue |
|
The next equation and its input values. |
Finish |
send the last equation output |
|
Each yielded equation carries its primitive and parameters. The concrete input values have the same pytree shape as that equation’s inputs.
Minimal Example¶
import autoform as af
def program(text: str) -> str:
text = af.concat(text, "!")
return af.format("[{}]", text)
ir = af.trace(program)("seed")
gen = ir.walk("world")
ir_eqn, in_values = next(gen)
assert ir_eqn.prim.name == "concat"
assert in_values == ("world", "!")
out_values = ir_eqn.bind(in_values, **ir_eqn.params)
ir_eqn, in_values = gen.send(out_values)
assert ir_eqn.prim.name == "format"
out_values = ir_eqn.bind(in_values, **ir_eqn.params)
ir_eqn, output = gen.send(out_values)
assert ir_eqn is None
assert output == "[world!]"
ir_eqn.bind(...) runs the primitive’s synchronous implementation for that one equation. Async runners can use await ir_eqn.abind(...) instead.
Non-Goals¶
walk is not an IR transform. It does not take an IR and return another IR.
walk is not a context manager. It does not wrap trace-time or execution-time behavior around a block.
It is an advanced execution interface for the traced object. The built-in .call(...) and .acall(...) methods use the same stepping model.