MCPcopy Index your code
hub / github.com/tensorflow/tfjs / locToIndex

Method locToIndex

tfjs-core/src/tensor.ts:120–131  ·  view source on GitHub ↗
(locs: number[])

Source from the content-addressed store, hash-verified

118 }
119
120 locToIndex(locs: number[]): number {
121 if (this.rank === 0) {
122 return 0;
123 } else if (this.rank === 1) {
124 return locs[0];
125 }
126 let index = locs[locs.length - 1];
127 for (let i = 0; i < locs.length - 1; ++i) {
128 index += this.strides[i] * locs[i];
129 }
130 return index;
131 }
132
133 indexToLoc(index: number): number[] {
134 if (this.rank === 0) {

Callers 10

setMethod · 0.95
mirrorPadFunction · 0.80
Dilation2D.tsFile · 0.80
gatherV2ImplFunction · 0.80
tileImplFunction · 0.80
padV2Function · 0.80
transposeImplFunction · 0.80
tensor_test.tsFile · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected