PermuteBuild.offset: def of bendtorch-core@0.1.0.0 Import: import bendtorch-core@0.1.0.0/src/tensor/permute_build.bend as PermuteBuild Lines 94-101 of bendtorch-core@0.1.0.0/src/tensor/permute_build.bend: https://jend.leeeet.dev/read.txt?path=bendtorch-core@0.1.0.0/src/tensor/permute_build.bend&start_line=94&end_line=101 import Base import bendtorch-core@0.1.0.0/src/shape/core.bend as Shape # `Shape.offset` of the scattered coordinates, each through U32 and back as # `Shape.words` and `Shape.naturals` take it. def offset(+strides: List<&2, Nat>, +picks: List<&2, Pick>, +x: Nat) -> Nat: match strides picks: case +stride <> rest +pick <> others: Nat.add(Nat.mul(U32.to_nat(U32.from_nat(coordinate(pick, x))), stride), offset(rest, others, x)) case strides picks: 0n Uses (8): 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.add https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat.mul https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.from_nat https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.to_nat https://jend.leeeet.dev/definition.txt?path=bendtorch-core@0.1.0.0/src/tensor/permute_build.bend&name=Pick https://jend.leeeet.dev/definition.txt?path=bendtorch-core@0.1.0.0/src/tensor/permute_build.bend&name=coordinate