Reduce.contiguous: def of bendtorch-core@0.1.0.0 Import: import bendtorch-core@0.1.0.0/src/autograd/reduce.bend as Reduce Lines 229-239 of bendtorch-core@0.1.0.0/src/autograd/reduce.bend: https://jend.leeeet.dev/read.txt?path=bendtorch-core@0.1.0.0/src/autograd/reduce.bend&start_line=229&end_line=239 import Base import bendtorch-core@0.1.0.0/src/shape/core.bend as Shape # Whether every fiber is one contiguous run of the contribution: no axis the # target keeps comes after an axis it reduces, counting only axes of extent # above 1. Row sums such as [n, m] to [n, 1] are contiguous; column and batch # sums such as [n, m] to [1, m] or [b, n, m] to [n, m] are strided. def contiguous(+rows: List<&2, Shape.Row>, +extents: List<&2, Nat>) -> Bool: match rows extents: case Shape.Row{stride, +left, right} <> +rest +extent <> +others: Bool.pick(Bool, Bool.and(Nat.is_lt(1n, extent), Nat.is_eq(left, 0n)), Bool.not(kept_after(rest, others)), contiguous(rest, others)) case _ _: True{} Uses (10): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Bool https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Bool.and https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Bool.not https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Bool.pick https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=List https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat.is_eq https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat.is_lt https://jend.leeeet.dev/definition.txt?path=bendtorch-core@0.1.0.0/src/autograd/reduce.bend&name=kept_after https://jend.leeeet.dev/definition.txt?path=bendtorch-core@0.1.0.0/src/shape/core.bend&name=Row