Unlock this feature

This feature isn’t part of your plan yet

Contact sales to get upgraded to the full DevStudio experience.

Unlock this feature

This feature isn't part of your plan yet.

Non-max Suppression

Objectness

nmsObjectnessfunction
File: /src/nms.hppLines 97–192

This function takes as input a tensor with box coordinates, objectness probability and class scores and returns a tensor of box coordinates and another tensor with class scores.

template <std::int32_t numBoxes,
          std::int32_t numClasses,
          std::int32_t numValidBoxes,
          typename InputShape,
          FracRepType InFracBits,
          typename OutputBoxShape,
          FracRepType BoxFracBits,
          typename OutputScoreShape,
          FracRepType ScoreFracBits>
INLINE nmsObjectness(NmsSpec& nmsObj,
                     InputShape& ocmRawInp,
                     OutputBoxShape& ocmValidBoxes,
                     OutputScoreShape& scores,
                     FixedPoint<std::int32_t, InFracBits>& confidenceThreshFP)
NameTypeDefaultDescription
numBoxesstd::int32_tThe number of boxes in the input tensor.
numClassesstd::int32_tThe number of classes in the input tensor.
numValidBoxesstd::int32_tThe maximum number of boxes selected after objectness filtering.
InputShapetypenamethe shape of the input tensor.
InFracBitsFracRepTypeThe number of fractional bits in the input type of the input tensor.
OutputBoxShapetypenameThe shape of the output box tensor.
BoxFracBitsFracRepTypeThe number of fractional bits in the type of the box tensor.
OutputScoreShapetypenameThe shape of the output score tensor.
ScoreFracBitsFracRepTypeThe number of fractional bits in the type of the output score tensor.
NameTypeDescription
nmsObjNmsSpec&A structure of various constants associated with nms used this function.
ocmRawInpInputShape&Input tensor with box coordinates, objectness probability and class scores.
ocmValidBoxesOutputBoxShape&Tensor containing valid boxes that are not filtered by NMS.
scoresOutputScoreShape&Scores of boxes that are deemed valid and are not filtered by NMS.
confidenceThreshFPFixedPoint<std::int32_t, InFracBits>&Confidence threshold below which bounding boxes will be filtered.

INLINE — nms_results An integer specifying the number of boxes and associated class scores selected from the input tensor. / // clang-format on

Intersection-over-Union (IoU)

nmsIoufunction
File: /src/nms.hppLines 221–282

Computes Non-Max Suppression (NMS) of Intersection-over-Union predictions.

The box tensor has a list of boxes, The arrays qSortedR and qTScores are arrays of indices and scores (sorted by scores). These are qVars where each core has data for one class. The indices specify the box in the boxes tensor. The score is the score for a class for the box. A qvar (qValidBoxCount) specifies the number of boxes for each class with valid scores. overlapthreshFP is used to eleminate boxes with overlap greater than this threshold.

template <typename BoxTensorShape,
          std::int16_t boxCacheSize,
          std::size_t numSortedBoxes,
          std::size_t numScores,
          std::uint8_t numBoxFracBits,
          std::uint8_t numScoreFracBits>
INLINE nmsIou(BoxTensorShape& boxes,
              std::int32_t vmaxcount,
              container::NDArray<qVar_t<FixedPoint<std::int32_t, numBoxFracBits>>, boxCacheSize, 4>& qBoxCache,
              container::NDArray<qVar_t<std::int16_t>, numSortedBoxes>& qSortedR,
              container::NDArray<qVar_t<FixedPoint<std::int16_t, numScoreFracBits>>, numScores>& qTScores,
              qVar_t<std::int16_t> qValidBoxCount,
              FixedPoint<std::int32_t, numBoxFracBits> overlapthreshFP)
NameTypeDefaultDescription
BoxTensorShapetypenameShape of the box tensor. It is a 2-dimensional tensor of 4 rows and validBoxSize columns. It has elements of type `FixedPoint<int32, numBoxFracBits>`.
boxCacheSizestd::int16_tThe size of the box Cache array on the core
numSortedBoxesstd::size_tThe size of the index array qSortedR
numScoresstd::size_tThe size of the score array qTScores
numBoxFracBitsstd::uint8_tThe number of fractional bits for the boxes in the box tensor and core box variables
numScoreFracBitsstd::uint8_tThe number of fractional bits for the scores in the qTScores array.
NameTypeDescription
boxesBoxTensorShape&The input box tensor
vmaxcountstd::int32_tThe count of valid boxes in the box tensor
qBoxCachecontainer::NDArray<qVar_t<FixedPoint<std::int32_t, numBoxFracBits>>, boxCacheSize, 4>&An array on the core that is used to cache boxes loaded into the core from OCM. it has a maximum size of boxCacheSize.
qSortedRcontainer::NDArray<qVar_t<std::int16_t>, numSortedBoxes>&An array of indices. The index (column number in the box tensor) refers to box in the box tensor.
qTScorescontainer::NDArray<qVar_t<FixedPoint<std::int16_t, numScoreFracBits>>, numScores>&An array of scores per class (on each core) of the box referenced by the indices
qValidBoxCountqVar_t<std::int16_t>The initial count of valid boxes (indices/scores) per class. These are usually boxes with scores above a scorethreshold
overlapthreshFPFixedPoint<std::int32_t, numBoxFracBits>The value of overlap threshold

INLINE — qValidBoxCount The number of valid bounding boxes, i.e. boxes not filtered out by NMS algorithm. / // clang-format on

Sign in to your account

Don't have an account? 
By signing in, you are agreeing to our Terms of Use and Privacy Policy.
Quadric // One architecture. Every algorithm.

Develop.

Simulate.

Profile.

Collaborate.