def reshape_count
bendtorch-core@0.1.0.0 · src/tensor/reshape_contract.bend:122
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/read_contract.bend as Reads
import bendtorch-core@0.1.0.0/src/tensor/transform_observation.bend as Observation
122def reshape_count(+input: Shape.Shape, +fill: F32, +target: Shape.Shape, +same: {Shape.logical_numel(Shape.dimensions(input)) == Shape.logical_numel(Shape.dimensions(target)) : Nat}) ->
123 {Observation.reshape_count(input, Shape.dimensions(target), Core.new(input, fill)) == Some{Shape.count(target)} : Maybe<&2, U32>}:
124 Reads.new_lift(input, fill, result => {Observation.reshape_count(input, Shape.dimensions(target), result) == Some{Shape.count(target)} : Maybe<&2, U32>},
125 valid => reshape_lift(input, target, StorageLaws.created(Shape.count(input), fill), valid, same,
126 result => {Observation.output_count(result) == Some{Shape.count(target)} : Maybe<&2, U32>},
127 output => preserved => fits => Equal.cong(Nat, Maybe<&2, U32>, number => Some{U32.from_nat(number)}, Shape.elements(output), Shape.elements(target),
128 Equal.trans(Nat, Shape.elements(output), Shape.elements(input), Shape.elements(target),
129 Equal.sym(Nat, Shape.elements(input), Shape.elements(output), elements_output(input, target, output, same, preserved)),
130 Equal.trans(Nat, Shape.elements(input), Shape.logical_numel(Shape.dimensions(input)), Shape.elements(target), Shape.elements_exact(input),
131 Equal.trans(Nat, Shape.logical_numel(Shape.dimensions(input)), Shape.logical_numel(Shape.dimensions(target)), Shape.elements(target), same, Equal.sym(Nat, Shape.elements(target), Shape.logical_numel(Shape.dimensions(target)), Shape.elements_exact(target))))))))