license import { KernelConfig , tensor1d , Transpose , TransposeAttrs , TransposeInputs } from '@tensorflow/tfjs' ; import { createTensorsTypeOpAttr , NodeJSKernelBackend } from '../nodejs_kernel_backend' ; export const transposeConfig = { kernelName : Transpose , backendName : 'tensorflow' , kernelFunc : ( args ) => { const { x } = args . inputs as TransposeInputs ; const backend = args . backend as NodeJSKernelBackend ; const { perm } = args . attrs as { } as TransposeAttrs ; const permTensor = tensor1d ( perm , 'int32' ) ; const opAttrs = [ createTensorsTypeOpAttr ( 'T' , x . dtype ) , createTensorsTypeOpAttr ( 'Tperm' , 'int32' ) ] ; const res = backend . executeSingleOutput ( Transpose , opAttrs , [ x , permTensor ] ) ; permTensor . dispose ( ) ; return res ; } } ;