def owned_sum

bendtorch-core@0.1.0.0 · src/tensor/reduction.bend:139

import bendtorch-core@0.1.0.0/src/tensor/reduction.bend as Reduction
import Base
import bendtorch-core@0.1.0.0/src/shape/core.bend as Shape
import bendtorch-core@0.1.0.0/src/storage/main.bend as Storage
import bendtorch-core@0.1.0.0/src/storage/model.bend as Model
import bendtorch-core@0.1.0.0/src/tensor/core.bend as Core

139def owned_sum(-shape: Shape.Shape, +depth: Nat, +length: Nat, -array: Array<F32>,
140  -balanced: Model.Balanced(F32, depth, array), -valid: {Storage.bounds(depth, length) == True{} : Bool},
141  -exact: {length == Shape.logical_numel(Shape.dimensions(shape)) : Nat},
142  pair: F32 & Array<F32>, -kept: Fact<{Pair.snd(F32, Array<F32>, pair) == array : Array<F32>}>) ->
143  Result<&2, &1, Core.Error, Core.Tensor<shape> & F32>:
144  (value, retained) = pair
145  Done{(Core.TTensor{Storage.Owned{depth, length, retained,
146    {\{Fact: p => p} : Fact<(Model.Balanced(F32, depth, retained))> -> Model.Balanced(F32, depth, retained)}(
147      kept_balanced(depth, array, balanced, retained,
148        {\{Fact: p => p} : Fact<({Pair.snd(F32, Array<F32>, (value, retained)) == array : Array<F32>})> -> {retained == array : Array<F32>}}(kept))),
149    valid}, exact}, value)}

Uses (18)

Used by (4)