diff --git a/otherarch/sdcpp/sdtype_adapter.cpp b/otherarch/sdcpp/sdtype_adapter.cpp index 6149193bc65a..e7dc280ccb4c 100644 --- a/otherarch/sdcpp/sdtype_adapter.cpp +++ b/otherarch/sdcpp/sdtype_adapter.cpp @@ -363,7 +363,9 @@ static bool is_video_model(kcpp_sd::model_info info) bool sdtype_load_model(const sd_load_model_inputs inputs) { - kcpp_sd_preserve_ggml_logger(); + sddebugmode = inputs.debugmode; + set_sd_log_level(sddebugmode); + ggml_log_set(kcpp_sd_ggml_log_callback); sd_is_quiet = inputs.quiet; set_sd_quiet(sd_is_quiet); @@ -537,10 +539,6 @@ bool sdtype_load_model(const sd_load_model_inputs inputs) { } } - sddebugmode = inputs.debugmode; - - set_sd_log_level(sddebugmode); - sd_ctx_params_t params = {}; sd_ctx_params_init(¶ms); @@ -1943,6 +1941,9 @@ void sdtype_request_ongoing_generation_preview() sd_generation_outputs sdtype_upscale(const sd_upscale_inputs inputs) { + set_sd_log_level(sddebugmode); + ggml_log_set(kcpp_sd_ggml_log_callback); + sd_generation.reset(); if(sd_ctx == nullptr || upscaler_ctx == nullptr || sd_params == nullptr) diff --git a/otherarch/sdcpp/src/core/util.cpp b/otherarch/sdcpp/src/core/util.cpp index 2ba895d9083f..b6daf6eb75ce 100644 --- a/otherarch/sdcpp/src/core/util.cpp +++ b/otherarch/sdcpp/src/core/util.cpp @@ -522,6 +522,14 @@ bool parse_strict_bool(const std::string& text, bool& value) { // { kcpp static int sdloglevel = INT_MAX; // -1 = hide all, 0 = normal, 1 = showall, INT_MAX = sdcpp static bool sdquiet = false; + +void kcpp_sd_ggml_log_set(void) { + /* block ggml log changes on Koboldcpp */ + if (sdloglevel == INT_MAX) { + ggml_log_set(sd_ggml_log_callback, nullptr); + } +} + // } kcpp static std::string build_progress_bar(int step, int steps, char progress_char = '=', bool show_head = true) { diff --git a/otherarch/sdcpp/src/core/util.h b/otherarch/sdcpp/src/core/util.h index bb4dc9d7adf9..a5b9b0f1c646 100644 --- a/otherarch/sdcpp/src/core/util.h +++ b/otherarch/sdcpp/src/core/util.h @@ -120,4 +120,7 @@ bool sd_backend_is(ggml_backend_t backend, const std::string& name); #define LOG_INFO(format, ...) log_printf(SD_LOG_INFO, __FILE__, __LINE__, format, ##__VA_ARGS__) #define LOG_WARN(format, ...) log_printf(SD_LOG_WARN, __FILE__, __LINE__, format, ##__VA_ARGS__) #define LOG_ERROR(format, ...) log_printf(SD_LOG_ERROR, __FILE__, __LINE__, format, ##__VA_ARGS__) + +void kcpp_sd_ggml_log_set(void); + #endif // __SD_CORE_UTIL_H__ diff --git a/otherarch/sdcpp/src/pipeline/diffusion_engine.cpp b/otherarch/sdcpp/src/pipeline/diffusion_engine.cpp index 52be854b2978..09c52e819cbe 100644 --- a/otherarch/sdcpp/src/pipeline/diffusion_engine.cpp +++ b/otherarch/sdcpp/src/pipeline/diffusion_engine.cpp @@ -26,7 +26,6 @@ #include "model_builders.h" #include "model_loader.h" #include "model_manager.h" -#include "sdcpp_logger_adapter.h" #include "stable-diffusion.h" #include "conditioning/conditioner.hpp" @@ -1099,7 +1098,7 @@ bool StableDiffusionGGML::init(const sd_ctx_params_t* sd_ctx_params) { sampler_rng = rng; } - ggml_log_set(kcpp_sd_ggml_log_callback, nullptr); + kcpp_sd_ggml_log_set(); model_manager = std::make_shared(); model_manager->set_n_threads(n_threads); diff --git a/otherarch/sdcpp/src/upscaler.cpp b/otherarch/sdcpp/src/upscaler.cpp index 4b112774d637..d09416863fc1 100644 --- a/otherarch/sdcpp/src/upscaler.cpp +++ b/otherarch/sdcpp/src/upscaler.cpp @@ -3,7 +3,6 @@ #include "core/util.h" #include "model_loader.h" #include "runtime/tiling.h" -#include "sdcpp_logger_adapter.h" #include "stable-diffusion.h" #include @@ -36,7 +35,7 @@ void UpscalerGGML::set_max_graph_vram_bytes(size_t max_vram_bytes) { bool UpscalerGGML::load_from_file(const std::string& esrgan_path, int n_threads) { - ggml_log_set(kcpp_sd_ggml_log_callback, nullptr); + kcpp_sd_ggml_log_set(); std::string error; if (!backend_manager.init(backend_spec.c_str(),