diff --git a/examples/cli/main.cpp b/examples/cli/main.cpp index ed3f849..bc54442 100644 --- a/examples/cli/main.cpp +++ b/examples/cli/main.cpp @@ -1306,7 +1306,7 @@ void parse_args(int argc, const char** argv, SDParams& params) { } if (params.n_threads <= 0) { - params.n_threads = get_num_physical_cores(); + params.n_threads = sd_get_num_physical_cores(); } if ((params.mode == IMG_GEN || params.mode == VID_GEN) && params.prompt.length() == 0) { diff --git a/model.cpp b/model.cpp index 1f0ad82..f771d4e 100644 --- a/model.cpp +++ b/model.cpp @@ -265,8 +265,8 @@ void convert_tensor(void* src, } else { auto qtype = ggml_get_type_traits(src_type); if (qtype->to_float == nullptr) { - throw std::runtime_error(format("type %s unsupported for integer quantization: no dequantization available", - ggml_type_name(src_type))); + throw std::runtime_error(sd_format("type %s unsupported for integer quantization: no dequantization available", + ggml_type_name(src_type))); } qtype->to_float(src, (float*)dst, n); } @@ -275,8 +275,8 @@ void convert_tensor(void* src, // src_type is quantized => dst_type == GGML_TYPE_F16 or dst_type is quantized auto qtype = ggml_get_type_traits(src_type); if (qtype->to_float == nullptr) { - throw std::runtime_error(format("type %s unsupported for integer quantization: no dequantization available", - ggml_type_name(src_type))); + throw std::runtime_error(sd_format("type %s unsupported for integer quantization: no dequantization available", + ggml_type_name(src_type))); } std::vector buf; buf.resize(sizeof(float) * n); @@ -1355,7 +1355,7 @@ bool ModelLoader::load_tensors(on_new_tensor_cb_t on_new_tensor_cb, int n_thread std::atomic copy_to_backend_time_ms(0); std::atomic convert_time_ms(0); - int num_threads_to_use = n_threads_p > 0 ? n_threads_p : get_num_physical_cores(); + int num_threads_to_use = n_threads_p > 0 ? n_threads_p : sd_get_num_physical_cores(); LOG_DEBUG("using %d threads for model loading", num_threads_to_use); int64_t start_time = ggml_time_ms(); diff --git a/stable-diffusion.cpp b/stable-diffusion.cpp index 8bebba2..7306561 100644 --- a/stable-diffusion.cpp +++ b/stable-diffusion.cpp @@ -2474,7 +2474,7 @@ void sd_ctx_params_init(sd_ctx_params_t* sd_ctx_params) { *sd_ctx_params = {}; sd_ctx_params->vae_decode_only = true; sd_ctx_params->free_params_immediately = true; - sd_ctx_params->n_threads = get_num_physical_cores(); + sd_ctx_params->n_threads = sd_get_num_physical_cores(); sd_ctx_params->wtype = SD_TYPE_COUNT; sd_ctx_params->rng_type = CUDA_RNG; sd_ctx_params->sampler_rng_type = RNG_TYPE_COUNT; diff --git a/stable-diffusion.h b/stable-diffusion.h index 0cbefd9..b0d3ee6 100644 --- a/stable-diffusion.h +++ b/stable-diffusion.h @@ -288,7 +288,7 @@ typedef void (*sd_preview_cb_t)(int step, int frame_count, sd_image_t* frames, b SD_API void sd_set_log_callback(sd_log_cb_t sd_log_cb, void* data); SD_API void sd_set_progress_callback(sd_progress_cb_t cb, void* data); SD_API void sd_set_preview_callback(sd_preview_cb_t cb, enum preview_t mode, int interval, bool denoised, bool noisy, void* data); -SD_API int32_t get_num_physical_cores(); +SD_API int32_t sd_get_num_physical_cores(); SD_API const char* sd_get_system_info(); SD_API const char* sd_type_name(enum sd_type_t type); diff --git a/util.cpp b/util.cpp index f101c3b..68250a9 100644 --- a/util.cpp +++ b/util.cpp @@ -57,7 +57,7 @@ void replace_all_chars(std::string& str, char target, char replacement) { } } -std::string format(const char* fmt, ...) { +std::string sd_format(const char* fmt, ...) { va_list ap; va_list ap2; va_start(ap, fmt); @@ -148,7 +148,7 @@ std::string get_full_path(const std::string& dir, const std::string& filename) { // get_num_physical_cores is copy from // https://github.com/ggerganov/llama.cpp/blob/master/examples/common.cpp // LICENSE: https://github.com/ggerganov/llama.cpp/blob/master/LICENSE -int32_t get_num_physical_cores() { +int32_t sd_get_num_physical_cores() { #ifdef __linux__ // enumerate the set of thread siblings, num entries is num cores std::unordered_set siblings; diff --git a/util.h b/util.h index 2721f29..61ca933 100644 --- a/util.h +++ b/util.h @@ -14,7 +14,7 @@ bool ends_with(const std::string& str, const std::string& ending); bool starts_with(const std::string& str, const std::string& start); bool contains(const std::string& str, const std::string& substr); -std::string format(const char* fmt, ...); +std::string sd_format(const char* fmt, ...); void replace_all_chars(std::string& str, char target, char replacement);