def same_left

bendtorch-core@0.1.0.0 · src/tensor/elementwise.bend:266

import bendtorch-core@0.1.0.0/src/tensor/elementwise.bend as Elementwise
import Base
import bendtorch-core@0.1.0.0/src/shape/core.bend as Shape

266# Whether the left input's stride is the output's on every axis and the last
267# one is 1, so that the walk of every position is the position itself. Equal
268# left and output shapes with no axis of extent 1 have such rows.
269def same_left(rows: List<&2, Shape.Row>) -> Bool:
270  match rows:
271    case Shape.Row{+stride, +left, right} <> Nil{}:
272      Bool.and(Nat.is_eq(stride, 1n), Nat.is_eq(left, 1n))
273    case Shape.Row{+stride, +left, right} <> rest:
274      Bool.and(Nat.is_eq(left, stride), same_left(rest))
275    case Nil{}:
276      False{}

Uses (5)

Used by (4)