TensorRT  7.2.1.6
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 
103 #define TRTNOEXCEPT
104 
110 // forward declare some CUDA types to avoid an include dependency
111 
112 struct cublasContext;
113 struct cudnnContext;
114 
115 typedef struct CUstream_st* cudaStream_t;
116 typedef struct CUevent_st* cudaEvent_t;
117 
118 static const int32_t NV_TENSORRT_VERSION
119  = (NV_TENSORRT_MAJOR * 1000) + (NV_TENSORRT_MINOR * 100) + NV_TENSORRT_PATCH; // major, minor, patch
120 
126 namespace nvinfer1
127 {
128 
129 class IErrorRecorder;
130 class IGpuAllocator;
131 
133 template <typename T>
134 constexpr inline int32_t EnumMax();
135 
141 enum class ActivationType : int32_t
142 {
143  kRELU = 0,
144  kSIGMOID = 1,
145  kTANH = 2,
146  kLEAKY_RELU = 3,
147  kELU = 4,
148  kSELU = 5,
149  kSOFTSIGN = 6,
150  kSOFTPLUS = 7,
151  kCLIP = 8,
152  kHARD_SIGMOID = 9,
153  kSCALED_TANH = 10,
154  kTHRESHOLDED_RELU = 11
155 };
156 
158 template <>
159 constexpr inline int32_t EnumMax<ActivationType>()
160 {
161  return 12;
162 }
163 
169 enum class DataType : int32_t
170 {
172  kFLOAT = 0,
173 
175  kHALF = 1,
176 
178  kINT8 = 2,
179 
181  kINT32 = 3,
182 
184  kBOOL = 4
185 };
186 
188 template <>
189 constexpr inline int32_t EnumMax<DataType>()
190 {
191  return 5;
192 }
193 
198 enum class DimensionType : int32_t
199 {
200  kSPATIAL = 0,
201  kCHANNEL = 1,
202  kINDEX = 2,
203  kSEQUENCE = 3
204 };
205 
207 template <>
208 constexpr inline int32_t EnumMax<DimensionType>()
209 {
210  return 4;
211 }
212 
227 class Dims
228 {
229 public:
230  static const int32_t MAX_DIMS = 8;
231  int32_t nbDims;
232  int32_t d[MAX_DIMS];
233  TRT_DEPRECATED DimensionType type[MAX_DIMS];
234 };
236 
243 typedef uint32_t TensorFormats;
244 
258 enum class TensorFormat : int32_t
259 {
264  kLINEAR = 0,
265  kNCHW TRT_DEPRECATED_ENUM = kLINEAR,
266 
274  kCHW2 = 1,
275  kNC2HW2 TRT_DEPRECATED_ENUM = kCHW2,
276 
284  kHWC8 = 2,
285  kNHWC8 TRT_DEPRECATED_ENUM = kHWC8,
286 
300  kCHW4 = 3,
301 
311  kCHW16 = 4,
312 
322  kCHW32 = 5,
323 
330  kDHWC8 = 6,
331 
338  kCDHW32 = 7,
339 
342  kHWC = 8
343 };
344 
351 
353 template <>
354 constexpr inline int32_t EnumMax<TensorFormat>()
355 {
356  return 9;
357 }
358 
370 {
371  Dims dims;
373  TensorFormat format;
374  float scale;
375 };
376 
383 enum class PluginVersion : uint8_t
384 {
385  kV2 = 0,
386  kV2_EXT = 1,
387  kV2_IOEXT = 2,
388  kV2_DYNAMICEXT = 3,
389 };
390 
403 {
404 public:
411  virtual int32_t getTensorRTVersion() const TRTNOEXCEPT
412  {
413  return NV_TENSORRT_VERSION;
414  }
415 
420  virtual const char* getPluginType() const TRTNOEXCEPT = 0;
421 
426  virtual const char* getPluginVersion() const TRTNOEXCEPT = 0;
427 
436  virtual int32_t getNbOutputs() const TRTNOEXCEPT = 0;
437 
448  virtual Dims getOutputDimensions(int32_t index, const Dims* inputs, int32_t nbInputDims) TRTNOEXCEPT = 0;
449 
467  virtual bool supportsFormat(DataType type, PluginFormat format) const TRTNOEXCEPT = 0;
468 
492  virtual void configureWithFormat(const Dims* inputDims, int32_t nbInputs, const Dims* outputDims, int32_t nbOutputs,
493  DataType type, PluginFormat format, int32_t maxBatchSize) TRTNOEXCEPT = 0;
494 
500  virtual int32_t initialize() TRTNOEXCEPT = 0;
501 
506  virtual void terminate() TRTNOEXCEPT = 0;
507 
516  virtual size_t getWorkspaceSize(int32_t maxBatchSize) const TRTNOEXCEPT = 0;
517 
529  virtual int32_t enqueue(int32_t batchSize, const void* const* inputs, void** outputs, void* workspace,
530  cudaStream_t stream) TRTNOEXCEPT = 0;
531 
537  virtual size_t getSerializationSize() const TRTNOEXCEPT = 0;
538 
546  virtual void serialize(void* buffer) const TRTNOEXCEPT = 0;
547 
551  virtual void destroy() TRTNOEXCEPT = 0;
552 
556  virtual IPluginV2* clone() const TRTNOEXCEPT = 0;
557 
562  virtual void setPluginNamespace(const char* pluginNamespace) TRTNOEXCEPT = 0;
563 
567  virtual const char* getPluginNamespace() const TRTNOEXCEPT = 0;
568 
569 protected:
570  virtual ~IPluginV2() {}
571 };
572 
583 class IPluginV2Ext : public IPluginV2
584 {
585 public:
594  int32_t index, const nvinfer1::DataType* inputTypes, int32_t nbInputs) const TRTNOEXCEPT = 0;
595 
606  virtual bool isOutputBroadcastAcrossBatch(
607  int32_t outputIndex, const bool* inputIsBroadcasted, int32_t nbInputs) const TRTNOEXCEPT = 0;
608 
622  virtual bool canBroadcastInputAcrossBatch(int32_t inputIndex) const TRTNOEXCEPT = 0;
623 
651 
652  virtual void configurePlugin(const Dims* inputDims, int32_t nbInputs, const Dims* outputDims, int32_t nbOutputs,
653  const DataType* inputTypes, const DataType* outputTypes, const bool* inputIsBroadcast,
654  const bool* outputIsBroadcast, PluginFormat floatFormat, int32_t maxBatchSize) TRTNOEXCEPT = 0;
655 
656  virtual ~IPluginV2Ext() {}
657 
669  virtual void attachToContext(cudnnContext* /*cudnn*/, cublasContext* /*cublas*/, IGpuAllocator* /*allocator*/) TRTNOEXCEPT {}
670 
677  virtual void detachFromContext() TRTNOEXCEPT {}
678 
684  virtual IPluginV2Ext* clone() const _TENSORRT_OVERRIDE TRTNOEXCEPT = 0;
685 
686 protected:
695  {
696  return (static_cast<int32_t>(PluginVersion::kV2_EXT) << 24 | (NV_TENSORRT_VERSION & 0xFFFFFF));
697  }
698 
702  void configureWithFormat(const Dims* /*inputDims*/, int32_t /*nbInputs*/, const Dims* /*outputDims*/,
703  int32_t /*nbOutputs*/, DataType /*type*/, PluginFormat /*format*/,
704  int32_t /*maxBatchSize*/) _TENSORRT_OVERRIDE TRTNOEXCEPT
705  {
706  }
707 };
708 
719 {
720 public:
732  virtual void configurePlugin(
733  const PluginTensorDesc* in, int32_t nbInput, const PluginTensorDesc* out, int32_t nbOutput) TRTNOEXCEPT = 0;
734 
767  virtual bool supportsFormatCombination(
768  int32_t pos, const PluginTensorDesc* inOut, int32_t nbInputs, int32_t nbOutputs) const TRTNOEXCEPT = 0;
769 
770 protected:
780  TRT_DEPRECATED
782  {
783  return (static_cast<int32_t>(PluginVersion::kV2_IOEXT) << 24 | (NV_TENSORRT_VERSION & 0xFFFFFF));
784  }
785 
792  TRT_DEPRECATED
794  const Dims*, int32_t, const Dims*, int32_t, DataType, PluginFormat, int32_t) _TENSORRT_OVERRIDE _TENSORRT_FINAL
795  {
796  }
797 
804  TRT_DEPRECATED
805  void configurePlugin(const Dims*, int32_t, const Dims*, int32_t, const DataType*, const DataType*, const bool*,
806  const bool*, PluginFormat, int32_t) _TENSORRT_OVERRIDE _TENSORRT_FINAL
807  {
808  }
809 
816  TRT_DEPRECATED
818  {
819  return false;
820  }
821 };
822 
827 
828 enum class PluginFieldType : int32_t
829 {
830  kFLOAT16 = 0,
831  kFLOAT32 = 1,
832  kFLOAT64 = 2,
833  kINT8 = 3,
834  kINT16 = 4,
835  kINT32 = 5,
836  kCHAR = 6,
837  kDIMS = 7,
838  kUNKNOWN = 8
839 };
840 
849 {
850 public:
854  const char* name{nullptr};
858  const void* data{nullptr};
863  PluginFieldType type{PluginFieldType::kUNKNOWN};
867  int32_t length{0};
868 
869  PluginField(const char* name_ = nullptr, const void* data_ = nullptr, const PluginFieldType type_ = PluginFieldType::kUNKNOWN, int32_t length_ = 0)
870  : name(name_)
871  , data(data_)
872  , type(type_)
873  , length(length_)
874  {
875  }
876 };
877 
879 {
880  int32_t nbFields;
882 };
883 
891 
893 {
894 public:
898  virtual int32_t getTensorRTVersion() const TRTNOEXCEPT
899  {
900  return NV_TENSORRT_VERSION;
901  }
902 
906  virtual const char* getPluginName() const TRTNOEXCEPT = 0;
907 
911  virtual const char* getPluginVersion() const TRTNOEXCEPT = 0;
912 
917  virtual const PluginFieldCollection* getFieldNames() TRTNOEXCEPT = 0;
918 
922  virtual IPluginV2* createPlugin(const char* name, const PluginFieldCollection* fc) TRTNOEXCEPT = 0;
923 
927  virtual IPluginV2* deserializePlugin(const char* name, const void* serialData, size_t serialLength) TRTNOEXCEPT = 0;
928 
935  virtual void setPluginNamespace(const char* pluginNamespace) TRTNOEXCEPT = 0;
936 
940  virtual const char* getPluginNamespace() const TRTNOEXCEPT = 0;
941 
942  virtual ~IPluginCreator() {}
943 };
944 
959 
961 {
962 public:
967  virtual bool registerCreator(IPluginCreator& creator, const char* pluginNamespace) noexcept = 0;
968 
973  virtual IPluginCreator* const* getPluginCreatorList(int32_t* numCreators) const noexcept = 0;
974 
979  virtual IPluginCreator* getPluginCreator(const char* pluginType, const char* pluginVersion, const char* pluginNamespace = "") noexcept = 0;
980 
981 protected:
982  virtual ~IPluginRegistry() noexcept {}
983 
984 public:
994  //
997  virtual void setErrorRecorder(IErrorRecorder* recorder) noexcept = 0;
998 
1010  virtual IErrorRecorder* getErrorRecorder() const noexcept = 0;
1011 };
1012 
1017 enum class TensorLocation : int32_t
1018 {
1019  kDEVICE = 0,
1020  kHOST = 1,
1021 };
1022 
1024 template <>
1025 constexpr inline int32_t EnumMax<TensorLocation>()
1026 {
1027  return 2;
1028 }
1029 
1036 {
1037 public:
1052  virtual void* allocate(uint64_t size, uint64_t alignment, uint32_t flags) TRTNOEXCEPT = 0;
1053 
1061  virtual void free(void* memory) TRTNOEXCEPT = 0;
1062 
1067  virtual ~IGpuAllocator() {}
1068 };
1069 
1078 class ILogger
1079 {
1080 public:
1086  enum class Severity : int32_t
1087  {
1088  kINTERNAL_ERROR = 0,
1089  kERROR = 1,
1090  kWARNING = 2,
1091  kINFO = 3,
1092  kVERBOSE = 4,
1093  };
1094 
1101  virtual void log(Severity severity, const char* msg) TRTNOEXCEPT = 0;
1102 
1103  virtual ~ILogger() {}
1104 };
1105 
1107 template <>
1108 constexpr inline int32_t EnumMax<ILogger::Severity>()
1109 {
1110  return 5;
1111 }
1112 
1118 enum class ErrorCode : int32_t
1119 {
1123  kSUCCESS = 0,
1124 
1128  kUNSPECIFIED_ERROR = 1,
1129 
1133  kINTERNAL_ERROR = 2,
1134 
1139  kINVALID_ARGUMENT = 3,
1140 
1148  kINVALID_CONFIG = 4,
1149 
1155  kFAILED_ALLOCATION = 5,
1156 
1162 
1169  kFAILED_EXECUTION = 7,
1170 
1177  kFAILED_COMPUTATION = 8,
1178 
1191  kINVALID_STATE = 9,
1192 
1203  kUNSUPPORTED_STATE = 10,
1204 
1205 };
1206 
1208 template <>
1209 constexpr inline int32_t EnumMax<ErrorCode>()
1210 {
1211  return 11;
1212 }
1213 
1236 {
1237 public:
1241  using ErrorDesc = const char*;
1242 
1246  using RefCount = int32_t;
1247 
1248  virtual ~IErrorRecorder() noexcept {};
1249 
1250  // Public API’s used to retrieve information from the error recorder.
1251 
1265  virtual int32_t getNbErrors() const noexcept = 0;
1266 
1279  virtual ErrorCode getErrorCode(int32_t errorIdx) const noexcept = 0;
1280 
1295  virtual ErrorDesc getErrorDesc(int32_t errorIdx) const noexcept = 0;
1296 
1306  virtual bool hasOverflowed() const noexcept = 0;
1307 
1317  virtual void clear() noexcept = 0;
1318 
1319  // API’s used by TensorRT to report Error information to the application.
1320 
1333  virtual bool reportError(ErrorCode val, ErrorDesc desc) noexcept = 0;
1334 
1347  virtual RefCount incRefCount() noexcept = 0;
1348 
1360  virtual RefCount decRefCount() noexcept = 0;
1361 
1362 }; // class IErrorRecorder
1363 
1364 } // namespace nvinfer1
1365 
1370 extern "C" TENSORRTAPI void* createSafeInferRuntime_INTERNAL(void* logger, int32_t version);
1371 
1375 extern "C" TENSORRTAPI nvinfer1::ILogger* getLogger();
1376 
1382 extern "C" TENSORRTAPI int32_t getInferLibVersion();
1383 
1387 extern "C" TENSORRTAPI nvinfer1::IPluginRegistry* getPluginRegistry();
1388 
1389 namespace nvinfer1
1390 {
1391 
1398 template <typename T>
1400 {
1401 public:
1402  PluginRegistrar() { getPluginRegistry()->registerCreator(instance, ""); }
1403 private:
1404  T instance{};
1405 };
1406 
1407 #define REGISTER_TENSORRT_PLUGIN(name) \
1408  static nvinfer1::PluginRegistrar<name> pluginRegistrar##name {}
1409 
1410 } // namespace nvinfer1
1411 
1412 #endif // NV_INFER_RUNTIME_COMMON_H
nvinfer1::ActivationType::kHARD_SIGMOID
Hard sigmoid activation: max(0, min(1, alpha*x+beta))
nvinfer1::ILogger::Severity::kWARNING
Application error has been discovered. TensorRT has recovered or fallen back to a default.
nvinfer1::IGpuAllocator::free
virtual void free(void *memory)=0
nvinfer1::IPluginCreator::getTensorRTVersion
virtual int32_t getTensorRTVersion() const
Return the version of the API the plugin creator was compiled with.
Definition: NvInferRuntimeCommon.h:898
nvinfer1::ErrorCode::kINVALID_ARGUMENT
nvinfer1::ILogger::Severity::kINTERNAL_ERROR
Internal error has occurred. Execution is unrecoverable.
nvinfer1::ErrorCode::kFAILED_ALLOCATION
nvinfer1::ActivationType::kSOFTPLUS
Parametric softplus activation: alpha*log(exp(beta*x)+1)
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::Dims::nbDims
int32_t nbDims
The number of dimensions.
Definition: NvInferRuntimeCommon.h:231
nvinfer1::TensorFormat::kCDHW32
nvinfer1::IPluginRegistry::getPluginCreatorList
virtual IPluginCreator *const * getPluginCreatorList(int32_t *numCreators) const noexcept=0
Return all the registered plugin creators and the number of registered plugin creators....
nvinfer1::TensorFormat::kCHW16
nvinfer1::TensorFormat::kCHW32
nvinfer1::IPluginCreator::getPluginNamespace
virtual const char * getPluginNamespace() const =0
Return the namespace of the plugin creator object.
nvinfer1::IPluginV2Ext::isOutputBroadcastAcrossBatch
virtual bool isOutputBroadcastAcrossBatch(int32_t outputIndex, const bool *inputIsBroadcasted, int32_t 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::DataType::kINT32
Signed 32-bit integer format.
nvinfer1::ScaleMode::kCHANNEL
Per-channel coefficients.
nvinfer1::IPluginV2Ext::getTensorRTVersion
int32_t 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:694
nvinfer1::IPluginV2Ext::configureWithFormat
void configureWithFormat(const Dims *, int32_t, const Dims *, int32_t, DataType, PluginFormat, int32_t) _TENSORRT_OVERRIDE
Derived classes should not implement this. In a C++11 API it would be override final.
Definition: NvInferRuntimeCommon.h:702
nvinfer1::PluginRegistrar
Register the plugin creator to the registry The static registry object will be instantiated when the ...
Definition: NvInferRuntimeCommon.h:1399
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:881
nvinfer1::ErrorCode
ErrorCode
Error codes that can be returned by TensorRT during execution.
Definition: NvInferRuntimeCommon.h:1118
nvinfer1::PluginFieldType::kDIMS
nvinfer1::Dims field type.
nvinfer1::IPluginV2IOExt::getTensorRTVersion
TRT_DEPRECATED int32_t 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:781
nvinfer1::ActivationType::kSELU
Selu activation: x>0 ? beta * x : beta * (alpha*exp(x) - alpha)
nvinfer1::DataType::kBOOL
8-bit boolean. 0 = false, 1 = true, other values undefined.
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::ActivationType::kCLIP
Clip activation: max(alpha, min(beta, x))
nvinfer1::IPluginV2
Plugin class for user-implemented layers.
Definition: NvInferRuntimeCommon.h:402
nvinfer1::ActivationType::kSCALED_TANH
Scaled tanh activation: alpha*tanh(beta*x)
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:243
nvinfer1::ActivationType::kSOFTSIGN
Softsign activation: x / (1+|x|)
nvinfer1::IErrorRecorder::RefCount
int32_t RefCount
Definition: NvInferRuntimeCommon.h:1246
nvinfer1::IPluginV2IOExt::supportsFormatCombination
virtual bool supportsFormatCombination(int32_t pos, const PluginTensorDesc *inOut, int32_t nbInputs, int32_t nbOutputs) const =0
Return true if plugin supports the format and datatype for the input/output indexed by pos.
nvinfer1::DataType::kHALF
IEEE 16-bit floating-point format.
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::PluginFieldType::kCHAR
char field type.
nvinfer1::IPluginCreator::getPluginVersion
virtual const char * getPluginVersion() const =0
Return the plugin version.
nvinfer1::TensorFormat
TensorFormat
Format of the input/output tensors.
Definition: NvInferRuntimeCommon.h:258
nvinfer1::IPluginCreator
Plugin creator class for user implemented layers.
Definition: NvInferRuntimeCommon.h:892
nvinfer1::IPluginRegistry
Single registration point for all plugins in an application. It is used to find plugin implementation...
Definition: NvInferRuntimeCommon.h:960
nvinfer1::TensorFormat::kDHWC8
nvinfer1::Dims
Structure to define the dimensions of a tensor.
Definition: NvInferRuntimeCommon.h:227
nvinfer1::PluginVersion::kV2_EXT
IPluginV2.
nvinfer1::IPluginV2Ext::canBroadcastInputAcrossBatch
virtual bool canBroadcastInputAcrossBatch(int32_t inputIndex) const =0
Return true if plugin can use input that is broadcast across batch without replication.
NvInferVersion.h
nvinfer1::PluginFieldType
PluginFieldType
Definition: NvInferRuntimeCommon.h:828
nvinfer1::ILogger
Application-implemented logging interface for the builder, engine and runtime.
Definition: NvInferRuntimeCommon.h:1078
nvinfer1::IPluginV2::serialize
virtual void serialize(void *buffer) const =0
Serialize the layer.
nvinfer1::EnumMax< ErrorCode >
constexpr int32_t EnumMax< ErrorCode >()
Maximum number of elements in ErrorCode enum.
Definition: NvInferRuntimeCommon.h:1209
nvinfer1::ActivationType
ActivationType
Enumerates the types of activation to perform in an activation layer.
Definition: NvInferRuntimeCommon.h:141
nvinfer1::EnumMax< TensorLocation >
constexpr int32_t EnumMax< TensorLocation >()
Maximum number of elements in TensorLocation enum.
Definition: NvInferRuntimeCommon.h:1025
nvinfer1::ILogger::Severity::kERROR
Application error has occurred.
TRTNOEXCEPT
#define TRTNOEXCEPT
Definition: NvInferRuntimeCommon.h:103
nvinfer1::Dims::d
int32_t d[MAX_DIMS]
The extent of each dimension.
Definition: NvInferRuntimeCommon.h:232
nvinfer1::IPluginV2IOExt::configurePlugin
TRT_DEPRECATED void configurePlugin(const Dims *, int32_t, const Dims *, int32_t, const DataType *, const DataType *, const bool *, const bool *, PluginFormat, int32_t) _TENSORRT_OVERRIDE _TENSORRT_FINAL
Deprecated interface inheriting from base class. Derived classes should not implement this....
Definition: NvInferRuntimeCommon.h:805
nvinfer1::RNNOperation::kRELU
Single gate RNN w/ ReLU activation function.
nvinfer1::TensorFormat::kNC2HW2
be removed in TensorRT 8.0.
nvinfer1::IPluginV2Ext::getOutputDataType
virtual nvinfer1::DataType getOutputDataType(int32_t index, const nvinfer1::DataType *inputTypes, int32_t nbInputs) const =0
Return the DataType of the plugin output at the requested index. The default behavior should be to re...
nvinfer1::PluginField::length
int32_t length
Number of data entries in the Plugin attribute.
Definition: NvInferRuntimeCommon.h:867
getLogger
nvinfer1::ILogger * getLogger()
Return the logger object.
nvinfer1::EnumMax< DimensionType >
constexpr int32_t EnumMax< DimensionType >()
Maximum number of elements in DimensionType enum.
Definition: NvInferRuntimeCommon.h:208
nvinfer1::PluginField::type
PluginFieldType type
Plugin field attribute type.
Definition: NvInferRuntimeCommon.h:863
nvinfer1::PluginTensorDesc::type
DataType type
Definition: NvInferRuntimeCommon.h:372
nvinfer1::Dims::type
TRT_DEPRECATED DimensionType type[MAX_DIMS]
Definition: NvInferRuntimeCommon.h:233
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::EnumMax< TensorFormat >
constexpr int32_t EnumMax< TensorFormat >()
Maximum number of elements in TensorFormat enum.
Definition: NvInferRuntimeCommon.h:354
nvinfer1::ILogger::log
virtual void log(Severity severity, const char *msg)=0
nvinfer1::PluginFieldType::kINT16
INT16 field type.
nvinfer1::TensorFormat::kHWC8
nvinfer1::EnumMax< DataType >
constexpr int32_t EnumMax< DataType >()
Maximum number of elements in DataType enum.
Definition: NvInferRuntimeCommon.h:189
nvinfer1
The TensorRT API version 1 namespace.
nvinfer1::TensorLocation::kHOST
Data stored on host.
nvinfer1::IGpuAllocator::allocate
virtual void * allocate(uint64_t size, uint64_t alignment, uint32_t flags)=0
nvinfer1::ActivationType::kTHRESHOLDED_RELU
Thresholded ReLU activation: x>alpha ? x : 0.
nvinfer1::TensorFormat::kNHWC8
be removed in TensorRT 8.0.
nvinfer1::IErrorRecorder::ErrorDesc
const char * ErrorDesc
Definition: NvInferRuntimeCommon.h:1241
NV_TENSORRT_MINOR
#define NV_TENSORRT_MINOR
TensorRT minor version.
Definition: NvInferVersion.h:60
nvinfer1::IPluginV2::getTensorRTVersion
virtual int32_t getTensorRTVersion() const
Return the API version with which this plugin was built.
Definition: NvInferRuntimeCommon.h:411
cudaStream_t
struct CUstream_st * cudaStream_t
Forward declaration of cudaStream_t.
Definition: NvInferRuntimeCommon.h:115
nvinfer1::IPluginV2::terminate
virtual void terminate()=0
Release resources acquired during plugin layer initialization. This is called when the engine is dest...
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.
nvinfer1::ErrorCode::kUNSUPPORTED_STATE
nvinfer1::TensorFormat::kHWC
_TENSORRT_OVERRIDE
#define _TENSORRT_OVERRIDE
Items that are marked as deprecated will be removed in a future release.
Definition: NvInferRuntimeCommon.h:62
nvinfer1::IPluginV2IOExt::configurePlugin
virtual void configurePlugin(const PluginTensorDesc *in, int32_t nbInput, const PluginTensorDesc *out, int32_t nbOutput)=0
Configure the layer.
cudaEvent_t
struct CUevent_st * cudaEvent_t
Forward declaration of cudaEvent_t.
Definition: NvInferRuntimeCommon.h:116
nvinfer1::ErrorCode::kINVALID_CONFIG
nvinfer1::ErrorCode::kSUCCESS
PluginVersion
Definition of plugin versions.
nvinfer1::RNNInputMode::kLINEAR
Perform the normal matrix multiplication in the first recurrent layer.
nvinfer1::PluginFieldType::kFLOAT64
FP64 field type.
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::PluginFieldCollection::nbFields
int32_t nbFields
Number of PluginField entries.
Definition: NvInferRuntimeCommon.h:880
nvinfer1::TensorFormat::kNCHW
be removed in TensorRT 8.0.
nvinfer1::IErrorRecorder::incRefCount
virtual RefCount incRefCount() noexcept=0
Increments the refcount for the current ErrorRecorder.
nvinfer1::PluginFieldType::kFLOAT16
FP16 field type.
nvinfer1::IPluginV2::getSerializationSize
virtual size_t getSerializationSize() const =0
Find the size of the serialization buffer required.
nvinfer1::DataType
DataType
The type of weights and tensors.
Definition: NvInferRuntimeCommon.h:169
nvinfer1::ActivationType::kELU
Elu activation: x>=0 ? x : alpha * (exp(x) - 1).
nvinfer1::IPluginV2::getWorkspaceSize
virtual size_t getWorkspaceSize(int32_t 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::TensorFormat::kCHW4
nvinfer1::ILogger::Severity
Severity
Definition: NvInferRuntimeCommon.h:1086
nvinfer1::Dims::MAX_DIMS
static const int32_t MAX_DIMS
The maximum number of dimensions supported for a tensor.
Definition: NvInferRuntimeCommon.h:230
nvinfer1::IPluginV2IOExt
Plugin class for user-implemented layers.
Definition: NvInferRuntimeCommon.h:718
nvinfer1::ActivationType::kLEAKY_RELU
LeakyRelu activation: x>=0 ? x : alpha * x.
nvinfer1::TensorLocation::kDEVICE
Data stored on device.
getInferLibVersion
int32_t getInferLibVersion()
Return the library version number.
nvinfer1::ErrorCode::kFAILED_INITIALIZATION
nvinfer1::IErrorRecorder::hasOverflowed
virtual bool hasOverflowed() const noexcept=0
Determine if the error stack has overflowed.
nvinfer1::EnumMax< ActivationType >
constexpr int32_t EnumMax< ActivationType >()
Maximum number of elements in ActivationType enum.
Definition: NvInferRuntimeCommon.h:159
nvinfer1::IErrorRecorder
Reference counted application-implemented error reporting interface for TensorRT objects.
Definition: NvInferRuntimeCommon.h:1235
nvinfer1::ErrorCode::kFAILED_COMPUTATION
getPluginRegistry
nvinfer1::IPluginRegistry * getPluginRegistry()
Return the plugin registry.
nvinfer1::ILogger::Severity::kVERBOSE
Verbose messages with debugging information.
nvinfer1::IPluginV2::getOutputDimensions
virtual Dims getOutputDimensions(int32_t index, const Dims *inputs, int32_t nbInputDims)=0
Get the dimension of an output tensor.
nvinfer1::ActivationType::kSIGMOID
Sigmoid activation.
nvinfer1::IPluginV2Ext
Plugin class for user-implemented layers.
Definition: NvInferRuntimeCommon.h:583
nvinfer1::ErrorCode::kUNSPECIFIED_ERROR
nvinfer1::IErrorRecorder::getNbErrors
virtual int32_t getNbErrors() const noexcept=0
Return the number of errors.
nvinfer1::DataType::kFLOAT
32-bit floating point format.
nvinfer1::TensorFormat::kCHW2
nvinfer1::IPluginV2Ext::detachFromContext
virtual void detachFromContext()
Detach the plugin object from its execution context.
Definition: NvInferRuntimeCommon.h:677
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::DimensionType
DimensionType
The type of data encoded across this dimension.
Definition: NvInferRuntimeCommon.h:198
nvinfer1::IPluginV2::enqueue
virtual int32_t enqueue(int32_t batchSize, const void *const *inputs, void **outputs, void *workspace, cudaStream_t stream)=0
Execute the layer.
nvinfer1::IPluginV2IOExt::configureWithFormat
TRT_DEPRECATED void configureWithFormat(const Dims *, int32_t, const Dims *, int32_t, DataType, PluginFormat, int32_t) _TENSORRT_OVERRIDE _TENSORRT_FINAL
Deprecated interface inheriting from base class. Derived classes should not implement this....
Definition: NvInferRuntimeCommon.h:793
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::ILogger::Severity::kINFO
Informational messages with instructional information.
nvinfer1::PluginFieldType::kFLOAT32
FP32 field type.
nvinfer1::IPluginV2::getPluginNamespace
virtual const char * getPluginNamespace() const =0
Return the namespace of the plugin object.
nvinfer1::PluginTensorDesc
Fields that a plugin might see for an input or output.
Definition: NvInferRuntimeCommon.h:369
NV_TENSORRT_MAJOR
#define NV_TENSORRT_MAJOR
TensorRT major version.
Definition: NvInferVersion.h:59
nvinfer1::IGpuAllocator::~IGpuAllocator
virtual ~IGpuAllocator()
Definition: NvInferRuntimeCommon.h:1067
nvinfer1::ErrorCode::kINVALID_STATE
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::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:817
nvinfer1::IErrorRecorder::clear
virtual void clear() noexcept=0
Clear the error stack on the error recorder.
nvinfer1::EnumMax
constexpr int32_t EnumMax()
Forward declare IGpuAllocator for use in other interfaces.
nvinfer1::RNNOperation::kTANH
Single gate RNN w/ TANH activation function.
nvinfer1::IPluginV2::configureWithFormat
virtual void configureWithFormat(const Dims *inputDims, int32_t nbInputs, const Dims *outputDims, int32_t nbOutputs, DataType type, PluginFormat format, int32_t maxBatchSize)=0
Configure the layer.
nvinfer1::IPluginCreator::getFieldNames
virtual const PluginFieldCollection * getFieldNames()=0
Return a list of fields that needs to be passed to createPlugin.
nvinfer1::DimensionType::kSEQUENCE
Elements correspond to different sequence values.
nvinfer1::IGpuAllocator
Application-implemented class for controlling allocation on the GPU.
Definition: NvInferRuntimeCommon.h:1035
nvinfer1::IPluginV2::initialize
virtual int32_t initialize()=0
Initialize the layer for execution. This is called when the engine is created.
nvinfer1::DimensionType::kSPATIAL
Elements correspond to different spatial data.
nvinfer1::ErrorCode::kINTERNAL_ERROR
nvinfer1::PluginField::data
const void * data
Plugin field attribute data.
Definition: NvInferRuntimeCommon.h:858
NV_TENSORRT_PATCH
#define NV_TENSORRT_PATCH
TensorRT patch version.
Definition: NvInferVersion.h:61
nvinfer1::ErrorCode::kFAILED_EXECUTION
nvinfer1::PluginFieldCollection
Definition: NvInferRuntimeCommon.h:878
nvinfer1::PluginField
Structure containing plugin attribute field names and associated data This information can be parsed ...
Definition: NvInferRuntimeCommon.h:848
nvinfer1::DimensionType::kINDEX
Elements correspond to different batch index.
nvinfer1::TensorLocation
TensorLocation
The location for tensor data storage, device or host.
Definition: NvInferRuntimeCommon.h:1017
nvinfer1::IPluginV2Ext::configurePlugin
virtual void configurePlugin(const Dims *inputDims, int32_t nbInputs, const Dims *outputDims, int32_t nbOutputs, const DataType *inputTypes, const DataType *outputTypes, const bool *inputIsBroadcast, const bool *outputIsBroadcast, PluginFormat floatFormat, int32_t maxBatchSize)=0
Configure the layer with input and output data types.
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:669
nvinfer1::PluginField::name
const char * name
Plugin field attribute name.
Definition: NvInferRuntimeCommon.h:854
nvinfer1::IPluginV2::getNbOutputs
virtual int32_t getNbOutputs() const =0
Get the number of outputs from the layer.