license import { KernelConfig , Round } from '@tensorflow/tfjs-core' ; import { unaryKernelFunc } from '../utils/unary_utils' ; export const round = unaryKernelFunc ( Round , ( xi ) => { const base = Math . floor ( xi ) ; if ( xi - base < 0.5 ) { return Math . floor ( xi ) ; } else if ( xi - base > 0.5 ) { return Math . ceil ( xi ) ; } else { if ( base % 2.0 === 0.0 ) { return base ; } else { return base + 1.0 ; } } } ) ; export const roundConfig = { kernelName : Round , backendName : 'cpu' , kernelFunc : round , } ;