pub struct INMSLayer { /* private fields */ }Expand description
INMSLayer
A non-maximum suppression layer in a network definition.
The NMS algorithm iterates through a set of bounding boxes and their confidence scores, in decreasing order of score. Boxes are selected if their score is above a given threshold, and their intersection-over-union (IoU) with previously selected boxes is less than or equal to a given threshold. This layer implements NMS per batch item and per class.
Per batch item, boxes are initially sorted by their scores without regard to class. Only boxes up to a maximum of the TopK limit are considered for selection (per batch). During selection, only overlapping boxes of the same class are compared, so that overlapping boxes of different classes do not suppress each other.
For each batch item, the ordering of candidate bounding boxes with the same score is unspecified, but the ordering will be consistent across different runs for the same inputs.
The layer has the following inputs, in order of input index:
- Boxes contains the input bounding boxes. It is a linear tensor of type kFLOAT or kHALF. It has shape [batchSize, numInputBoundingBoxes, numClasses, 4] if the boxes are per class, or [batchSize, numInputBoundingBoxes, 4] if the same boxes are to be used for each class.
- Scores contains the per-box scores. It is a linear tensor of the same type as Boxes. It has shape [batchSize, numInputBoundingBoxes, numClasses].
- MaxOutputBoxesPerClass is the maximum number of output boxes per batch item per class. It is a scalar (0D tensor) of type kINT32.
- IoUThreshold is the maximum IoU for selected boxes. It is a scalar (0D tensor) of type kFLOAT in the range [0.0f, 1.0f]. It is an optional input with default 0.0f.
- ScoreThreshold is the value that a box score must exceed in order to be selected. It is a scalar (0D tensor) of type kFLOAT. It is an optional input with default 0.0f.
The layer has the following outputs, in order of output index:
- SelectedIndices contains the indices of the selected boxes. It is a linear tensor of type kINT32 or kINT64. It has shape [NumOutputBoxes, 3]. Each row contains a (batchIndex, classIndex, boxIndex) tuple. The output boxes are sorted in order of increasing batchIndex and then in order of decreasing score within each batchIndex. For each batchIndex, the ordering of output boxes with the same score is unspecified. If MaxOutputBoxesPerClass is a constant input, the maximum number of output boxes is batchSize * numClasses * min(numInputBoundingBoxes, MaxOutputBoxesPerClass). Otherwise, the maximum number of output boxes is batchSize * numClasses * numInputBoundingBoxes. The maximum number of output boxes is used to determine the upper-bound on allocated memory for this output tensor.
- NumOutputBoxes is the number of output boxes in SelectedIndices. It is a scalar (0D tensor) of type kINT32.
There is a hardware-dependent limit K such that only the K highest scoring boxes in each batch item will be considered for selection. The value of K is 2000 for SM 5.3 and 6.2 devices, and 5000 otherwise.
Do not inherit from this class, as doing so will break forward-compatibility of the API and ABI.
Implementations§
Source§impl INMSLayer
impl INMSLayer
Sourcepub fn setBoundingBoxFormat(self: Pin<&mut INMSLayer>, fmt: BoundingBoxFormat)
pub fn setBoundingBoxFormat(self: Pin<&mut INMSLayer>, fmt: BoundingBoxFormat)
Set the bounding box format parameter for the layer.
The default value for the bounding box format parameter is kCORNER_PAIRS.
See [getBoundingBoxFormat()]
Sourcepub fn getBoundingBoxFormat(self: &INMSLayer) -> BoundingBoxFormat
pub fn getBoundingBoxFormat(self: &INMSLayer) -> BoundingBoxFormat
Get the bounding box format parameter for the layer.
See [setBoundingBoxFormat()]
Sourcepub fn setTopKBoxLimit(self: Pin<&mut INMSLayer>, limit: i32)
pub fn setTopKBoxLimit(self: Pin<&mut INMSLayer>, limit: i32)
Set the TopK box limit parameter for the layer.
The TopK box limit is the maximum number of filtered boxes considered for selection per batch item. The default value for the TopK box limit parameter is 2000 for SM 5.3 and 6.2 devices, and 5000 otherwise. The TopK box limit must be less than or equal to {2000 for SM 5.3 and 6.2 devices, 5000 otherwise}.
See [getTopKBoxLimit()]
Sourcepub fn getTopKBoxLimit(self: &INMSLayer) -> i32
pub fn getTopKBoxLimit(self: &INMSLayer) -> i32
Get the TopK box limit parameter for the layer.
See [setTopKBoxLimit()]
Sourcepub fn setIndicesType(self: Pin<&mut INMSLayer>, type_: DataType) -> bool
pub fn setIndicesType(self: Pin<&mut INMSLayer>, type_: DataType) -> bool
Set the indices type for the layer.
typeThe DataType of the indices tensor.
true if set successfully, false otherwise.
Set the indices (the first output) type of the NMS layer. Valid values are DataType::kINT32 and DataType::kINT64, otherwise an error occurs and the type is not updated.
Sourcepub fn getIndicesType(self: &INMSLayer) -> DataType
pub fn getIndicesType(self: &INMSLayer) -> DataType
Return the NMS layer indices type.
indices type set during layer creation or by setIndicesType(). The return value is the indices type of the NMS layer. The default value is DataType::kINT32.