def MappingWith

bendtorch-core@0.1.0.0 · src/autograd/broadcast_LAWS.bend:34

import bendtorch-core@0.1.0.0/src/autograd/broadcast_LAWS.bend as BroadcastLAWS
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/elementwise_totality.bend as Totality
import bendtorch-core@0.1.0.0/src/autograd/broadcast.bend as Broadcast

34def MappingWith(-input: Core.Dynamic, +target: Shape.Shape, plan: Result<&2, &2, Shape.Error, Shape.BroadcastPlan>,
35  pair: Core.Dynamic & Result<&2, &1, Broadcast.Error, Core.Dynamic>) -> Type:
36  (retained, result) = pair
37  match result:
38    case Fail{error}:
39      Unit
40    case Done{output}:
41      {Totality.dimensions(output) == Shape.dimensions(target) : List<&2, U32>} &
42        (@+index: U32 -> @inside: Shape.LT(U32.to_nat(index), Shape.logical_numel(Shape.dimensions(target))) ->
43          {Core.observe_dynamic(output, index) == planned_source(input, index, plan) : Maybe<&2, F32>})

Uses (20)

Used by (2)