def view_around

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

import bendtorch-core@0.1.0.0/src/tensor/slice_PROOF.bend as SlicePROOF
import Base
import bendtorch-core@0.1.0.0/src/shape/core.bend as Shape
import bendtorch-core@0.1.0.0/src/shape/nat_proofs.bend as Nats
import bendtorch-core@0.1.0.0/src/tensor/slice.bend as Slice

230def view_around(+prefix: List<&2, U32>, +extent: U32, +suffix: List<&2, U32>, +outer: Nat) ->
231  {Slice.view_at(List.append(&2, U32, prefix, extent <> suffix), Shape.rank_dimensions(prefix), outer) ==
232    Slice.View{Nat.mul(outer, Shape.logical_numel(prefix)), U32.to_nat(extent), Shape.logical_numel(suffix)} : Slice.View}:
233  match prefix:
234    case Nil{}:
235      %Equal.sym(Nat, Nat.mul(outer, 1n), outer, Nats.mul_one_right(outer)) :
236        {Slice.View{outer, U32.to_nat(extent), Shape.logical_numel(suffix)} ==
237          Slice.View{_, U32.to_nat(extent), Shape.logical_numel(suffix)} : Slice.View}
238      {==}
239    case +head <> +tail:
240      %Nats.mul_assoc(outer, U32.to_nat(head), Shape.logical_numel(tail)) :
241        {Slice.view_at(List.append(&2, U32, tail, extent <> suffix), Shape.rank_dimensions(tail), Nat.mul(outer, U32.to_nat(head))) ==
242          Slice.View{_, U32.to_nat(extent), Shape.logical_numel(suffix)} : Slice.View}
243      view_around(tail, extent, suffix, Nat.mul(outer, U32.to_nat(head)))

Uses (13)

Used by (1)