TorchLean API

NN.IR.Check

IR Validation #

Validation helpers for NN.IR.Graph.

There are two validation levels:

Shape logic has one source of truth: Infer.inferNodeOutShape states the per-op shape rules, and Graph.checkShapes validates graph nodes through those rules.

Validate declared IR shapes using the central inference rules.

This wrapper keeps the public checker name aligned with Graph.checkInferredShapes, so callers, widgets, and backends all use the same per-op shape contracts.

Instances For

    Prop-level well-formedness wrappers #

    The IR layer primarily exposes executable checkers (checkWellFormed, checkShapes) because that is what compilers/backends/exporters need: either accept a graph or produce a readable error.

    For proofs it is often nicer to assume a proposition instead of carrying around Except String: WellFormed g means the checker succeeds, and similarly for WellShaped g.

    These wrappers keep the executable checker names and proposition-level assumptions in the same module.

    Core structural well-formedness (ids, arity, topo order), as a proposition.

    Instances For

      Shape-consistency well-formedness (WellFormed + extra shape/axis checks), as a proposition.

      Instances For

        WellFormed g is just the proposition that checkWellFormed returns .ok ().

        WellShaped g is just the proposition that checkShapes returns .ok ().