What to use instead of `nvonnxparser::IParser::destroy()`?

I have some code that calls the deprecated function nvonnxparser::IParser::destroy() - the API notes that this is deprecated but doesn’t suggest an alternative, how should I modify my code to not use this deprecated lib function?

The warning:

warning: 'virtual void nvonnxparser::IParser::destroy()' is deprecated [-Wdeprecated-declarations] parser->destroy();

the code in context:

    nvinfer1::IBuilder *builder =                                                  
        nvinfer1::createInferBuilder(gLogger.getTRTLogger());                      
    assert(builder != nullptr);                                                    
                                                                                   
    const auto explicitBatch =                                                     
        1U << static_cast<uint32_t>(                                               
            nvinfer1::NetworkDefinitionCreationFlag::kEXPLICIT_BATCH);             
    auto network = builder->createNetworkV2(explicitBatch);                        
    auto config = builder->createBuilderConfig();                                  
                                                                                   
    auto parser = nvonnxparser::createParser(*network, gLogger.getTRTLogger());    
    if (!parser->parseFromFile(                                                    
            modelFile.c_str(),                                                     
            static_cast<int>(gLogger.getReportableSeverity()))) {                  
      gLogError << "Failure while parsing ONNX file" << std::endl;                 
    }                                                                              
    // Build the engine                                                            
    builder->setMaxBatchSize(BATCH_SIZE);                                          
    config->setMaxWorkspaceSize(2300_MiB);                                         
    config->setFlag(nvinfer1::BuilderFlag::kFP16);                                 
                                                                                   
    std::cout << "start building engine" << std::endl;                             
    nvinfer1::IHostMemory*  serializedModel = builder->buildSerializedNetwork(*network, *config);
    std::cout << "build engine done" << std::endl;                                 
    assert(engine);                                                                
    // we can destroy the parser                                                   
    parser->destroy();  

Hi,

Please refer to the following API doc, as mentioned destroy() will be removed from the TensorRT 10.0 onwards.
https://docs.nvidia.com/deeplearning/tensorrt/api/c_api/classnvonnxparser_1_1_i_parser.html#a6eb44b7dcbc7880c9bb11663424a3e14

We can just use the destructor. or delete/free if it’s a pointer.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.