license import { KernelConfig , ResizeNearestNeighbor , ResizeNearestNeighborAttrs , ResizeNearestNeighborInputs , tensor1d } from '@tensorflow/tfjs' ; import { createTensorsTypeOpAttr , NodeJSKernelBackend } from '../nodejs_kernel_backend' ; export const resizeNearestNeighborConfig = { kernelName : ResizeNearestNeighbor , backendName : 'tensorflow' , kernelFunc : ( args ) => { const { images } = args . inputs as ResizeNearestNeighborInputs ; const backend = args . backend as NodeJSKernelBackend ; const { alignCorners , halfPixelCenters , size } = args . attrs as { } as ResizeNearestNeighborAttrs ; const opAttrs = [ createTensorsTypeOpAttr ( 'T' , images . dtype ) , { name : 'align_corners' , type : backend . binding . TF_ATTR_BOOL , value : alignCorners } , { name : 'half_pixel_centers' , type : backend . binding . TF_ATTR_BOOL , value : halfPixelCenters } , ] ; const [ newHeight , newWidth ] = size ; const sizeTensor = tensor1d ( [ newHeight , newWidth ] , 'int32' ) ; const res = backend . executeSingleOutput ( ResizeNearestNeighbor , opAttrs , [ images , sizeTensor ] ) ; sizeTensor . dispose ( ) ; return res ; } } ;