TorchLean API

NN.Verification.Builtin.Proved.Correctness.Eval.ShapeOps

Shape-Changing IR Evaluation #

Local semantics for the shape-oriented IR nodes emitted by PyTorch/ONNX import paths. These facts pin the executable IR evaluator to the corresponding typed tensor operations.

Shape-changing unary operations with statically typed output tensors.

Instances For

    IR opcode represented by a typed shape operation.

    Instances For

      Typed denotation of a shape operation.

      Instances For
        theorem NN.Verification.Builtin.Proved.Correctness.IRStep.evalAt_shapeOperation_eq {α : Type} [TorchLean.Storage α] [Context α] {inShape outShape : Spec.Shape} (op : ShapeOperation inShape outShape) (x : TorchLean.Tensor α inShape) :
        (unaryGraphOut op.toOpKind inShape outShape).evalAt { } { shape := inShape, tensor := x } #[{ shape := inShape, tensor := x }] 1 = Except.ok { shape := outShape, tensor := op.denote x }

        Evaluate any typed shape operation in its canonical two-node graph.

        theorem NN.Verification.Builtin.Proved.Correctness.IRStep.evalAt_reshape_eq {α : Type} [TorchLean.Storage α] [Context α] {inShape outShape : Spec.Shape} (x : TorchLean.Tensor α inShape) (hsize : inShape.size = outShape.size) :
        (unaryGraphOut (IR.OpKind.reshape inShape outShape) inShape outShape).evalAt { } { shape := inShape, tensor := x } #[{ shape := inShape, tensor := x }] 1 = Except.ok { shape := outShape, tensor := x.reshapeSpec hsize }

        Local IR semantics for reshape when the element counts match.

        theorem NN.Verification.Builtin.Proved.Correctness.IRStep.evalAt_broadcastTo_eq {α : Type} [TorchLean.Storage α] [Context α] {s₁ s₂ : Spec.Shape} (x : TorchLean.Tensor α s₁) (cb : s₁.CanBroadcastTo s₂) :
        (unaryGraphOut (IR.OpKind.broadcastTo s₁ s₂) s₁ s₂).evalAt { } { shape := s₁, tensor := x } #[{ shape := s₁, tensor := x }] 1 = Except.ok { shape := s₂, tensor := TorchLean.Tensor.broadcastTo cb x }

        Local IR semantics for broadcastTo when the shapes are broadcast compatible.

        Local IR semantics for reduction to a scalar sum.