license import { kernel_impls , KernelConfig , KernelFunc , NonMaxSuppressionV4 , NonMaxSuppressionV4Attrs , NonMaxSuppressionV4Inputs , TensorInfo , TypedArray } from '@tensorflow/tfjs-core' ; const nonMaxSuppressionV4Impl = kernel_impls . nonMaxSuppressionV4Impl ; import { MathBackendCPU } from '../backend_cpu' ; import { assertNotComplex } from '../cpu_util' ; export function nonMaxSuppressionV4 ( args ) { const { inputs , backend , attrs } = args ; const { boxes , scores } = inputs ; const { maxOutputSize , iouThreshold , scoreThreshold , padToMaxOutputSize } = attrs ; assertNotComplex ( boxes , 'NonMaxSuppressionPadded' ) ; const boxesVals = backend . data . get ( boxes . dataId ) . values as TypedArray ; const scoresVals = backend . data . get ( scores . dataId ) . values as TypedArray ; const { selectedIndices , validOutputs } = nonMaxSuppressionV4Impl ( boxesVals , scoresVals , maxOutputSize , iouThreshold , scoreThreshold , padToMaxOutputSize ) ; return [ backend . makeTensorInfo ( [ selectedIndices . length ] , 'int32' , new Int32Array ( selectedIndices ) ) , backend . makeTensorInfo ( [ ] , 'int32' , new Int32Array ( [ validOutputs ] ) ) ] ; } export const nonMaxSuppressionV4Config = { kernelName : NonMaxSuppressionV4 , backendName : 'cpu' , kernelFunc : nonMaxSuppressionV4 as { } as KernelFunc } ;