first of all, i use caffe, :)
about sample fasterRCNN
in sample fasterRCNN, we call createRPNROIPlugin in IPluginFactoryV2.createPlugin, so the plugin be registed in runtime
so that, when we deserialize, we could get the right thing even though we pass nullptr into deserializeCudaEngine
FRCNNPluginFactory pluginFactory;
ICudaEngine* engine = runtime->deserializeCudaEngine(trtModelStream->data(), trtModelStream->size(), nullptr);
hope that i understand right about sample fasterRCNN registery process
about deserializeCudaEngine
but, what if i have a FooPlugin, and clearly there is not such CreateFooPlugin function in NvInferPlugin.h
so, i write a FooPluginV2, and write a FooPluginFactoryV2, and serialize engine and write IHostMemory->data() into a file
class FooPluginV2 : public nvinfer1::IPluginV2{
}
class FooPluginFactoryV2 : public nvcaffeparser1::IPluginFactoryV2{
}
FooPluginFactoryV2 foo_factoryv2;
parser->setPluginFactoryV2(foo_factoryv2);
// we build done
trtModelStream = engine->serialize();
ifile.write((char*)trtModelStream->data(), trtModelStream->size());
// serialize done
still, i can not deserialize from file
runtime->deserializeCudaEngine accept IPluginFactory* but not IPluginV2Factory*
// not IPluginFactoryV2!!!!!!!
nvinfer1::ICudaEngine* deserializeCudaEngine(const void* blob, std::size_t size, IPluginFactory* pluginFactory)
so i can not pass my FooIPluginFactoryV2 into runtime->deserializeCudaEngine
now, i am stuck
IPluginCreator
well, a lot of questions
from sdk docs, what i should do:
class FooPluginCreator : public IPluginCreator
{
...implement all creator methods here
};
REGISTER_TENSORRT_PLUGIN(FooPluginCreator);
what if i have some layers, different names, but same layer type
like 5 layers, name foo1, foo2, foo3, foo4, foo5, and they are same layer type FoolType
so i must create one IPluginCreator for each one layer?
class IPluginCreator
{
// return name, not pass a name!
virtual const char* getPluginName() const = 0;
// but why pass a name?
virtual IPluginV2* deserializePlugin(const char* name, const void* serialData, size_t serialLength) = 0;
}