You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I need to write the CPU implementation of NMS, and I'd like to refer to the code for EfficientNMS.
I know what the EfficientNMSFilter in the EfficientNMS plugin does is, get the category with the highest confidence for each anchor and get filtered out by the threshold.
template <typename T>
__global__voidEfficientNMSFilter(EfficientNMSParameters param, const T* __restrict__ scoresInput,
int* __restrict__ topNumData, int* __restrict__ topIndexData, int* __restrict__ topAnchorsData,
T* __restrict__ topScoresData, int* __restrict__ topClassData)
{
int elementIdx = blockDim.x * blockIdx.x + threadIdx.x;
int imageIdx = blockDim.y * blockIdx.y + threadIdx.y;
// Boundary Conditionsif (elementIdx >= param.numScoreElements || imageIdx >= param.batchSize)
{
return;
}
// Shape of scoresInput: [batchSize, numAnchors, numClasses]int scoresInputIdx = imageIdx * param.numScoreElements + elementIdx;
// For each class, check its corresponding score if it crosses the threshold, and if so select this anchor,// and keep track of the maximum score and the corresponding (argmax) class id
T score = scoresInput[scoresInputIdx];
if (gte_mp(score, (T) param.scoreThreshold))
{
// Unpack the class and anchor index from the element indexint classIdx = elementIdx % param.numClasses;
int anchorIdx = elementIdx / param.numClasses;
// If this is a background class, ignore it.if (classIdx == param.backgroundClass)
{
return;
}
// Use an atomic to find an open slot where to write the selected anchor data.if (topNumData[imageIdx] >= param.numScoreElements)
{
return;
}
int selectedIdx = atomicAdd((unsignedint*) &topNumData[imageIdx], 1);
if (selectedIdx >= param.numScoreElements)
{
topNumData[imageIdx] = param.numScoreElements;
return;
}
// Shape of topScoresData / topClassData: [batchSize, numScoreElements]int topIdx = imageIdx * param.numScoreElements + selectedIdx;
if (param.scoreBits > 0)
{
score = add_mp(score, (T) 1);
if (gt_mp(score, (T) (2.f - 1.f / 1024.f)))
{
// Ensure the incremented score fits in the mantissa without changing the exponent
score = (2.f - 1.f / 1024.f);
}
}
topIndexData[topIdx] = selectedIdx;
topAnchorsData[topIdx] = anchorIdx;
topScoresData[topIdx] = score;
topClassData[topIdx] = classIdx;
}
}
Can you explain how EfficientNMSFilter selects the category with the highest confidence for anchar?
The text was updated successfully, but these errors were encountered:
Description
I need to write the CPU implementation of NMS, and I'd like to refer to the code for EfficientNMS.
I know what the EfficientNMSFilter in the EfficientNMS plugin does is, get the category with the highest confidence for each anchor and get filtered out by the threshold.
This is the code of EfficientNMSFilter:
Can you explain how EfficientNMSFilter selects the category with the highest confidence for anchar?
The text was updated successfully, but these errors were encountered: