def digits_words

bendtorch-core@0.1.0.0 · src/shape/core.bend:409

import bendtorch-core@0.1.0.0/src/shape/core.bend as Core
import Base

409def digits_words(dims: List<&2, U32>, +index: Nat) -> List<&2, Nat>:
410  match dims:
411    case Nil{}:
412      Nil{}
413    case head <> +tail:
414      +stride = numel_words(tail)
415      Nat.div(index, stride) <> digits_words(tail, Nat.mod(index, stride))

Uses (6)

Used by (5)