TensorBackwardPROOF.restored_contract: def of bendtorch-core@0.1.0.0
Import: import bendtorch-core@0.1.0.0/src/autograd/tensor_backward_PROOF.bend as TensorBackwardPROOF
Lines 473-488 of bendtorch-core@0.1.0.0/src/autograd/tensor_backward_PROOF.bend: https://jend.leeeet.dev/read.txt?path=bendtorch-core@0.1.0.0/src/autograd/tensor_backward_PROOF.bend&start_line=473&end_line=488
import Base
import bendtorch-core@0.1.0.0/src/shape/core.bend as Shape
import bendtorch-core@0.1.0.0/src/autograd/tensor_backward.bend as Backward
import bendtorch-core@0.1.0.0/src/autograd/tensor_backward_LAWS.bend as Laws
# restored only puts g back in its own shape: the contributions are the pass's.
def restored_contract(-a: Nat, -target: Shape.Shape, -cell: Nat -> F32, +shape: Shape.Shape, pass: Backward.Pass,
contract: Laws.SoleContract) -> Laws.SoleContract:
match pass:
case Backward.Pass{saved, g, Fail{error}}:
Laws.SoleContract{target_id, dimensions, value} = contract
Laws.SoleContract{target_id, dimensions, value}
case Backward.Pass{saved, g, Done{Nil{}}}:
Laws.SoleContract{target_id, dimensions, value} = contract
Laws.SoleContract{target_id, dimensions, value}
case Backward.Pass{saved, g, Done{Con{contribution, Nil{}}}}:
Laws.SoleContract{target_id, dimensions, value} = contract
Laws.SoleContract{target_id, dimensions, value}
case Backward.Pass{saved, g, Done{Con{contribution, Con{other, rest}}}}:
Laws.SoleContract{target_id, dimensions, value} = contract
Laws.SoleContract{target_id, dimensions, value}
Uses (8):
https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=F32
https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=List
https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat
https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Result
https://jend.leeeet.dev/definition.txt?path=bendtorch-core@0.1.0.0/src/autograd/tensor_backward.bend&name=Pass
https://jend.leeeet.dev/definition.txt?path=bendtorch-core@0.1.0.0/src/autograd/tensor_backward.bend&name=restored
https://jend.leeeet.dev/definition.txt?path=bendtorch-core@0.1.0.0/src/autograd/tensor_backward_LAWS.bend&name=SoleContract
https://jend.leeeet.dev/definition.txt?path=bendtorch-core@0.1.0.0/src/shape/core.bend&name=Shape