MCPcopy Create free account
hub / github.com/NVIDIA/TensorRT / addPluginCreator

Method addPluginCreator

plugin/api/inferPlugin.cpp:94–140  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

92
93 template <typename CreatorType>
94 void addPluginCreator(void* logger, char const* libNamespace)
95 {
96 // Make accesses to the plugin creator registry thread safe
97 std::lock_guard<std::mutex> lock(mRegistryLock);
98
99 std::string errorMsg;
100 std::string verboseMsg;
101
102 std::unique_ptr<CreatorType> pluginCreator{new CreatorType{}};
103 pluginCreator->setPluginNamespace(libNamespace);
104
105 nvinfer1::plugin::gLogger = static_cast<nvinfer1::ILogger*>(logger);
106 std::string pluginType = std::string{pluginCreator->getPluginNamespace()}
107 + "::" + std::string{pluginCreator->getPluginName()} + " version "
108 + std::string{pluginCreator->getPluginVersion()};
109
110 if (mRegistryList.find(pluginType) == mRegistryList.end())
111 {
112 bool status = getPluginRegistry()->registerCreator(*pluginCreator, libNamespace);
113 if (status)
114 {
115 mRegistry.push(std::move(pluginCreator));
116 mRegistryList.insert(pluginType);
117 verboseMsg = "Registered plugin creator - " + pluginType;
118 }
119 else
120 {
121 errorMsg = "Could not register plugin creator - " + pluginType;
122 }
123 }
124 else
125 {
126 verboseMsg = "Plugin creator already registered - " + pluginType;
127 }
128
129 if (logger)
130 {
131 if (!errorMsg.empty())
132 {
133 nvinfer1::plugin::gLogger->log(ILogger::Severity::kERROR, errorMsg.c_str());
134 }
135 if (!verboseMsg.empty())
136 {
137 nvinfer1::plugin::gLogger->log(ILogger::Severity::kVERBOSE, verboseMsg.c_str());
138 }
139 }
140 }
141
142 ~PluginCreatorRegistry()
143 {

Callers

nothing calls this directly

Calls 9

insertMethod · 0.80
c_strMethod · 0.80
setPluginNamespaceMethod · 0.45
getPluginNamespaceMethod · 0.45
getPluginNameMethod · 0.45
getPluginVersionMethod · 0.45
findMethod · 0.45
emptyMethod · 0.45
logMethod · 0.45

Tested by

no test coverage detected