13#ifndef NV_INFER_RUNTIME_COMMON_H
14#define NV_INFER_RUNTIME_COMMON_H
19#include <cuda_runtime_api.h>
22#if __cplusplus >= 201402L
23#define TRT_DEPRECATED [[deprecated]]
25#define TRT_DEPRECATED_ENUM
27#define TRT_DEPRECATED_ENUM TRT_DEPRECATED
30#define TRT_DEPRECATED_API __declspec(dllexport)
32#define TRT_DEPRECATED_API [[deprecated]] __attribute__((visibility("default")))
37#define TRT_DEPRECATED_ENUM
38#define TRT_DEPRECATED_API __declspec(dllexport)
40#define TRT_DEPRECATED __attribute__((deprecated))
41#define TRT_DEPRECATED_ENUM
42#define TRT_DEPRECATED_API __attribute__((deprecated, visibility("default")))
47#ifdef TENSORRT_BUILD_LIB
49#define TENSORRTAPI __declspec(dllexport)
51#define TENSORRTAPI __attribute__((visibility("default")))
73#define NV_TENSORRT_VERSION nvinfer1::kNV_TENSORRT_VERSION_IMPL
82static constexpr int32_t kNV_TENSORRT_VERSION_IMPL
156 static constexpr int32_t kVALUE = 6;
335 static constexpr int32_t kVALUE = 12;
437 virtual
AsciiChar const* getPluginVersion() const noexcept = 0;
452 virtual int32_t getNbOutputs() const noexcept = 0;
473 virtual
Dims getOutputDimensions(int32_t index,
Dims const* inputs, int32_t nbInputDims) noexcept = 0;
530 virtual
void configureWithFormat(
Dims const* inputDims, int32_t nbInputs,
Dims const* outputDims, int32_t nbOutputs,
545 virtual int32_t initialize() noexcept = 0;
559 virtual
void terminate() noexcept = 0;
575 virtual
size_t getWorkspaceSize(int32_t maxBatchSize) const noexcept = 0;
593 virtual int32_t enqueue(int32_t batchSize,
void const* const* inputs,
void* const* outputs,
void* workspace,
594 cudaStream_t stream) noexcept
607 virtual
size_t getSerializationSize() const noexcept = 0;
622 virtual
void serialize(
void* buffer) const noexcept = 0;
632 virtual
void destroy() noexcept = 0;
664 virtual
void setPluginNamespace(
AsciiChar const* pluginNamespace) noexcept = 0;
674 virtual
AsciiChar const* getPluginNamespace() const noexcept = 0;
741 int32_t outputIndex,
bool const* inputIsBroadcasted, int32_t nbInputs)
const noexcept
799 DataType const* inputTypes,
DataType const* outputTypes,
bool const* inputIsBroadcast,
800 bool const* outputIsBroadcast,
PluginFormat floatFormat, int32_t maxBatchSize)
noexcept
882 int32_t getTensorRTVersion() const noexcept
override
968 int32_t pos,
PluginTensorDesc const* inOut, int32_t nbInputs, int32_t nbOutputs)
const noexcept
1138 virtual
AsciiChar const* getPluginVersion() const noexcept = 0;
1172 virtual
IPluginV2* deserializePlugin(
AsciiChar const* name,
void const* serialData,
size_t serialLength) noexcept
1187 virtual
void setPluginNamespace(
AsciiChar const* pluginNamespace) noexcept = 0;
1201 virtual
AsciiChar const* getPluginNamespace() const noexcept = 0;
1271 AsciiChar const*
const pluginNamespace =
"") noexcept
1350 static constexpr int32_t kVALUE = 1;
1554 static constexpr int32_t kVALUE = 5;
1661 static constexpr int32_t kVALUE = 11;
1699 static constexpr size_t kMAX_DESC_LENGTH{127U};
1729 virtual int32_t getNbErrors() const noexcept = 0;
1748 virtual
ErrorCode getErrorCode(int32_t errorIdx) const noexcept = 0;
1769 virtual
ErrorDesc getErrorDesc(int32_t errorIdx) const noexcept = 0;
1785 virtual
bool hasOverflowed() const noexcept = 0;
1801 virtual
void clear() noexcept = 0;
1896 static constexpr int32_t kVALUE = 3;
#define TENSORRTAPI
Definition: NvInferRuntimeCommon.h:54
int32_t getInferLibVersion() noexcept
Return the library version number.
#define NV_TENSORRT_VERSION
Definition: NvInferRuntimeCommon.h:73
#define TRT_DEPRECATED
Definition: NvInferRuntimeCommon.h:40
#define NV_TENSORRT_MINOR
TensorRT minor version.
Definition: NvInferVersion.h:23
#define NV_TENSORRT_MAJOR
TensorRT major version.
Definition: NvInferVersion.h:22
#define NV_TENSORRT_PATCH
TensorRT patch version.
Definition: NvInferVersion.h:24
Definition: NvInferRuntimeCommon.h:171
int32_t nbDims
The rank (number of dimensions).
Definition: NvInferRuntimeCommon.h:176
static constexpr int32_t MAX_DIMS
The maximum rank (number of dimensions) supported for a tensor.
Definition: NvInferRuntimeCommon.h:174
int32_t d[MAX_DIMS]
The extent of each dimension.
Definition: NvInferRuntimeCommon.h:178
Reference counted application-implemented error reporting interface for TensorRT objects.
Definition: NvInferRuntimeCommon.h:1689
virtual ~IErrorRecorder() noexcept=default
char const * ErrorDesc
Definition: NvInferRuntimeCommon.h:1694
int32_t RefCount
Definition: NvInferRuntimeCommon.h:1704
Application-implemented class for controlling allocation on the GPU.
Definition: NvInferRuntimeCommon.h:1362
virtual bool deallocate(void *const memory) noexcept
Definition: NvInferRuntimeCommon.h:1472
virtual void * reallocate(void *, uint64_t, uint64_t) noexcept
Definition: NvInferRuntimeCommon.h:1447
virtual ~IGpuAllocator()=default
virtual void * allocate(uint64_t const size, uint64_t const alignment, AllocatorFlags const flags) noexcept=0
virtual TRT_DEPRECATED void free(void *const memory) noexcept=0
Application-implemented logging interface for the builder, refitter and runtime.
Definition: NvInferRuntimeCommon.h:1500
virtual ~ILogger()=default
Severity
Definition: NvInferRuntimeCommon.h:1508
virtual void log(Severity severity, AsciiChar const *msg) noexcept=0
Plugin creator class for user implemented layers.
Definition: NvInferRuntimeCommon.h:1098
virtual int32_t getTensorRTVersion() const noexcept
Return the version of the API the plugin creator was compiled with.
Definition: NvInferRuntimeCommon.h:1107
virtual AsciiChar const * getPluginName() const noexcept=0
Return the plugin name.
Single registration point for all plugins in an application. It is used to find plugin implementation...
Definition: NvInferRuntimeCommon.h:1234
virtual bool registerCreator(IPluginCreator &creator, AsciiChar const *const pluginNamespace) noexcept=0
Register a plugin creator. Returns false if one with same type is already registered.
virtual IPluginCreator * getPluginCreator(AsciiChar const *const pluginName, AsciiChar const *const pluginVersion, AsciiChar const *const pluginNamespace="") noexcept=0
Return plugin creator based on plugin name, version, and namespace associated with plugin during netw...
virtual IPluginCreator *const * getPluginCreatorList(int32_t *const numCreators) const noexcept=0
Return all the registered plugin creators and the number of registered plugin creators....
Plugin class for user-implemented layers.
Definition: NvInferRuntimeCommon.h:704
~IPluginV2Ext() override=default
virtual bool canBroadcastInputAcrossBatch(int32_t inputIndex) const noexcept=0
Return true if plugin can use input that is broadcast across batch without replication.
void configureWithFormat(Dims const *, int32_t, Dims const *, int32_t, DataType, PluginFormat, int32_t) noexcept override
Derived classes should not implement this. In a C++11 API it would be override final.
Definition: NvInferRuntimeCommon.h:891
virtual bool isOutputBroadcastAcrossBatch(int32_t outputIndex, bool const *inputIsBroadcasted, int32_t nbInputs) const noexcept=0
Return true if output tensor is broadcast across a batch.
IPluginV2Ext * clone() const noexcept override=0
Clone the plugin object. This copies over internal plugin parameters as well and returns a new plugin...
virtual void configurePlugin(Dims const *inputDims, int32_t nbInputs, Dims const *outputDims, int32_t nbOutputs, DataType const *inputTypes, DataType const *outputTypes, bool const *inputIsBroadcast, bool const *outputIsBroadcast, PluginFormat floatFormat, int32_t maxBatchSize) noexcept=0
Configure the layer with input and output data types.
virtual void detachFromContext() noexcept
Detach the plugin object from its execution context.
Definition: NvInferRuntimeCommon.h:847
virtual void attachToContext(cudnnContext *, cublasContext *, IGpuAllocator *) noexcept
Attach the plugin object to an execution context and grant the plugin the access to some context reso...
Definition: NvInferRuntimeCommon.h:829
virtual nvinfer1::DataType getOutputDataType(int32_t index, nvinfer1::DataType const *inputTypes, int32_t nbInputs) const noexcept=0
Return the DataType of the plugin output at the requested index.
Plugin class for user-implemented layers.
Definition: NvInferRuntimeCommon.h:394
virtual AsciiChar const * getPluginType() const noexcept=0
Return the plugin type. Should match the plugin name returned by the corresponding plugin creator.
virtual int32_t getTensorRTVersion() const noexcept
Return the API version with which this plugin was built.
Definition: NvInferRuntimeCommon.h:406
Plugin class for user-implemented layers.
Definition: NvInferRuntimeCommon.h:907
int32_t getTensorRTVersion() const noexcept override
Return the API version with which this plugin was built. The upper byte is reserved by TensorRT and i...
Definition: NvInferRuntimeCommon.h:995
virtual void configurePlugin(PluginTensorDesc const *in, int32_t nbInput, PluginTensorDesc const *out, int32_t nbOutput) noexcept=0
Configure the layer.
virtual bool supportsFormatCombination(int32_t pos, PluginTensorDesc const *inOut, int32_t nbInputs, int32_t nbOutputs) const noexcept=0
Return true if plugin supports the format and datatype for the input/output indexed by pos.
Structure containing plugin attribute field names and associated data This information can be parsed ...
Definition: NvInferRuntimeCommon.h:1050
AsciiChar const * name
Plugin field attribute name.
Definition: NvInferRuntimeCommon.h:1055
PluginField(AsciiChar const *const name_=nullptr, void const *const data_=nullptr, PluginFieldType const type_=PluginFieldType::kUNKNOWN, int32_t const length_=0) noexcept
Definition: NvInferRuntimeCommon.h:1070
void const * data
Plugin field attribute data.
Definition: NvInferRuntimeCommon.h:1059
int32_t length
Number of data entries in the Plugin attribute.
Definition: NvInferRuntimeCommon.h:1068
PluginFieldType type
Plugin field attribute type.
Definition: NvInferRuntimeCommon.h:1064
The TensorRT API version 1 namespace.
ErrorCode
Error codes that can be returned by TensorRT during execution.
Definition: NvInferRuntimeCommon.h:1564
TensorIOMode
Definition of tensor IO Mode.
Definition: NvInferRuntimeCommon.h:1878
PluginFieldType
Definition: NvInferRuntimeCommon.h:1021
@ kUNKNOWN
Unknown field type.
@ kFLOAT32
FP32 field type.
@ kINT16
INT16 field type.
@ kDIMS
nvinfer1::Dims field type.
@ kFLOAT64
FP64 field type.
@ kFLOAT16
FP16 field type.
char_t AsciiChar
Definition: NvInferRuntimeCommon.h:91
char char_t
char_t is the type used by TensorRT to represent all valid characters.
Definition: NvInferRuntimeCommon.h:86
@ kV2_DYNAMICEXT
IPluginV2DynamicExt.
@ kV2_IOEXT
IPluginV2IOExt.
@ kOUTPUT
Output gate (o).
DataType
The type of weights and tensors.
Definition: NvInferRuntimeCommon.h:117
@ kFLOAT
32-bit floating point format.
@ kBOOL
8-bit boolean. 0 = false, 1 = true, other values undefined.
@ kHALF
IEEE 16-bit floating-point format.
@ kINT8
Signed 8-bit integer representing a quantized floating-point value.
@ kINT32
Signed 32-bit integer format.
TensorFormat PluginFormat
PluginFormat is reserved for backward compatibility.
Definition: NvInferRuntimeCommon.h:326
@ kINT8
Enable Int8 layer selection, with FP32 fallback with FP16 fallback if kFP16 also specified.
TensorFormat
Format of the input/output tensors.
Definition: NvInferRuntimeCommon.h:201
constexpr int32_t EnumMax() noexcept
Maximum number of elements in an enumeration type.
Definition: NvInferRuntimeCommon.h:107
AllocatorFlag
Definition: NvInferRuntimeCommon.h:1340
@ kRESIZABLE
TensorRT may call realloc() on this allocation.
uint32_t AllocatorFlags
Definition: NvInferRuntimeCommon.h:1354
Definition of plugin versions.
Plugin field collection struct.
Definition: NvInferRuntimeCommon.h:1082
PluginField const * fields
Pointer to PluginField entries.
Definition: NvInferRuntimeCommon.h:1086
int32_t nbFields
Number of PluginField entries.
Definition: NvInferRuntimeCommon.h:1084
Fields that a plugin might see for an input or output.
Definition: NvInferRuntimeCommon.h:350
DataType type
Definition: NvInferRuntimeCommon.h:354
Dims dims
Dimensions.
Definition: NvInferRuntimeCommon.h:352
TensorFormat format
Tensor format.
Definition: NvInferRuntimeCommon.h:356
float scale
Scale for INT8 data type.
Definition: NvInferRuntimeCommon.h:358
Declaration of EnumMaxImpl struct to store maximum number of elements in an enumeration type.
Definition: NvInferRuntimeCommon.h:102