50 #ifndef NV_INFER_RUNTIME_COMMON_H 51 #define NV_INFER_RUNTIME_COMMON_H 55 #include "NvInferVersion.h" 57 #if __cplusplus > 201103L 58 #define _TENSORRT_FINAL final 59 #define _TENSORRT_OVERRIDE override 61 #define _TENSORRT_FINAL 62 #define _TENSORRT_OVERRIDE 66 #if __cplusplus >= 201402L 67 #define TRT_DEPRECATED [[deprecated]] 69 #define TRT_DEPRECATED_ENUM 71 #define TRT_DEPRECATED_ENUM TRT_DEPRECATED 74 #define TRT_DEPRECATED_API __declspec(dllexport) 76 #define TRT_DEPRECATED_API [[deprecated]] __attribute__((visibility("default"))) 80 #define TRT_DEPRECATED 81 #define TRT_DEPRECATED_ENUM 82 #define TRT_DEPRECATED_API __declspec(dllexport) 84 #define TRT_DEPRECATED __attribute__((deprecated)) 85 #define TRT_DEPRECATED_ENUM 86 #define TRT_DEPRECATED_API __attribute__((deprecated, visibility("default"))) 91 #ifdef TENSORRT_BUILD_LIB 93 #define TENSORRTAPI __declspec(dllexport) 95 #define TENSORRTAPI __attribute__((visibility("default"))) 109 struct cublasContext;
115 static const int NV_TENSORRT_VERSION = (NV_TENSORRT_MAJOR * 1000) + (NV_TENSORRT_MINOR * 100) + NV_TENSORRT_PATCH;
125 class IErrorRecorder;
149 template <
typename T>
150 constexpr
inline int EnumMax();
208 static const int MAX_DIMS = 8;
242 kNCHW TRT_DEPRECATED_ENUM =
kLINEAR,
251 kNC2HW2 TRT_DEPRECATED_ENUM =
kCHW2,
260 kNHWC8 TRT_DEPRECATED_ENUM =
kHWC8,
353 return NV_TENSORRT_VERSION;
360 virtual const char* getPluginType()
const TRTNOEXCEPT = 0;
366 virtual const char* getPluginVersion()
const TRTNOEXCEPT = 0;
375 virtual int getNbOutputs()
const TRTNOEXCEPT = 0;
386 virtual Dims getOutputDimensions(
int index,
const Dims* inputs,
int nbInputDims) TRTNOEXCEPT = 0;
424 virtual void configureWithFormat(
const Dims* inputDims,
int nbInputs,
const Dims* outputDims,
int nbOutputs,
DataType type,
PluginFormat format,
int maxBatchSize) TRTNOEXCEPT = 0;
431 virtual int initialize() TRTNOEXCEPT = 0;
437 virtual void terminate() TRTNOEXCEPT = 0;
447 virtual size_t getWorkspaceSize(
int maxBatchSize)
const TRTNOEXCEPT = 0;
460 virtual int enqueue(
int batchSize,
const void*
const* inputs,
void** outputs,
void* workspace,
cudaStream_t stream) TRTNOEXCEPT = 0;
467 virtual size_t getSerializationSize()
const TRTNOEXCEPT = 0;
476 virtual void serialize(
void* buffer)
const TRTNOEXCEPT = 0;
481 virtual void destroy() TRTNOEXCEPT = 0;
486 virtual IPluginV2* clone()
const TRTNOEXCEPT = 0;
492 virtual void setPluginNamespace(
const char* pluginNamespace) TRTNOEXCEPT = 0;
497 virtual const char* getPluginNamespace()
const TRTNOEXCEPT = 0;
534 virtual bool isOutputBroadcastAcrossBatch(
int outputIndex,
const bool* inputIsBroadcasted,
int nbInputs)
const TRTNOEXCEPT = 0;
549 virtual bool canBroadcastInputAcrossBatch(
int inputIndex)
const TRTNOEXCEPT = 0;
578 virtual void configurePlugin(
const Dims* inputDims,
int nbInputs,
const Dims* outputDims,
580 const bool* inputIsBroadcast,
const bool* outputIsBroadcast,
PluginFormat floatFormat,
int maxBatchSize) TRTNOEXCEPT = 0;
687 virtual bool supportsFormatCombination(
int pos,
const PluginTensorDesc* inOut,
int nbInputs,
int nbOutputs)
const TRTNOEXCEPT = 0;
764 const char* name{
nullptr};
768 const void* data{
nullptr};
779 PluginField(
const char* name_ =
nullptr,
const void* data_ =
nullptr,
const PluginFieldType type_ = PluginFieldType::kUNKNOWN, int32_t length_ = 0)
813 virtual const char* getPluginName()
const TRTNOEXCEPT = 0;
818 virtual const char* getPluginVersion()
const TRTNOEXCEPT = 0;
834 virtual IPluginV2* deserializePlugin(
const char* name,
const void* serialData,
size_t serialLength) TRTNOEXCEPT = 0;
842 virtual void setPluginNamespace(
const char* pluginNamespace) TRTNOEXCEPT = 0;
847 virtual const char* getPluginNamespace()
const TRTNOEXCEPT = 0;
874 virtual bool registerCreator(
IPluginCreator& creator,
const char* pluginNamespace) noexcept = 0;
880 virtual IPluginCreator*
const* getPluginCreatorList(
int* numCreators)
const noexcept = 0;
886 virtual IPluginCreator* getPluginCreator(
const char* pluginType,
const char* pluginVersion,
const char* pluginNamespace =
"") noexcept = 0;
904 virtual void setErrorRecorder(
IErrorRecorder* recorder) noexcept = 0;
959 virtual void* allocate(uint64_t size, uint64_t alignment, uint32_t flags) TRTNOEXCEPT = 0;
968 virtual void free(
void* memory) TRTNOEXCEPT = 0;
1008 virtual void log(
Severity severity,
const char* msg) TRTNOEXCEPT = 0;
1014 constexpr
inline int EnumMax<ILogger::Severity>()
1171 virtual int32_t getNbErrors()
const noexcept = 0;
1185 virtual ErrorCode getErrorCode(int32_t errorIdx)
const noexcept = 0;
1201 virtual ErrorDesc getErrorDesc(int32_t errorIdx)
const noexcept = 0;
1212 virtual bool hasOverflowed()
const noexcept = 0;
1223 virtual void clear() noexcept = 0;
1253 virtual RefCount incRefCount() noexcept = 0;
1266 virtual RefCount decRefCount() noexcept = 0;
1300 template <
typename T>
1309 #define REGISTER_TENSORRT_PLUGIN(name) \ 1310 static nvinfer1::PluginRegistrar<name> pluginRegistrar##name {} 1314 #endif // NV_INFER_RUNTIME_COMMON_H Perform the normal matrix multiplication in the first recurrent layer.
DataType
The type of weights and tensors.
Definition: NvInferRuntimeCommon.h:162
constexpr int EnumMax< ErrorCode >()
Maximum number of elements in ErrorCode enum.
Definition: NvInferRuntimeCommon.h:1114
int32_t RefCount
Definition: NvInferRuntimeCommon.h:1152
Plugin class for user-implemented layers.
Definition: NvInferRuntimeCommon.h:343
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:718
Single gate RNN w/ TANH activation function.
struct CUstream_st * cudaStream_t
Forward declaration of cudaStream_t.
Definition: NvInferRuntimeCommon.h:112
PluginFieldType
Definition: NvInferRuntimeCommon.h:739
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:708
Parametric softplus activation: alpha*log(exp(beta*x)+1)
const PluginField * fields
Pointer to PluginField entries.
Definition: NvInferRuntimeCommon.h:791
nvinfer1::IPluginRegistry * getPluginRegistry()
Return the plugin registry.
Severity
Definition: NvInferRuntimeCommon.h:993
Definition: NvInferRuntimeCommon.h:788
TensorLocation
The location for tensor data storage, device or host.
Definition: NvInferRuntimeCommon.h:925
void * createSafeInferRuntime_INTERNAL(void *logger, int version)
Internal C entry point for creating safe::IRuntime.
constexpr int EnumMax< TensorFormat >()
Maximum number of elements in TensorFormat enum.
Definition: NvInferRuntimeCommon.h:295
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:595
Register the plugin creator to the registry The static registry object will be instantiated when the ...
Definition: NvInferRuntimeCommon.h:1301
Scaled tanh activation: alpha*tanh(beta*x)
Per-channel coefficients.
Elements correspond to different spatial data.
Clip activation: max(alpha, min(beta, x))
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:698
The TensorRT API version 1 namespace.
Elements correspond to different sequence values.
virtual ~IGpuAllocator()
Definition: NvInferRuntimeCommon.h:974
virtual void detachFromContext()
Detach the plugin object from its execution context.
Definition: NvInferRuntimeCommon.h:603
Single registration point for all plugins in an application. It is used to find plugin implementation...
Definition: NvInferRuntimeCommon.h:867
Plugin creator class for user implemented layers.
Definition: NvInferRuntimeCommon.h:802
Elu activation: x>=0 ? x : alpha * (exp(x) - 1).
Structure containing plugin attribute field names and associated data This information can be parsed ...
Definition: NvInferRuntimeCommon.h:759
nvinfer1::Dims field type.
ActivationType
Forward declare IGpuAllocator for use in other interfaces.
Definition: NvInferRuntimeCommon.h:133
int getInferLibVersion()
Return the library version number.
constexpr int EnumMax< TensorLocation >()
Maximum number of elements in TensorLocation enum.
Definition: NvInferRuntimeCommon.h:932
Reference counted application-implemented error reporting interface for TensorRT objects.
Definition: NvInferRuntimeCommon.h:1141
Structure to define the dimensions of a tensor.
Definition: NvInferRuntimeCommon.h:205
const char * ErrorDesc
Definition: NvInferRuntimeCommon.h:1147
constexpr int EnumMax< DimensionType >()
Maximum number of elements in DimensionType enum.
Definition: NvInferRuntimeCommon.h:189
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:619
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:627
Single gate RNN w/ ReLU activation function.
uint32_t TensorFormats
It is capable of representing one or more TensorFormat by binary OR operations, e.g., 1U << TensorFormats::kCHW4 | 1U << TensorFormats::kCHW32.
Definition: NvInferRuntimeCommon.h:220
ErrorCode
Error codes that can be returned by TensorRT during execution.
Definition: NvInferRuntimeCommon.h:1024
<– Deprecated, used for backward compatibility
constexpr int EnumMax< DataType >()
Maximum number of elements in DataType enum.
Definition: NvInferRuntimeCommon.h:171
Plugin class for user-implemented layers.
Definition: NvInferRuntimeCommon.h:640
Enable Int8 layer selection.
int nbDims
The number of dimensions.
Definition: NvInferRuntimeCommon.h:209
TensorFormat
Format of the input/output tensors.
Definition: NvInferRuntimeCommon.h:235
Application-implemented logging interface for the builder, engine and runtime.
Definition: NvInferRuntimeCommon.h:985
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:728
Fields that a plugin might see for an input or output.
Definition: NvInferRuntimeCommon.h:310
virtual bool registerCreator(IPluginCreator &creator, const char *pluginNamespace) noexcept=0
Register a plugin creator. Returns false if one with same type is already registered.
Selu activation: x>0 ? beta * x : beta * (alpha*exp(x) - alpha)
constexpr int EnumMax()
Maximum number of elements in an enumeration type.
DimensionType
The type of data encoded across this dimension.
Definition: NvInferRuntimeCommon.h:180
Thresholded ReLU activation: x>alpha ? x : 0.
virtual int getTensorRTVersion() const
Return the version of the API the plugin creator was compiled with.
Definition: NvInferRuntimeCommon.h:808
#define _TENSORRT_OVERRIDE
Items that are marked as deprecated will be removed in a future release.
Definition: NvInferRuntimeCommon.h:62
Application-implemented class for controlling allocation on the GPU.
Definition: NvInferRuntimeCommon.h:942
<– Deprecated, used for backward compatibility
nvinfer1::ILogger * getLogger()
Return the logger object.
Definition of plugin versions.
Elements correspond to different batch index.
LeakyRelu activation: x>=0 ? x : alpha * x.
constexpr int EnumMax< ActivationType >()
Maximum number of elements in ActivationType enum.
Definition: NvInferRuntimeCommon.h:153
Plugin class for user-implemented layers.
Definition: NvInferRuntimeCommon.h:513
Hard sigmoid activation: max(0, min(1, alpha*x+beta))
<– Deprecated, used for backward compatibility
int nbFields
Number of PluginField entries.
Definition: NvInferRuntimeCommon.h:790
struct CUevent_st * cudaEvent_t
Forward declaration of cudaEvent_t.
Definition: NvInferRuntimeCommon.h:113
Softsign activation: x / (1+|x|)
virtual int getTensorRTVersion() const
Return the API version with which this plugin was built.
Definition: NvInferRuntimeCommon.h:351