chore: import upstream snapshot with attribution
Docker Image CI / build-ubuntu2004 (push) Has been cancelled

This commit is contained in:
wehub-resource-sync
2026-07-13 13:36:55 +08:00
commit c8a779b1bb
1887 changed files with 3245738 additions and 0 deletions
+22
View File
@@ -0,0 +1,22 @@
#
# SPDX-FileCopyrightText: Copyright (c) 1993-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
add_plugin_source(
reorgPlugin.cpp
reorgPlugin.h
)
+263
View File
@@ -0,0 +1,263 @@
# reorgPlugin [DEPRECATED]
**This plugin is deprecated since TensorRT 10.12 and will be removed in a future release. No alternatives are planned to be provided.**
**Table Of Contents**
- [Description](#description)
* [Structure](#structure)
- [Parameters](#parameters)
- [Additional resources](#additional-resources)
- [License](#license)
- [Changelog](#changelog)
- [Known issues](#known-issues)
## Description
The`reorgPlugin` is specifically used for the reorg layer in the YOLOv2 model in TensorRT. It reorganizes the elements in the input tensor and generates an output tensor of a different shape. In YOLOv2, the output tensor from the reorg layer matches the shape of the output tensor from a downstream layer Conv20_1024 in the neural network. The two output tensors are then concatenated together as one single tensor.
### Structure
The `reorgPlugin` takes one input and generates one output. The tensor format must be in NCHW format.
The input is a tensor that has a shape of `[N, C, H, W]` where:
- `N` is the batch size
- `C` is the number of channels
- `H` is the height of tensor
- `W` is the width of the tensor
After a [unique one-to-one mapping](https://github.com/pjreddie/darknet/blob/8215a8864d4ad07e058acafd75b2c6ff6600b9e8/src/blas.c#L9), the output tensor of shape `[N, C x s x s, H / s, W / s]`, where s is the stride, is generated.
For example, if we have an input tensor of shape `[2, 4, 6, 6]`.
```
[[[[ 0 1 2 3 4 5]
[ 6 7 8 9 10 11]
[ 12 13 14 15 16 17]
[ 18 19 20 21 22 23]
[ 24 25 26 27 28 29]
[ 30 31 32 33 34 35]]
[[ 36 37 38 39 40 41]
[ 42 43 44 45 46 47]
[ 48 49 50 51 52 53]
[ 54 55 56 57 58 59]
[ 60 61 62 63 64 65]
[ 66 67 68 69 70 71]]
[[ 72 73 74 75 76 77]
[ 78 79 80 81 82 83]
[ 84 85 86 87 88 89]
[ 90 91 92 93 94 95]
[ 96 97 98 99 100 101]
[102 103 104 105 106 107]]
[[108 109 110 111 112 113]
[114 115 116 117 118 119]
[120 121 122 123 124 125]
[126 127 128 129 130 131]
[132 133 134 135 136 137]
[138 139 140 141 142 143]]]
[[[144 145 146 147 148 149]
[150 151 152 153 154 155]
[156 157 158 159 160 161]
[162 163 164 165 166 167]
[168 169 170 171 172 173]
[174 175 176 177 178 179]]
[[180 181 182 183 184 185]
[186 187 188 189 190 191]
[192 193 194 195 196 197]
[198 199 200 201 202 203]
[204 205 206 207 208 209]
[210 211 212 213 214 215]]
[[216 217 218 219 220 221]
[222 223 224 225 226 227]
[228 229 230 231 232 233]
[234 235 236 237 238 239]
[240 241 242 243 244 245]
[246 247 248 249 250 251]]
[[252 253 254 255 256 257]
[258 259 260 261 262 263]
[264 265 266 267 268 269]
[270 271 272 273 274 275]
[276 277 278 279 280 281]
[282 283 284 285 286 287]]]]
```
We set `stride = 2` and perform the reorganization, we will get the following output tensor of shape `[2, 16, 3, 3]`.
```
[[[[ 0 2 4]
[ 6 8 10]
[ 24 26 28]]
[[ 30 32 34]
[ 48 50 52]
[ 54 56 58]]
[[ 72 74 76]
[ 78 80 82]
[ 96 98 100]]
[[102 104 106]
[120 122 124]
[126 128 130]]
[[ 1 3 5]
[ 7 9 11]
[ 25 27 29]]
[[ 31 33 35]
[ 49 51 53]
[ 55 57 59]]
[[ 73 75 77]
[ 79 81 83]
[ 97 99 101]]
[[103 105 107]
[121 123 125]
[127 129 131]]
[[ 12 14 16]
[ 18 20 22]
[ 36 38 40]]
[[ 42 44 46]
[ 60 62 64]
[ 66 68 70]]
[[ 84 86 88]
[ 90 92 94]
[108 110 112]]
[[114 116 118]
[132 134 136]
[138 140 142]]
[[ 13 15 17]
[ 19 21 23]
[ 37 39 41]]
[[ 43 45 47]
[ 61 63 65]
[ 67 69 71]]
[[ 85 87 89]
[ 91 93 95]
[109 111 113]]
[[115 117 119]
[133 135 137]
[139 141 143]]]
[[[144 146 148]
[150 152 154]
[168 170 172]]
[[174 176 178]
[192 194 196]
[198 200 202]]
[[216 218 220]
[222 224 226]
[240 242 244]]
[[246 248 250]
[264 266 268]
[270 272 274]]
[[145 147 149]
[151 153 155]
[169 171 173]]
[[175 177 179]
[193 195 197]
[199 201 203]]
[[217 219 221]
[223 225 227]
[241 243 245]]
[[247 249 251]
[265 267 269]
[271 273 275]]
[[156 158 160]
[162 164 166]
[180 182 184]]
[[186 188 190]
[204 206 208]
[210 212 214]]
[[228 230 232]
[234 236 238]
[252 254 256]]
[[258 260 262]
[276 278 280]
[282 284 286]]
[[157 159 161]
[163 165 167]
[181 183 185]]
[[187 189 191]
[205 207 209]
[211 213 215]]
[[229 231 233]
[235 237 239]
[253 255 257]]
[[259 261 263]
[277 279 281]
[283 285 287]]]]
```
## Parameters
The `reorgPlugin` has plugin creator class `ReorgPluginCreator` and plugin class `Reorg`.
The following parameters were used to create the `Reorg` instance.
| Type | Parameter | Description
|----------|--------------------------|--------------------------------------------------------
|`int` |`stride` |Dimension reduction factor for the input tensor. The stride has to be divisible by the height and the width of the input tensor.
## Additional resources
The following resources provide a deeper understanding of the `reorgPlugin` plugin:
- [YOLOv2 paper](https://arxiv.org/abs/1612.08242)
- [Reorg layer in YOLOv2](https://github.com/pjreddie/darknet/blob/8215a8864d4ad07e058acafd75b2c6ff6600b9e8/src/blas.c#L9)
- [YOLOv2 architecture](https://ethereon.github.io/netscope/#/gist/d08a41711e48cf111e330827b1279c31)
## License
For terms and conditions for use, reproduction, and distribution, see the [TensorRT Software License Agreement](https://docs.nvidia.com/deeplearning/sdk/tensorrt-sla/index.html)
documentation.
## Changelog
May 2025
Add deprecation note.
Feb 2024
Support IPluginV2DynamicExt in version 2.
May 2019
This is the first release of this `README.md` file.
## Known issues
There are no known issues in this plugin.
@@ -0,0 +1,34 @@
#
# SPDX-FileCopyrightText: Copyright (c) 2022-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
---
name: Reorg_TRT
interface: "IPluginV2DynamicExt"
versions:
"2":
attributes:
- stride
attribute_types:
stride: int32
attribute_length:
stride: 1
attribute_options:
stride:
min: "0"
max: "=pinf"
attributes_required:
- stride
...
+391
View File
@@ -0,0 +1,391 @@
/*
* SPDX-FileCopyrightText: Copyright (c) 1993-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "reorgPlugin.h"
#include <memory>
#include <string_view>
namespace nvinfer1::plugin
{
static char const* const kREORG_PLUGIN_STATIC_VERSION{"1"};
static char const* const kREORG_PLUGIN_DYNAMIC_VERSION{"2"};
static char const* const kREORG_PLUGIN_NAME{"Reorg_TRT"};
template <class TBaseClass>
Reorg<TBaseClass>::Reorg(int32_t strideValue)
: stride(strideValue)
{
}
template <class TBaseClass>
int32_t Reorg<TBaseClass>::getNbOutputs() const noexcept
{
return 1;
}
template <class TBaseClass>
int32_t Reorg<TBaseClass>::initialize() noexcept
{
return STATUS_SUCCESS;
}
template <class TBaseClass>
void Reorg<TBaseClass>::terminate() noexcept
{
}
template <class TBaseClass>
char const* Reorg<TBaseClass>::getPluginType() const noexcept
{
return kREORG_PLUGIN_NAME;
}
template <class TBaseClass>
void Reorg<TBaseClass>::destroy() noexcept
{
delete this;
}
// Set plugin namespace
template <class TBaseClass>
void Reorg<TBaseClass>::setPluginNamespace(char const* pluginNamespace) noexcept
{
mPluginNamespace = pluginNamespace;
}
template <class TBaseClass>
char const* Reorg<TBaseClass>::getPluginNamespace() const noexcept
{
return mPluginNamespace.c_str();
}
// Return the DataType of the plugin output at the requested index
template <class TBaseClass>
DataType Reorg<TBaseClass>::getOutputDataType(
int32_t index, nvinfer1::DataType const* inputTypes, int32_t nbInputs) const noexcept
{
// Only 1 input and 1 output from the plugin layer
PLUGIN_ASSERT(index == 0);
// Only DataType::kFLOAT is acceptable by the plugin layer
return DataType::kFLOAT;
}
// Attach the plugin object to an execution context and grant the plugin the access to some context resource.
template <class TBaseClass>
void Reorg<TBaseClass>::attachToContext(
cudnnContext* cudnnContext, cublasContext* cublasContext, IGpuAllocator* gpuAllocator) noexcept
{
}
// Detach the plugin object from its execution context.
template <class TBaseClass>
void Reorg<TBaseClass>::detachFromContext() noexcept
{
}
ReorgDynamic::ReorgDynamic(int32_t stride)
: Reorg<IPluginV2DynamicExt>(stride)
{
}
ReorgDynamic::ReorgDynamic(void const* buffer, size_t length)
{
char const* d = reinterpret_cast<char const*>(buffer);
char const* a = d;
stride = read<int32_t>(d);
PLUGIN_VALIDATE(d == a + length);
}
char const* ReorgDynamic::getPluginVersion() const noexcept
{
return kREORG_PLUGIN_DYNAMIC_VERSION;
}
size_t ReorgDynamic::getSerializationSize() const noexcept
{
// stride
return sizeof(int32_t);
}
size_t ReorgDynamic::getWorkspaceSize(nvinfer1::PluginTensorDesc const* inputs, int32_t nbInputs,
PluginTensorDesc const* outputs, int32_t nbOutputs) const noexcept
{
return 0;
}
void ReorgDynamic::serialize(void* buffer) const noexcept
{
char *d = reinterpret_cast<char*>(buffer), *a = d;
write(d, stride);
PLUGIN_ASSERT(d == a + getSerializationSize());
}
DimsExprs ReorgDynamic::getOutputDimensions(
int32_t outputIndex, DimsExprs const* inputs, int32_t nbInputs, IExprBuilder& exprBuilder) noexcept
{
PLUGIN_ASSERT(nbInputs == 1);
PLUGIN_ASSERT(outputIndex == 0);
DimsExprs output{3, {}};
auto const* strideExpr = exprBuilder.constant(stride);
auto const* strideSquareExpr = exprBuilder.constant(stride * stride);
output.d[0] = exprBuilder.operation(DimensionOperation::kPROD, *inputs[0].d[0], *strideSquareExpr);
output.d[1] = exprBuilder.operation(DimensionOperation::kFLOOR_DIV, *inputs[0].d[1], *strideExpr);
output.d[2] = exprBuilder.operation(DimensionOperation::kFLOOR_DIV, *inputs[0].d[2], *strideExpr);
return output;
}
bool ReorgDynamic::supportsFormatCombination(
int32_t pos, PluginTensorDesc const* inOut, int32_t nbInputs, int32_t nbOutputs) noexcept
{
PLUGIN_ASSERT(pos >= 0 && pos <= 1);
PLUGIN_ASSERT(nbInputs == 1);
PLUGIN_ASSERT(nbOutputs == 1);
return (inOut[pos].type == DataType::kFLOAT && inOut[pos].format == PluginFormat::kLINEAR);
}
void ReorgDynamic::configurePlugin(
DynamicPluginTensorDesc const* in, int32_t nbInputs, DynamicPluginTensorDesc const* out, int32_t nbOutputs) noexcept
{
PLUGIN_ASSERT(nbInputs == 1);
PLUGIN_ASSERT(nbOutputs == 1);
PLUGIN_ASSERT(in->desc.type == DataType::kFLOAT);
PLUGIN_ASSERT(out->desc.type == DataType::kFLOAT);
PLUGIN_ASSERT(in->desc.format == PluginFormat::kLINEAR);
PLUGIN_ASSERT(out->desc.format == PluginFormat::kLINEAR);
PLUGIN_ASSERT(stride > 0);
int32_t H = in->desc.dims.d[2];
int32_t W = in->desc.dims.d[3];
PLUGIN_ASSERT(H % stride == 0);
PLUGIN_ASSERT(W % stride == 0);
}
int32_t ReorgDynamic::enqueue(nvinfer1::PluginTensorDesc const* inputDesc, nvinfer1::PluginTensorDesc const* outputDesc,
void const* const* inputs, void* const* outputs, void* workspace, cudaStream_t stream) noexcept
{
void const* inputData = inputs[0];
void* outputData = outputs[0];
int32_t const N = inputDesc[0].dims.d[0];
int32_t const C = inputDesc[0].dims.d[1];
int32_t const H = inputDesc[0].dims.d[2];
int32_t const W = inputDesc[0].dims.d[3];
pluginStatus_t status = reorgInference(stream, N, C, H, W, stride, inputData, outputData);
return status;
}
IPluginV2DynamicExt* ReorgDynamic::clone() const noexcept
{
try
{
auto plugin = std::make_unique<ReorgDynamic>(stride);
plugin->setPluginNamespace(mPluginNamespace.c_str());
return plugin.release();
}
catch (std::exception const& e)
{
caughtError(e);
}
return nullptr;
}
ReorgStatic::ReorgStatic(int32_t stride)
: Reorg<IPluginV2Ext>(stride)
{
}
ReorgStatic::ReorgStatic(int32_t C, int32_t H, int32_t W, int32_t stride)
: Reorg<IPluginV2Ext>(stride)
, C(C)
, H(H)
, W(W)
{
}
ReorgStatic::ReorgStatic(void const* buffer, size_t length)
{
char const* d = reinterpret_cast<char const*>(buffer);
char const* a = d;
C = read<int32_t>(d);
H = read<int32_t>(d);
W = read<int32_t>(d);
stride = read<int32_t>(d);
PLUGIN_VALIDATE(d == a + length);
}
char const* ReorgStatic::getPluginVersion() const noexcept
{
return kREORG_PLUGIN_STATIC_VERSION;
}
size_t ReorgStatic::getWorkspaceSize(int32_t maxBatchSize) const noexcept
{
return 0;
}
size_t ReorgStatic::getSerializationSize() const noexcept
{
// C, H, W, stride
return sizeof(int32_t) * 4;
}
void ReorgStatic::serialize(void* buffer) const noexcept
{
char *d = reinterpret_cast<char*>(buffer), *a = d;
write(d, C);
write(d, H);
write(d, W);
write(d, stride);
PLUGIN_ASSERT(d == a + getSerializationSize());
}
Dims ReorgStatic::getOutputDimensions(int32_t index, Dims const* inputs, int32_t nbInputDims) noexcept
{
PLUGIN_ASSERT(nbInputDims == 1);
PLUGIN_ASSERT(index == 0);
return Dims3(inputs[0].d[0] * stride * stride, inputs[0].d[1] / stride, inputs[0].d[2] / stride);
}
int32_t ReorgStatic::enqueue(
int32_t batchSize, void const* const* inputs, void* const* outputs, void* workspace, cudaStream_t stream) noexcept
{
void const* inputData = inputs[0];
void* outputData = outputs[0];
pluginStatus_t status = reorgInference(stream, batchSize, C, H, W, stride, inputData, outputData);
return status;
}
bool ReorgStatic::supportsFormat(DataType type, PluginFormat format) const noexcept
{
return (type == DataType::kFLOAT && format == PluginFormat::kLINEAR);
}
IPluginV2Ext* ReorgStatic::clone() const noexcept
{
try
{
auto plugin = std::make_unique<ReorgStatic>(C, H, W, stride);
plugin->setPluginNamespace(mPluginNamespace.c_str());
return plugin.release();
}
catch (std::exception const& e)
{
caughtError(e);
}
return nullptr;
}
// Configure the layer with input and output data types.
void ReorgStatic::configurePlugin(Dims const* inputDims, int32_t nbInputs, Dims const* outputDims, int32_t nbOutputs,
DataType const* inputTypes, DataType const* outputTypes, bool const* inputIsBroadcast,
bool const* outputIsBroadcast, PluginFormat floatFormat, int32_t maxBatchSize) noexcept
{
PLUGIN_ASSERT(*inputTypes == DataType::kFLOAT && floatFormat == PluginFormat::kLINEAR);
PLUGIN_ASSERT(nbInputs == 1);
PLUGIN_ASSERT(nbOutputs == 1);
PLUGIN_ASSERT(stride > 0);
C = inputDims[0].d[0];
H = inputDims[0].d[1];
W = inputDims[0].d[2];
PLUGIN_ASSERT(H % stride == 0);
PLUGIN_ASSERT(W % stride == 0);
}
template <class TPluginClass>
ReorgPluginCreator<TPluginClass>::ReorgPluginCreator()
{
mPluginAttributes.clear();
mPluginAttributes.emplace_back(PluginField("stride", nullptr, PluginFieldType::kINT32, 1));
mFC.nbFields = mPluginAttributes.size();
mFC.fields = mPluginAttributes.data();
}
template <class TPluginClass>
char const* ReorgPluginCreator<TPluginClass>::getPluginName() const noexcept
{
return kREORG_PLUGIN_NAME;
}
template <class TPluginClass>
char const* ReorgPluginCreator<TPluginClass>::getPluginVersion() const noexcept
{
if (std::is_same_v<TPluginClass, ReorgStatic>)
{
return kREORG_PLUGIN_STATIC_VERSION;
}
else if (std::is_same_v<TPluginClass, ReorgDynamic>)
{
return kREORG_PLUGIN_DYNAMIC_VERSION;
}
return "";
}
template <class TPluginClass>
PluginFieldCollection const* ReorgPluginCreator<TPluginClass>::getFieldNames() noexcept
{
return &mFC;
}
template <class TPluginClass>
IPluginV2Ext* ReorgPluginCreator<TPluginClass>::createPlugin(char const* name, PluginFieldCollection const* fc) noexcept
{
try
{
using namespace std::string_view_literals;
PluginField const* fields = fc->fields;
PLUGIN_VALIDATE(fc->nbFields == 1);
PLUGIN_VALIDATE(fields[0].type == PluginFieldType::kINT32);
PLUGIN_VALIDATE(fields[0].name == "stride"sv);
stride = static_cast<int32_t>(*(static_cast<int32_t const*>(fields[0].data)));
PLUGIN_VALIDATE(stride > 0);
auto obj = std::make_unique<TPluginClass>(stride);
obj->setPluginNamespace(mNamespace.c_str());
return obj.release();
}
catch (std::exception const& e)
{
caughtError(e);
}
return nullptr;
}
template <class TPluginClass>
IPluginV2Ext* ReorgPluginCreator<TPluginClass>::deserializePlugin(
char const* name, void const* serialData, size_t serialLength) noexcept
{
try
{
// This object will be deleted when the network is destroyed, which will
// call ReorgPlugin::destroy()
auto obj = std::make_unique<TPluginClass>(serialData, serialLength);
obj->setPluginNamespace(mNamespace.c_str());
return obj.release();
}
catch (std::exception const& e)
{
caughtError(e);
}
return nullptr;
}
template class ReorgPluginCreator<ReorgStatic>;
template class ReorgPluginCreator<ReorgDynamic>;
} // namespace nvinfer1::plugin
+140
View File
@@ -0,0 +1,140 @@
/*
* SPDX-FileCopyrightText: Copyright (c) 1993-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef TRT_REORG_PLUGIN_H
#define TRT_REORG_PLUGIN_H
#include "common/kernels/kernel.h"
#include "common/plugin.h"
#include <iostream>
#include <vector>
namespace nvinfer1
{
namespace plugin
{
template <class TBaseClass>
class Reorg : public TBaseClass
{
public:
Reorg(int32_t stride = 0);
~Reorg() override = default;
int32_t getNbOutputs() const noexcept override;
int32_t initialize() noexcept override;
void terminate() noexcept override;
char const* getPluginType() const noexcept override;
void destroy() noexcept override;
void setPluginNamespace(char const* pluginNamespace) noexcept override;
char const* getPluginNamespace() const noexcept override;
DataType getOutputDataType(
int32_t index, nvinfer1::DataType const* inputTypes, int32_t nbInputs) const noexcept override;
void attachToContext(
cudnnContext* cudnnContext, cublasContext* cublasContext, IGpuAllocator* gpuAllocator) noexcept override;
void detachFromContext() noexcept override;
protected:
int32_t stride{};
std::string mPluginNamespace;
};
class TRT_DEPRECATED ReorgStatic : public Reorg<IPluginV2Ext>
{
public:
ReorgStatic(int32_t stride);
ReorgStatic(int32_t C, int32_t H, int32_t W, int32_t stride);
ReorgStatic(void const* buffer, size_t length);
char const* getPluginVersion() const noexcept override;
Dims getOutputDimensions(int32_t index, Dims const* inputs, int32_t nbInputDims) noexcept override;
size_t getWorkspaceSize(int32_t maxBatchSize) const noexcept override;
int32_t enqueue(int32_t batchSize, void const* const* inputs, void* const* outputs, void* workspace,
cudaStream_t stream) noexcept override;
bool supportsFormat(DataType type, PluginFormat format) const noexcept override;
IPluginV2Ext* clone() const noexcept override;
void configurePlugin(Dims const* inputDims, int32_t nbInputs, Dims const* outputDims, int32_t nbOutputs,
DataType const* inputTypes, DataType const* outputTypes, bool const* inputIsBroadcast,
bool const* outputIsBroadcast, PluginFormat floatFormat, int32_t maxBatchSize) noexcept override;
size_t getSerializationSize() const noexcept override;
void serialize(void* buffer) const noexcept override;
protected:
int32_t C{};
int32_t H{};
int32_t W{};
};
class ReorgDynamic : public Reorg<IPluginV2DynamicExt>
{
public:
ReorgDynamic(int32_t stride);
ReorgDynamic(void const* buffer, size_t length);
char const* getPluginVersion() const noexcept override;
DimsExprs getOutputDimensions(
int32_t outputIndex, DimsExprs const* inputs, int32_t nbInputs, IExprBuilder& exprBuilder) noexcept override;
bool supportsFormatCombination(
int32_t pos, PluginTensorDesc const* inOut, int32_t nbInputs, int32_t nbOutputs) noexcept override;
void configurePlugin(DynamicPluginTensorDesc const* in, int32_t nbInputs, DynamicPluginTensorDesc const* out,
int32_t nbOutputs) noexcept override;
size_t getWorkspaceSize(nvinfer1::PluginTensorDesc const* inputs, int32_t nbInputs, PluginTensorDesc const* outputs,
int32_t nbOutputs) const noexcept override;
int32_t enqueue(nvinfer1::PluginTensorDesc const* inputDesc, nvinfer1::PluginTensorDesc const* outputDesc,
void const* const* inputs, void* const* outputs, void* workspace, cudaStream_t stream) noexcept override;
IPluginV2DynamicExt* clone() const noexcept override;
size_t getSerializationSize() const noexcept override;
void serialize(void* buffer) const noexcept override;
};
template <class TPluginClass>
class ReorgPluginCreator : public nvinfer1::pluginInternal::BaseCreator
{
public:
ReorgPluginCreator();
~ReorgPluginCreator() override = default;
char const* getPluginName() const noexcept override;
char const* getPluginVersion() const noexcept override;
PluginFieldCollection const* getFieldNames() noexcept override;
IPluginV2Ext* createPlugin(char const* name, PluginFieldCollection const* fc) noexcept override;
IPluginV2Ext* deserializePlugin(char const* name, void const* serialData, size_t serialLength) noexcept override;
private:
PluginFieldCollection mFC;
int32_t stride{};
std::vector<PluginField> mPluginAttributes;
};
using ReorgStaticPluginCreator = ReorgPluginCreator<ReorgStatic>;
using ReorgDynamicPluginCreator = ReorgPluginCreator<ReorgDynamic>;
} // namespace plugin
} // namespace nvinfer1
#endif // TRT_REORG_PLUGIN_H