pub enum StepInfo<T: Clone> {
EnterDimension(usize),
ExitDimension(usize),
Value(T),
End,
}Expand description
A single event in a structural walk of a tensor, produced by
Tensor::informed_iter.
A walk is the nested loop it would take to visit every element - one loop per
dimension, the innermost yielding values. Each variant marks a point in that
loop: EnterDimension when a loop opens, Value for an element the
innermost loop reads, ExitDimension when a loop closes, and End once
every loop has finished.
The walk follows the tensor’s logical layout, so a sliced or transposed tensor is visited in the order its shape implies.
§Examples
use candela::{StepInfo, Tensor};
let t = Tensor::from_slice(&[1.0, 2.0], &[2]);
let events: Vec<StepInfo<f64>> = t.informed_iter().collect();
assert_eq!(events, vec![
StepInfo::EnterDimension(0),
StepInfo::Value(1.0),
StepInfo::Value(2.0),
StepInfo::ExitDimension(0),
]);Variants§
EnterDimension(usize)
A dimension’s loop has opened; the payload is its index, 0 being the
outermost.
ExitDimension(usize)
A dimension’s loop has closed; the payload is its index.
Value(T)
An element, read by the innermost loop in logical order.
End
Every loop has finished. Iteration terminates by returning None, so the
iterator does not yield this variant.