def loop_allocated

bendtorch-core@0.1.0.0 · src/tensor/transforms.bend:184

import bendtorch-core@0.1.0.0/src/tensor/transforms.bend as Transforms
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

184# The sequential copy: one checked read and one checked write per output
185# cell, in index order. The laws about the copy loop state what it does, and
186# permute_build_proof.bend proves that `copy_allocated` meets the loop's
187# meaning (`LoopMeaning`) on every source. `permute_copy` no longer runs it;
188# the tensor gate's parallel probe runs it as the sequential reference.
189def loop_allocated(+input: Shape.Shape, +axes: List<&2, U32>, +plan: Layout.Plan<input, axes>,
190  source: Core.Tensor<input>, allocated: Result<&2, &1, Core.Error, Core.Tensor<Layout.output(input, axes, plan)>>) ->
191  Core.Tensor<input> & Result<&2, &1, Error, Core.Dynamic>:
192  match allocated:
193    case Fail{error}:
194      (source, Fail{TensorError{error}})
195    case Done{target}:
196      copy_pack(input, axes, plan,
197        copy_loop(Shape.elements(Layout.output(input, axes, plan)), input, axes, plan, source, target, 0n))

Uses (15)

Used by (0)

No other definition uses this definition.