Various minor fixes for plugins

Limit output_dims == W[1] for plugin test
update embLayernorm plugin doc
Remove else after return as they are not required.
Fix FlattenConcat plugin readme

Signed-off-by: Shuyue Lan <shuyuel@nvidia.com>
Signed-off-by: Rajeev Rao <rajeevrao@nvidia.com>
This commit is contained in:
Jin Li (Engrg-Hardware 1)
2022-10-30 22:53:33 -07:00
committed by Rajeev Rao
parent fde09d7530
commit e8d5e1671f
10 changed files with 60 additions and 103 deletions
@@ -234,7 +234,7 @@ bool QKVToContextPluginDynamic::supportsFormatCombination(
if (inMask->dims.d[1] != -1 && inMask->dims.d[1] != packedSize)
{
gLogError << "CustomEmbLayerNormPluginDynamic returned mask with pack size " << inMask->dims.d[1]
<< ", but " << kQKV_TO_CONTEXT_PLUGIN_NAME << " expects mask pack size " << packedSize
<< ", but " << QKV_TO_CONTEXT_PLUGIN_NAME << " expects mask pack size " << packedSize
<< std::endl;
return false;
}
@@ -275,10 +275,8 @@ bool CropAndResizePlugin::supportsFormat(DataType type, PluginFormat format) con
{
return true;
}
else
{
return false;
}
return false;
}
bool CropAndResizeDynamicPlugin::supportsFormatCombination(
@@ -61,11 +61,9 @@ int EfficientNMSPlugin::getNbOutputs() const noexcept
// ONNX NonMaxSuppression Compatibility
return 1;
}
else
{
// Standard Plugin Implementation
return 4;
}
// Standard Plugin Implementation
return 4;
}
int EfficientNMSPlugin::initialize() noexcept
@@ -135,16 +133,14 @@ nvinfer1::DataType EfficientNMSPlugin::getOutputDataType(
// ONNX NMS uses an integer output
return nvinfer1::DataType::kINT32;
}
else
// On standard NMS, num_detections and detection_classes use integer outputs
if (index == 0 || index == 3)
{
// On standard NMS, num_detections and detection_classes use integer outputs
if (index == 0 || index == 3)
{
return nvinfer1::DataType::kINT32;
}
// All others should use the same datatype as the input
return inputTypes[0];
return nvinfer1::DataType::kINT32;
}
// All others should use the same datatype as the input
return inputTypes[0];
}
IPluginV2DynamicExt* EfficientNMSPlugin::clone() const noexcept
@@ -256,14 +252,13 @@ bool EfficientNMSPlugin::supportsFormatCombination(
return (inOut[pos].type == DataType::kHALF || inOut[pos].type == DataType::kFLOAT)
&& (inOut[0].type == inOut[pos].type);
}
else
PLUGIN_ASSERT(nbInputs == 2 || nbInputs == 3);
PLUGIN_ASSERT(nbOutputs == 4);
if (nbInputs == 2)
{
PLUGIN_ASSERT(nbInputs == 2 || nbInputs == 3);
PLUGIN_ASSERT(nbOutputs == 4);
if (nbInputs == 2)
{
PLUGIN_ASSERT(0 <= pos && pos <= 5);
}
PLUGIN_ASSERT(0 <= pos && pos <= 5);
}
if (nbInputs == 3)
{
PLUGIN_ASSERT(0 <= pos && pos <= 6);
@@ -279,7 +274,6 @@ bool EfficientNMSPlugin::supportsFormatCombination(
// all other inputs/outputs: fp32 or fp16
return (inOut[pos].type == DataType::kHALF || inOut[pos].type == DataType::kFLOAT)
&& (inOut[0].type == inOut[pos].type);
}
}
void EfficientNMSPlugin::configurePlugin(
@@ -387,21 +381,19 @@ int EfficientNMSPlugin::enqueue(const PluginTensorDesc* inputDesc, const PluginT
return EfficientNMSInference(mParam, boxesInput, scoresInput, nullptr, nullptr, nullptr, nullptr, nullptr,
nmsIndicesOutput, workspace, stream);
}
else
{
// Standard NMS Operation
const void* const boxesInput = inputs[0];
const void* const scoresInput = inputs[1];
const void* const anchorsInput = mParam.boxDecoder ? inputs[2] : nullptr;
void* numDetectionsOutput = outputs[0];
void* nmsBoxesOutput = outputs[1];
void* nmsScoresOutput = outputs[2];
void* nmsClassesOutput = outputs[3];
// Standard NMS Operation
void const* const boxesInput = inputs[0];
void const* const scoresInput = inputs[1];
void const* const anchorsInput = mParam.boxDecoder ? inputs[2] : nullptr;
return EfficientNMSInference(mParam, boxesInput, scoresInput, anchorsInput, numDetectionsOutput,
nmsBoxesOutput, nmsScoresOutput, nmsClassesOutput, nullptr, workspace, stream);
}
void* numDetectionsOutput = outputs[0];
void* nmsBoxesOutput = outputs[1];
void* nmsScoresOutput = outputs[2];
void* nmsClassesOutput = outputs[3];
return EfficientNMSInference(mParam, boxesInput, scoresInput, anchorsInput, numDetectionsOutput, nmsBoxesOutput,
nmsScoresOutput, nmsClassesOutput, nullptr, workspace, stream);
}
catch (const std::exception& e)
{
+3 -3
View File
@@ -50,7 +50,7 @@ The final output embedding is the sum of embeddings for the token, the segment a
`maskIdx`
embedded_input is an `int32` tensor with shape `[B,]` where `B` is batch size.
embedded_input is an `int32` tensor with shape `[B, packSize]` where `B` is batch size, `packSize` is the packed mask size that depends on the sequence length.
The maskIdx is a more compact representation of the input mask, consisting of the number of valid elements, assuming that the original mask was contiguous.
@@ -88,10 +88,10 @@ documentation.
## Changelog
October 2020
October 2020
Add V2 plugin that supports variable sequence length.
November 2019
November 2019
This is the first release of this `README.md` file.
@@ -46,8 +46,7 @@ versions:
max: "=pinf, =pinf"
attribute_options:
out_dims:
min: "=1"
max: "=pinf"
from_shape: "W_1"
type_id:
- 0
- 1
+2 -2
View File
@@ -149,7 +149,7 @@ The following parameters were used to create `FlattenConcat` instance:
| Type | Parameter | Description
|------------------|--------------------------------|--------------------------------------------------------
|`int` |`concatAxis` |The dimension along which to concatenate. Currently only `concatAxis = 1` is supported.
|`int` |`axis` |The dimension along which to concatenate. Currently only `axis = 1` is supported.
|`bool` |`ignoreBatch` |Whether to ignore batch or not. Currently only `ignoreBatch = false` is supported.
@@ -174,4 +174,4 @@ This is the first release of this `README.md` file.
## Known issues
There are no known issues in this plugin.
There are no known issues in this plugin.
@@ -80,16 +80,10 @@ bool MultiscaleDeformableAttnPlugin::supportsFormatCombination(
{
return (inOut[pos].type == nvinfer1::DataType::kINT32);
}
else
{
return ((inOut[pos].type == inOut[0].type) &&
((inOut[pos].type == nvinfer1::DataType::kFLOAT) || (inOut[pos].type == nvinfer1::DataType::kHALF)));
}
}
else
{
return false;
return ((inOut[pos].type == inOut[0].type)
&& ((inOut[pos].type == nvinfer1::DataType::kFLOAT) || (inOut[pos].type == nvinfer1::DataType::kHALF)));
}
return false;
}
void MultiscaleDeformableAttnPlugin::configurePlugin(nvinfer1::DynamicPluginTensorDesc const* inputs, int32_t nbInputs,
+2 -4
View File
@@ -159,10 +159,8 @@ Dims RPROIPlugin::getOutputDimensions(int index, const Dims* inputs, int nbInput
return Dims3(1, params.nmsMaxOut, 4);
}
// Feature map of each ROI after ROI Pooling
else // pool5
{
return Dims4(params.nmsMaxOut, inputs[2].d[0], params.poolingH, params.poolingW);
}
// pool5
return Dims4(params.nmsMaxOut, inputs[2].d[0], params.poolingH, params.poolingW);
}
size_t RPROIPlugin::getWorkspaceSize(int maxBatchSize) const noexcept
+18 -40
View File
@@ -144,48 +144,26 @@ int PillarScatterPlugin::enqueue(const nvinfer1::PluginTensorDesc* inputDesc,
int status = -1;
if(inputType == nvinfer1::DataType::kHALF){
auto pillar_features_data = static_cast<const half *>(inputs[0]);
auto spatial_feature_data = static_cast<half *>(outputs[0]);
cudaMemsetAsync(spatial_feature_data, 0, batchSize*numFeatures*featureY*featureX * sizeof(half), stream);
status = pillarScatterKernelLaunch<half>(
batchSize,
maxPillarNum,
numFeatures,
pillar_features_data,
coords_data,
params_data,
featureX,
featureY,
spatial_feature_data,
stream
);
PLUGIN_ASSERT(status == STATUS_SUCCESS);
return status;
if (inputType == nvinfer1::DataType::kHALF)
{
auto pillar_features_data = static_cast<const half*>(inputs[0]);
auto spatial_feature_data = static_cast<half*>(outputs[0]);
cudaMemsetAsync(
spatial_feature_data, 0, batchSize * numFeatures * featureY * featureX * sizeof(half), stream);
status = pillarScatterKernelLaunch<half>(batchSize, maxPillarNum, numFeatures, pillar_features_data,
coords_data, params_data, featureX, featureY, spatial_feature_data, stream);
}
else if(inputType == nvinfer1::DataType::kFLOAT){
auto pillar_features_data = static_cast<const float *>(inputs[0]);
auto spatial_feature_data = static_cast<float *>(outputs[0]);
cudaMemsetAsync(spatial_feature_data, 0, batchSize*numFeatures*featureY*featureX * sizeof(float), stream);
status = pillarScatterKernelLaunch<float>(
batchSize,
maxPillarNum,
numFeatures,
pillar_features_data,
coords_data,
params_data,
featureX,
featureY,
spatial_feature_data,
stream
);
PLUGIN_ASSERT(status == STATUS_SUCCESS);
return status;
}
else{
PLUGIN_ASSERT(status == STATUS_SUCCESS);
return status;
else if (inputType == nvinfer1::DataType::kFLOAT)
{
auto const* pillar_features_data = static_cast<float const*>(inputs[0]);
auto* spatial_feature_data = static_cast<float*>(outputs[0]);
cudaMemsetAsync(
spatial_feature_data, 0, batchSize * numFeatures * featureY * featureX * sizeof(float), stream);
status = pillarScatterKernelLaunch<float>(batchSize, maxPillarNum, numFeatures, pillar_features_data,
coords_data, params_data, featureX, featureY, spatial_feature_data, stream);
}
PLUGIN_ASSERT(status == STATUS_SUCCESS);
return status;
}
catch (const std::exception& e)
{
+2 -4
View File
@@ -412,10 +412,8 @@ bool ProposalPlugin::supportsFormat(DataType type, PluginFormat format) const no
{
return true;
}
else
{
return false;
}
return false;
}
bool ProposalDynamicPlugin::supportsFormatCombination(