def reshape_length
bendtorch-core@0.1.0.0 · src/tensor/reshape_contract.bend:114
import bendtorch-core@0.1.0.0/src/tensor/reshape_contract.bend as ReshapeContract
import Base
import bendtorch-core@0.1.0.0/src/shape/core.bend as Shape
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/read_contract.bend as Reads
import bendtorch-core@0.1.0.0/src/tensor/transform_observation.bend as Observation
114def reshape_length(+input: Shape.Shape, +fill: F32, +target: Shape.Shape, +same: {Shape.logical_numel(Shape.dimensions(input)) == Shape.logical_numel(Shape.dimensions(target)) : Nat}) ->
115 {Observation.reshape_length(input, Shape.dimensions(target), Core.new(input, fill)) == Some{Shape.logical_numel(Shape.dimensions(target))} : Maybe<&2, Nat>}:
116 Reads.new_lift(input, fill, result => {Observation.reshape_length(input, Shape.dimensions(target), result) == Some{Shape.logical_numel(Shape.dimensions(target))} : Maybe<&2, Nat>},
117 valid => reshape_lift(input, target, StorageLaws.created(Shape.count(input), fill), valid, same,
118 result => {Observation.output_length(result) == Some{Shape.logical_numel(Shape.dimensions(target))} : Maybe<&2, Nat>},
119 output => preserved => fits => Equal.cong(Nat, Maybe<&2, Nat>, number => Some{number}, Lifecycle.logical_length(StorageLaws.created(Shape.count(input), fill)), Shape.logical_numel(Shape.dimensions(target)),
120 Equal.trans(Nat, Lifecycle.logical_length(StorageLaws.created(Shape.count(input), fill)), Shape.logical_numel(Shape.dimensions(input)), Shape.logical_numel(Shape.dimensions(target)), Reads.created_exact(input, fill), same))))