def result_point

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

import bendtorch-core@0.1.0.0/src/tensor/construction_contract_PROOF.bend as ConstructionContractPROOF
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/LAWS.bend as StorageLaws
import bendtorch-core@0.1.0.0/src/storage/arith.bend as Arith
import bendtorch-core@0.1.0.0/src/tensor/core.bend as Core
import bendtorch-core@0.1.0.0/src/tensor/lifecycle.bend as Lifecycle
import bendtorch-core@0.1.0.0/src/tensor/allocation_spec.bend as Allocation
import bendtorch-core@0.1.0.0/src/tensor/observation.bend as Observation

91def result_point(+shape: Shape.Shape, +fill: F32, +index: U32,
92  result: Result<&2, &1, Storage.Error, Storage.Storage>,
93  counted: {Allocation.storage_length(result) == Some{Shape.elements(shape)} : Maybe<&2, Nat>},
94  value: {Lifecycle.read_value(Storage.get(StorageLaws.created.of(result), index)) == Some{fill} : Maybe<&2, F32>}) ->
95  {Observation.point(shape, index, Core.new_result(shape, result)) == Some{fill} : Maybe<&2, F32>}:
96  match result:
97    case Fail{error}:
98      Empty.absurd({None{} == Some{fill} : Maybe<&2, F32>},
99        Arith.clash(Equal.cong(Maybe<&2, Nat>, Bool, value => Maybe.is_some(&2, Nat, value),
100          None{}, Some{Shape.elements(shape)}, counted)))
101    case Done{storage}:
102      attach_point(shape, fill, index, storage,
103        Equal.cong(Maybe<&2, Nat>, Nat, value => Maybe.default(&2, Nat, value, 0n),
104          Some{Lifecycle.logical_length(storage)}, Some{Shape.elements(shape)}, counted), value)

Uses (23)

Used by (1)