def cells_keep

bendtorch-core@0.1.0.0 · src/autograd/broadcast_pointwise_PROOF.bend:23

import bendtorch-core@0.1.0.0/src/autograd/broadcast_pointwise_PROOF.bend as BroadcastPointwisePROOF
import Base
import bendtorch-core@0.1.0.0/src/shape/core.bend as Shape
import bendtorch-core@0.1.0.0/src/storage/LAWS.bend as StorageLaws
import bendtorch-core@0.1.0.0/src/tensor/elementwise.bend as Elementwise
import bendtorch-core@0.1.0.0/src/tensor/contracts/replayed.bend as Replayed
import bendtorch-core@0.1.0.0/src/tensor/contracts/broadcast.bend as PointwiseBroadcast
import bendtorch-core@0.1.0.0/src/tensor/contracts/binary_LAWS.bend as BinaryLaws
import bendtorch-core@0.1.0.0/src/autograd/broadcast_pointwise_LAWS.bend as Laws

23# The pointwise family's KeepLeft words, with the input on the left and the
24# +0.0 tensor of the target on the right, are broadcast_to's `cells`.
25def cells_keep(+plan: Shape.BroadcastPlan, +shape: Shape.Shape, +fill: F32, +ops: List<&2, StorageLaws.Op>, +target: Shape.Shape,
26  +count: Nat) ->
27  {BinaryLaws.cells(Elementwise.KeepLeft{}, plan, shape, fill, ops, target, 0.0, Nil{}, count) ==
28    Laws.cells(plan, shape, fill, ops, count) : List<&2, F32>}:
29  match count:
30    case 0n:
31      {==}
32    case 1n+previous:
33      Equal.cong(List<&2, F32>, List<&2, F32>,
34        before => List.append(&2, F32, before, [Replayed.value(shape, fill, ops, U32.from_nat(PointwiseBroadcast.left_map(plan, previous)))]),
35        BinaryLaws.cells(Elementwise.KeepLeft{}, plan, shape, fill, ops, target, 0.0, Nil{}, previous), Laws.cells(plan, shape, fill, ops, previous),
36        cells_keep(plan, shape, fill, ops, target, previous))

Uses (14)

Used by (1)