TensorRT  7.1.3.0
NvInferRuntimeCommon.h
Go to the documentation of this file.
1 /*
2  * Copyright 1993-2020 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_RUNTIME_COMMON_H
51 #define NV_INFER_RUNTIME_COMMON_H
52 
53 #include <cstddef>
54 #include <cstdint>
55 #include "NvInferVersion.h"
56 
57 #if __cplusplus >= 201103L
58 #define _TENSORRT_FINAL final
59 #define _TENSORRT_OVERRIDE override
60 #else
61 #define _TENSORRT_FINAL
62 #define _TENSORRT_OVERRIDE
63 #endif
64 
66 #if __cplusplus >= 201402L
67 #define TRT_DEPRECATED [[deprecated]]
68 #if __GNUC__ < 6
69 #define TRT_DEPRECATED_ENUM
70 #else
71 #define TRT_DEPRECATED_ENUM TRT_DEPRECATED
72 #endif
73 #ifdef _MSC_VER
74 #define TRT_DEPRECATED_API __declspec(dllexport)
75 #else
76 #define TRT_DEPRECATED_API [[deprecated]] __attribute__((visibility("default")))
77 #endif
78 #else
79 #ifdef _MSC_VER
80 #define TRT_DEPRECATED
81 #define TRT_DEPRECATED_ENUM
82 #define TRT_DEPRECATED_API __declspec(dllexport)
83 #else
84 #define TRT_DEPRECATED __attribute__((deprecated))
85 #define TRT_DEPRECATED_ENUM
86 #define TRT_DEPRECATED_API __attribute__((deprecated, visibility("default")))
87 #endif
88 #endif
89 
91 #ifdef TENSORRT_BUILD_LIB
92 #ifdef _MSC_VER
93 #define TENSORRTAPI __declspec(dllexport)
94 #else
95 #define TENSORRTAPI __attribute__((visibility("default")))
96 #endif
97 #else
98 #define TENSORRTAPI
99 #endif
100 #define TRTNOEXCEPT
101 
107 // forward declare some CUDA types to avoid an include dependency
108 
109 struct cublasContext;
110 struct cudnnContext;
111 
112 typedef struct CUstream_st* cudaStream_t;
113 typedef struct CUevent_st* cudaEvent_t;
114 
115 static const int NV_TENSORRT_VERSION = (NV_TENSORRT_MAJOR * 1000) + (NV_TENSORRT_MINOR * 100) + NV_TENSORRT_PATCH; // major, minor, patch
116 
122 namespace nvinfer1
123 {
124 
125 class IErrorRecorder;
126 class IGpuAllocator;
127 
133 enum class ActivationType : int
134 {
135  kRELU = 0,
136  kSIGMOID = 1,
137  kTANH = 2,
138  kLEAKY_RELU = 3,
139  kELU = 4,
140  kSELU = 5,
141  kSOFTSIGN = 6,
142  kSOFTPLUS = 7,
143  kCLIP = 8,
144  kHARD_SIGMOID = 9,
145  kSCALED_TANH = 10,
146  kTHRESHOLDED_RELU = 11
147 };
148 
149 template <typename T>
150 constexpr inline int EnumMax();
151 
152 template <>
153 constexpr inline int EnumMax<ActivationType>()
154 {
155  return 12;
156 }
157 
163 enum class DataType : int
164 {
166  kFLOAT = 0,
167 
169  kHALF = 1,
170 
172  kINT8 = 2,
173 
175  kINT32 = 3,
176 
178  kBOOL = 4
179 };
180 
181 template <>
182 constexpr inline int EnumMax<DataType>()
183 {
184  return 5;
185 }
186 
191 enum class DimensionType : int
192 {
193  kSPATIAL = 0,
194  kCHANNEL = 1,
195  kINDEX = 2,
196  kSEQUENCE = 3
197 };
198 
199 template <>
200 constexpr inline int EnumMax<DimensionType>()
201 {
202  return 4;
203 }
204 
219 class Dims
220 {
221 public:
222  static const int MAX_DIMS = 8;
223  int nbDims;
224  int d[MAX_DIMS];
225  TRT_DEPRECATED DimensionType type[MAX_DIMS];
226 };
227 
234 typedef uint32_t TensorFormats;
235 
249 enum class TensorFormat : int
250 {
258  kLINEAR = 0,
259  kNCHW TRT_DEPRECATED_ENUM = kLINEAR,
260 
267  kCHW2 = 1,
268  kNC2HW2 TRT_DEPRECATED_ENUM = kCHW2,
269 
276  kHWC8 = 2,
277  kNHWC8 TRT_DEPRECATED_ENUM = kHWC8,
278 
288  kCHW4 = 3,
289 
300  kCHW16 = 4,
301 
312  kCHW32 = 5
313 };
314 
321 
322 template <>
323 constexpr inline int EnumMax<TensorFormat>()
324 {
325  return 6;
326 }
327 
339 {
340  Dims dims;
342  TensorFormat format;
343  float scale;
344 };
345 
352 enum class PluginVersion : uint8_t
353 {
354  kV2 = 0,
355  kV2_EXT = 1,
356  kV2_IOEXT = 2,
357  kV2_DYNAMICEXT = 3,
358 };
359 
372 {
373 public:
379  virtual int getTensorRTVersion() const TRTNOEXCEPT
380  {
381  return NV_TENSORRT_VERSION;
382  }
383 
386  // \see IPluginCreator::getPluginName()
388  virtual const char* getPluginType() const TRTNOEXCEPT = 0;
389 
392  // \see IPluginCreator::getPluginVersion()
394  virtual const char* getPluginVersion() const TRTNOEXCEPT = 0;
395 
403  virtual int getNbOutputs() const TRTNOEXCEPT = 0;
404 
414  virtual Dims getOutputDimensions(int index, const Dims* inputs, int nbInputDims) TRTNOEXCEPT = 0;
415 
432  virtual bool supportsFormat(DataType type, PluginFormat format) const TRTNOEXCEPT = 0;
433 
456  virtual void configureWithFormat(const Dims* inputDims, int nbInputs, const Dims* outputDims, int nbOutputs, DataType type, PluginFormat format, int maxBatchSize) TRTNOEXCEPT = 0;
457 
463  virtual int initialize() TRTNOEXCEPT = 0;
464 
469  virtual void terminate() TRTNOEXCEPT = 0;
470 
479  virtual size_t getWorkspaceSize(int maxBatchSize) const TRTNOEXCEPT = 0;
480 
492  virtual int enqueue(int batchSize, const void* const* inputs, void** outputs, void* workspace, cudaStream_t stream) TRTNOEXCEPT = 0;
493 
499  virtual size_t getSerializationSize() const TRTNOEXCEPT = 0;
500 
508  virtual void serialize(void* buffer) const TRTNOEXCEPT = 0;
509 
513  virtual void destroy() TRTNOEXCEPT = 0;
514 
518  virtual IPluginV2* clone() const TRTNOEXCEPT = 0;
519 
524  virtual void setPluginNamespace(const char* pluginNamespace) TRTNOEXCEPT = 0;
525 
529  virtual const char* getPluginNamespace() const TRTNOEXCEPT = 0;
530 
531 protected:
532  virtual ~IPluginV2() {}
533 };
534 
545 class IPluginV2Ext : public IPluginV2
546 {
547 public:
556  virtual nvinfer1::DataType getOutputDataType(int index, const nvinfer1::DataType* inputTypes, int nbInputs) const TRTNOEXCEPT = 0;
557 
568  virtual bool isOutputBroadcastAcrossBatch(int outputIndex, const bool* inputIsBroadcasted, int nbInputs) const TRTNOEXCEPT = 0;
569 
583  virtual bool canBroadcastInputAcrossBatch(int inputIndex) const TRTNOEXCEPT = 0;
584 
611 
612  virtual void configurePlugin(const Dims* inputDims, int nbInputs, const Dims* outputDims,
613  int nbOutputs, const DataType* inputTypes, const DataType* outputTypes,
614  const bool* inputIsBroadcast, const bool* outputIsBroadcast, PluginFormat floatFormat, int maxBatchSize) TRTNOEXCEPT = 0;
615 
616  virtual ~IPluginV2Ext() {}
617 
629  virtual void attachToContext(cudnnContext* /*cudnn*/, cublasContext* /*cublas*/, IGpuAllocator* /*allocator*/) TRTNOEXCEPT {}
630 
637  virtual void detachFromContext() TRTNOEXCEPT {}
638 
644  virtual IPluginV2Ext* clone() const _TENSORRT_OVERRIDE TRTNOEXCEPT = 0;
645 
646 protected:
653  int getTensorRTVersion() const _TENSORRT_OVERRIDE TRTNOEXCEPT
654  {
655  return (static_cast<int>(PluginVersion::kV2_EXT) << 24 | (NV_TENSORRT_VERSION & 0xFFFFFF));
656  }
657 
661  void configureWithFormat(const Dims* /*inputDims*/, int /*nbInputs*/, const Dims* /*outputDims*/,
662  int /*nbOutputs*/, DataType /*type*/, PluginFormat /*format*/, int /*maxBatchSize*/) _TENSORRT_OVERRIDE TRTNOEXCEPT {}
663 };
664 
675 {
676 public:
688  virtual void configurePlugin(const PluginTensorDesc* in, int nbInput, const PluginTensorDesc* out, int nbOutput) TRTNOEXCEPT = 0;
689 
721  virtual bool supportsFormatCombination(int pos, const PluginTensorDesc* inOut, int nbInputs, int nbOutputs) const TRTNOEXCEPT = 0;
722 
723 protected:
731  TRT_DEPRECATED
733  {
734  return (static_cast<int>(PluginVersion::kV2_IOEXT) << 24 | (NV_TENSORRT_VERSION & 0xFFFFFF));
735  }
736 
741  TRT_DEPRECATED
743  const Dims*, int, const Dims*, int, DataType, PluginFormat, int) _TENSORRT_OVERRIDE _TENSORRT_FINAL
744  {
745  }
746 
751  TRT_DEPRECATED
752  void configurePlugin(const Dims*, int, const Dims*, int, const DataType*, const DataType*, const bool*, const bool*,
753  PluginFormat, int) _TENSORRT_OVERRIDE _TENSORRT_FINAL
754  {
755  }
756 
761  TRT_DEPRECATED
763  {
764  return false;
765  }
766 };
767 
772 
773 enum class PluginFieldType : int
774 {
775  kFLOAT16 = 0,
776  kFLOAT32 = 1,
777  kFLOAT64 = 2,
778  kINT8 = 3,
779  kINT16 = 4,
780  kINT32 = 5,
781  kCHAR = 6,
782  kDIMS = 7,
783  kUNKNOWN = 8
784 };
785 
794 {
795 public:
799  const char* name{nullptr};
803  const void* data{nullptr};
808  PluginFieldType type{PluginFieldType::kUNKNOWN};
812  int32_t length{0};
813 
814  PluginField(const char* name_ = nullptr, const void* data_ = nullptr, const PluginFieldType type_ = PluginFieldType::kUNKNOWN, int32_t length_ = 0)
815  : name(name_)
816  , data(data_)
817  , type(type_)
818  , length(length_)
819  {
820  }
821 };
822 
824 {
825  int nbFields;
827 };
828 
836 
838 {
839 public:
843  virtual int getTensorRTVersion() const TRTNOEXCEPT { return NV_TENSORRT_VERSION; }
844 
848  virtual const char* getPluginName() const TRTNOEXCEPT = 0;
849 
853  virtual const char* getPluginVersion() const TRTNOEXCEPT = 0;
854 
859  virtual const PluginFieldCollection* getFieldNames() TRTNOEXCEPT = 0;
860 
864  virtual IPluginV2* createPlugin(const char* name, const PluginFieldCollection* fc) TRTNOEXCEPT = 0;
865 
869  virtual IPluginV2* deserializePlugin(const char* name, const void* serialData, size_t serialLength) TRTNOEXCEPT = 0;
870 
877  virtual void setPluginNamespace(const char* pluginNamespace) TRTNOEXCEPT = 0;
878 
882  virtual const char* getPluginNamespace() const TRTNOEXCEPT = 0;
883 
884  virtual ~IPluginCreator() {}
885 };
886 
901 
903 {
904 public:
909  virtual bool registerCreator(IPluginCreator& creator, const char* pluginNamespace) noexcept = 0;
910 
915  virtual IPluginCreator* const* getPluginCreatorList(int* numCreators) const noexcept = 0;
916 
921  virtual IPluginCreator* getPluginCreator(const char* pluginType, const char* pluginVersion, const char* pluginNamespace = "") noexcept = 0;
922 
923 protected:
924  virtual ~IPluginRegistry() noexcept {}
925 
926 public:
936  //
939  virtual void setErrorRecorder(IErrorRecorder* recorder) noexcept = 0;
940 
952  virtual IErrorRecorder* getErrorRecorder() const noexcept = 0;
953 };
954 
955 
960 enum class TensorLocation : int
961 {
962  kDEVICE = 0,
963  kHOST = 1,
964 };
965 
966 template <>
967 constexpr inline int EnumMax<TensorLocation>()
968 {
969  return 2;
970 }
971 
978 {
979 public:
994  virtual void* allocate(uint64_t size, uint64_t alignment, uint32_t flags) TRTNOEXCEPT = 0;
995 
1003  virtual void free(void* memory) TRTNOEXCEPT = 0;
1004 
1009  virtual ~IGpuAllocator() {}
1010 };
1011 
1020 class ILogger
1021 {
1022 public:
1028  enum class Severity : int
1029  {
1030  kINTERNAL_ERROR = 0,
1031  kERROR = 1,
1032  kWARNING = 2,
1033  kINFO = 3,
1034  kVERBOSE = 4,
1035  };
1036 
1043  virtual void log(Severity severity, const char* msg) TRTNOEXCEPT = 0;
1044 
1045  virtual ~ILogger() {}
1046 };
1047 
1048 template <>
1049 constexpr inline int EnumMax<ILogger::Severity>()
1050 {
1051  return 5;
1052 }
1053 
1059 enum class ErrorCode : int
1060 {
1064  kSUCCESS = 0,
1065 
1069  kUNSPECIFIED_ERROR = 1,
1070 
1074  kINTERNAL_ERROR = 2,
1075 
1080  kINVALID_ARGUMENT = 3,
1081 
1089  kINVALID_CONFIG = 4,
1090 
1096  kFAILED_ALLOCATION = 5,
1097 
1103 
1110  kFAILED_EXECUTION = 7,
1111 
1118  kFAILED_COMPUTATION = 8,
1119 
1132  kINVALID_STATE = 9,
1133 
1144  kUNSUPPORTED_STATE = 10,
1145 
1146 };
1147 
1148 template <>
1149 constexpr inline int EnumMax<ErrorCode>()
1150 {
1151  return 11;
1152 }
1153 
1176 {
1177 public:
1181  using ErrorDesc = const char*;
1182 
1186  using RefCount = int32_t;
1187 
1188  virtual ~IErrorRecorder() noexcept {};
1189 
1190  // Public API’s used to retrieve information from the error recorder.
1191 
1205  virtual int32_t getNbErrors() const noexcept = 0;
1206 
1219  virtual ErrorCode getErrorCode(int32_t errorIdx) const noexcept = 0;
1220 
1235  virtual ErrorDesc getErrorDesc(int32_t errorIdx) const noexcept = 0;
1236 
1246  virtual bool hasOverflowed() const noexcept = 0;
1247 
1257  virtual void clear() noexcept = 0;
1258 
1259  // API’s used by TensorRT to report Error information to the application.
1260 
1273  virtual bool reportError(ErrorCode val, ErrorDesc desc) noexcept = 0;
1274 
1287  virtual RefCount incRefCount() noexcept = 0;
1288 
1300  virtual RefCount decRefCount() noexcept = 0;
1301 
1302 }; // class IErrorRecorder
1303 
1304 } // namespace nvinfer1
1305 
1310 extern "C" TENSORRTAPI void* createSafeInferRuntime_INTERNAL(void* logger, int version);
1311 
1315 extern "C" TENSORRTAPI nvinfer1::ILogger* getLogger();
1316 
1322 extern "C" TENSORRTAPI int getInferLibVersion();
1323 
1327 extern "C" TENSORRTAPI nvinfer1::IPluginRegistry* getPluginRegistry();
1328 
1329 namespace nvinfer1
1330 {
1331 
1338 template <typename T>
1340 {
1341 public:
1342  PluginRegistrar() { getPluginRegistry()->registerCreator(instance, ""); }
1343 private:
1344  T instance{};
1345 };
1346 
1347 #define REGISTER_TENSORRT_PLUGIN(name) \
1348  static nvinfer1::PluginRegistrar<name> pluginRegistrar##name {}
1349 
1350 } // namespace nvinfer1
1351 
1352 #endif // NV_INFER_RUNTIME_COMMON_H
nvinfer1::ErrorCode::kINVALID_CONFIG
nvinfer1::IGpuAllocator::free
virtual void free(void *memory)=0
nvinfer1::TensorFormat::kCHW16
nvinfer1::ActivationType::kSCALED_TANH
Scaled tanh activation: alpha*tanh(beta*x)
nvinfer1::ActivationType
ActivationType
Forward declare IGpuAllocator for use in other interfaces.
Definition: NvInferRuntimeCommon.h:133
nvinfer1::ErrorCode::kFAILED_COMPUTATION
nvinfer1::ILogger::Severity::kERROR
An application error has occurred.
nvinfer1::IPluginV2::supportsFormat
virtual bool supportsFormat(DataType type, PluginFormat format) const =0
Check format support.
nvinfer1::IPluginV2::getPluginType
virtual const char * getPluginType() const =0
Return the plugin type. Should match the plugin name returned by the corresponding plugin creator.
nvinfer1::IPluginRegistry::getErrorRecorder
virtual IErrorRecorder * getErrorRecorder() const noexcept=0
set the ErrorRecorder assigned to this interface.
nvinfer1::PluginFieldType::kFLOAT64
FP64 field type.
nvinfer1::IPluginV2::getNbOutputs
virtual int getNbOutputs() const =0
Get the number of outputs from the layer.
nvinfer1::ILogger::Severity
Severity
Definition: NvInferRuntimeCommon.h:1028
nvinfer1::IPluginCreator::getPluginNamespace
virtual const char * getPluginNamespace() const =0
Return the namespace of the plugin creator object.
nvinfer1::IPluginV2Ext::isOutputBroadcastAcrossBatch
virtual bool isOutputBroadcastAcrossBatch(int outputIndex, const bool *inputIsBroadcasted, int nbInputs) const =0
Return true if output tensor is broadcast across a batch.
nvinfer1::IPluginCreator::getPluginName
virtual const char * getPluginName() const =0
Return the plugin name.
nvinfer1::IPluginV2Ext::clone
virtual IPluginV2Ext * clone() const _TENSORRT_OVERRIDE=0
Clone the plugin object. This copies over internal plugin parameters as well and returns a new plugin...
nvinfer1::PluginRegistrar
Register the plugin creator to the registry The static registry object will be instantiated when the ...
Definition: NvInferRuntimeCommon.h:1339
nvinfer1::PluginVersion::kV2_IOEXT
IPluginV2Ext.
nvinfer1::IPluginV2::destroy
virtual void destroy()=0
Destroy the plugin object. This will be called when the network, builder or engine is destroyed.
nvinfer1::PluginFieldCollection::fields
const PluginField * fields
Pointer to PluginField entries.
Definition: NvInferRuntimeCommon.h:826
nvinfer1::DataType::kFLOAT
32-bit floating point format.
nvinfer1::ActivationType::kSOFTPLUS
Parametric softplus activation: alpha*log(exp(beta*x)+1)
nvinfer1::EnumMax
constexpr int EnumMax()
Maximum number of elements in an enumeration type.
nvinfer1::ActivationType::kTHRESHOLDED_RELU
Thresholded ReLU activation: x>alpha ? x : 0.
nvinfer1::IErrorRecorder::getErrorCode
virtual ErrorCode getErrorCode(int32_t errorIdx) const noexcept=0
Returns the ErrorCode enumeration.
nvinfer1::IPluginV2::setPluginNamespace
virtual void setPluginNamespace(const char *pluginNamespace)=0
Set the namespace that this plugin object belongs to. Ideally, all plugin objects from the same plugi...
nvinfer1::ErrorCode::kFAILED_INITIALIZATION
nvinfer1::IPluginV2
Plugin class for user-implemented layers.
Definition: NvInferRuntimeCommon.h:371
nvinfer1::TensorLocation
TensorLocation
The location for tensor data storage, device or host.
Definition: NvInferRuntimeCommon.h:960
nvinfer1::IPluginV2::getPluginVersion
virtual const char * getPluginVersion() const =0
Return the plugin version. Should match the plugin version returned by the corresponding plugin creat...
nvinfer1::TensorFormats
uint32_t TensorFormats
It is capable of representing one or more TensorFormat by binary OR operations, e....
Definition: NvInferRuntimeCommon.h:234
nvinfer1::IErrorRecorder::RefCount
int32_t RefCount
Definition: NvInferRuntimeCommon.h:1186
nvinfer1::EnumMax< DataType >
constexpr int EnumMax< DataType >()
Maximum number of elements in DataType enum.
Definition: NvInferRuntimeCommon.h:182
nvinfer1::ErrorCode::kUNSPECIFIED_ERROR
nvinfer1::Dims::nbDims
int nbDims
The number of dimensions.
Definition: NvInferRuntimeCommon.h:223
nvinfer1::ErrorCode::kINVALID_ARGUMENT
nvinfer1::PluginVersion::kV2_DYNAMICEXT
IPluginV2IOExt.
nvinfer1::IErrorRecorder::decRefCount
virtual RefCount decRefCount() noexcept=0
Decrements the refcount for the current ErrorRecorder.
nvinfer1::IErrorRecorder::getErrorDesc
virtual ErrorDesc getErrorDesc(int32_t errorIdx) const noexcept=0
Returns the c-style string description of the error.
nvinfer1::BuilderFlag::kINT8
Enable Int8 layer selection, with FP32 fallback with FP16 fallback if kFP16 also specified.
nvinfer1::IPluginRegistry::setErrorRecorder
virtual void setErrorRecorder(IErrorRecorder *recorder) noexcept=0
Set the ErrorRecorder for this interface.
nvinfer1::IPluginV2Ext::getOutputDataType
virtual nvinfer1::DataType getOutputDataType(int index, const nvinfer1::DataType *inputTypes, int nbInputs) const =0
Return the DataType of the plugin output at the requested index. The default behavior should be to re...
nvinfer1::DataType::kBOOL
8-bit boolean. 0 = false, 1 = true, other values undefined.
nvinfer1::ActivationType::kCLIP
Clip activation: max(alpha, min(beta, x))
nvinfer1::EnumMax< DimensionType >
constexpr int EnumMax< DimensionType >()
Maximum number of elements in DimensionType enum.
Definition: NvInferRuntimeCommon.h:200
nvinfer1::IPluginV2::enqueue
virtual int enqueue(int batchSize, const void *const *inputs, void **outputs, void *workspace, cudaStream_t stream)=0
Execute the layer.
nvinfer1::PluginFieldType
PluginFieldType
Definition: NvInferRuntimeCommon.h:773
nvinfer1::IPluginCreator::getPluginVersion
virtual const char * getPluginVersion() const =0
Return the plugin version.
nvinfer1::IPluginCreator
Plugin creator class for user implemented layers.
Definition: NvInferRuntimeCommon.h:837
nvinfer1::IPluginRegistry
Single registration point for all plugins in an application. It is used to find plugin implementation...
Definition: NvInferRuntimeCommon.h:902
nvinfer1::Dims
Structure to define the dimensions of a tensor.
Definition: NvInferRuntimeCommon.h:219
nvinfer1::ErrorCode::kFAILED_ALLOCATION
nvinfer1::PluginVersion::kV2_EXT
IPluginV2.
nvinfer1::PluginFieldType::kCHAR
char field type.
NvInferVersion.h
nvinfer1::ILogger
Application-implemented logging interface for the builder, engine and runtime.
Definition: NvInferRuntimeCommon.h:1020
nvinfer1::IPluginV2::serialize
virtual void serialize(void *buffer) const =0
Serialize the layer.
nvinfer1::ActivationType::kHARD_SIGMOID
Hard sigmoid activation: max(0, min(1, alpha*x+beta))
nvinfer1::IPluginV2Ext::canBroadcastInputAcrossBatch
virtual bool canBroadcastInputAcrossBatch(int inputIndex) const =0
Return true if plugin can use input that is broadcast across batch without replication.
nvinfer1::IPluginV2IOExt::getTensorRTVersion
TRT_DEPRECATED int getTensorRTVersion() const _TENSORRT_OVERRIDE
Return the API version with which this plugin was built. The upper byte is reserved by TensorRT and i...
Definition: NvInferRuntimeCommon.h:732
nvinfer1::IPluginV2IOExt::configurePlugin
TRT_DEPRECATED void configurePlugin(const Dims *, int, const Dims *, int, const DataType *, const DataType *, const bool *, const bool *, PluginFormat, int) _TENSORRT_OVERRIDE _TENSORRT_FINAL
Deprecated interface inheriting from base class. Derived classes should not implement this....
Definition: NvInferRuntimeCommon.h:752
nvinfer1::ActivationType::kELU
Elu activation: x>=0 ? x : alpha * (exp(x) - 1).
nvinfer1::PluginField::length
int32_t length
Number of data entries in the Plugin attribute.
Definition: NvInferRuntimeCommon.h:812
nvinfer1::DimensionType
DimensionType
The type of data encoded across this dimension.
Definition: NvInferRuntimeCommon.h:191
getLogger
nvinfer1::ILogger * getLogger()
Return the logger object.
nvinfer1::PluginField::type
PluginFieldType type
Plugin field attribute type.
Definition: NvInferRuntimeCommon.h:808
nvinfer1::TensorFormat::kCHW32
nvinfer1::PluginTensorDesc::type
DataType type
Definition: NvInferRuntimeCommon.h:341
nvinfer1::Dims::type
TRT_DEPRECATED DimensionType type[MAX_DIMS]
The type of each dimension.
Definition: NvInferRuntimeCommon.h:225
nvinfer1::IErrorRecorder::reportError
virtual bool reportError(ErrorCode val, ErrorDesc desc) noexcept=0
report an error to the error recorder with the corresponding enum and description.
nvinfer1::RNNInputMode::kLINEAR
Perform the normal matrix multiplication in the first recurrent layer.
nvinfer1::ILogger::log
virtual void log(Severity severity, const char *msg)=0
nvinfer1::EnumMax< ActivationType >
constexpr int EnumMax< ActivationType >()
Maximum number of elements in ActivationType enum.
Definition: NvInferRuntimeCommon.h:153
nvinfer1::ScaleMode::kCHANNEL
Per-channel coefficients.
nvinfer1
The TensorRT API version 1 namespace.
nvinfer1::TensorFormat
TensorFormat
Format of the input/output tensors.
Definition: NvInferRuntimeCommon.h:249
nvinfer1::IPluginV2Ext::getTensorRTVersion
int getTensorRTVersion() const _TENSORRT_OVERRIDE
Return the API version with which this plugin was built. The upper byte reserved by TensorRT and is u...
Definition: NvInferRuntimeCommon.h:653
nvinfer1::IGpuAllocator::allocate
virtual void * allocate(uint64_t size, uint64_t alignment, uint32_t flags)=0
nvinfer1::TensorLocation::kDEVICE
Data stored on device.
nvinfer1::TensorFormat::kNC2HW2
Deprecated name of kCHW2, provided for backwards compatibility.
nvinfer1::ActivationType::kLEAKY_RELU
LeakyRelu activation: x>=0 ? x : alpha * x.
nvinfer1::IErrorRecorder::ErrorDesc
const char * ErrorDesc
Definition: NvInferRuntimeCommon.h:1181
nvinfer1::IPluginV2::initialize
virtual int initialize()=0
Initialize the layer for execution. This is called when the engine is created.
NV_TENSORRT_MINOR
#define NV_TENSORRT_MINOR
TensorRT minor version.
Definition: NvInferVersion.h:60
nvinfer1::ActivationType::kSOFTSIGN
Softsign activation: x / (1+|x|)
cudaStream_t
struct CUstream_st * cudaStream_t
Forward declaration of cudaStream_t.
Definition: NvInferRuntimeCommon.h:112
nvinfer1::IPluginV2::terminate
virtual void terminate()=0
Release resources acquired during plugin layer initialization. This is called when the engine is dest...
nvinfer1::PluginFieldType::kFLOAT16
FP16 field type.
nvinfer1::TensorFormat::kNHWC8
Deprecated name of kHWC8, provided for backwards compatibility.
nvinfer1::ILogger::Severity::kINTERNAL_ERROR
An internal error has occurred. Execution is unrecoverable.
nvinfer1::IPluginRegistry::registerCreator
virtual bool registerCreator(IPluginCreator &creator, const char *pluginNamespace) noexcept=0
Register a plugin creator. Returns false if one with same type is already registered.
_TENSORRT_OVERRIDE
#define _TENSORRT_OVERRIDE
Items that are marked as deprecated will be removed in a future release.
Definition: NvInferRuntimeCommon.h:62
cudaEvent_t
struct CUevent_st * cudaEvent_t
Forward declaration of cudaEvent_t.
Definition: NvInferRuntimeCommon.h:113
nvinfer1::IPluginV2::configureWithFormat
virtual void configureWithFormat(const Dims *inputDims, int nbInputs, const Dims *outputDims, int nbOutputs, DataType type, PluginFormat format, int maxBatchSize)=0
Configure the layer.
nvinfer1::DataType
DataType
The type of weights and tensors.
Definition: NvInferRuntimeCommon.h:163
nvinfer1::PluginFieldType::kINT16
INT16 field type.
PluginVersion
Definition of plugin versions.
nvinfer1::RNNOperation::kRELU
Single gate RNN w/ ReLU activation function.
nvinfer1::EnumMax< ErrorCode >
constexpr int EnumMax< ErrorCode >()
Maximum number of elements in ErrorCode enum.
Definition: NvInferRuntimeCommon.h:1149
nvinfer1::IPluginCreator::setPluginNamespace
virtual void setPluginNamespace(const char *pluginNamespace)=0
Set the namespace of the plugin creator based on the plugin library it belongs to....
nvinfer1::ErrorCode::kINTERNAL_ERROR
nvinfer1::TensorFormat::kNCHW
Deprecated name of kLINEAR, provided for backwards compatibility.
nvinfer1::IErrorRecorder::incRefCount
virtual RefCount incRefCount() noexcept=0
Increments the refcount for the current ErrorRecorder.
nvinfer1::EnumMax< TensorLocation >
constexpr int EnumMax< TensorLocation >()
Maximum number of elements in TensorLocation enum.
Definition: NvInferRuntimeCommon.h:967
nvinfer1::IPluginV2::getSerializationSize
virtual size_t getSerializationSize() const =0
Find the size of the serialization buffer required.
nvinfer1::IPluginV2::getWorkspaceSize
virtual size_t getWorkspaceSize(int maxBatchSize) const =0
Find the workspace size required by the layer.
nvinfer1::IPluginCreator::createPlugin
virtual IPluginV2 * createPlugin(const char *name, const PluginFieldCollection *fc)=0
Return a plugin object. Return nullptr in case of error.
nvinfer1::IPluginV2IOExt::configureWithFormat
TRT_DEPRECATED void configureWithFormat(const Dims *, int, const Dims *, int, DataType, PluginFormat, int) _TENSORRT_OVERRIDE _TENSORRT_FINAL
Deprecated interface inheriting from base class. Derived classes should not implement this....
Definition: NvInferRuntimeCommon.h:742
nvinfer1::DimensionType::kSEQUENCE
Elements correspond to different sequence values.
nvinfer1::TensorFormat::kCHW4
nvinfer1::IPluginV2IOExt::supportsFormatCombination
virtual bool supportsFormatCombination(int pos, const PluginTensorDesc *inOut, int nbInputs, int nbOutputs) const =0
Return true if plugin supports the format and datatype for the input/output indexed by pos.
nvinfer1::IPluginV2IOExt
Plugin class for user-implemented layers.
Definition: NvInferRuntimeCommon.h:674
nvinfer1::RNNOperation::kTANH
Single gate RNN w/ TANH activation function.
nvinfer1::Dims::d
int d[MAX_DIMS]
The extent of each dimension.
Definition: NvInferRuntimeCommon.h:224
nvinfer1::ErrorCode::kINVALID_STATE
nvinfer1::IErrorRecorder::hasOverflowed
virtual bool hasOverflowed() const noexcept=0
Determine if the error stack has overflowed.
nvinfer1::IErrorRecorder
Reference counted application-implemented error reporting interface for TensorRT objects.
Definition: NvInferRuntimeCommon.h:1175
getPluginRegistry
nvinfer1::IPluginRegistry * getPluginRegistry()
Return the plugin registry.
nvinfer1::IPluginV2Ext::configurePlugin
virtual void configurePlugin(const Dims *inputDims, int nbInputs, const Dims *outputDims, int nbOutputs, const DataType *inputTypes, const DataType *outputTypes, const bool *inputIsBroadcast, const bool *outputIsBroadcast, PluginFormat floatFormat, int maxBatchSize)=0
Configure the layer with input and output data types.
nvinfer1::IPluginV2::getTensorRTVersion
virtual int getTensorRTVersion() const
Return the API version with which this plugin was built.
Definition: NvInferRuntimeCommon.h:379
nvinfer1::ILogger::Severity::kVERBOSE
Verbose messages with debugging information.
nvinfer1::IPluginV2Ext
Plugin class for user-implemented layers.
Definition: NvInferRuntimeCommon.h:545
nvinfer1::EnumMax< TensorFormat >
constexpr int EnumMax< TensorFormat >()
Maximum number of elements in TensorFormat enum.
Definition: NvInferRuntimeCommon.h:323
nvinfer1::IErrorRecorder::getNbErrors
virtual int32_t getNbErrors() const noexcept=0
Return the number of errors.
nvinfer1::ILogger::Severity::kINFO
Informational messages with instructional information.
nvinfer1::ErrorCode::kSUCCESS
nvinfer1::ILogger::Severity::kWARNING
An application error has been discovered, but TensorRT has recovered or fallen back to a default.
nvinfer1::Dims::MAX_DIMS
static const int MAX_DIMS
The maximum number of dimensions supported for a tensor.
Definition: NvInferRuntimeCommon.h:222
nvinfer1::IPluginCreator::getTensorRTVersion
virtual int getTensorRTVersion() const
Return the version of the API the plugin creator was compiled with.
Definition: NvInferRuntimeCommon.h:843
getInferLibVersion
int getInferLibVersion()
Return the library version number.
nvinfer1::IPluginV2Ext::detachFromContext
virtual void detachFromContext()
Detach the plugin object from its execution context.
Definition: NvInferRuntimeCommon.h:637
nvinfer1::IPluginV2::clone
virtual IPluginV2 * clone() const =0
Clone the plugin object. This copies over internal plugin parameters and returns a new plugin object ...
nvinfer1::IPluginRegistry::getPluginCreatorList
virtual IPluginCreator *const * getPluginCreatorList(int *numCreators) const noexcept=0
Return all the registered plugin creators and the number of registered plugin creators....
nvinfer1::PluginFieldCollection::nbFields
int nbFields
Number of PluginField entries.
Definition: NvInferRuntimeCommon.h:825
nvinfer1::ErrorCode::kFAILED_EXECUTION
nvinfer1::IPluginRegistry::getPluginCreator
virtual IPluginCreator * getPluginCreator(const char *pluginType, const char *pluginVersion, const char *pluginNamespace="") noexcept=0
Return plugin creator based on plugin type, version and namespace associated with plugin during netwo...
nvinfer1::TensorLocation::kHOST
Data stored on host.
nvinfer1::IPluginV2::getPluginNamespace
virtual const char * getPluginNamespace() const =0
Return the namespace of the plugin object.
nvinfer1::DimensionType::kINDEX
Elements correspond to different batch index.
nvinfer1::PluginTensorDesc
Fields that a plugin might see for an input or output.
Definition: NvInferRuntimeCommon.h:338
NV_TENSORRT_MAJOR
#define NV_TENSORRT_MAJOR
TensorRT major version.
Definition: NvInferVersion.h:59
nvinfer1::IGpuAllocator::~IGpuAllocator
virtual ~IGpuAllocator()
Definition: NvInferRuntimeCommon.h:1009
nvinfer1::IPluginV2IOExt::configurePlugin
virtual void configurePlugin(const PluginTensorDesc *in, int nbInput, const PluginTensorDesc *out, int nbOutput)=0
Configure the layer.
nvinfer1::IPluginCreator::deserializePlugin
virtual IPluginV2 * deserializePlugin(const char *name, const void *serialData, size_t serialLength)=0
Called during deserialization of plugin layer. Return a plugin object.
nvinfer1::TensorFormat::kHWC8
nvinfer1::IPluginV2IOExt::supportsFormat
TRT_DEPRECATED bool supportsFormat(DataType, PluginFormat) const _TENSORRT_OVERRIDE _TENSORRT_FINAL
Deprecated interface inheriting from base class. Derived classes should not implement this....
Definition: NvInferRuntimeCommon.h:762
nvinfer1::DataType::kHALF
IEEE 16-bit floating-point format.
nvinfer1::IErrorRecorder::clear
virtual void clear() noexcept=0
Clear the error stack on the error recorder.
nvinfer1::PluginFieldType::kDIMS
nvinfer1::Dims field type.
nvinfer1::PluginFieldType::kFLOAT32
FP32 field type.
nvinfer1::TensorFormat::kCHW2
nvinfer1::IPluginCreator::getFieldNames
virtual const PluginFieldCollection * getFieldNames()=0
Return a list of fields that needs to be passed to createPlugin.
nvinfer1::ActivationType::kSELU
Selu activation: x>0 ? beta * x : beta * (alpha*exp(x) - alpha)
nvinfer1::IGpuAllocator
Application-implemented class for controlling allocation on the GPU.
Definition: NvInferRuntimeCommon.h:977
nvinfer1::IPluginV2::getOutputDimensions
virtual Dims getOutputDimensions(int index, const Dims *inputs, int nbInputDims)=0
Get the dimension of an output tensor.
nvinfer1::PluginField::data
const void * data
Plugin field attribute data.
Definition: NvInferRuntimeCommon.h:803
NV_TENSORRT_PATCH
#define NV_TENSORRT_PATCH
TensorRT patch version.
Definition: NvInferVersion.h:61
nvinfer1::ErrorCode
ErrorCode
Error codes that can be returned by TensorRT during execution.
Definition: NvInferRuntimeCommon.h:1059
nvinfer1::PluginFieldCollection
Definition: NvInferRuntimeCommon.h:823
nvinfer1::PluginField
Structure containing plugin attribute field names and associated data This information can be parsed ...
Definition: NvInferRuntimeCommon.h:793
nvinfer1::DataType::kINT32
Signed 32-bit integer format.
nvinfer1::IPluginV2Ext::configureWithFormat
void configureWithFormat(const Dims *, int, const Dims *, int, DataType, PluginFormat, int) _TENSORRT_OVERRIDE
Derived classes should not implement this. In a C++11 API it would be override final.
Definition: NvInferRuntimeCommon.h:661
nvinfer1::ErrorCode::kUNSUPPORTED_STATE
nvinfer1::DimensionType::kSPATIAL
Elements correspond to different spatial data.
nvinfer1::IPluginV2Ext::attachToContext
virtual void attachToContext(cudnnContext *, cublasContext *, IGpuAllocator *)
Attach the plugin object to an execution context and grant the plugin the access to some context reso...
Definition: NvInferRuntimeCommon.h:629
nvinfer1::PluginField::name
const char * name
Plugin field attribute name.
Definition: NvInferRuntimeCommon.h:799
nvinfer1::ActivationType::kSIGMOID
Sigmoid activation.