Expand description
Hierarchical type system resolved at compile time by the
compiler’s TypeSolver. The tree is open via inventory: backends
and DSL authors register new leaves via inventory::submit!. The
Lattice is built once at startup; is_subtype_of walks the
parent chain with caching. The runtime never sees abstract types.
Modules§
- builtins
- Built-in
TypeNodeconstants the framework + DSL ship out of the box. - common_
relations - Named
TypeRelationslice constants for the common op shapes. - lattice
- Global lattice of registered
TypeNodes. - relations
- Type relations on ops.
- storage
Storage— static link between a Rust storage type and its IRTypeNode. Library makers declare where in the polymorphism tree their concrete sits by picking theStorageimpl for their associated type.
Structs§
- AnyTensor
- Concrete-erased tensor. Stores raw bytes plus a runtime-known
dtype + shape. Compute-outsourcing concretes (an index that
delegates distance math to a bound Backend) declare
type Vector = AnyTensor—Storage::TYPE = &TYPE_TENSORputs the value at a non-leaf position in the tree, so any tensor subtype unifies into it. - Custom
Relation Ctx - Context passed to a
Customrelation’srunfunction. Borrows from the solver; exposes a read-only view of each participating port’s current type resolution. Concrete shape lands when the TypeSolver (T4) materializes. - Lattice
- Process-wide lattice. Single instance via
Lattice::get. - Type
Node - Static type-identity carrier. Identity is pointer equality;
subtype queries route through
Lattice. - Type
Node Reg - Inventory submission carrier for
TypeNodes.
Enums§
- Dtype
- Runtime dtype tag for
AnyTensorand any caller that needs to dispatch over the framework’s known tensor dtypes. - PortRef
- Reference to a port position on an op’s input/output list.
Indices into
AtomicOpDecl.inputs/outputs. - Relation
Result - Outcome of running a relation against the solver’s current type
nodes. The solver’s worklist treats each variant differently:
Refinedrequeues dependents,Satisfiedremoves the relation,Deferparks it for later,Failedaborts the solve. - Type
Kind - Concrete dispatchable leaf vs. abstract interior bound.
- Type
Relation - One type relation declared on an op. The TypeSolver instantiates each as a constraint node linked to its participating type variables via back-edges.
Statics§
- BROADCAST_
BINARY - Binary broadcast arithmetic:
Add,Sub,Mul,Div,Pow. Inputs + output share element type AND the output’s shape is the broadcast of the two inputs. - ELEMENTWISE
- Unary element-wise:
output.TypeNode == input.TypeNode. Shape preserved, element type preserved. Use forNeg,Abs,Sqrt,Exp,Log,Identity,Relu,Sigmoid,Tanh,Softmax,LeakyRelu,Gelu,GlobalAveragePool. - MATMUL_
BINARY MatMul/Dot— both inputs and the output share an element type; shape is matmul-specific and stays unconstrained until aCustomshape relation lands.- NO_
RELATIONS []— explicit “no constraint” slot. Use this on ops whose type is attribute-driven (Cast), variadic (Concat,Split,Gemm), structural (Reshape’s output shape comes from an attribute), or whose I/O types are heterogeneous and lack a shared element-type bound (most role placeholders).- REDUCE_
AXIS ReduceSum/ReduceMean/ReduceMax/ReduceMin— same element type, reduced shape driven byaxes/keepdimsattributes.- TYPE_
ADDRESS_ VEC - Concrete
Vec<Address>- the ordered local-or-peer address list stamped on everywire.Sendenvelope, the carrier for the local address bag installed bybb::install, and the payload shape for the multi-addressAddressBooksyscalls. Distinct wire hash fromTYPE_MULTIADDRESSso receivers can disambiguate single vs many. - TYPE_
ANY - The universal supertype. Every other type is a (transitive)
subtype of
Any. Used as a port bound when no narrower constraint applies. - TYPE_
BYTES - Concrete
Bytes- opaque byte buffer. - TYPE_
COMPOSITE - Concrete
Composite- envelope holding N typed child payloads, each tagged with its sourcetype_hashand bincode-encoded bytes. The DSLg.bundlerecorder produces this on the output of aBundleop; the matchingUnbundleop decomposes it back into per-childBytesValueoutputs whoseValueInfoProto.denotationis stamped from the declared child-type list. Parent isAnybecause a composite can wrap any wire-eligible child types. - TYPE_
MULTIADDRESS - Concrete
Multiaddress- sequence of typed protocol segments describing a delivery path. The framework’s canonical address type; binds toframework::Addressinbb-runtime. Lives directly underAny(no abstract address parent — there is no second address-shaped concrete). The 0x03xx wire-hash range is reserved for address-related leaves. - TYPE_
PEER_ ID - Concrete
PeerId- canonical peer identifier (multihash). - TYPE_
PEER_ ID_ VEC - Concrete
Vec<PeerId>- fan-out destination list forg.net_out. - TYPE_
SCALAR - Abstract
Scalar- matches anyScalar<T>concrete leaf. - TYPE_
SCALAR_ F16 - Concrete
Scalar<F16>- single f16 value. - TYPE_
SCALAR_ F32 - Concrete
Scalar<F32>- single f32 value. - TYPE_
SCALAR_ F64 - Concrete
Scalar<F64>- single f64 value. - TYPE_
SCALAR_ I32 - Concrete
Scalar<I32>- single i32 value. - TYPE_
SCALAR_ U8 - Concrete
Scalar<U8>- single u8 value. - TYPE_
TENSOR - Abstract
Tensor- matches anyTensor<T>concrete leaf. - TYPE_
TENSOR_ BF16 - Concrete
Tensor<BF16>- dense bfloat16 tensor. Modern ML mixed-precision standard. Stored ashalf::bf16(binary newtype around the 16-bit bfloat bit pattern). - TYPE_
TENSOR_ BOOL - Concrete
Tensor<Bool>- dense bool tensor. Masks, predicates, comparison-op results. - TYPE_
TENSOR_ F16 - Concrete
Tensor<F16>- dense f16 tensor. - TYPE_
TENSOR_ F32 - Concrete
Tensor<F32>- dense f32 tensor. - TYPE_
TENSOR_ F64 - Concrete
Tensor<F64>- dense f64 tensor. - TYPE_
TENSOR_ I8 - Concrete
Tensor<I8>- dense i8 tensor. Edge quantization (the positional reason this is shipping as a v1 type, not a future feature: edge ML without int8 isn’t really edge ML). - TYPE_
TENSOR_ I16 - Concrete
Tensor<I16>- dense i16 tensor. Wider-than-byte quantization slots, audio samples. - TYPE_
TENSOR_ I32 - Concrete
Tensor<I32>- dense i32 tensor. - TYPE_
TENSOR_ I64 - Concrete
Tensor<I64>- dense i64 tensor. Index / embedding lookups (the canonical ‘Int’ kind default for most Burn underlying backends). - TYPE_
TENSOR_ U8 - Concrete
Tensor<U8>- dense u8 tensor. - TYPE_
TENSOR_ U16 - Concrete
Tensor<U16>- dense u16 tensor. Image bit-depth, count types. - TYPE_
TENSOR_ U32 - Concrete
Tensor<U32>- dense u32 tensor. Hash buckets, large counts. - TYPE_
TENSOR_ U64 - Concrete
Tensor<U64>- dense u64 tensor. Wide indices, IDs. - TYPE_
TRIGGER - Concrete
Trigger- zero-payload signal value. - TYPE_
WIRE_ REQ_ ID - Concrete
WireReqId- correlation token returned byg.net_out. - UNARY_
SAME_ ELEMENT input[0].ElementType == output[0].ElementTypewithout constraining shape. Use for ops that preserve element type but reshape (Reshape,Transpose,Slice,Squeeze,Unsqueeze).
Traits§
- Storage
- Static link between a Rust storage type and its IR
TypeNode.
Functions§
- lookup_
by_ id - Resolve a
TypeNodeby itsidstring.Noneif no submission has registered that id at startup. - lookup_
denotation - Map a canonical denotation string to the corresponding
TypeNodestatic. ReturnsNonefor denotations the framework doesn’t recognize; the solver leaves those values atTYPE_ANY(custom types can declare their owntype_relationsto seed concrete types).