def read_value_projection

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

import bendtorch-core@0.1.0.0/src/tensor/read_contract.bend as ReadContract
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/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/observation.bend as Observation

165def read_value_projection(-shape: Shape.Shape, -original: Storage.Storage,
166  -valid: {Lifecycle.logical_length(original) == Shape.logical_numel(Shape.dimensions(shape)) : Nat}, +index: U32, +other: U32,
167  pair: Storage.Storage & Result<&2, &2, Storage.Error, F32>, -same: {pair == Storage.get(original, index) : Storage.Storage & Result<&2, &2, Storage.Error, F32>}) ->
168  {Observation.after_value_pair(shape, other, Core.read_result(shape, original, valid, index, pair, same)) ==
169    Lifecycle.read_value(Storage.get(StorageLaws.owner(Result<&2, &2, Storage.Error, F32>, pair), other)) : Maybe<&2, F32>}:
170  (storage, result) = pair
171  Core.read_result_value(shape, storage,
172    Equal.trans(Nat, Lifecycle.logical_length(storage), Lifecycle.logical_length(original), Shape.logical_numel(Shape.dimensions(shape)),
173      %Equal.sym(Storage.Storage & Result<&2, &2, Storage.Error, F32>, (storage, result), Storage.get(original, index), same) :
174        {Lifecycle.retained_read(_) == Lifecycle.logical_length(original) : Nat}
175      Lifecycle.get_length(original, index), valid),
176    other, Storage.get(storage, other), {==})

Uses (23)

Used by (1)