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

Function getPermuted

tfjs-core/src/ops/array_ops_util.ts:55–84  ·  view source on GitHub ↗
(
    reshapedRank: number, blockShapeRank: number,
    batchToSpace = true)

Source from the content-addressed store, hash-verified

53 * see step 2: https://www.tensorflow.org/api_docs/python/tf/batch_to_space_nd
54 */
55export function getPermuted(
56 reshapedRank: number, blockShapeRank: number,
57 batchToSpace = true): number[] {
58 const permuted = [];
59 if (batchToSpace) {
60 permuted.push(blockShapeRank);
61 for (let i = blockShapeRank + 1; i < reshapedRank; ++i) {
62 if (i <= 2 * blockShapeRank) {
63 permuted.push(i);
64 permuted.push(i - (blockShapeRank + 1));
65 } else {
66 permuted.push(i);
67 }
68 }
69 } else {
70 const permutedBeforeBatch = [];
71 const permutedAfterBatch = [];
72 for (let i = 1; i < reshapedRank; ++i) {
73 if (i >= blockShapeRank * 2 + 1 || i % 2 === 1) {
74 permutedAfterBatch.push(i);
75 } else {
76 permutedBeforeBatch.push(i);
77 }
78 }
79 permuted.push(...permutedBeforeBatch);
80 permuted.push(0);
81 permuted.push(...permutedAfterBatch);
82 }
83 return permuted;
84}
85
86/**
87 * Gets the shape of the reshaped and permuted input Tensor before any cropping

Callers

nothing calls this directly

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…