其他分享
首页 > 其他分享> > TensorRT升级错误:error: invalid new-expression of abstract class type ‘nvinfer1::UpsampleLayerPlugin’

TensorRT升级错误:error: invalid new-expression of abstract class type ‘nvinfer1::UpsampleLayerPlugin’

作者:互联网

将TensorRT由7升级到8的过程中遇到如下错误

plugins/upsample.cpp: In member function ‘virtual nvinfer1::IPluginV2Ext* nvinfer1::UpsampleLayerPlugin::clone() const’:
plugins/upsample.cpp:176:53: error: invalid new-expression of abstract class type ‘nvinfer1::UpsampleLayerPlugin’
         auto* plugin = new UpsampleLayerPlugin(*this);
                                                     ^
In file included from plugins/upsample.cpp:6:0:
plugins/upsample.h:22:11: note:   because the following virtual functions are pure within ‘nvinfer1::UpsampleLayerPlugin’:
     class UpsampleLayerPlugin : public IPluginV2IOExt
           ^
In file included from ../include/tensorrt/NvInferLegacyDims.h:53:0,
                 from ../include/tensorrt/NvInfer.h:53,
                 from plugins/upsample.cpp:2:
../include/tensorrt/NvInferRuntimeCommon.h:541:21: note: 	virtual int32_t nvinfer1::IPluginV2::enqueue(int32_t, const void* const*, void* const*, void*, cudaStream_t)
     virtual int32_t enqueue(int32_t batchSize, void const* const* inputs, void* const* outputs, void* workspace,
                     ^
plugins/upsample.cpp: In member function ‘virtual nvinfer1::IPluginV2* nvinfer1::UpsampleLayerCreator::deserializePlugin(const char*, const void*, size_t)’:
plugins/upsample.cpp:220:64: error: invalid new-expression of abstract class type ‘nvinfer1::UpsampleLayerPlugin’
         return new UpsampleLayerPlugin(serialData, serialLength);

google搜索得到如下答案:

以及如下答案:

原因就是基类的某个纯虚函数没有被派生类实例化,从报错看是因为基类的enqueue纯虚函数没有被派生类实例化导致报错.然后发现派生类中有enqueue这个函数,只是函数参数有一个小差别.

标签:const,nvinfer1,abstract,upsample,UpsampleLayerPlugin,plugins,type,void
来源: https://blog.csdn.net/u013171226/article/details/119175525