Skip to content

fix(//core/plugins: Fix plugin debug log while importing trtorch #458

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

peri044
Copy link
Collaborator

@peri044 peri044 commented May 13, 2021

Description

import trtorch unnecessarily prints plugin debug info

Type of change

Please delete options that are not relevant and/or add your own.

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • My code follows the style guidelines of this project (You can use the linters)
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas and hacks
  • I have made corresponding changes to the documentation
  • I have added tests to verify my fix or my feature
  • New and existing unit tests pass locally with my changes

@peri044 peri044 requested a review from narendasan May 13, 2021 01:26
@github-actions github-actions bot added the component: core Issues re: The core compiler label May 13, 2021
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code conforms to Python style guidelines

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some changes that do not conform to C++ style guidelines:

diff --git a/workspace/core/plugins/register_plugins.cpp b/tmp/changes.txt
index f48214b..99c290f 100644
--- a/workspace/core/plugins/register_plugins.cpp
+++ b/tmp/changes.txt
@@ -14,9 +14,9 @@ namespace impl {
class TRTorchPluginRegistry {
 public:
  TRTorchPluginRegistry() {
-    #ifndef NDEBUG
-      trtorch_logger.log(util::logging::LogLevel::kDEBUG, "Instatiated the TRTorch plugin registry class");
-    #endif
+#ifndef NDEBUG
+    trtorch_logger.log(util::logging::LogLevel::kDEBUG, "Instatiated the TRTorch plugin registry class");
+#endif
    // register libNvInferPlugins and TRTorch plugins
    // trtorch_logger logging level is set to kERROR and reset back to kDEBUG.
    // This is because initLibNvInferPlugins initializes only a subset of plugins and logs them.
@@ -26,22 +26,22 @@ class TRTorchPluginRegistry {
    trtorch_logger.set_reportable_log_level(util::logging::LogLevel::kERROR);
    initLibNvInferPlugins(&trtorch_logger, "");
    trtorch_logger.set_reportable_log_level(util::logging::LogLevel::kDEBUG);
-    #ifndef NDEBUG
-      int numCreators = 0;
-      auto pluginsList = getPluginRegistry()->getPluginCreatorList(&numCreators);
-      for (int k = 0; k < numCreators; ++k) {
-        if (!pluginsList[k]) {
-          trtorch_logger.log(util::logging::LogLevel::kDEBUG, "Plugin creator for plugin " + str(k) + " is a nullptr");
-          continue;
-        }
-        std::string pluginNamespace = pluginsList[k]->getPluginNamespace();
-        trtorch_logger.log(
-            util::logging::LogLevel::kDEBUG,
-            "Registered plugin creator - " + std::string(pluginsList[k]->getPluginName()) +
-                ", Namespace: " + pluginNamespace);
+#ifndef NDEBUG
+    int numCreators = 0;
+    auto pluginsList = getPluginRegistry()->getPluginCreatorList(&numCreators);
+    for (int k = 0; k < numCreators; ++k) {
+      if (!pluginsList[k]) {
+        trtorch_logger.log(util::logging::LogLevel::kDEBUG, "Plugin creator for plugin " + str(k) + " is a nullptr");
+        continue;
      }
-      trtorch_logger.log(util::logging::LogLevel::kDEBUG, "Total number of plugins registered: " + str(numCreators));
-    #endif
+      std::string pluginNamespace = pluginsList[k]->getPluginNamespace();
+      trtorch_logger.log(
+          util::logging::LogLevel::kDEBUG,
+          "Registered plugin creator - " + std::string(pluginsList[k]->getPluginName()) +
+              ", Namespace: " + pluginNamespace);
+    }
+    trtorch_logger.log(util::logging::LogLevel::kDEBUG, "Total number of plugins registered: " + str(numCreators));
+#endif
  }

 public:
ERROR: Some files do not conform to style guidelines

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some changes that do not conform to C++ style guidelines:

diff --git a/workspace/core/plugins/register_plugins.cpp b/tmp/changes.txt
index f48214b..99c290f 100644
--- a/workspace/core/plugins/register_plugins.cpp
+++ b/tmp/changes.txt
@@ -14,9 +14,9 @@ namespace impl {
class TRTorchPluginRegistry {
 public:
  TRTorchPluginRegistry() {
-    #ifndef NDEBUG
-      trtorch_logger.log(util::logging::LogLevel::kDEBUG, "Instatiated the TRTorch plugin registry class");
-    #endif
+#ifndef NDEBUG
+    trtorch_logger.log(util::logging::LogLevel::kDEBUG, "Instatiated the TRTorch plugin registry class");
+#endif
    // register libNvInferPlugins and TRTorch plugins
    // trtorch_logger logging level is set to kERROR and reset back to kDEBUG.
    // This is because initLibNvInferPlugins initializes only a subset of plugins and logs them.
@@ -26,22 +26,22 @@ class TRTorchPluginRegistry {
    trtorch_logger.set_reportable_log_level(util::logging::LogLevel::kERROR);
    initLibNvInferPlugins(&trtorch_logger, "");
    trtorch_logger.set_reportable_log_level(util::logging::LogLevel::kDEBUG);
-    #ifndef NDEBUG
-      int numCreators = 0;
-      auto pluginsList = getPluginRegistry()->getPluginCreatorList(&numCreators);
-      for (int k = 0; k < numCreators; ++k) {
-        if (!pluginsList[k]) {
-          trtorch_logger.log(util::logging::LogLevel::kDEBUG, "Plugin creator for plugin " + str(k) + " is a nullptr");
-          continue;
-        }
-        std::string pluginNamespace = pluginsList[k]->getPluginNamespace();
-        trtorch_logger.log(
-            util::logging::LogLevel::kDEBUG,
-            "Registered plugin creator - " + std::string(pluginsList[k]->getPluginName()) +
-                ", Namespace: " + pluginNamespace);
+#ifndef NDEBUG
+    int numCreators = 0;
+    auto pluginsList = getPluginRegistry()->getPluginCreatorList(&numCreators);
+    for (int k = 0; k < numCreators; ++k) {
+      if (!pluginsList[k]) {
+        trtorch_logger.log(util::logging::LogLevel::kDEBUG, "Plugin creator for plugin " + str(k) + " is a nullptr");
+        continue;
      }
-      trtorch_logger.log(util::logging::LogLevel::kDEBUG, "Total number of plugins registered: " + str(numCreators));
-    #endif
+      std::string pluginNamespace = pluginsList[k]->getPluginNamespace();
+      trtorch_logger.log(
+          util::logging::LogLevel::kDEBUG,
+          "Registered plugin creator - " + std::string(pluginsList[k]->getPluginName()) +
+              ", Namespace: " + pluginNamespace);
+    }
+    trtorch_logger.log(util::logging::LogLevel::kDEBUG, "Total number of plugins registered: " + str(numCreators));
+#endif
  }

 public:
ERROR: Some files do not conform to style guidelines

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code conforms to Python style guidelines

Signed-off-by: Dheeraj Peri <[email protected]>
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code conforms to Python style guidelines

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code conforms to C++ style guidelines

@narendasan
Copy link
Collaborator

I think this PR is unnecessary. The logger will already gate messages based on severity

@narendasan
Copy link
Collaborator

#463 I think is a better implementation of this, closing in favor of that

@narendasan narendasan closed this May 13, 2021
@peri044 peri044 deleted the plugin_fix branch November 16, 2021 20:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: core Issues re: The core compiler
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants