caching logging functions + single include rebuild

This commit is contained in:
alexander-g 2021-01-24 15:44:07 +01:00
parent 059221a7de
commit a0f9af965a
3 changed files with 2101 additions and 2082 deletions

View file

@ -2,24 +2,21 @@
#include <pybind11/stl.h>
#include <pybind11/numpy.h>
#include <kompute/Core.hpp>
#include <kompute/Manager.hpp>
#include <kompute/operations/OpAlgoBase.hpp>
#include <kompute/operations/OpMult.hpp>
#include <kompute/operations/OpTensorSyncLocal.hpp>
#include <kompute/operations/OpTensorSyncDevice.hpp>
#include <kompute/operations/OpTensorCopy.hpp>
#include <kompute/operations/OpAlgoLhsRhsOut.hpp>
#include <AggregateHeaders.cpp>
#include "docstrings.hpp"
namespace py = pybind11;
//used in Core.hpp
py::object kp_logger;
py::object kp_debug, kp_info, kp_warning, kp_error;
PYBIND11_MODULE(kp, m) {
py::module_ logging = py::module_::import("logging");
kp_logger = logging.attr("getLogger")("kp");
py::module_ logging = py::module_::import("logging");
py::object kp_logger = logging.attr("getLogger")("kp");
kp_debug = kp_logger.attr("debug");
kp_info = kp_logger.attr("info");
kp_warning = kp_logger.attr("warning");
kp_error = kp_logger.attr("error");
logging.attr("basicConfig")();
py::module_ np = py::module_::import("numpy");

File diff suppressed because it is too large Load diff

View file

@ -36,7 +36,7 @@ static const char* KOMPUTE_LOG_TAG = "KomputeLog";
#include <pybind11/pybind11.h>
namespace py = pybind11;
//from python/src/main.cpp
extern py::object kp_logger;
extern py::object kp_debug, kp_info, kp_warning, kp_error;
#endif
@ -53,7 +53,7 @@ static const char* KOMPUTE_LOG_TAG = "KomputeLog";
((void)__android_log_print(ANDROID_LOG_DEBUG, KOMPUTE_LOG_TAG, message))
#elif defined(KOMPUTE_BUILD_PYTHON)
#define SPDLOG_DEBUG(message, ...) \
kp_logger.attr("debug")(message);
kp_debug(message);
#else
#define SPDLOG_DEBUG(message, ...) \
std::cout << "DEBUG: " << message << std::endl
@ -68,7 +68,7 @@ static const char* KOMPUTE_LOG_TAG = "KomputeLog";
((void)__android_log_print(ANDROID_LOG_INFO, KOMPUTE_LOG_TAG, message))
#elif defined(KOMPUTE_BUILD_PYTHON)
#define SPDLOG_INFO(message, ...) \
kp_logger.attr("info")(message);
kp_info(message);
#else
#define SPDLOG_INFO(message, ...) std::cout << "INFO: " << message << std::endl
#endif // VK_USE_PLATFORM_ANDROID_KHR
@ -82,7 +82,7 @@ static const char* KOMPUTE_LOG_TAG = "KomputeLog";
((void)__android_log_print(ANDROID_LOG_INFO, KOMPUTE_LOG_TAG, message))
#elif defined(KOMPUTE_BUILD_PYTHON)
#define SPDLOG_WARN(message, ...) \
kp_logger.attr("warning")(message);
kp_warning(message);
#else
#define SPDLOG_WARN(message, ...) \
std::cout << "WARNING: " << message << std::endl
@ -97,7 +97,7 @@ static const char* KOMPUTE_LOG_TAG = "KomputeLog";
((void)__android_log_print(ANDROID_LOG_INFO, KOMPUTE_LOG_TAG, message))
#elif defined(KOMPUTE_BUILD_PYTHON)
#define SPDLOG_ERROR(message, ...) \
kp_logger.attr("error")(message);
kp_error(message);
#else
#define SPDLOG_ERROR(message, ...) \
std::cout << "ERROR: " << message << std::endl