def held_checked_mapping

bendtorch-core@0.1.0.0 · src/autograd/gradient_PROOF.bend:539

import bendtorch-core@0.1.0.0/src/autograd/gradient_PROOF.bend as GradientPROOF
import Base
import bendtorch-core@0.1.0.0/src/shape/core.bend as Shape
import bendtorch-core@0.1.0.0/src/tensor/core.bend as Core
import bendtorch-core@0.1.0.0/src/tensor/layout.bend as Layout
import bendtorch-core@0.1.0.0/src/autograd/gradient.bend as Gradient
import bendtorch-core@0.1.0.0/src/autograd/gradient_LAWS.bend as Laws

539def held_checked_mapping(+shape: Shape.Shape, contribution: Core.Dynamic, +total_shape: Shape.Shape, total: Core.Tensor<total_shape>, same: Bool,
540  -decided: {same == Layout.words_same(Shape.dimensions(total_shape), Shape.dimensions(shape)) : Bool}) ->
541  Holds<Laws.Mapping(Gradient.Held{Core.Packed{total_shape, total}}, contribution, shape, Gradient.held_checked(contribution, total_shape, total, same))>:
542  match same:
543    case False{}:
544      Holds{Unit{}}
545    case True{}:
546      finish_mapping(total_shape, shape, total, contribution,
547        Gradient.loop(Shape.elements(total_shape), total_shape, 0n, Gradient.State{contribution, total}),
548        {\{Holds: proof => proof} : Holds<{Shape.dimensions(total_shape) == Shape.dimensions(shape) : List<&2, U32>}> ->
549          {Shape.dimensions(total_shape) == Shape.dimensions(shape) : List<&2, U32>}}(words_dimensions(total_shape, shape, decided)),
550        {\{Holds: proof => proof} :
551          Holds<LoopInv(total_shape, total, contribution, Nat.add(Shape.elements(total_shape), 0n),
552            Gradient.loop(Shape.elements(total_shape), total_shape, 0n, Gradient.State{contribution, total}))> ->
553          LoopInv(total_shape, total, contribution, Nat.add(Shape.elements(total_shape), 0n),
554            Gradient.loop(Shape.elements(total_shape), total_shape, 0n, Gradient.State{contribution, total}))}(
555          loop_inv(Shape.elements(total_shape), total_shape, total, contribution, 0n, Gradient.State{contribution, total},
556            {\{Holds: proof => proof} : Holds<Inv(total_shape, total, contribution, 0n, total)> -> Inv(total_shape, total, contribution, 0n, total)}(
557              initial_inv(total_shape, total, contribution)),
558            property => {==})))

Uses (23)

Used by (1)