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

Function computeStrides

tfjs-core/src/util_base.ts:565–579  ·  view source on GitHub ↗
(shape: number[])

Source from the content-addressed store, hash-verified

563}
564
565export function computeStrides(shape: number[]): number[] {
566 const rank = shape.length;
567 if (rank < 2) {
568 return [];
569 }
570
571 // Last dimension has implicit stride of 1, thus having D-1 (instead of D)
572 // strides.
573 const strides = new Array(rank - 1);
574 strides[rank - 2] = shape[rank - 1];
575 for (let i = rank - 3; i >= 0; --i) {
576 strides[i] = strides[i + 1] * shape[i + 1];
577 }
578 return strides;
579}
580
581function createNestedArray(
582 offset: number, shape: number[], a: TypedArray, isComplex = false) {

Callers 5

tensorToStringFunction · 0.90
constructorMethod · 0.90
constructorMethod · 0.90
calculateShapesFunction · 0.90
prepareAndValidateFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…