license import { backend_util , kernel_impls , KernelConfig , KernelFunc , NonMaxSuppressionV4 , NonMaxSuppressionV4Attrs , NonMaxSuppressionV4Inputs , TensorInfo , TypedArray } from '@tensorflow/tfjs-core' ; const nonMaxSuppressionV4Impl = kernel_impls . nonMaxSuppressionV4Impl ; import { MathBackendWebGL } from '../backend_webgl' ; export function nonMaxSuppressionV4 ( args ) { backend_util . warn ( 'tf.nonMaxSuppression() in webgl locks the UI thread. ' + 'Call tf.nonMaxSuppressionAsync() instead' ) ; const { inputs , backend , attrs } = args ; const { boxes , scores } = inputs ; const { maxOutputSize , iouThreshold , scoreThreshold , padToMaxOutputSize } = attrs ; const boxesVals = backend . readSync ( boxes . dataId ) as TypedArray ; const scoresVals = backend . readSync ( scores . dataId ) 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 : 'webgl' , kernelFunc : nonMaxSuppressionV4 as { } as KernelFunc } ;