TensorRT  8.0.0
nvinfer1::IBuilder Class Reference

Builds an engine from a network definition. More...

#include <NvInfer.h>

Inheritance diagram for nvinfer1::IBuilder:
nvinfer1::INoCopy

Public Member Functions

void setMaxBatchSize (int32_t batchSize) noexcept
 Set the maximum batch size. More...
 
int32_t getMaxBatchSize () const noexcept
 Get the maximum batch size. More...
 
bool platformHasFastFp16 () const noexcept
 Determine whether the platform has fast native fp16.
 
bool platformHasFastInt8 () const noexcept
 Determine whether the platform has fast native int8.
 
TRT_DEPRECATED void destroy () noexcept
 Destroy this object. More...
 
int32_t getMaxDLABatchSize () const noexcept
 Get the maximum batch size DLA can support. For any tensor the total volume of index dimensions combined(dimensions other than CHW) with the requested batch size should not exceed the value returned by this function. More...
 
int32_t getNbDLACores () const noexcept
 Return the number of DLA engines available to this builder.
 
void setGpuAllocator (IGpuAllocator *allocator) noexcept
 Set the GPU allocator. More...
 
nvinfer1::IBuilderConfigcreateBuilderConfig () noexcept
 Create a builder configuration object. More...
 
TRT_DEPRECATED nvinfer1::ICudaEnginebuildEngineWithConfig (INetworkDefinition &network, IBuilderConfig &config) noexcept
 Builds an engine for the given INetworkDefinition and given IBuilderConfig. More...
 
nvinfer1::INetworkDefinitioncreateNetworkV2 (NetworkDefinitionCreationFlags flags) noexcept
 Create a network definition object. More...
 
nvinfer1::IOptimizationProfilecreateOptimizationProfile () noexcept
 Create a new optimization profile. More...
 
void setErrorRecorder (IErrorRecorder *recorder) noexcept
 Set the ErrorRecorder for this interface. More...
 
IErrorRecordergetErrorRecorder () const noexcept
 get the ErrorRecorder assigned to this interface. More...
 
void reset () noexcept
 Resets the builder state to default values.
 
bool platformHasTf32 () const noexcept
 Determine whether the platform has TF32 support.
 
nvinfer1::IHostMemorybuildSerializedNetwork (INetworkDefinition &network, IBuilderConfig &config) noexcept
 Builds and serializes a network for the given INetworkDefinition and IBuilderConfig. More...
 

Protected Attributes

apiv::VBuildermImpl
 

Additional Inherited Members

- Protected Member Functions inherited from nvinfer1::INoCopy
 INoCopy (const INoCopy &other)=delete
 
INoCopyoperator= (const INoCopy &other)=delete
 
 INoCopy (INoCopy &&other)=delete
 
INoCopyoperator= (INoCopy &&other)=delete
 

Detailed Description

Builds an engine from a network definition.

Warning
Do not inherit from this class, as doing so will break forward-compatibility of the API and ABI.

Member Function Documentation

◆ buildEngineWithConfig()

TRT_DEPRECATED nvinfer1::ICudaEngine* nvinfer1::IBuilder::buildEngineWithConfig ( INetworkDefinition network,
IBuilderConfig config 
)
inlinenoexcept

Builds an engine for the given INetworkDefinition and given IBuilderConfig.

It enables the builder to build multiple engines based on the same network definition, but with different builder configurations.

Note
This function will synchronize the cuda stream returned by config.getProfileStream() before returning.
Deprecated:
API will be removed in TensorRT 10.0, use IBuilder::buildSerializedNetwork instead.

◆ buildSerializedNetwork()

nvinfer1::IHostMemory* nvinfer1::IBuilder::buildSerializedNetwork ( INetworkDefinition network,
IBuilderConfig config 
)
inlinenoexcept

Builds and serializes a network for the given INetworkDefinition and IBuilderConfig.

This function allows building and serialization of a network without creating an engine.

Parameters
networkNetwork definition.
configBuilder configuration.
Returns
A pointer to a IHostMemory object that contains a serialized network.
Note
This function will synchronize the cuda stream returned by config.getProfileStream() before returning.
See also
INetworkDefinition, IBuilderConfig, IHostMemory

◆ createBuilderConfig()

nvinfer1::IBuilderConfig* nvinfer1::IBuilder::createBuilderConfig ( )
inlinenoexcept

