type ReduceToContract

bendtorch-core@0.1.0.0 · src/autograd/reduce_fold_LAWS.bend:62

import bendtorch-core@0.1.0.0/src/autograd/reduce_fold_LAWS.bend as ReduceFoldLAWS
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/autograd/reduce.bend as Reduce
import bendtorch-core@0.1.0.0/src/autograd/reduce_LAWS.bend as ReduceLaws

62# What reduce_to promises, stated only through the result: it succeeds with
63# the target's dimensions, every in-bounds target cell holds `expected`, and
64# the returned contribution still holds every word.
65type ReduceToContract<-target: Shape.Shape, -input: Shape.Shape, -expected: U32 -> Maybe<&2, F32>, -word: U32 -> F32,
66  -result: Core.Dynamic & Result<&2, &1, Reduce.Error, Core.Dynamic>> is Type:
67  ReduceToContract{
68    successful: {ReduceLaws.succeeded(result) == True{} : Bool},
69    dimensions: {output_dimensions(result) == Some{Shape.dimensions(target)} : Maybe<&2, List<&2, U32>>},
70    value: @+index: U32 -> @inside: {Nat.is_lt(U32.to_nat(index), Shape.logical_numel(Shape.dimensions(target))) == True{} : Bool} ->
71      {output_point(result, index) == expected(index) : Maybe<&2, F32>},
72    kept: @+other: U32 -> @inside: {Nat.is_lt(U32.to_nat(other), Shape.logical_numel(Shape.dimensions(input))) == True{} : Bool} ->
73      {input_point(result, other) == Some{word(other)} : Maybe<&2, F32>}}

Uses (18)

Used by (6)