Tensors & the Computational Graph
teeny-core::graph (API docs) defines the
types every other crate builds on:
Shape—Vec<Option<usize>>;Noneentries are symbolic/dynamic dimensions (e.g. a batch dimension left unbound until trace time).DtypeRepr— the element dtype of a tensor (F32, etc. — see The Dtype System).Op— the set of graph operations (elementwise, reductions, layout, etc.).GraphNode/Graph— the traced computational graph: nodes areOpapplications, edges are data dependencies.SymTensor— a symbolic tensor handle used while tracing a model: calling layers with aSymTensorinput recordsOps into aGraphrather than executing eagerly.
Tracing
Building a Graph from a model is “tracing”: construct a SymTensor::input(dtype, shape), call
your model with it (via the nn::Layer trait), and read back the Graph that was recorded as a
side effect. See teeny-cli’s aot_compile for a
concrete example of this pattern.
What happens to the Graph next is covered in Compilation Flow.