Create a builder configuration object.

See also
IBuilderConfig

◆ createNetworkV2()

nvinfer1::INetworkDefinition* nvinfer1::IBuilder::createNetworkV2 ( NetworkDefinitionCreationFlags  flags)
inlinenoexcept

Create a network definition object.

Creates a network definition object with immutable properties specified using the flags parameter. Providing the kDEFAULT flag as parameter mimics the behaviour of createNetwork(). CreateNetworkV2 supports dynamic shapes and explicit batch dimensions when used with NetworkDefinitionCreationFlag::kEXPLICIT_BATCH flag.

Parameters
flagsBitset of NetworkDefinitionCreationFlags specifying network properties combined with bitwise OR. e.g., 1U << NetworkDefinitionCreationFlag::kEXPLICIT_BATCH
See also
INetworkDefinition, NetworkDefinitionCreationFlags

◆ createOptimizationProfile()

nvinfer1::IOptimizationProfile* nvinfer1::IBuilder::createOptimizationProfile ( )
inlinenoexcept

Create a new optimization profile.

If the network has any dynamic input tensors, the appropriate calls to setDimensions() must be made. Likewise, if there are any shape input tensors, the appropriate calls to setShapeValues() are required. The builder retains ownership of the created optimization profile and returns a raw pointer, i.e. the users must not attempt to delete the returned pointer.

See also
IOptimizationProfile

◆ destroy()

TRT_DEPRECATED void nvinfer1::IBuilder::destroy ( )
inlinenoexcept

Destroy this object.

Deprecated:
Deprecated interface will be removed in TensorRT 10.0.
Warning
Calling destroy on a managed pointer will result in a double-free error.

◆ getErrorRecorder()

IErrorRecorder* nvinfer1::IBuilder::getErrorRecorder ( ) const
inlinenoexcept

get the ErrorRecorder assigned to this interface.

Retrieves the assigned error recorder object for the given class. A nullptr will be returned if setErrorRecorder has not been called.

Returns
A pointer to the IErrorRecorder object that has been registered.
See also
setErrorRecorder()

◆ getMaxBatchSize()

int32_t nvinfer1::IBuilder::getMaxBatchSize ( ) const
inlinenoexcept

Get the maximum batch size.

Returns
The maximum batch size.
See also
setMaxBatchSize()
getMaxDLABatchSize()

◆ getMaxDLABatchSize()

int32_t nvinfer1::IBuilder::getMaxDLABatchSize ( ) const
inlinenoexcept

Get the maximum batch size DLA can support. For any tensor the total volume of index dimensions combined(dimensions other than CHW) with the requested batch size should not exceed the value returned by this function.

Warning
getMaxDLABatchSize does not work with dynamic shapes.

◆ setErrorRecorder()

void nvinfer1::IBuilder::setErrorRecorder ( IErrorRecorder recorder)
inlinenoexcept

Set the ErrorRecorder for this interface.

Assigns the ErrorRecorder to this interface. The ErrorRecorder will track all errors during execution. This function will call incRefCount of the registered ErrorRecorder at least once. Setting recorder to nullptr unregisters the recorder with the interface, resulting in a call to decRefCount if a recorder has been registered.

If an error recorder is not set, messages will be sent to the global log stream.

Parameters
recorderThe error recorder to register with this interface.
See also
getErrorRecorder()

◆ setGpuAllocator()

void nvinfer1::IBuilder::setGpuAllocator ( IGpuAllocator allocator)
inlinenoexcept

Set the GPU allocator.

Parameters
allocatorSet the GPU allocator to be used by the builder. All GPU memory acquired will use this allocator. If NULL is passed, the default allocator will be used.

Default: uses cudaMalloc/cudaFree.

Note
This allocator will be passed to any engines created via the builder; thus the lifetime of the allocator must span the lifetime of those engines as well as that of the builder. If nullptr is passed, the default allocator will be used.

◆ setMaxBatchSize()

void nvinfer1::IBuilder::setMaxBatchSize ( int32_t  batchSize)
inlinenoexcept

Set the maximum batch size.

Parameters
batchSizeThe maximum batch size which can be used at execution time, and also the batch size for which the engine will be optimized.
See also
getMaxBatchSize()

The documentation for this class was generated from the following file: