license import { KernelConfig , SpaceToBatchND , SpaceToBatchNDAttrs , SpaceToBatchNDInputs , tensor1d , tensor2d } from '@tensorflow/tfjs' ; import { createTensorsTypeOpAttr , NodeJSKernelBackend } from '../nodejs_kernel_backend' ; export const spaceToBatchNDConfig = { kernelName : SpaceToBatchND , backendName : 'tensorflow' , kernelFunc : ( args ) => { const { x } = args . inputs as SpaceToBatchNDInputs ; const backend = args . backend as NodeJSKernelBackend ; const { blockShape , paddings } = args . attrs as { } as SpaceToBatchNDAttrs ; const blockShapeTensor = tensor1d ( blockShape , 'int32' ) ; const paddingsTensor = tensor2d ( paddings , [ paddings . length , paddings [ 0 ] . length ] , 'int32' ) ; const opAttrs = [ createTensorsTypeOpAttr ( 'T' , x . dtype ) , createTensorsTypeOpAttr ( 'Tblock_shape' , 'int32' ) , createTensorsTypeOpAttr ( 'Tpaddings' , paddingsTensor . dtype ) ] ; const res = backend . executeSingleOutput ( SpaceToBatchND , opAttrs , [ x , blockShapeTensor , paddingsTensor ] ) ; blockShapeTensor . dispose ( ) ; paddingsTensor . dispose ( ) ; return res ; } } ;