license import { BatchToSpaceND , BatchToSpaceNDAttrs , BatchToSpaceNDInputs , KernelConfig , tensor1d , tensor2d } from '@tensorflow/tfjs' ; import { createTensorsTypeOpAttr , NodeJSKernelBackend } from '../nodejs_kernel_backend' ; export const batchToSpaceNDConfig = { kernelName : BatchToSpaceND , backendName : 'tensorflow' , kernelFunc : ( args ) => { const { x } = args . inputs as BatchToSpaceNDInputs ; const backend = args . backend as NodeJSKernelBackend ; const { blockShape , crops } = args . attrs as { } as BatchToSpaceNDAttrs ; const blockShapeTensor = tensor1d ( blockShape , 'int32' ) ; const cropsTensor = tensor2d ( crops , [ crops . length , crops [ 0 ] . length ] , 'int32' ) ; const opAttrs = [ createTensorsTypeOpAttr ( 'T' , x . dtype ) , createTensorsTypeOpAttr ( 'Tblock_shape' , 'int32' ) , createTensorsTypeOpAttr ( 'Tcrops' , cropsTensor . dtype ) ] ; const res = backend . executeSingleOutput ( BatchToSpaceND , opAttrs , [ x , blockShapeTensor , cropsTensor ] ) ; cropsTensor . dispose ( ) ; blockShapeTensor . dispose ( ) ; return res ; } } ;