TensorRT 10.13.0
nvonnxparser::IParserRefitter Class Referenceabstract

An interface designed to refit weights from an ONNX model. More...

#include <NvOnnxParser.h>

Public Member Functions

virtual bool refitFromBytes (void const *serializedOnnxModel, size_t serializedOnnxModelSize, char const *modelPath=nullptr) noexcept=0
 Load a serialized ONNX model from memory and perform weight refit. More...
 
virtual bool refitFromFile (char const *onnxModelFile) noexcept=0
 Load and parse a ONNX model from disk and perform weight refit. More...
 
virtual int32_t getNbErrors () const noexcept=0
 Get the number of errors that occurred during prior calls to refitFromBytes or refitFromFile. More...
 
virtual IParserError const * getError (int32_t index) const noexcept=0
 Get an error that occurred during prior calls to refitFromBytes or refitFromFile. More...
 
virtual void clearErrors ()=0
 Clear errors from prior calls to refitFromBytes or refitFromFile. More...
 
virtual ~IParserRefitter () noexcept=default
 
virtual bool loadModelProto (void const *serializedOnnxModel, size_t serializedOnnxModelSize, char const *modelPath=nullptr) noexcept=0
 Load a serialized ONNX model into the parser. Unlike the refit(), or refitFromFile() functions, this function does not immediately begin the refit process. Using this function allows users to provide their own initializers for the ONNX model through the loadInitializer() function. More...
 
virtual bool loadInitializer (char const *name, void const *data, size_t size) noexcept=0
 Prompt the ONNX refitter to load an initializer with user-provided binary data. The lifetime of the data must exceed the lifetime of the refitter. More...
 
virtual bool refitModelProto () noexcept=0
 Begin the refit process from the loaded ONNX model. More...
 

Detailed Description

An interface designed to refit weights from an ONNX model.

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

Constructor & Destructor Documentation

◆ ~IParserRefitter()

virtual nvonnxparser::IParserRefitter::~IParserRefitter ( )
virtualdefaultnoexcept

Member Function Documentation

◆ clearErrors()

virtual void nvonnxparser::IParserRefitter::clearErrors ( )
pure virtual

Clear errors from prior calls to refitFromBytes or refitFromFile.

See also
getNbErrors() getError() IParserError

◆ getError()

virtual IParserError const * nvonnxparser::IParserRefitter::getError ( int32_t  index) const
pure virtualnoexcept

Get an error that occurred during prior calls to refitFromBytes or refitFromFile.

See also
getNbErrors() IParserError

◆ getNbErrors()

virtual int32_t nvonnxparser::IParserRefitter::getNbErrors ( ) const
pure virtualnoexcept

Get the number of errors that occurred during prior calls to refitFromBytes or refitFromFile.

See also
getError() IParserError

◆ loadInitializer()

virtual bool nvonnxparser::IParserRefitter::loadInitializer ( char const *  name,
void const *  data,
size_t  size 
)
pure virtualnoexcept

Prompt the ONNX refitter to load an initializer with user-provided binary data. The lifetime of the data must exceed the lifetime of the refitter.

All user-provided initializers must be provided prior to calling refitModelProto().

This function can be called multiple times to specify the names of multiple initializers.

Calling this function with an initializer previously specified will overwrite the previous instance.

This function will return false if initializer validation fails. Possible validation errors are:

  • This function was called prior to loadModelProto()
  • The requested initializer was not found in the model.
  • The size of the data provided is different from the corresponding initializer in the model.
Parameters
nameName of the initializer.
dataBinary data containing the values of the initializer.
sizeSize of the initializer in bytes.
Returns
true if the initializer was loaded successfully
See also
loadModelProto()

◆ loadModelProto()

virtual bool nvonnxparser::IParserRefitter::loadModelProto ( void const *  serializedOnnxModel,
size_t  serializedOnnxModelSize,
char const *  modelPath = nullptr 
)
pure virtualnoexcept

Load a serialized ONNX model into the parser. Unlike the refit(), or refitFromFile() functions, this function does not immediately begin the refit process. Using this function allows users to provide their own initializers for the ONNX model through the loadInitializer() function.

Only one model can be loaded at a time. Subsequent calls to loadModelProto() will result in an error.

To begin the refit process, use refitModelProto().

Parameters
serializedOnnxModelPointer to the serialized ONNX model. Can be freed after this function returns.
serializedOnnxModelSizeSize of the serialized ONNX model in bytes.
modelPathAbsolute path to the model file for loading external weights if required.
Returns
true if the model was loaded successfully
See also
getNbErrors() getError()

◆ refitFromBytes()

virtual bool nvonnxparser::IParserRefitter::refitFromBytes ( void const *  serializedOnnxModel,
size_t  serializedOnnxModelSize,
char const *  modelPath = nullptr 
)
pure virtualnoexcept

Load a serialized ONNX model from memory and perform weight refit.

Parameters
serializedOnnxModelPointer to the serialized ONNX model
serializedOnnxModelSizeSize of the serialized ONNX model in bytes
modelPathAbsolute path to the model file for loading external weights if required
Returns
true if all the weights in the engine were refit successfully.

The serialized ONNX model must be identical to the one used to generate the engine that will be refit.

◆ refitFromFile()

virtual bool nvonnxparser::IParserRefitter::refitFromFile ( char const *  onnxModelFile)
pure virtualnoexcept

Load and parse a ONNX model from disk and perform weight refit.

Parameters
onnxModelFilePath to the ONNX model to load from disk.
Returns
true if the model was loaded successfully, and if all the weights in the engine were refit successfully.

The provided ONNX model must be identical to the one used to generate the engine that will be refit.

◆ refitModelProto()

virtual bool nvonnxparser::IParserRefitter::refitModelProto ( )
pure virtualnoexcept

Begin the refit process from the loaded ONNX model.

Returns
true if refit was successful
See also
getNbErrors() getError() loadModelProto()

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

  Copyright © 2024 NVIDIA Corporation
  Privacy Policy | Manage My Privacy | Do Not Sell or Share My Data | Terms of Service | Accessibility | Corporate Policies | Product Security | Contact