|
|
NVIDIA DeepStream SDK API Reference
|
9.2 Release
|
Go to the documentation of this file.
18 #ifndef TRTMODULE_HPP_
19 #define TRTMODULE_HPP_
26 #include <NvOnnxParser.h>
27 #include "nvdsinfer_context.h"
28 #include "modules/utility/cuda_common.hpp"
29 #include "modules/NvMultiObjectTracker/NvTrackerParams.hpp"
44 TRTConfigParams(
const std::string &configFilePath,
const std::string moduleName,
const std::string submoduleName);
56 void read(
const YAML::Node &fn)
override;
86 : m_CalibrationTableFile(calibrationTableFile)
101 bool getBatch(
void* bindings[],
const char* names[],
int nbBindings) noexcept
override {
return false; }
111 m_CalibrationCache.clear();
113 input >> std::noskipws;
116 std::istream_iterator<char>(input), std::istream_iterator<char>(),
117 std::back_inserter(m_CalibrationCache)
120 length = m_CalibrationCache.size();
121 return length ? m_CalibrationCache.data() :
nullptr;
132 std::string m_CalibrationTableFile;
133 std::vector<char> m_CalibrationCache;
150 nvinfer1::INetworkDefinition *network, nvinfer1::IBuilder *builder,
151 nvinfer1::IBuilderConfig *config,
int batchSize
153 std::function<
void(
TrtModule*,
const std::vector<int>& sizes)> setRuntimeDimFunc
166 nvinfer1::INetworkDefinition &network, nvinfer1::ILogger &
logger, std::unique_ptr<nvonnxparser::IParser>& parser
175 nvinfer1::ICudaEngine*
decodeTltModel(nvinfer1::IBuilder*
const builder, nvinfer1::IBuilderConfig*
const config);
209 nvinfer1::INetworkDefinition *network, nvinfer1::IBuilder *builder, nvinfer1::IBuilderConfig *config,
214 #endif // TRTMODULE_HPP_
std::shared_ptr< nvinfer1::IExecutionContext > m_context
TensorRT execution context.
void setCudaStream(cudaStream_t cuStream)
Set the CUDA stream used for TensorRT inference.
int m_width
Input image patch width.
void initializeModel(std::function< void(nvinfer1::INetworkDefinition *network, nvinfer1::IBuilder *builder, nvinfer1::IBuilderConfig *config, int batchSize)> onnxProfileFunc, std::function< void(TrtModule *, const std::vector< int > &sizes)> setRuntimeDimFunc)
Create TensorRT inference engine; if engine does not exist, serialize from model.
__host__ __device__ float length(float2 v)
Compute the Euclidean length of a vector.
void parseOnnxModel(nvinfer1::INetworkDefinition &network, nvinfer1::ILogger &logger, std::unique_ptr< nvonnxparser::IParser > &parser)
Load ONNX model into network.
TrackerInt8EntropyCalibrator(std::string calibrationTableFile)
Construct a calibrator that reads a serialized calibration table.
Stores TensorRT model and engine configuration.
std::function< void(TrtModule *, const std::vector< int > &)> m_setRuntimeDimFunc
Custom function to set runtime dimension required by TRT.
bool getBatch(void *bindings[], const char *names[], int nbBindings) noexcept override
Provide a calibration batch when available.
std::string m_calibrationTableFilePath
Reid int8 calibration table file path.
int m_maxBatchSize
Maximum batch size for reid network.
ReID int8 calibrator used for TensorRT int8 precision inference.
void printEngineInfo()
Print TRT engine information.
TrtModule()
Construct a TrtModule instance.
int m_debugVerboseLevel
Debug message verbose mode level.
void createInferEngine()
Build a TensorRT engine from the configured network model.
HALF_CONSTEXPR_CONST binary_t binary
Tag for binary construction.
std::string m_tltEncodedModelFilePath
Reid network tao model path.
nvinfer1::ICudaEngine * decodeTltModel(nvinfer1::IBuilder *const builder, nvinfer1::IBuilderConfig *const config)
Decode TAO encrypted model.
TRTConfigParams m_params
TRT module config.
TRTConfigParams()
Construct a TRTConfigParams instance.
TRT module to perform various deep learning inference.
std::shared_ptr< nvinfer1::IRuntime > m_runtime
TensorRT runtime used to deserialize engines.
bool loadTRTEngine()
Load reid TRT engine.
std::string m_onnxFilePath
Reid network onnx model path.
int getBatchSize() const noexcept override
Report the calibrator batch size.
std::vector< int > m_inferDims
Reid input dimension.
void writeCalibrationCache(const void *cache, size_t length) noexcept override
Accept a generated TensorRT calibration cache.
cudaStream_t m_cuStream
Cuda stream to run all GPU tasks.
void submitInput(std::vector< void * > &bindings, const std::vector< int > &batchSize, cudaStream_t &cuStream)
Submit network input for inference.
int m_channel
Input image patch channel.
int m_inputOrder
Input dimension order: 0: NCHW, 1: NHWC.
Provides common loading helpers for tracker configuration parameters.
std::function< void(nvinfer1::INetworkDefinition *network, nvinfer1::IBuilder *builder, nvinfer1::IBuilderConfig *config, int batchSize)> m_onnxProfileFunc
Custom function to perform profiling for dynamic shapes required by TRT.
int m_height
Input image patch height.
nvinfer1::DataType m_networkMode
Reid network precision.
size_t m_workspaceSize
Work space for reid network in MiB.
std::string m_tltModelKey
Tao model key.
std::string m_engineFilePath
Reid engine path.
~TrackerInt8EntropyCalibrator()
Release resources owned by the TrackerInt8EntropyCalibrator instance.
std::string m_absModelFilePath
Absolute model file path.
int m_builderOptimizationLevel
Engine builder optimization level.
const void * readCalibrationCache(size_t &length) noexcept override
Read the calibration table file into a buffer and return a pointer to it.
void read(const YAML::Node &fn) override
Load configuration values from a YAML node.
std::shared_ptr< TrackerInt8EntropyCalibrator > m_calibrator
TensorRT int8 calibrator.
std::shared_ptr< nvinfer1::ICudaEngine > m_engine
TensorRT engine for reid.