MCPcopy
hub / github.com/tensorflow/tfjs / transpose

Function transpose

tfjs-backend-cpu/src/kernels/Transpose.ts:25–48  ·  view source on GitHub ↗
(args: {
  inputs: TransposeInputs,
  attrs: TransposeAttrs,
  backend: MathBackendCPU
})

Source from the content-addressed store, hash-verified

23import {transposeImpl} from './Transpose_impl';
24
25export function transpose(args: {
26 inputs: TransposeInputs,
27 attrs: TransposeAttrs,
28 backend: MathBackendCPU
29}): TensorInfo {
30 const {inputs, attrs, backend} = args;
31 const {x} = inputs;
32 const {perm} = attrs;
33
34 assertNotComplex(x, 'transpose');
35
36 const xRank = x.shape.length;
37
38 const newShape: number[] = new Array(xRank);
39 for (let i = 0; i < newShape.length; i++) {
40 newShape[i] = x.shape[perm[i]];
41 }
42
43 const values = backend.data.get(x.dataId).values as TypedArray;
44 const result = transposeImpl(values, x.shape, x.dtype, perm, newShape);
45
46 const dataId = backend.write(result, newShape, x.dtype);
47 return {dataId, shape: newShape, dtype: x.dtype};
48}
49
50export const transposeConfig: KernelConfig = {
51 kernelName: Transpose,

Callers 15

allFunction · 0.90
anyFunction · 0.90
minFunction · 0.90
cumsumFunction · 0.90
prodFunction · 0.90
argMaxFunction · 0.90
cumprodFunction · 0.90
batchToSpaceNDFunction · 0.90
argMinFunction · 0.90
einsumFunction · 0.90
sumFunction · 0.90
spaceToBatchNDFunction · 0.90

Calls 4

assertNotComplexFunction · 0.90
transposeImplFunction · 0.90
writeMethod · 0.65
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…