TensorRT  7.2.1.6
NVIDIA TensorRT
Looking for a C++ dev who knows TensorRT?
I'm looking for work. Hire me!
nvonnxparser::IParser Class Referenceabstract

an object for parsing ONNX models into a TensorRT network definition More...

Public Member Functions

virtual bool parse (void const *serialized_onnx_model, size_t serialized_onnx_model_size)=0
 Parse a serialized ONNX model into the TensorRT network. More...
 
virtual bool parseFromFile (const char *onnxModelFile, int verbosity)=0
 Parse an onnx model file, can be a binary protobuf or a text onnx model calls parse method inside. More...
 
virtual bool supportsModel (void const *serialized_onnx_model, size_t serialized_onnx_model_size, SubGraphCollection_t &sub_graph_collection)=0
 Check whether TensorRT supports a particular ONNX model. More...
 
virtual bool parseWithWeightDescriptors (void const *serialized_onnx_model, size_t serialized_onnx_model_size, uint32_t weight_count, onnxTensorDescriptorV1 const *weight_descriptors)=0
 Parse a serialized ONNX model into the TensorRT network with consideration of user provided weights. More...
 
virtual bool supportsOperator (const char *op_name) const =0
 Returns whether the specified operator may be supported by the parser. More...
 
virtual void destroy ()=0
 destroy this object More...
 
virtual int getNbErrors () const =0
 Get the number of errors that occurred during prior calls to parse. More...
 
virtual IParserError const * getError (int index) const =0
 Get an error that occurred during prior calls to parse. More...
 
virtual void clearErrors ()=0
 Clear errors from prior calls to parse. More...
 
virtual int getRefitMap (const char **weightNames, const char **layerNames, nvinfer1::WeightsRole *roles)=0
 Get description of all ONNX weights that can be refitted. More...
 

Protected Member Functions

virtual ~IParser ()
 

Detailed Description

an object for parsing ONNX models into a TensorRT network definition

Constructor & Destructor Documentation

◆ ~IParser()

virtual nvonnxparser::IParser::~IParser ( )
inlineprotectedvirtual

Member Function Documentation

◆ parse()

virtual bool nvonnxparser::IParser::parse ( void const *  serialized_onnx_model,
size_t  serialized_onnx_model_size 
)
pure virtual

Parse a serialized ONNX model into the TensorRT network.

This method has very limited diagnostic. If parsing the serialized model fails for any reason (e.g. unsupported IR version, unsupported opset, etc.) it the user responsibility to intercept and report the error. To obtain a better diagnostic, use the parseFromFile method below.

Parameters
serialized_onnx_modelPointer to the serialized ONNX model
serialized_onnx_model_sizeSize of the serialized ONNX model in bytes
Returns
true if the model was parsed successfully
See also
getNbErrors() getError()

◆ parseFromFile()

virtual bool nvonnxparser::IParser::parseFromFile ( const char *  onnxModelFile,
int  verbosity 
)
pure virtual

Parse an onnx model file, can be a binary protobuf or a text onnx model calls parse method inside.

Parameters
Filename
VerbosityLevel
Returns
true if the model was parsed successfully

◆ supportsModel()

virtual bool nvonnxparser::IParser::supportsModel ( void const *  serialized_onnx_model,
size_t  serialized_onnx_model_size,
SubGraphCollection_t &  sub_graph_collection 
)
pure virtual

Check whether TensorRT supports a particular ONNX model.

Parameters
serialized_onnx_modelPointer to the serialized ONNX model
serialized_onnx_model_sizeSize of the serialized ONNX model in bytes
sub_graph_collectionContainer to hold supported subgraphs
Returns
true if the model is supported

◆ parseWithWeightDescriptors()

virtual bool nvonnxparser::IParser::parseWithWeightDescriptors ( void const *  serialized_onnx_model,
size_t  serialized_onnx_model_size,
uint32_t  weight_count,
onnxTensorDescriptorV1 const *  weight_descriptors 
)
pure virtual

Parse a serialized ONNX model into the TensorRT network with consideration of user provided weights.

Parameters
serialized_onnx_modelPointer to the serialized ONNX model
serialized_onnx_model_sizeSize of the serialized ONNX model in bytes
weight_countnumber of user provided weights
weight_descriptorspointer to user provided weight array
Returns
true if the model was parsed successfully
See also
getNbErrors() getError()

◆ supportsOperator()

virtual bool nvonnxparser::IParser::supportsOperator ( const char *  op_name) const
pure virtual

Returns whether the specified operator may be supported by the parser.

Note that a result of true does not guarantee that the operator will be supported in all cases (i.e., this function may return false-positives).

Parameters
op_nameThe name of the ONNX operator to check for support

◆ destroy()

virtual void nvonnxparser::IParser::destroy ( )
pure virtual

destroy this object

◆ getNbErrors()

virtual int nvonnxparser::IParser::getNbErrors ( ) const
pure virtual

Get the number of errors that occurred during prior calls to parse.

See also
getError() clearErrors() IParserError

◆ getError()

virtual IParserError const* nvonnxparser::IParser::getError ( int  index) const
pure virtual

Get an error that occurred during prior calls to parse.

See also
getNbErrors() clearErrors() IParserError

◆ clearErrors()

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

Clear errors from prior calls to parse.

See also
getNbErrors() getError() IParserError

◆ getRefitMap()

virtual int nvonnxparser::IParser::getRefitMap ( const char **  weightNames,
const char **  layerNames,
nvinfer1::WeightsRole roles 
)
pure virtual

Get description of all ONNX weights that can be refitted.

Parameters
weightsNamesWhere to write the weight names to
layerNamesWhere to write the layer names to
rolesWhere to write the roles to
Returns
The number of weights from the ONNX model that can be refitted

If weightNames or layerNames != nullptr, each written pointer points to a string owned by the parser, and becomes invalid when the parser is destroyed

If the same weight is used in multiple TRT layers it will be represented as a new entry in weightNames with name <weightName>_x, with x being the number of times the weight has been used before the current layer


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