Remove third party debug functionality (#1658)
authorРоман Михайлович Русяев/AI Tools Lab /SRR/Staff Engineer/삼성전자 <r.rusyaev@samsung.com>
Thu, 27 Sep 2018 11:49:27 +0000 (14:49 +0300)
committerSergey Vostokov/AI Tools Lab /SRR/Staff Engineer/삼성전자 <s.vostokov@samsung.com>
Thu, 27 Sep 2018 11:49:27 +0000 (14:49 +0300)
* Remove unused third party debug functionality

Signed-off-by: Roman Rusyaev <r.rusyaev@samsung.com>
contrib/nnc/README.md
contrib/nnc/driver/Options.cpp
contrib/nnc/driver/main.cpp
contrib/nnc/include/option/Options.h
contrib/nnc/include/support/Debug.h [deleted file]
contrib/nnc/support/CMakeLists.txt
contrib/nnc/support/Debug.cpp [deleted file]

index d1f0373..538811f 100644 (file)
@@ -13,8 +13,6 @@ nnc OPTIONS
 ### OPTIONS
 
         --help, -h            -    print usage and exit
-        --debug               -    turn debugging on (optional: provide filename)
-        --debug-area          -    if specified, debug code will be executed only in given areas
         --caffe               -    treat input file as Caffe model
         --tflite              -    treat input file as Tensor Flow Lite model
         --target              -    select target language to emit for given architecture.
index 85f34bb..32e58bc 100644 (file)
@@ -18,16 +18,6 @@ Option<bool> Help(optname("--help, -h"),
                   overview("print usage and exit"),
                   false,
                   optional(true));
-Option<std::string> debugMode(optname("--debug"),
-                               overview("turn debugging on (optional: provide filename)"),
-                               "-", // when option is not passed to command line
-                               optional(true),
-                               optvalues(""),
-                               checkDebugFile);
-Option<std::string> debugZones(optname("--debug-area"),
-                               overview("if specified, debug code will be executed only in given areas"),
-                               "",
-                               optional(true));
 Option<bool> caffeFrontend(optname("--caffe"),
                            overview("treat input file as Caffe model"),
                            false,
index 58b00f0..26d3420 100644 (file)
@@ -5,8 +5,6 @@
 #include "pass/PassException.h"
 #include "Driver.h"
 
-#define DEBUG_AREA
-
 using namespace nncc::contrib;
 using namespace nncc::contrib::pass;
 
index c33c7bf..4e03212 100644 (file)
@@ -22,8 +22,6 @@ extern Option<bool> tflFrontend;    // frontend for TensorFlow Lite AI framework
 #define NNC_TARGET_ARM_GPU_CPP  "arm-gpu-c++"
 #define NNC_TARGET_INTERPRETER  "interpreter"
 extern Option<std::string> target;  // kind of target for which compiler generates code
-extern Option<std::string> debugMode;
-extern Option<std::string> debugZones;
 
 /**
  * Frontend options
diff --git a/contrib/nnc/include/support/Debug.h b/contrib/nnc/include/support/Debug.h
deleted file mode 100644 (file)
index 2dad4cd..0000000
+++ /dev/null
@@ -1,105 +0,0 @@
-// The implementation is mostly borrowed from LLVM
-//
-// This file is distributed under the University of Illinois Open Source
-// License.
-// TODO: add license text
-//
-// !!! If NO_NNC_DEBUG is defined the functionality of the following code in disabled !!!
-//
-// Usage:
-// 1- Make sure the project is built in debug configuration.
-//    It should have macros NO_NNC_DEBUG undefinded.
-//
-// 2- Include this header and define DEBUG_AREA as a string in your code, enclosing it.
-//    Example:
-//    #define DEBUG_AREA "interpreter"
-//    ...
-//    <interpreter source code>
-//    ...
-//    #undef DEBUG_AREA
-//
-// 3- When running nnc, enable debugging by providing "--debug" option.
-//    If the option is not provided, the debugging functionality is disabled.
-//    Optionally, you may provide a filename to print debug info into.
-//    Example: nnc --debug log.txt <...>
-//
-// 4- If you only want to debug some specified areas of code, use
-//    "--debug-area area1,area2,area3", (areas are separated by commas)
-//    where area1 etc. are DEBUG_AREAs as defined in your code
-//    (in this example: #define DEBUG_AREA "area1" ... etc.)
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef NNCC_DEBUG_H
-#define NNCC_DEBUG_H
-
-#include <iostream>
-#include <vector>
-
-namespace nncc {
-namespace contrib {
-
-/// This boolean is set to true if the "--debug" command line option
-/// is specified.  This should probably not be referenced directly, instead, use
-/// the DEBUG macro below.
-///
-extern bool DebugFlag;
-
-/// dbgs() - This returns a reference to an ostream for debugging
-/// messages. Return std::cerr by default.
-/// Use it like: dbgs() << "foo" << "bar";
-std::ostream &dbgs();
-
-// When building in release configuration, define NO_NNC_DEBUG to disable debugging features.
-#ifndef NO_NNC_DEBUG
-/// isCurrentDebugZone - Return true if the specified string is the debug type
-/// specified on the command line, or if none was specified on the command line
-/// with the "--debug-area X" option.
-///
-bool isCurrentDebugZone(const char *zone);
-
-/// setCurrentDebugZones - Set the current debug type, as if the
-/// "--debug-area X,Y,Z" option were specified. Note that DebugFlag
-/// also needs to be set to true for debug output to be produced.
-///
-void setCurrentDebugZones(std::vector<const char *> zones);
-
-/// setDebugFile - Set file to output debug info to.
-///
-void setDebugFile(const char* filename);
-
-/// DEBUG_SPECIFIED macro - This macro should be used by passes to emit debug
-/// information.  If the '--debug' option is specified on the commandline, and if
-/// this is a debug build, then the code specified as the option to the macro
-/// will be executed.  Otherwise it will not be.
-/// Example:
-///
-/// DEBUG_SPECIFIED("bitset", dbgs() << "Bitset contains: " << Bitset << "\n");
-///
-/// will emit the debug information if --debug is present, and --debug-area
-/// is not specified, or is specified as "bitset".
-#define DEBUG_SPECIFIED(ZONE, X)                                 \
-   do { if (::nncc::contrib::DebugFlag &&                      \
-            ::nncc::contrib::isCurrentDebugZone(ZONE)) { X; }  \
-   } while (false)
-
-#else
-#define isCurrentDebugZone(X) (false)
-#define setCurrentDebugZones(X, N)
-#define setDebugFile(X)
-#define DEBUG_SPECIFIED(ZONE, X) do { } while (false)
-#endif // NO_NNC_DEBUG
-
-// DEBUG macro - This macro should be used by passes to emit debug information.
-// If the '--debug' option is specified on the commandline, and if this is a
-// debug build, then the code specified as the option to the macro will be
-// executed.  Otherwise it will not be.  Example:
-//
-// NNC_DEBUG(dbgs() << "Bitset contains: " << Bitset << "\n");
-//
-#define NNC_DEBUG(X) DEBUG_SPECIFIED(DEBUG_AREA, X)
-
-}  // namespace contrib
-}  // namespace nncc
-
-#endif // NNCC_DEBUG_H
index edd06fc..03d980e 100644 (file)
@@ -1,7 +1,6 @@
 set(SUPPORT_SOURCES
         CommandLine.cpp
-        CLOptionChecker.cpp
-        Debug.cpp)
+        CLOptionChecker.cpp)
 
 add_library(nnc_support SHARED ${SUPPORT_SOURCES})
 set_target_properties(nnc_support PROPERTIES LINKER_LANGUAGE CXX)
diff --git a/contrib/nnc/support/Debug.cpp b/contrib/nnc/support/Debug.cpp
deleted file mode 100644 (file)
index f2005b9..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-// The implementation is mostly borrowed from LLVM
-//
-// This file is distributed under the University of Illinois Open Source
-// License.
-// TODO: add license text
-//===----------------------------------------------------------------------===//
-
-#include <fstream>
-
-#include "support/Debug.h"
-
-#undef isCurrentDebugZone
-#undef setCurrentDebugZones
-#undef setDebugFile
-
-namespace nncc {
-namespace contrib {
-
-bool DebugFlag = false;
-
-#ifndef NO_NNC_DEBUG
-
-static std::vector <std::string> currentDebugZone;
-
-bool isCurrentDebugZone(const char *debugZone) {
-  if (currentDebugZone.empty())
-    return true;
-  // Note: do not use find() as that forces us to
-  // unnecessarily create an std::string instance.
-  for (auto &d : currentDebugZone) {
-    if (d == debugZone)
-      return true;
-  }
-  return false;
-}
-
-void setCurrentDebugZones(std::vector<const char *> zones) {
-  currentDebugZone.clear();
-  for (const char * zone : zones) {
-    currentDebugZone.push_back(zone);
-  }
-}
-
-static std::ofstream log;
-
-void setDebugFile(const char* filename)
-{
-  log.open(filename, std::ofstream::trunc);
-}
-
-std::ostream &dbgs()
-{
-  if (log.is_open())
-    return log;
-  else
-    return std::cerr;
-}
-
-#else
-
-std::ostream &dbgs() { return std::cerr; }
-
-#endif // NO_NNC_DEBUG
-
-} // namespace contrib
-} // namespace nncc