Skip to content

Commit e4c50f1

Browse files
authored
chore: add sd_ prefix to a few functions (#967)
1 parent 0743a1b commit e4c50f1

File tree

6 files changed

+11
-11
lines changed

6 files changed

+11
-11
lines changed

examples/cli/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1306,7 +1306,7 @@ void parse_args(int argc, const char** argv, SDParams& params) {
13061306
}
13071307

13081308
if (params.n_threads <= 0) {
1309-
params.n_threads = get_num_physical_cores();
1309+
params.n_threads = sd_get_num_physical_cores();
13101310
}
13111311

13121312
if ((params.mode == IMG_GEN || params.mode == VID_GEN) && params.prompt.length() == 0) {

model.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -265,8 +265,8 @@ void convert_tensor(void* src,
265265
} else {
266266
auto qtype = ggml_get_type_traits(src_type);
267267
if (qtype->to_float == nullptr) {
268-
throw std::runtime_error(format("type %s unsupported for integer quantization: no dequantization available",
269-
ggml_type_name(src_type)));
268+
throw std::runtime_error(sd_format("type %s unsupported for integer quantization: no dequantization available",
269+
ggml_type_name(src_type)));
270270
}
271271
qtype->to_float(src, (float*)dst, n);
272272
}
@@ -275,8 +275,8 @@ void convert_tensor(void* src,
275275
// src_type is quantized => dst_type == GGML_TYPE_F16 or dst_type is quantized
276276
auto qtype = ggml_get_type_traits(src_type);
277277
if (qtype->to_float == nullptr) {
278-
throw std::runtime_error(format("type %s unsupported for integer quantization: no dequantization available",
279-
ggml_type_name(src_type)));
278+
throw std::runtime_error(sd_format("type %s unsupported for integer quantization: no dequantization available",
279+
ggml_type_name(src_type)));
280280
}
281281
std::vector<char> buf;
282282
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
13551355
std::atomic<int64_t> copy_to_backend_time_ms(0);
13561356
std::atomic<int64_t> convert_time_ms(0);
13571357

1358-
int num_threads_to_use = n_threads_p > 0 ? n_threads_p : get_num_physical_cores();
1358+
int num_threads_to_use = n_threads_p > 0 ? n_threads_p : sd_get_num_physical_cores();
13591359
LOG_DEBUG("using %d threads for model loading", num_threads_to_use);
13601360

13611361
int64_t start_time = ggml_time_ms();

stable-diffusion.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2474,7 +2474,7 @@ void sd_ctx_params_init(sd_ctx_params_t* sd_ctx_params) {
24742474
*sd_ctx_params = {};
24752475
sd_ctx_params->vae_decode_only = true;
24762476
sd_ctx_params->free_params_immediately = true;
2477-
sd_ctx_params->n_threads = get_num_physical_cores();
2477+
sd_ctx_params->n_threads = sd_get_num_physical_cores();
24782478
sd_ctx_params->wtype = SD_TYPE_COUNT;
24792479
sd_ctx_params->rng_type = CUDA_RNG;
24802480
sd_ctx_params->sampler_rng_type = RNG_TYPE_COUNT;

stable-diffusion.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ typedef void (*sd_preview_cb_t)(int step, int frame_count, sd_image_t* frames, b
288288
SD_API void sd_set_log_callback(sd_log_cb_t sd_log_cb, void* data);
289289
SD_API void sd_set_progress_callback(sd_progress_cb_t cb, void* data);
290290
SD_API void sd_set_preview_callback(sd_preview_cb_t cb, enum preview_t mode, int interval, bool denoised, bool noisy, void* data);
291-
SD_API int32_t get_num_physical_cores();
291+
SD_API int32_t sd_get_num_physical_cores();
292292
SD_API const char* sd_get_system_info();
293293

294294
SD_API const char* sd_type_name(enum sd_type_t type);

util.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ void replace_all_chars(std::string& str, char target, char replacement) {
5757
}
5858
}
5959

60-
std::string format(const char* fmt, ...) {
60+
std::string sd_format(const char* fmt, ...) {
6161
va_list ap;
6262
va_list ap2;
6363
va_start(ap, fmt);
@@ -148,7 +148,7 @@ std::string get_full_path(const std::string& dir, const std::string& filename) {
148148
// get_num_physical_cores is copy from
149149
// https://github.com/ggerganov/llama.cpp/blob/master/examples/common.cpp
150150
// LICENSE: https://github.com/ggerganov/llama.cpp/blob/master/LICENSE
151-
int32_t get_num_physical_cores() {
151+
int32_t sd_get_num_physical_cores() {
152152
#ifdef __linux__
153153
// enumerate the set of thread siblings, num entries is num cores
154154
std::unordered_set<std::string> siblings;

util.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ bool ends_with(const std::string& str, const std::string& ending);
1414
bool starts_with(const std::string& str, const std::string& start);
1515
bool contains(const std::string& str, const std::string& substr);
1616

17-
std::string format(const char* fmt, ...);
17+
std::string sd_format(const char* fmt, ...);
1818

1919
void replace_all_chars(std::string& str, char target, char replacement);
2020

0 commit comments

Comments
 (0)