license import { KernelConfig , PadV2 , PadV2Attrs , PadV2Inputs , scalar , tensor2d } from '@tensorflow/tfjs' ; import { createTensorsTypeOpAttr , NodeJSKernelBackend } from '../nodejs_kernel_backend' ; export const padV2Config = { kernelName : PadV2 , backendName : 'tensorflow' , kernelFunc : ( args ) => { const { x } = args . inputs as PadV2Inputs ; const backend = args . backend as NodeJSKernelBackend ; const { paddings , constantValue } = args . attrs as { } as PadV2Attrs ; const paddingsTensor = tensor2d ( paddings , [ paddings . length , 2 ] , 'int32' ) ; const constantTensor = scalar ( constantValue , x . dtype ) ; const opAttrs = [ createTensorsTypeOpAttr ( 'T' , x . dtype ) , createTensorsTypeOpAttr ( 'Tpaddings' , paddingsTensor . dtype ) ] ; const res = backend . executeSingleOutput ( PadV2 , opAttrs , [ x , paddingsTensor , constantTensor ] ) ; paddingsTensor . dispose ( ) ; constantTensor . dispose ( ) ; return res ; } } ;