IPluginV2 clone 3 tims? why?

i create a prelu plugin(PreluPlugin), it has a name relu0, and has two outputs

class PreluPlugin : public nvinfer1::IPluginV2{
name = "relu0";

then, when it clone, we would append a “_split” suffixin into new clone name, like:

IPluginV2* PreluPlugin::clone() const {
	PreluPlugin* new_prelu = new PreluPlugin();
	new_prelu->name = name + "_split";
	return new_prelu;

then, iadd some cout statements in destroymethod, like:

void PreluPlugin::destroy() {
	// \brief Destroy the plugin object. This will be called when the network, builder or engine is destroyed.
	std::cout << "PreluPlugin.destroy: " << name << "\n";

i run a example code, then found there are 3 clone objects, like:

and the first two, i can understand why, it is that maybe tensorrt would clone relu0 twice and pass ech one of them to next two layers, and destroy them when finish builting engine

but the last one, it would be destroyed when main function return, and i can not figure why by myself?

Hello, is this for ONNX? If so, latest TensorRT 5GA already supports PreLu.


it is for caffe, and i see prelu plugin in NvInferPlugin.h

but there are some custom plugin in my net, and i wanna use tensorrt to increase the performance

so, i just wanna figure out how tensorrt works inside, learn more source details


From the documentation - clone()

This is called every time a new builder, network or engine is created which includes this plugin layer. It should return a new plugin object with the correct parameters. The objects get destroyed when the builder, network or engine are respectively destroyed.

The plugin object created in the caffe IPluginFactoryV2 createPlugin() function should be destroyed by the user.