Skip to content

Commit a156b56

Browse files
committed
Custom plugin registration calls moved
Signed-off-by: Dheeraj Peri <[email protected]>
1 parent 5660f55 commit a156b56

File tree

4 files changed

+29
-7
lines changed

4 files changed

+29
-7
lines changed

core/plugins/impl/interpolate_plugin.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,8 @@ const nvinfer1::PluginFieldCollection* InterpolatePluginCreator::getFieldNames()
417417
return nullptr;
418418
}
419419

420+
REGISTER_TRTORCH_PLUGIN(InterpolatePluginCreator);
421+
420422
} // namespace impl
421423
} // namespace plugins
422424
} // namespace core

core/plugins/impl/normalize_plugin.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,8 @@ const nvinfer1::PluginFieldCollection* NormalizePluginCreator::getFieldNames() {
286286
return nullptr;
287287
}
288288

289+
REGISTER_TRTORCH_PLUGIN(NormalizePluginCreator);
290+
289291
} // namespace impl
290292
} // namespace plugins
291293
} // namespace core

core/plugins/register_plugins.cpp

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,33 @@ namespace impl {
1414
class TRTorchPluginRegistry {
1515
public:
1616
TRTorchPluginRegistry() {
17-
auto trtorch_logger = util::logging::TRTorchLogger(
18-
"[TRTorch Plugins Context] - ",
19-
util::logging::get_logger().get_reportable_severity(),
20-
util::logging::get_logger().get_is_colored_output_on());
17+
trtorch_logger.log(util::logging::LogLevel::kINFO, "Instatiated the TRTorch plugin registry class");
2118
// register libNvInferPlugins and TRTorch plugins
19+
// trtorch_logger logging level is set to kERROR and reset back to kDEBUG.
20+
// This is because initLibNvInferPlugins initializes only a subset of plugins and logs them.
21+
// Plugins outside this subset in TensorRT are not being logged in this. So temporarily we disable this to prevent multiple logging of same plugins.
22+
// To provide a clear list of all plugins, we iterate through getPluginRegistry() where it prints the
23+
// list of all the plugins registered in TensorRT with their namespaces.
24+
trtorch_logger.set_reportable_log_level(util::logging::LogLevel::kERROR);
2225
initLibNvInferPlugins(&trtorch_logger, "");
23-
REGISTER_TRTORCH_PLUGIN(InterpolatePluginCreator);
24-
REGISTER_TRTORCH_PLUGIN(NormalizePluginCreator);
26+
trtorch_logger.set_reportable_log_level(util::logging::LogLevel::kDEBUG);
27+
28+
int numCreators = 0;
29+
auto pluginsList = getPluginRegistry()->getPluginCreatorList(&numCreators);
30+
for (int k = 0; k < numCreators; ++k) {
31+
if (!pluginsList[k]) {
32+
trtorch_logger.log(util::logging::LogLevel::kDEBUG, "Plugin creator for plugin " + str(k) + " is a nullptr");
33+
continue;
34+
}
35+
std::string pluginNamespace = pluginsList[k]->getPluginNamespace();
36+
trtorch_logger.log(util::logging::LogLevel::kDEBUG, "Registered plugin creator - " + std::string(pluginsList[k]->getPluginName()) + ", Namespace: " + pluginNamespace);
37+
}
38+
trtorch_logger.log(util::logging::LogLevel::kDEBUG, "Total number of plugins registered: " + str(numCreators));
2539
}
40+
public:
41+
util::logging::TRTorchLogger trtorch_logger = util::logging::TRTorchLogger("[TRTorch Plugins Context] - ",
42+
util::logging::LogLevel::kDEBUG,
43+
true);
2644
};
2745

2846
namespace {

examples/sample_rt_app/BUILD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ package(default_visibility = ["//visibility:public"])
44
# It has include, lib, bin directory and LICENSE file
55
cc_library(
66
name = "trtorch_runtime",
7-
srcs = ["trtorch/lib/libtrtorchrt.so", "trtorch/lib/libtrtorch_plugins.so"],
7+
srcs = ["trtorch/lib/libtrtorchrt.so"], # , "trtorch/lib/libtrtorch_plugins.so"
88
)
99

1010
cc_binary(

0 commit comments

Comments
 (0)