Skip to content

Commit 47a4656

Browse files
committed
refactor: log util
Signed-off-by: thxCode <thxcode0824@gmail.com>
1 parent c798862 commit 47a4656

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

stable-diffusion.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ SD_API void sd_log_set(sd_log_cb_t sd_log_cb, void* data);
109109
SD_API void sd_progress_set(sd_progress_cb_t cb, void* data);
110110
SD_API int32_t get_num_physical_cores();
111111
SD_API const char* sd_get_system_info();
112+
SD_API ggml_log_level sd_log_level_to_ggml_log_level(sd_log_level_t level);
112113

113114
typedef struct {
114115
uint32_t width;

util.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,19 @@ const char* sd_get_system_info() {
423423
return buffer;
424424
}
425425

426+
ggml_log_level sd_log_level_to_ggml_log_level(sd_log_level_t level) {
427+
switch (level) {
428+
case SD_LOG_INFO:
429+
return GGML_LOG_LEVEL_INFO;
430+
case SD_LOG_WARN:
431+
return GGML_LOG_LEVEL_WARN;
432+
case SD_LOG_ERROR:
433+
return GGML_LOG_LEVEL_ERROR;
434+
default:
435+
return GGML_LOG_LEVEL_DEBUG;
436+
}
437+
}
438+
426439
sd_image_f32_t sd_image_t_to_sd_image_f32_t(sd_image_t image) {
427440
sd_image_f32_t converted_image;
428441
converted_image.width = image.width;

0 commit comments

Comments
 (0)