def view_at

bendtorch-core@0.1.0.0 · src/tensor/slice.bend:77

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

77def view_at(dimensions: List<&2, U32>, +dim: Nat, +outer: Nat) -> View:
78  match dimensions dim:
79    case extent <> rest 0n:
80      View{outer, U32.to_nat(extent), Shape.logical_numel(rest)}
81    case extent <> rest 1n+next:
82      view_at(rest, next, Nat.mul(outer, U32.to_nat(extent)))
83    case Nil{} _:
84      View{outer, 0n, 1n}

Uses (7)

Used by (2)