TensorRT
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
NvInferPlugin.h
Go to the documentation of this file.
1 /*
2  * Copyright 1993-2018 NVIDIA Corporation. All rights reserved.
3  *
4  * NOTICE TO LICENSEE:
5  *
6  * This source code and/or documentation ("Licensed Deliverables") are
7  * subject to NVIDIA intellectual property rights under U.S. and
8  * international Copyright laws.
9  *
10  * These Licensed Deliverables contained herein is PROPRIETARY and
11  * CONFIDENTIAL to NVIDIA and is being provided under the terms and
12  * conditions of a form of NVIDIA software license agreement by and
13  * between NVIDIA and Licensee ("License Agreement") or electronically
14  * accepted by Licensee. Notwithstanding any terms or conditions to
15  * the contrary in the License Agreement, reproduction or disclosure
16  * of the Licensed Deliverables to any third party without the express
17  * written consent of NVIDIA is prohibited.
18  *
19  * NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
20  * LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
21  * SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE. IT IS
22  * PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
23  * NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
24  * DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
25  * NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
26  * NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
27  * LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
28  * SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
29  * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
30  * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
31  * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
32  * OF THESE LICENSED DELIVERABLES.
33  *
34  * U.S. Government End Users. These Licensed Deliverables are a
35  * "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
36  * 1995), consisting of "commercial computer software" and "commercial
37  * computer software documentation" as such terms are used in 48
38  * C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government
39  * only as a commercial end item. Consistent with 48 C.F.R.12.212 and
40  * 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
41  * U.S. Government End Users acquire the Licensed Deliverables with
42  * only those rights set forth herein.
43  *
44  * Any use of the Licensed Deliverables in individual and commercial
45  * software must include, in the user documentation and internal
46  * comments to the code, the above Disclaimer and U.S. Government End
47  * Users Notice.
48  */
49 
50 #ifndef NV_INFER_PLUGIN_H
51 #define NV_INFER_PLUGIN_H
52 
53 #include "NvInfer.h"
54 
60 
61 namespace nvinfer1
62 {
70  enum class PluginType : int
71  {
72  kFASTERRCNN = 0,
73  kNORMALIZE = 1,
74  kPERMUTE = 2,
75  kPRIORBOX = 3,
77  kCONCAT = 5,
78  kPRELU = 6,
79  kYOLOREORG = 7,
80  kYOLOREGION = 8,
81  kANCHORGENERATOR = 9,
82  };
83 
85  template <>
86  inline int EnumMax<PluginType>() { return 10; }
87 
88 namespace plugin
89 {
100  class INvPlugin : public IPlugin
101  {
102  public:
108  virtual PluginType getPluginType() const = 0;
109 
117  virtual const char *getName() const = 0;
118 
124  virtual void destroy() = 0;
125  protected:
126  ~INvPlugin() {}
127  }; // INvPlugin
128 
145  TENSORRTAPI INvPlugin * createFasterRCNNPlugin(int featureStride, int preNmsTop,
146  int nmsMaxOut, float iouThreshold, float minBoxSize,
147  float spatialScale, DimsHW pooling,
148  Weights anchorRatios, Weights anchorScales);
149  TENSORRTAPI INvPlugin * createFasterRCNNPlugin(const void * data, size_t length);
150 
151 
159  TENSORRTAPI INvPlugin * createSSDNormalizePlugin(const Weights *scales, bool acrossSpatial, bool channelShared, float eps);
160  TENSORRTAPI INvPlugin * createSSDNormalizePlugin(const void * data, size_t length);
161 
166  typedef struct
167  {
168  int data[4];
169  } Quadruple;
170 
174  TENSORRTAPI INvPlugin * createSSDPermutePlugin(Quadruple permuteOrder);
175  TENSORRTAPI INvPlugin * createSSDPermutePlugin(const void * data, size_t length);
176 
197  {
198  float *minSize, *maxSize, *aspectRatios;
199  int numMinSize, numMaxSize, numAspectRatios;
200  bool flip;
201  bool clip;
202  float variance[4];
203  int imgH, imgW;
204  float stepH, stepW;
205  float offset;
206  };
207 
221  {
222  float minSize, maxSize;
223  float *aspectRatios;
224  int numAspectRatios, H, W;
225  float variance[4];
226  };
227 
231  TENSORRTAPI INvPlugin * createSSDPriorBoxPlugin(PriorBoxParameters param);
232  TENSORRTAPI INvPlugin * createSSDPriorBoxPlugin(const void * data, size_t length);
233 
239  TENSORRTAPI INvPlugin * createSSDAnchorGeneratorPlugin(GridAnchorParameters* param, int numLayers);
240  TENSORRTAPI INvPlugin * createSSDAnchorGeneratorPlugin(const void * data, size_t length);
241 
246  enum class CodeTypeSSD : int
247  {
248  CORNER = 0,
249  CENTER_SIZE = 1,
250  CORNER_SIZE = 2,
251  TF_CENTER = 3
252  };
253 
272  {
273  bool shareLocation, varianceEncodedInTarget;
274  int backgroundLabelId, numClasses, topK, keepTopK;
275  float confidenceThreshold, nmsThreshold;
276  CodeTypeSSD codeType;
277  int inputOrder[3];
278  bool confSigmoid;
279  bool isNormalized;
280  };
281 
285  TENSORRTAPI INvPlugin * createSSDDetectionOutputPlugin(DetectionOutputParameters param);
286  TENSORRTAPI INvPlugin * createSSDDetectionOutputPlugin(const void * data, size_t length);
287 
293  TENSORRTAPI INvPlugin * createConcatPlugin(int concatAxis, bool ignoreBatch);
294  TENSORRTAPI INvPlugin * createConcatPlugin(const void * data, size_t length);
295 
300  TENSORRTAPI INvPlugin * createPReLUPlugin(float negSlope);
301  TENSORRTAPI INvPlugin * createPReLUPlugin(const void * data, size_t length);
302 
307  TENSORRTAPI INvPlugin * createYOLOReorgPlugin(int stride);
308  TENSORRTAPI INvPlugin * createYOLOReorgPlugin(const void * data, size_t length);
309 
318  typedef struct{
319  int *leaf;
320  int n;
321  int *parent;
322  int *child;
323  int *group;
324  char **name;
325 
326  int groups;
327  int *groupSize;
328  int *groupOffset;
329  } softmaxTree; // softmax tree
330 
332  {
333  int num;
334  int coords;
335  int classes;
336  softmaxTree * smTree;
337  };
338 
339  TENSORRTAPI INvPlugin * createYOLORegionPlugin(RegionParameters params);
340  TENSORRTAPI INvPlugin * createYOLORegionPlugin(const void * data, size_t length);
341 
342 } // end plugin namespace
343 } // end nvinfer1 namespace
344 #endif // NV_INFER_PLUGIN_H
The Permute plugin layer permutes the input tensor by changing the memory order of the data...
Definition: NvInferPlugin.h:166
YOLO PReLU Plugin.
virtual const char * getName() const =0
Get the name of the plugin from the ID.
SSD Grid Anchor Generator.
PluginType
The type values for the various plugins.
Definition: NvInferPlugin.h:70
virtual PluginType getPluginType() const =0
Get the parameter plugin ID.
Plugin class for user-implemented layers.
Definition: NvInfer.h:2355
Common interface for the Nvidia created plugins.
Definition: NvInferPlugin.h:100
FasterRCNN fused plugin (RPN + ROI pooling).
SSD DetectionOutput plugin.
The PriorBox plugin layer generates the prior boxes of designated sizes and aspect ratios across all ...
Definition: NvInferPlugin.h:196
virtual void destroy()=0
Destroy the plugin.
An array of weights used as a layer parameter.
Definition: NvInfer.h:493
The Region plugin layer performs region proposal calculation: generate 5 bounding boxes per cell (for...
Definition: NvInferPlugin.h:318
Definition: NvInferPlugin.h:331
Descriptor for two-dimensional spatial data.
Definition: NvInfer.h:201
The Anchor Generator plugin layer generates the prior boxes of designated sizes and aspect ratios acr...
Definition: NvInferPlugin.h:220
The DetectionOutput plugin layer generates the detection output based on location and confidence pred...
Definition: NvInferPlugin.h:271