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

Function getNormalizedAxes

tfjs-core/src/ops/slice_util.ts:169–205  ·  view source on GitHub ↗
(
    inputShape: number[], ellipsisAxes: number[], numInterpolatedAxes: number,
    begin: number[], end: number[], strides: number[], beginMask: number,
    endMask: number,
    ellipsisMask: number)

Source from the content-addressed store, hash-verified

167
168// Normalize the start, end and strides.
169export function getNormalizedAxes(
170 inputShape: number[], ellipsisAxes: number[], numInterpolatedAxes: number,
171 begin: number[], end: number[], strides: number[], beginMask: number,
172 endMask: number,
173 ellipsisMask: number): {begin: number[], end: number[], strides: number[]} {
174 const inputRank = inputShape.length;
175 let normalizedBegin = new Array(inputRank),
176 normalizedEnd = new Array(inputRank),
177 normalizedStrides = new Array(inputRank);
178 if (ellipsisAxes.length && numInterpolatedAxes > 0) {
179 const fullIndex = ellipsisAxes[0];
180
181 // The ellipsis applies to the masked index as well as any dimensions
182 // that are interpolated.
183 const numElidedAxes = numInterpolatedAxes + 1;
184 normalizedBegin = startIndicesWithElidedDims(
185 beginMask, fullIndex, numElidedAxes, begin, inputShape);
186 normalizedEnd = stopIndicesWithElidedDims(
187 endMask, fullIndex, numElidedAxes, end, inputShape);
188 normalizedStrides =
189 stridesWithElidedDims(strides, fullIndex, numElidedAxes, inputShape);
190 } else {
191 for (let axis = 0; axis < inputRank; axis++) {
192 normalizedBegin[axis] = startForAxis(
193 beginMask, begin, strides, inputShape, axis, ellipsisMask);
194 normalizedEnd[axis] =
195 stopForAxis(endMask, end, strides, inputShape, axis, ellipsisMask);
196 normalizedStrides[axis] = stridesForAxis(strides, axis, ellipsisMask);
197 }
198 }
199
200 return {
201 begin: normalizedBegin,
202 end: normalizedEnd,
203 strides: normalizedStrides
204 };
205}
206
207// Creates full selection at the elided dimensions. If the dimension matches
208// the ellipsis mask, override the current start value. Otherwise, insert.

Callers

nothing calls this directly

Calls 6

stridesWithElidedDimsFunction · 0.85
startForAxisFunction · 0.85
stopForAxisFunction · 0.85
stridesForAxisFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…