license import { backend_util , kernel_impls , KernelConfig , KernelFunc , NonMaxSuppressionV5 , NonMaxSuppressionV5Attrs , NonMaxSuppressionV5Inputs , TensorInfo , TypedArray } from '@tensorflow/tfjs-core' ; const nonMaxSuppressionV5Impl = kernel_impls . nonMaxSuppressionV5Impl ; import { MathBackendWebGL } from '../backend_webgl' ; export function nonMaxSuppressionV5 ( 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 , softNmsSigma } = attrs ; const boxesVals = backend . readSync ( boxes . dataId ) as TypedArray ; const scoresVals = backend . readSync ( scores . dataId ) as TypedArray ; const maxOutputSizeVal = maxOutputSize ; const iouThresholdVal = iouThreshold ; const scoreThresholdVal = scoreThreshold ; const softNmsSigmaVal = softNmsSigma ; const { selectedIndices , selectedScores } = nonMaxSuppressionV5Impl ( boxesVals , scoresVals , maxOutputSizeVal , iouThresholdVal , scoreThresholdVal , softNmsSigmaVal ) ; return [ backend . makeTensorInfo ( [ selectedIndices . length ] , 'int32' , new Int32Array ( selectedIndices ) ) , backend . makeTensorInfo ( [ selectedScores . length ] , 'float32' , new Float32Array ( selectedScores ) ) ] ; } export const nonMaxSuppressionV5Config = { kernelName : NonMaxSuppressionV5 , backendName : 'webgl' , kernelFunc : nonMaxSuppressionV5 as { } as KernelFunc } ;