def UpdateMeaning

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

import bendtorch-core@0.1.0.0/src/tensor/core.bend as Core
import Base
import bendtorch-core@0.1.0.0/src/shape/core.bend as Shape

253def UpdateMeaning(-shape: Shape.Shape, -original: Tensor<shape>, +index: U32, +value: F32,
254  pair: Tensor<shape> & Result<&2, &2, Error, Unit>) -> Type:
255  (tensor, result) = pair
256  match result:
257    case Fail{error}:
258      Unit
259    case Done{unit}:
260      ObservationChecked(Packed{shape, tensor}, index) &
261        ({observe(shape, tensor, index) == Some{value} : Maybe<&2, F32>} &
262          (@+other: U32 -> @checked: ObservationChecked(Packed{shape, original}, other) ->
263            @different: {Nat.is_eq(U32.to_nat(index), U32.to_nat(other)) == False{} : Bool} ->
264              ObservationChecked(Packed{shape, tensor}, other) &
265                {observe(shape, tensor, other) == observe(shape, original, other) : Maybe<&2, F32>}))

Uses (16)

Used by (8)