def CheckedUpdateMeaning

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

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

270def CheckedUpdateMeaning(-shape: Shape.Shape, -original: Tensor<shape>, +index: U32, +value: F32,
271  pair: Tensor<shape> & Result<&2, &2, Error, Unit>) -> Type:
272  (tensor, result) = pair
273  match result:
274    case Fail{error}:
275      Unit
276    case Done{unit}:
277      ObservationChecked(Packed{shape, tensor}, index) &
278        ({checked_observe(shape, tensor, index) == Some{value} : Maybe<&2, F32>} &
279          (@+other: U32 -> @checked: ObservationChecked(Packed{shape, original}, other) ->
280            @different: {Nat.is_eq(U32.to_nat(index), U32.to_nat(other)) == False{} : Bool} ->
281              ObservationChecked(Packed{shape, tensor}, other) &
282                {checked_observe(shape, tensor, other) == checked_observe(shape, original, other) : Maybe<&2, F32>}))

Uses (16)

Used by (18)