Engine¶
engine ¶
The engine under zeki's collections, built directly for float arithmetic: a DAG of float operations over arrays of one length, compiled once and evaluated in one parallel pass. The engine computes every kind for the collections; this interface to it takes floats only.
import numpy as np
from zeki import engine
length = 1_000_000
graph = engine.Graph(length)
gross = graph.input(np.random.lognormal(10, 1, length))
inflation = graph.input(np.full(length, 1.05))
trended = (gross * inflation) ** 1.03
# `trended` is one node: reusing it shares its computation.
capped = trended.min(1e5) + trended
losses = graph.compile(capped).eval() # 1-D array
both = graph.compile([trended, capped]).eval() # one row per output
It skips the collections' lineage, dims and kinds, so a large program of plain float arithmetic builds and evaluates with the least overhead. Most models want the collections.