BatchedNMS#
Functions#
- NVCVStatus pvaBatchedNMSCreate(NVCVOperatorHandle *handle, NVCVTensorRequirements const *inBoxesReqs, NVCVTensorRequirements const *inScoresReqs, NVCVTensorRequirements const *inClassesReqs, NVCVTensorRequirements const *inCountReqs, NVCVTensorRequirements const *outBoxesReqs, NVCVTensorRequirements const *outScoresReqs, NVCVTensorRequirements const *outClassesReqs, NVCVTensorRequirements const *outCountReqs, float iouThreshold)
Constructs an instance of the Batched NMS operator.
- NVCVStatus pvaBatchedNMSSubmit(NVCVOperatorHandle handle, cupvaStream_t stream, NVCVTensorHandle inBoxes, NVCVTensorHandle inScores, NVCVTensorHandle inClasses, NVCVTensorHandle inCount, NVCVTensorHandle outBoxes, NVCVTensorHandle outScores, NVCVTensorHandle outClasses, NVCVTensorHandle outCount)
Submits the Batched NMS operator to a cuPVA stream.
- NVCVStatus pvaBatchedNMSSubmit(NVCVOperatorHandle handle, cudaStream_t stream, NVCVTensorHandle inBoxes, NVCVTensorHandle inScores, NVCVTensorHandle inClasses, NVCVTensorHandle inCount, NVCVTensorHandle outBoxes, NVCVTensorHandle outScores, NVCVTensorHandle outClasses, NVCVTensorHandle outCount)
Submits the Batched NMS operator to a CUDA stream.
Functions#
- NVCVStatus pvaBatchedNMSCreate(
- NVCVOperatorHandle *handle,
- NVCVTensorRequirements const *inBoxesReqs,
- NVCVTensorRequirements const *inScoresReqs,
- NVCVTensorRequirements const *inClassesReqs,
- NVCVTensorRequirements const *inCountReqs,
- NVCVTensorRequirements const *outBoxesReqs,
- NVCVTensorRequirements const *outScoresReqs,
- NVCVTensorRequirements const *outClassesReqs,
- NVCVTensorRequirements const *outCountReqs,
- float iouThreshold,
Constructs an instance of the Batched NMS operator.
This operator performs per-class Non-Maximum Suppression on bounding boxes.
Algorithm:
For each class:
Sort boxes by confidence score (descending)
Keep highest-confidence box
Suppress overlapping boxes (IoU > threshold)
Repeat until no boxes remain
Collect all surviving boxes from all classes
Stop after maxOutputBoxes survivors in class first-appearance order. Survivors are confidence-sorted within each class, not globally across classes.
Limitations:
Max input boxes: 8192
Max output boxes: 1000
Max boxes per class: 4096. Only the first 4096 boxes of a class in input order take part in suppression; later boxes of that class are ignored regardless of their scores.
Runtime input count is clamped to [0, maxInputBoxes].
Input class identifiers must be in [0, 299]. Boxes with other identifiers are ignored.
Input scores must be finite and greater than 0. Boxes are ordered by the FP16 bit pattern of their scores, so zero, negative, infinite or NaN scores give an undefined order. The order of boxes with equal scores is unspecified.
Only the first count entries of the output tensors are written. Entries at and after the output count keep their previous contents.
Box tensors must have contiguous rows (strides[1] equal to the element size); row padding (strides[0] larger than the row size) is supported. One-dimensional tensors must be tightly packed.
Tensor layouts are not checked. The samples use “HW” for the box tensors and “W” for the one-dimensional tensors. The tensors passed at submission must match the requirements passed to pvaBatchedNMSCreate(), including the layout.
Input Tensors (Structure-of-Arrays format):
Tensor Name
dtype
rank
layout
shape
boxes
NVCV_DATA_TYPE_F32
2
HW
[4, maxInputBoxes]
scores
NVCV_DATA_TYPE_F16
1
W
[maxInputBoxes]
classes
NVCV_DATA_TYPE_S16
1
W
[maxInputBoxes]
count
NVCV_DATA_TYPE_S32
1
W
[1]
boxes format: rows [left, top, right, bottom] in pixel coordinates count: actual number of input boxes (can be < maxInputBoxes)
Output Tensors (Structure-of-Arrays format):
Tensor Name
dtype
rank
layout
shape
boxes
NVCV_DATA_TYPE_F32
2
HW
[4, maxOutputBoxes]
scores
NVCV_DATA_TYPE_F32
1
W
[maxOutputBoxes]
classes
NVCV_DATA_TYPE_S32
1
W
[maxOutputBoxes]
count
NVCV_DATA_TYPE_S32
1
W
[1]
count: number of boxes kept, in [0, maxOutputBoxes]
- Parameters:
handle – [out] Where the operator instance handle will be written to.
Must not be NULL.
inBoxesReqs – [in] Pointer to NVCVTensorRequirements for the input boxes tensor.
Must not be NULL.
inScoresReqs – [in] Pointer to NVCVTensorRequirements for the input scores tensor.
Must not be NULL.
inClassesReqs – [in] Pointer to NVCVTensorRequirements for the input classes tensor.
Must not be NULL.
inCountReqs – [in] Pointer to NVCVTensorRequirements for the input count tensor.
Must not be NULL.
outBoxesReqs – [in] Pointer to NVCVTensorRequirements for the output boxes tensor.
Must not be NULL.
outScoresReqs – [in] Pointer to NVCVTensorRequirements for the output scores tensor.
Must not be NULL.
outClassesReqs – [in] Pointer to NVCVTensorRequirements for the output classes tensor.
Must not be NULL.
outCountReqs – [in] Pointer to NVCVTensorRequirements for the output count tensor.
Must not be NULL.
iouThreshold – [in] IoU threshold for suppression (e.g., 0.45). Boxes with IoU > threshold are suppressed.
Must be in the range [0, 1].
- Return values:
NVCV_ERROR_INVALID_ARGUMENT – The possible cases might be the following: 1) handle or any of the tensor requirements is NULL. 2) iouThreshold is outside [0, 1] or is NaN. 3) A box tensor does not have rank 2, data type F32 or shape[0] equal to 4. 4) maxInputBoxes is outside [1, 8192] or maxOutputBoxes is outside [1, 1000]. 5) A box tensor has strides[1] different from 4 or a row stride strides[0] smaller than the row size. 6) A one-dimensional tensor does not have rank 1, has a data type other than the one listed above, or its extent is not maxInputBoxes, maxOutputBoxes or 1 as listed above. 7) A one-dimensional tensor is not tightly packed.
NVCV_ERROR_OUT_OF_MEMORY – Not enough memory to create the operator.
NVCV_ERROR_INTERNAL – Internal error in the operator.
NVCV_SUCCESS – Operator created successfully.
- NVCVStatus pvaBatchedNMSSubmit(
- NVCVOperatorHandle handle,
- cupvaStream_t stream,
- NVCVTensorHandle inBoxes,
- NVCVTensorHandle inScores,
- NVCVTensorHandle inClasses,
- NVCVTensorHandle inCount,
- NVCVTensorHandle outBoxes,
- NVCVTensorHandle outScores,
- NVCVTensorHandle outClasses,
- NVCVTensorHandle outCount,
Submits the Batched NMS operator to a cuPVA stream.
- Parameters:
handle – [in] Handle to the operator.
Must not be NULL.
stream – [in] Handle to a valid cuPVA stream.
inBoxes – [in] Input boxes tensor [4, maxInputBoxes].
Must not be NULL.
inScores – [in] Input scores tensor [maxInputBoxes].
Must not be NULL.
inClasses – [in] Input classes tensor [maxInputBoxes].
Must not be NULL.
inCount – [in] Input count tensor [1] containing the number of valid input boxes.
Must not be NULL.
outBoxes – [out] Output boxes tensor [4, maxOutputBoxes].
Must not be NULL.
outScores – [out] Output scores tensor [maxOutputBoxes].
Must not be NULL.
outClasses – [out] Output classes tensor [maxOutputBoxes].
Must not be NULL.
outCount – [out] Output count tensor [1] containing the number of output boxes.
Must not be NULL.
- Return values:
NVCV_ERROR_INVALID_ARGUMENT – The possible cases might be the following: 1) handle or any tensor is NULL, or points to an invalid address. 2) A tensor does not meet the requirements used to create the operator handle.
NVCV_ERROR_INTERNAL – Internal error in the operator, submission failed.
NVCV_SUCCESS – Operation submitted successfully.
- NVCVStatus pvaBatchedNMSSubmit(
- NVCVOperatorHandle handle,
- cudaStream_t stream,
- NVCVTensorHandle inBoxes,
- NVCVTensorHandle inScores,
- NVCVTensorHandle inClasses,
- NVCVTensorHandle inCount,
- NVCVTensorHandle outBoxes,
- NVCVTensorHandle outScores,
- NVCVTensorHandle outClasses,
- NVCVTensorHandle outCount,
Submits the Batched NMS operator to a CUDA stream.
Note
CUDA stream support requirements:
PVA SDK 2.7.0 or later
Jetpack 7 or later
DriveOS 7 or later
x86 Emulator is not supported
- Parameters:
handle – [in] Handle to the operator.
stream – [in] Handle to a valid CUDA stream.
inBoxes – [in] Input boxes tensor.
inScores – [in] Input scores tensor.
inClasses – [in] Input classes tensor.
inCount – [in] Input count tensor.
outBoxes – [out] Output boxes tensor.
outScores – [out] Output scores tensor.
outClasses – [out] Output classes tensor.
outCount – [out] Output count tensor.
- Return values:
NVCV_ERROR_NOT_IMPLEMENTED – CUDA stream submission is not supported on this platform.
NVCV_ERROR_INVALID_ARGUMENT – Invalid handle or tensor.
NVCV_ERROR_INTERNAL – Internal error in the operator, submission failed.
NVCV_SUCCESS – Operation submitted successfully.