TensorRT  7.2.3.4
NvInferRuntimeCommon.h
Go to the documentation of this file.
1 /*
2  * Copyright 1993-2021 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 {
265  kLINEAR = 0,
268  kNCHW TRT_DEPRECATED_ENUM = kLINEAR,
269 
276  kCHW2 = 1,
279  kNC2HW2 TRT_DEPRECATED_ENUM = kCHW2,
280 
287  kHWC8 = 2,
290  kNHWC8 TRT_DEPRECATED_ENUM = kHWC8,
291 
307  kCHW4 = 3,
308 
318  kCHW16 = 4,
319 
329  kCHW32 = 5,
330 
337  kDHWC8 = 6,
338 
345  kCDHW32 = 7,
346 
349  kHWC = 8,
350 
359  kDLA_LINEAR = 9,
360 
373  kDLA_HWC4 = 10
374 };
375 
382 
384 template <>
385 constexpr inline int32_t EnumMax<TensorFormat>()
386 {
387  return 11;
388 }
389 
401 {
402  Dims dims;
404  TensorFormat format;
405  float scale;
406 };
407 
414 enum class PluginVersion : uint8_t
415 {
416  kV2 = 0,
417  kV2_EXT = 1,
418  kV2_IOEXT = 2,
419  kV2_DYNAMICEXT = 3,
420 };
421 
434 {
435 public:
442  virtual int32_t getTensorRTVersion() const TRTNOEXCEPT
443  {
444  return NV_TENSORRT_VERSION;
445  }
446 
451  virtual const char* getPluginType() const TRTNOEXCEPT = 0;
452 
457  virtual const char* getPluginVersion() const TRTNOEXCEPT = 0;
458 
467  virtual int32_t getNbOutputs() const TRTNOEXCEPT = 0;
468 
479  virtual Dims getOutputDimensions(int32_t index, const Dims* inputs, int32_t nbInputDims) TRTNOEXCEPT = 0;
480 
498  virtual bool supportsFormat(DataType type, PluginFormat format) const TRTNOEXCEPT = 0;
499 
523  virtual void configureWithFormat(const Dims* inputDims, int32_t nbInputs, const Dims* outputDims, int32_t nbOutputs,
524  DataType type, PluginFormat format, int32_t maxBatchSize) TRTNOEXCEPT = 0;
525 
531  virtual int32_t initialize() TRTNOEXCEPT = 0;
532 
537  virtual void terminate() TRTNOEXCEPT = 0;
538 
547  virtual size_t getWorkspaceSize(int32_t maxBatchSize) const TRTNOEXCEPT = 0;
548 
560  virtual int32_t enqueue(int32_t batchSize, const void* const* inputs, void** outputs, void* workspace,
561  cudaStream_t stream) TRTNOEXCEPT = 0;
562 
568  virtual size_t getSerializationSize() const TRTNOEXCEPT = 0;
569 
577  virtual void serialize(void* buffer) const TRTNOEXCEPT = 0;
578 
582  virtual void destroy() TRTNOEXCEPT = 0;
583 
587  virtual IPluginV2* clone() const TRTNOEXCEPT = 0;
588 
593  virtual void setPluginNamespace(const char* pluginNamespace) TRTNOEXCEPT = 0;
594 
598  virtual const char* getPluginNamespace() const TRTNOEXCEPT = 0;
599 
600 protected:
601  virtual ~IPluginV2() {}
602 };
603 
614 class IPluginV2Ext : public IPluginV2
615 {
616 public:
625  int32_t index, const nvinfer1::DataType* inputTypes, int32_t nbInputs) const TRTNOEXCEPT = 0;
626 
637  virtual bool isOutputBroadcastAcrossBatch(
638  int32_t outputIndex, const bool* inputIsBroadcasted, int32_t nbInputs) const TRTNOEXCEPT = 0;
639 
653  virtual bool canBroadcastInputAcrossBatch(int32_t inputIndex) const TRTNOEXCEPT = 0;
654 
682 
683  virtual void configurePlugin(const Dims* inputDims, int32_t nbInputs, const Dims* outputDims, int32_t nbOutputs,
684  const DataType* inputTypes, const DataType* outputTypes, const bool* inputIsBroadcast,
685  const bool* outputIsBroadcast, PluginFormat floatFormat, int32_t maxBatchSize) TRTNOEXCEPT = 0;
686 
687  virtual ~IPluginV2Ext() {}
688 
700  virtual void attachToContext(cudnnContext* /*cudnn*/, cublasContext* /*cublas*/, IGpuAllocator* /*allocator*/) TRTNOEXCEPT {}
701 
708  virtual void detachFromContext() TRTNOEXCEPT {}
709 
715  virtual IPluginV2Ext* clone() const _TENSORRT_OVERRIDE TRTNOEXCEPT = 0;
716 
717 protected:
726  {
727  return (static_cast<int32_t>(PluginVersion::kV2_EXT) << 24 | (NV_TENSORRT_VERSION & 0xFFFFFF));
728  }
729 
733  void configureWithFormat(const Dims* /*inputDims*/, int32_t /*nbInputs*/, const Dims* /*outputDims*/,
734  int32_t /*nbOutputs*/, DataType /*type*/, PluginFormat /*format*/,
735  int32_t /*maxBatchSize*/) _TENSORRT_OVERRIDE TRTNOEXCEPT
736  {
737  }
738 };
739 
750 {
751 public:
763  virtual void configurePlugin(
764  const PluginTensorDesc* in, int32_t nbInput, const PluginTensorDesc* out, int32_t nbOutput) TRTNOEXCEPT = 0;
765 
798  virtual bool supportsFormatCombination(
799  int32_t pos, const PluginTensorDesc* inOut, int32_t nbInputs, int32_t nbOutputs) const TRTNOEXCEPT = 0;
800 
801 protected:
811  TRT_DEPRECATED
813  {
814  return (static_cast<int32_t>(PluginVersion::kV2_IOEXT) << 24 | (NV_TENSORRT_VERSION & 0xFFFFFF));
815  }
816 
823  TRT_DEPRECATED
825  const Dims*, int32_t, const Dims*, int32_t, DataType, PluginFormat, int32_t) _TENSORRT_OVERRIDE _TENSORRT_FINAL
826  {
827  }
828 
835  TRT_DEPRECATED
836  void configurePlugin(const Dims*, int32_t, const Dims*, int32_t, const DataType*, const DataType*, const bool*,
837  const bool*, PluginFormat, int32_t) _TENSORRT_OVERRIDE _TENSORRT_FINAL
838  {
839  }
840 
847  TRT_DEPRECATED
849  {
850  return false;
851  }
852 };
853 
858 
859 enum class PluginFieldType : int32_t
860 {
861  kFLOAT16 = 0,
862  kFLOAT32 = 1,
863  kFLOAT64 = 2,
864  kINT8 = 3,
865  kINT16 = 4,
866  kINT32 = 5,
867  kCHAR = 6,
868  kDIMS = 7,
869  kUNKNOWN = 8
870 };
871 
880 {
881 public:
885  const char* name{nullptr};
889  const void* data{nullptr};
894  PluginFieldType type{PluginFieldType::kUNKNOWN};
898  int32_t length{0};
899 
900  PluginField(const char* name_ = nullptr, const void* data_ = nullptr, const PluginFieldType type_ = PluginFieldType::kUNKNOWN, int32_t length_ = 0)
901  : name(name_)
902  , data(data_)
903  , type(type_)
904  , length(length_)
905  {
906  }
907 };
908 
910 {
911  int32_t nbFields;
913 };
914 
922 
924 {
925 public:
929  virtual int32_t getTensorRTVersion() const TRTNOEXCEPT
930  {
931  return NV_TENSORRT_VERSION;
932  }
933 
937  virtual const char* getPluginName() const TRTNOEXCEPT = 0;
938 
942  virtual const char* getPluginVersion() const TRTNOEXCEPT = 0;
943 
948  virtual const PluginFieldCollection* getFieldNames() TRTNOEXCEPT = 0;
949 
953  virtual IPluginV2* createPlugin(const char* name, const PluginFieldCollection* fc) TRTNOEXCEPT = 0;
954 
958  virtual IPluginV2* deserializePlugin(const char* name, const void* serialData, size_t serialLength) TRTNOEXCEPT = 0;
959 
966  virtual void setPluginNamespace(const char* pluginNamespace) TRTNOEXCEPT = 0;
967 
971  virtual const char* getPluginNamespace() const TRTNOEXCEPT = 0;
972 
973  virtual ~IPluginCreator() {}
974 };
975 
990 
992 {
993 public:
998  virtual bool registerCreator(IPluginCreator& creator, const char* pluginNamespace) noexcept = 0;
999 
1004  virtual IPluginCreator* const* getPluginCreatorList(int32_t* numCreators) const noexcept = 0;
1005 
1010  virtual IPluginCreator* getPluginCreator(const char* pluginType, const char* pluginVersion, const char* pluginNamespace = "") noexcept = 0;
1011 
1012 protected:
1013  virtual ~IPluginRegistry() noexcept {}
1014 
1015 public:
1025  //
1028  virtual void setErrorRecorder(IErrorRecorder* recorder) noexcept = 0;
1029 
1041  virtual IErrorRecorder* getErrorRecorder() const noexcept = 0;
1042 };
1043 
1048 enum class TensorLocation : int32_t
1049 {
1050  kDEVICE = 0,
1051  kHOST = 1,
1052 };
1053 
1055 template <>
1056 constexpr inline int32_t EnumMax<TensorLocation>()
1057 {
1058  return 2;
1059 }
1060 
1067 {
1068 public:
1083  virtual void* allocate(uint64_t size, uint64_t alignment, uint32_t flags) TRTNOEXCEPT = 0;
1084 
1092  virtual void free(void* memory) TRTNOEXCEPT = 0;
1093 
1098  virtual ~IGpuAllocator() {}
1099 };
1100 
1109 class ILogger
1110 {
1111 public:
1117  enum class Severity : int32_t
1118  {
1119  kINTERNAL_ERROR = 0,
1120  kERROR = 1,
1121  kWARNING = 2,
1122  kINFO = 3,
1123  kVERBOSE = 4,
1124  };
1125 
1132  virtual void log(Severity severity, const char* msg) TRTNOEXCEPT = 0;
1133 
1134  virtual ~ILogger() {}
1135 };
1136 
1138 template <>
1139 constexpr inline int32_t EnumMax<ILogger::Severity>()
1140 {
1141  return 5;
1142 }
1143 
1149 enum class ErrorCode : int32_t
1150 {
1154  kSUCCESS = 0,
1155 
1159  kUNSPECIFIED_ERROR = 1,
1160 
1164  kINTERNAL_ERROR = 2,
1165 
1170  kINVALID_ARGUMENT = 3,
1171 
1179  kINVALID_CONFIG = 4,
1180 
1186  kFAILED_ALLOCATION = 5,
1187 
1193 
1200  kFAILED_EXECUTION = 7,
1201 
1208  kFAILED_COMPUTATION = 8,
1209 
1222  kINVALID_STATE = 9,
1223 
1234  kUNSUPPORTED_STATE = 10,
1235 
1236 };
1237 
1239 template <>
1240 constexpr inline int32_t EnumMax<ErrorCode>()
1241 {
1242  return 11;
1243 }
1244 
1267 {
1268 public:
1272  using ErrorDesc = const char*;
1273 
1277  using RefCount = int32_t;
1278 
1279  virtual ~IErrorRecorder() noexcept {};
1280 
1281  // Public API’s used to retrieve information from the error recorder.
1282 
1296  virtual int32_t getNbErrors() const noexcept = 0;
1297 
1310  virtual ErrorCode getErrorCode(int32_t errorIdx) const noexcept = 0;
1311 
1326  virtual ErrorDesc getErrorDesc(int32_t errorIdx) const noexcept = 0;
1327 
1337  virtual bool hasOverflowed() const noexcept = 0;
1338 
1348  virtual void clear() noexcept = 0;
1349 
1350  // API’s used by TensorRT to report Error information to the application.
1351 
1364  virtual bool reportError(ErrorCode val, ErrorDesc desc) noexcept = 0;
1365 
1378  virtual RefCount incRefCount() noexcept = 0;
1379 
1391  virtual RefCount decRefCount() noexcept = 0;
1392 
1393 }; // class IErrorRecorder
1394 
1395 } // namespace nvinfer1
1396 
1401 extern "C" TENSORRTAPI void* createSafeInferRuntime_INTERNAL(void* logger, int32_t version);
1402 
1406 extern "C" TENSORRTAPI nvinfer1::ILogger* getLogger();
1407 
1413 extern "C" TENSORRTAPI int32_t getInferLibVersion();
1414 
1418 extern "C" TENSORRTAPI nvinfer1::IPluginRegistry* getPluginRegistry();
1419 
1420 namespace nvinfer1
1421 {
1422 
1429 template <typename T>
1431 {
1432 public:
1433  PluginRegistrar() { getPluginRegistry()->registerCreator(instance, ""); }
1434 private:
1435  T instance{};
1436 };
1437 
1438 #define REGISTER_TENSORRT_PLUGIN(name) \
1439  static nvinfer1::PluginRegistrar<name> pluginRegistrar##name {}
1440 
1441 } // namespace nvinfer1
1442 
1443 #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:929
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:725
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:733
nvinfer1::PluginRegistrar
Register the plugin creator to the registry The static registry object will be instantiated when the ...
Definition: NvInferRuntimeCommon.h:1430
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:912
nvinfer1::ErrorCode
ErrorCode
Error codes that can be returned by TensorRT during execution.
Definition: NvInferRuntimeCommon.h:1149
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:812
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:433
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:1277
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:923
nvinfer1::IPluginRegistry
Single registration point for all plugins in an application. It is used to find plugin implementation...
Definition: NvInferRuntimeCommon.h:991
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:859
nvinfer1::ILogger
Application-implemented logging interface for the builder, engine and runtime.
Definition: NvInferRuntimeCommon.h:1109
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:1240
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:1056
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:836
nvinfer1::RNNOperation::kRELU
Single gate RNN w/ ReLU activation function.
nvinfer1::TensorFormat::kNC2HW2
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:898
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:894
nvinfer1::PluginTensorDesc::type
DataType type
Definition: NvInferRuntimeCommon.h:403
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:385
nvinfer1::ILogger::log
virtual void log(Severity severity, const char *msg)=0
nvinfer1::TensorFormat::kDLA_HWC4
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
nvinfer1::IErrorRecorder::ErrorDesc
const char * ErrorDesc
Definition: NvInferRuntimeCommon.h:1272
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:442
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:911
nvinfer1::TensorFormat::kNCHW
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:1117
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:749
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:1266
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:614
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:708
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:824
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:400
NV_TENSORRT_MAJOR
#define NV_TENSORRT_MAJOR
TensorRT major version.
Definition: NvInferVersion.h:59
nvinfer1::IGpuAllocator::~IGpuAllocator
virtual ~IGpuAllocator()
Definition: NvInferRuntimeCommon.h:1098
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:848
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:1066
nvinfer1::TensorFormat::kDLA_LINEAR
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:889
NV_TENSORRT_PATCH
#define NV_TENSORRT_PATCH
TensorRT patch version.
Definition: NvInferVersion.h:61
nvinfer1::ErrorCode::kFAILED_EXECUTION
nvinfer1::PluginFieldCollection
Definition: NvInferRuntimeCommon.h:909
nvinfer1::PluginField
Structure containing plugin attribute field names and associated data This information can be parsed ...
Definition: NvInferRuntimeCommon.h:879
nvinfer1::DimensionType::kINDEX
Elements correspond to different batch index.
nvinfer1::TensorLocation
TensorLocation
The location for tensor data storage, device or host.
Definition: NvInferRuntimeCommon.h:1048
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:700
nvinfer1::PluginField::name
const char * name
Plugin field attribute name.
Definition: NvInferRuntimeCommon.h:885
nvinfer1::IPluginV2::getNbOutputs
virtual int32_t getNbOutputs() const =0
Get the number of outputs from the layer.