From: Denis Maksimenko/AI Tools Lab /SRR/Assistant Engineer/삼성전자 Date: Wed, 15 Aug 2018 11:42:16 +0000 (+0300) Subject: [nnc debug] Update debug format in sources (#943) X-Git-Tag: nncc_backup~2160 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=57b4a81be5b7728c070ca0697a402e838b758e3b;p=platform%2Fcore%2Fml%2Fnnfw.git [nnc debug] Update debug format in sources (#943) Changed format used for debugging in most files. Signed-off-by: Denis Maksimenko --- diff --git a/contrib/nnc/CMakeLists.txt b/contrib/nnc/CMakeLists.txt index 2fc75b0..9c88137 100644 --- a/contrib/nnc/CMakeLists.txt +++ b/contrib/nnc/CMakeLists.txt @@ -9,6 +9,8 @@ file(GLOB_RECURSE TESTS "unittests/*.cpp") file(GLOB_RECURSE MAIN "src/main.cpp") list(REMOVE_ITEM SOURCES ${MAIN}) +include_directories(include) + # Used by unit tests set(NNC_SOFT_BACKEND_DIR ${CMAKE_CURRENT_SOURCE_DIR}/libs/backend/soft) set(NNC_CORE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/libs/core) diff --git a/contrib/nnc/examples/plugin_example/samplePlugin.cpp b/contrib/nnc/examples/plugin_example/samplePlugin.cpp index 528d366..14b504e 100644 --- a/contrib/nnc/examples/plugin_example/samplePlugin.cpp +++ b/contrib/nnc/examples/plugin_example/samplePlugin.cpp @@ -6,6 +6,11 @@ #include "ConfigException.h" #include "PluginType.h" +// Enable debugging +#include "debug.h" +#define DEBUG_AREA "examples" +using nncc::contrib::dbgs; + static const std::string pluginName = "Your plugin name here"; static const std::string pluginVersion = "Your plugin version here"; static const std::string pluginDesc = "Your plugin description here"; @@ -39,7 +44,7 @@ private: AbstractPluginInstance &SamplePluginInstance::getInstance() { static SamplePluginInstance instance; - std::cout << std::endl << "!!! plugin (" << pluginName << ") " << __func__ << std::endl; + NNC_DEBUG(dbgs() << std::endl << "!!! plugin (" << pluginName << ") " << __func__ << std::endl); return instance; } @@ -62,18 +67,18 @@ void SamplePluginInstance::fillSession() void SamplePluginInstance::checkConfig() { - std::cout << std::endl << "!!! plugin (" << pluginName << ") " << __func__ << std::endl; + NNC_DEBUG(dbgs() << std::endl << "!!! plugin (" << pluginName << ") " << __func__ << std::endl); } void *SamplePluginInstance::execute(void *data) { - std::cout << std::endl << "!!! plugin (" << pluginName << ") " << __func__ << std::endl; + NNC_DEBUG(dbgs() << std::endl << "!!! plugin (" << pluginName << ") " << __func__ << std::endl); return data; } void SamplePluginInstance::setParam(const std::string &name) { - std::cout << "bad parameter <" << name << ">"; + NNC_DEBUG(dbgs() << "bad parameter <" << name << ">"); } void SamplePluginInstance::setParam(const std::string &name, const std::string &value) @@ -86,12 +91,12 @@ void SamplePluginInstance::setParam(const std::string &name, const std::string & { throw nncc::contrib::ConfigException("unsupported parameter <" + name + ">"); } - std::cout << __func__ << " : " << name << " = " << value << std::endl; + NNC_DEBUG(dbgs() << __func__ << " : " << name << " = " << value << std::endl); } extern "C" AbstractPluginInstance *get_instance() { - std::cout << std::endl << "!!! plugin (" << pluginName << ") " << __func__ << std::endl; + NNC_DEBUG(dbgs() << std::endl << "!!! plugin (" << pluginName << ") " << __func__ << std::endl); return &SamplePluginInstance::getInstance(); } diff --git a/contrib/nnc/libs/backend/soft/CMakeLists.txt b/contrib/nnc/libs/backend/soft/CMakeLists.txt index 5c53acd..686749f 100644 --- a/contrib/nnc/libs/backend/soft/CMakeLists.txt +++ b/contrib/nnc/libs/backend/soft/CMakeLists.txt @@ -17,6 +17,8 @@ target_include_directories(soft_backend_common PRIVATE ${CMAKE_CURRENT_BINARY_DI target_link_libraries(soft_backend_common PRIVATE nncc_core) target_link_libraries(soft_backend_common PRIVATE nnc_plugin_core) target_link_libraries(soft_backend_common PRIVATE nnc_core) +# This is included because right now common functional is built into nnc_module +target_link_libraries(soft_backend_common PRIVATE nnc_module) function(make_soft_backend NAME) add_library(${NAME} SHARED ${ARGN} ${SOFT_GENERATED_SOURCES}) diff --git a/contrib/nnc/libs/backend/soft/src/soft_backend.cpp b/contrib/nnc/libs/backend/soft/src/soft_backend.cpp index c3fa362..a796fc9 100644 --- a/contrib/nnc/libs/backend/soft/src/soft_backend.cpp +++ b/contrib/nnc/libs/backend/soft/src/soft_backend.cpp @@ -12,6 +12,9 @@ #include #include +#include "debug.h" +#define DEBUG_AREA "soft_backend" + using namespace std; using namespace nncc::contrib; using namespace nncc::contrib::config; @@ -98,7 +101,7 @@ void *BaseSoftBackend::execute(void *data) assert(data); Graph *graph = static_cast(data); generate(graph); - clog << "[" << _pluginName << "] Plugin executed" << endl; + NNC_DEBUG(dbgs() << "[" << _pluginName << "] Plugin executed" << endl); return data; } diff --git a/contrib/nnc/src/module/plugin/PluginManager.cpp b/contrib/nnc/src/module/plugin/PluginManager.cpp index 1d3aa3f..79cb971 100644 --- a/contrib/nnc/src/module/plugin/PluginManager.cpp +++ b/contrib/nnc/src/module/plugin/PluginManager.cpp @@ -16,6 +16,9 @@ #define STR_EXTENSION_PLUGIN ".so" #endif /* __APPLE__ */ +#include "debug.h" +#define DEBUG_AREA "plugins" + namespace nncc { namespace contrib @@ -64,8 +67,7 @@ std::vector PluginManager::getPluginPathList() { } void PluginManager::loadPlugins(std::vector &modules) { - // FIXME: it's necessary to make this printing via debugging system (see issue #893) - //std::cout << "Current plugin path is <" << _pluginsPath << ">" << std::endl; + NNC_DEBUG(dbgs() << "Current plugin path is <" << _pluginsPath << ">" << std::endl); auto plugins = getPluginPathList(); for (const auto &pluginPath : plugins) { @@ -159,8 +161,7 @@ void PluginManager::applyParam(const std::string &name) { } void PluginManager::applyParam(const std::string &name, const std::string &value) { - // FIXME: it's necessary to make this printing via debugging system (see issue #893) - //std::cout << __func__ << " <" + name + "> = " + value << std::endl; + NNC_DEBUG(dbgs() << __func__ << " <" + name + "> = " + value << std::endl); if (name == paramPluginPath) { _pluginsPath = value; } else { diff --git a/contrib/nnc/src/module/plugin/shared_library.cpp b/contrib/nnc/src/module/plugin/shared_library.cpp index 6a67603..698529c 100644 --- a/contrib/nnc/src/module/plugin/shared_library.cpp +++ b/contrib/nnc/src/module/plugin/shared_library.cpp @@ -3,6 +3,9 @@ #include "module/plugin/shared_library.h" +#include "debug.h" +#define DEBUG_AREA "plugins" + namespace nncc { namespace contrib @@ -45,7 +48,7 @@ bool SharedLibrary::loadLibrary() _isLoaded = true; // open the library - std::cout << "Opening " << _path << std::endl; + NNC_DEBUG(dbgs() << "Opening " << _path << std::endl); _handle = dlopen(_path.c_str(), RTLD_LAZY);