MCPcopy Create free account
hub / github.com/tensorflow/tfjs / locToIndex

Function locToIndex

tfjs-core/src/util_base.ts:696–708  ·  view source on GitHub ↗
(
    locs: number[], rank: number, strides: number[])

Source from the content-addressed store, hash-verified

694 * @param strides Tensor strides.
695 */
696export function locToIndex(
697 locs: number[], rank: number, strides: number[]): number {
698 if (rank === 0) {
699 return 0;
700 } else if (rank === 1) {
701 return locs[0];
702 }
703 let index = locs[locs.length - 1];
704 for (let i = 0; i < locs.length - 1; ++i) {
705 index += strides[i] * locs[i];
706 }
707 return index;
708}
709
710/**
711 * Computes the location (multidimensional index) in a

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…