Skip to main content

Module types

Module types 

Source
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 TypeNode constants the framework + DSL ship out of the box.
common_relations
Named TypeRelation slice 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 IR TypeNode. Library makers declare where in the polymorphism tree their concrete sits by picking the Storage impl 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 = AnyTensorStorage::TYPE = &TYPE_TENSOR puts the value at a non-leaf position in the tree, so any tensor subtype unifies into it.
CustomRelationCtx
Context passed to a Custom relation’s run function. 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.
TypeNode
Static type-identity carrier. Identity is pointer equality; subtype queries route through Lattice.
TypeNodeReg
Inventory submission carrier for TypeNodes.

Enums§

Dtype
Runtime dtype tag for AnyTensor and 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.
RelationResult
Outcome of running a relation against the solver’s current type nodes. The solver’s worklist treats each variant differently: Refined requeues dependents, Satisfied removes the relation, Defer parks it for later, Failed aborts the solve.
TypeKind
Concrete dispatchable leaf vs. abstract interior bound.
TypeRelation
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 for Neg, 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 a Custom shape 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 by axes / keepdims attributes.
TYPE_ADDRESS_VEC
Concrete Vec<Address> - the ordered local-or-peer address list stamped on every wire.Send envelope, the carrier for the local address bag installed by bb::install, and the payload shape for the multi-address AddressBook syscalls. Distinct wire hash from TYPE_MULTIADDRESS so 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 source type_hash and bincode-encoded bytes. The DSL g.bundle recorder produces this on the output of a Bundle op; the matching Unbundle op decomposes it back into per-child BytesValue outputs whose ValueInfoProto.denotation is stamped from the declared child-type list. Parent is Any because 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 to framework::Address in bb-runtime. Lives directly under Any (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 for g.net_out.
TYPE_SCALAR
Abstract Scalar - matches any Scalar<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 any Tensor<T> concrete leaf.
TYPE_TENSOR_BF16
Concrete Tensor<BF16> - dense bfloat16 tensor. Modern ML mixed-precision standard. Stored as half::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 by g.net_out.
UNARY_SAME_ELEMENT
input[0].ElementType == output[0].ElementType without 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 TypeNode by its id string. None if no submission has registered that id at startup.
lookup_denotation
Map a canonical denotation string to the corresponding TypeNode static. Returns None for denotations the framework doesn’t recognize; the solver leaves those values at TYPE_ANY (custom types can declare their own type_relations to seed concrete types).