(
reshapedRank: number, blockShapeRank: number,
batchToSpace = true)
| 53 | * see step 2: https://www.tensorflow.org/api_docs/python/tf/batch_to_space_nd |
| 54 | */ |
| 55 | export 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 |
nothing calls this directly
no test coverage detected
searching dependent graphs…