Skip to main content

TypeRelation

Enum TypeRelation 

Source
pub enum TypeRelation {
    SameType(&'static [PortRef]),
    SameElementType(&'static [PortRef]),
    BroadcastShape {
        in0: PortRef,
        in1: PortRef,
        out: PortRef,
    },
    Elementwise {
        input: PortRef,
        output: PortRef,
    },
    ReduceOver {
        input: PortRef,
        output: PortRef,
    },
    Custom {
        name: &'static str,
        run: fn(&CustomRelationCtx<'_>) -> RelationResult,
    },
}
Expand description

One type relation declared on an op. The TypeSolver instantiates each as a constraint node linked to its participating type variables via back-edges.

Variants§

§

SameType(&'static [PortRef])

All listed ports share the SAME concrete TypeNode. Implements Julia’s “diagonal variable” rule - a port declared Tensor that participates in SameType([in0, in1, out0]) collapses to ONE element type across all three positions, regardless of the bound’s permissiveness.

§

SameElementType(&'static [PortRef])

All listed Tensor-typed ports share the same ELEMENT type. Shapes may differ (broadcasting is a separate concern). Add(x: Tensor, y: Tensor) -> Tensor uses this.

§

BroadcastShape

The output is the broadcast of two tensor inputs. Composes with SameElementType to express Add / Mul / Sub / Div fully.

Fields

§in0: PortRef

First broadcast operand.

§in1: PortRef

Second broadcast operand.

§out: PortRef

Output (shape = broadcast(in0.shape, in1.shape)).

§

Elementwise

Output preserves the input’s TypeNode entirely. Used by element-wise unary ops (Sqrt, Neg, Abs, Relu, etc.): shape preserved, element type preserved.

Fields

§input: PortRef

Input.

§output: PortRef

Output.

§

ReduceOver

Output is a reduction over the input: same element type, reduced shape (driven by op attributes like axes). ReduceSum / ReduceMean / ReduceMax use this.

Fields

§input: PortRef

Input tensor being reduced.

§output: PortRef

Output tensor (lower rank or same rank with size-1 axes).

§

Custom

Escape hatch for ops that don’t fit a predicate. The custom function receives the current TypeNodes for participating ports and returns a RelationResult.

Use sparingly - Reshape, Gather, Concat, Cast, and any op with attribute-driven type changes need this.

Fields

§name: &'static str

Stable identifier for diagnostics.

§run: fn(&CustomRelationCtx<'_>) -> RelationResult

Solver entry point. Receives the participating ports’ current resolutions (Option<&TypeNode>); narrows them or returns Failed.

Trait Implementations§

Source§

impl Debug for TypeRelation

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> ErasedComponent for T
where T: Any + Send + Sync,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more