pub fn eval<T: Leaves + ?Sized>(tree: &T) -> Result<()>Expand description
Evaluates the leaves of tree and everything they depend on, and waits for them. Each
node runs at most once, even across threads.
tree is any Leaves value: a slice or array of arrays (eval(&[a, b])), a Vec, a
model, or a borrowed view such as &(&loss, &grads), which evaluates both without
cloning either.
Nodes on the GPU stream run as Metal kernels where one exists, and on the CPU (over the
same unified memory) otherwise. Returns the first error among arrays. Errors are
sticky: a failed array, and anything computed from it, fails with the same error on
every later evaluation or readback.
A failed GPU command buffer fails the evaluation that encoded it (its outputs and those of its later command buffers) and every evaluation that read its results while they were in flight; independent evaluations, earlier or later, are unaffected.
Several threads may evaluate arrays that share work: each node runs once, and a thread that needs a node another thread is running waits for it (after submitting its own GPU work), receiving its error if it fails.