diff --git a/src/ggml_extend.hpp b/src/ggml_extend.hpp index 859270cbd..cfb38c8de 100644 --- a/src/ggml_extend.hpp +++ b/src/ggml_extend.hpp @@ -2758,16 +2758,16 @@ __STATIC_INLINE__ ggml_tensor* ggml_ext_lokr_forward( bool is_conv, WeightAdapter::ForwardParams::conv2d_params_t conv_params, float scale) { - GGML_ASSERT((w1 != NULL || (w1a != NULL && w1b != NULL))); - GGML_ASSERT((w2 != NULL || (w2a != NULL && w2b != NULL))); + GGML_ASSERT((w1 != nullptr || (w1a != nullptr && w1b != nullptr))); + GGML_ASSERT((w2 != nullptr || (w2a != nullptr && w2b != nullptr))); - int uq = (w1 != NULL) ? (int)w1->ne[0] : (int)w1a->ne[0]; - int up = (w1 != NULL) ? (int)w1->ne[1] : (int)w1b->ne[1]; + int uq = (w1 != nullptr) ? (int)w1->ne[0] : (int)w1a->ne[0]; + int up = (w1 != nullptr) ? (int)w1->ne[1] : (int)w1b->ne[1]; int q_actual = is_conv ? (int)h->ne[2] : (int)h->ne[0]; int vq = q_actual / uq; - int vp = (w2 != NULL) ? (is_conv ? (int)w2->ne[3] : (int)w2->ne[1]) + int vp = (w2 != nullptr) ? (is_conv ? (int)w2->ne[3] : (int)w2->ne[1]) : (int)w2a->ne[1]; GGML_ASSERT(q_actual == (uq * vq) && "Input dimension mismatch for LoKR split"); @@ -2803,7 +2803,7 @@ __STATIC_INLINE__ ggml_tensor* ggml_ext_lokr_forward( #endif ggml_tensor* h_split = ggml_reshape_3d(ctx, h, vq, uq * merge_batch_uq, batch / merge_batch_uq); - if (w2 != NULL) { + if (w2 != nullptr) { hb = ggml_mul_mat(ctx, w2, h_split); } else { hb = ggml_mul_mat(ctx, w2b, ggml_mul_mat(ctx, w2a, h_split)); @@ -2816,7 +2816,7 @@ __STATIC_INLINE__ ggml_tensor* ggml_ext_lokr_forward( hb_t = ggml_reshape_3d(ctx, hb_t, uq, vp * merge_batch_vp, batch / merge_batch_vp); ggml_tensor* hc_t; - if (w1 != NULL) { + if (w1 != nullptr) { hc_t = ggml_mul_mat(ctx, w1, hb_t); } else { hc_t = ggml_mul_mat(ctx, w1b, ggml_mul_mat(ctx, w1a, hb_t)); @@ -2834,7 +2834,7 @@ __STATIC_INLINE__ ggml_tensor* ggml_ext_lokr_forward( // 1. Reshape input: [W, H, vq*uq, batch] -> [W, H, vq, uq * batch] ggml_tensor* h_split = ggml_reshape_4d(ctx, h, h->ne[0], h->ne[1], vq, uq * batch); - if (w2 != NULL) { + if (w2 != nullptr) { hb = ggml_ext_conv_2d(ctx, h_split, w2, nullptr, conv_params.s0, conv_params.s1, @@ -2902,7 +2902,7 @@ __STATIC_INLINE__ ggml_tensor* ggml_ext_lokr_forward( ggml_tensor* hb_merged = ggml_reshape_2d(ctx, hb, w_out * h_out * vp, uq * batch); ggml_tensor* hc_t; ggml_tensor* hb_merged_t = ggml_cont(ctx, ggml_transpose(ctx, hb_merged)); - if (w1 != NULL) { + if (w1 != nullptr) { // Would be great to be able to transpose w1 instead to avoid transposing both hb and hc hc_t = ggml_mul_mat(ctx, w1, hb_merged_t); } else { diff --git a/src/stable-diffusion.cpp b/src/stable-diffusion.cpp index b9d3e9af1..d7aed2392 100644 --- a/src/stable-diffusion.cpp +++ b/src/stable-diffusion.cpp @@ -197,11 +197,11 @@ class StableDiffusionGGML { device = 0; } if (device >= device_count) { - LOG_WARN("Cannot find targeted vulkan device (%llu). Falling back to device 0.", device); + LOG_WARN("Cannot find targeted vulkan device (%zu). Falling back to device 0.", device); device = 0; } } - LOG_INFO("Vulkan: Using device %llu", device); + LOG_INFO("Vulkan: Using device %zu", device); backend = ggml_backend_vk_init(device); } if (!backend) { @@ -3127,7 +3127,7 @@ static sd_image_t* decode_image_outputs(sd_ctx_t* sd_ctx, } decoded_images.push_back(std::move(image)); int64_t t2 = ggml_time_ms(); - LOG_INFO("latent %" PRId64 " decoded, taking %.2fs", i + 1, (t2 - t1) * 1.0f / 1000); + LOG_INFO("latent %zu decoded, taking %.2fs", i + 1, (t2 - t1) * 1.0f / 1000); } int64_t t4 = ggml_time_ms(); @@ -3240,7 +3240,7 @@ SD_API sd_image_t* generate_image(sd_ctx_t* sd_ctx, const sd_img_gen_params_t* s sd_ctx->sd->diffusion_model->free_params_buffer(); } int64_t denoise_end = ggml_time_ms(); - LOG_INFO("generating %" PRId64 " latent images completed, taking %.2fs", + LOG_INFO("generating %zu latent images completed, taking %.2fs", final_latents.size(), (denoise_end - denoise_start) * 1.0f / 1000); diff --git a/src/tokenizers/clip_tokenizer.cpp b/src/tokenizers/clip_tokenizer.cpp index 57319306f..70d637724 100644 --- a/src/tokenizers/clip_tokenizer.cpp +++ b/src/tokenizers/clip_tokenizer.cpp @@ -62,7 +62,7 @@ void CLIPTokenizer::load_from_merges(const std::string& merges_utf8_str) { } vocab.push_back(utf8_to_utf32("<|startoftext|>")); vocab.push_back(utf8_to_utf32("<|endoftext|>")); - LOG_DEBUG("vocab size: %llu", vocab.size()); + LOG_DEBUG("vocab size: %zu", vocab.size()); int i = 0; for (const auto& token : vocab) { encoder[token] = i; diff --git a/src/tokenizers/mistral_tokenizer.cpp b/src/tokenizers/mistral_tokenizer.cpp index 0a56542aa..9b0624e3a 100644 --- a/src/tokenizers/mistral_tokenizer.cpp +++ b/src/tokenizers/mistral_tokenizer.cpp @@ -28,7 +28,7 @@ void MistralTokenizer::load_from_merges(const std::string& merges_utf8_str, cons byte_decoder[pair.second] = pair.first; } std::vector merges = split_utf32(merges_utf8_str); - LOG_DEBUG("merges size %llu", merges.size()); + LOG_DEBUG("merges size %zu", merges.size()); std::vector> merge_pairs; for (const auto& merge : merges) { size_t space_pos = merge.find(' '); diff --git a/src/tokenizers/qwen2_tokenizer.cpp b/src/tokenizers/qwen2_tokenizer.cpp index 5ddaf4ed1..9929ea387 100644 --- a/src/tokenizers/qwen2_tokenizer.cpp +++ b/src/tokenizers/qwen2_tokenizer.cpp @@ -11,7 +11,7 @@ void Qwen2Tokenizer::load_from_merges(const std::string& merges_utf8_str) { } std::vector merges = split_utf32(merges_utf8_str); - LOG_DEBUG("merges size %llu", merges.size()); + LOG_DEBUG("merges size %zu", merges.size()); std::vector> merge_pairs; for (const auto& merge : merges) { size_t space_pos = merge.find(' '); diff --git a/src/util.cpp b/src/util.cpp index e01876268..b28471d72 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -119,10 +119,10 @@ std::unique_ptr MmapWrapper::create(const std::string& filename) { filename.c_str(), GENERIC_READ, FILE_SHARE_READ, - NULL, + nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, - NULL); + nullptr); if (file_handle == INVALID_HANDLE_VALUE) { return nullptr; @@ -136,16 +136,16 @@ std::unique_ptr MmapWrapper::create(const std::string& filename) { file_size = static_cast(size.QuadPart); - HANDLE mapping_handle = CreateFileMapping(file_handle, NULL, PAGE_READONLY, 0, 0, NULL); + HANDLE mapping_handle = CreateFileMapping(file_handle, nullptr, PAGE_READONLY, 0, 0, nullptr); - if (mapping_handle == NULL) { + if (mapping_handle == nullptr) { CloseHandle(file_handle); return nullptr; } mapped_data = MapViewOfFile(mapping_handle, FILE_MAP_READ, 0, 0, file_size); - if (mapped_data == NULL) { + if (mapped_data == nullptr) { CloseHandle(mapping_handle); CloseHandle(file_handle); return nullptr; @@ -203,7 +203,7 @@ std::unique_ptr MmapWrapper::create(const std::string& filename) { size_t file_size = sb.st_size; - void* mapped_data = mmap(NULL, file_size, PROT_READ, mmap_flags, file_descriptor, 0); + void* mapped_data = mmap(nullptr, file_size, PROT_READ, mmap_flags, file_descriptor, 0); close(file_descriptor);