Skip to main content

Module common_relations

Module common_relations 

Source
Expand description

Named TypeRelation slice constants for the common op shapes.

Sharing one set of canonical slices across bb-ops::backends, bb-derive, and any third-party crate keeps op declarations one-liners and lets the TypeSolver work with stable pointer-equal constraint pools (the solver indexes relations by their &'static address). New shapes graft in alongside these without breaking the convention.

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.
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).