From a6c0a224b24d5fa55a1722993e75fcde809aaa64 Mon Sep 17 00:00:00 2001 From: Wagner Bruna Date: Mon, 23 Feb 2026 06:35:59 -0300 Subject: [PATCH] sd: sync to master-506-c9cd497 (#1991) --- otherarch/sdcpp/stable-diffusion.cpp | 6 ++++-- otherarch/sdcpp/tokenize_util.cpp | 14 ++++++++++---- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/otherarch/sdcpp/stable-diffusion.cpp b/otherarch/sdcpp/stable-diffusion.cpp index 4f8770d1a..8176e1dca 100644 --- a/otherarch/sdcpp/stable-diffusion.cpp +++ b/otherarch/sdcpp/stable-diffusion.cpp @@ -109,6 +109,7 @@ public: SDVersion version; bool vae_decode_only = false; + bool external_vae_is_invalid = false; bool free_params_immediately = false; std::shared_ptr rng = std::make_shared(); @@ -409,6 +410,7 @@ public: LOG_INFO("loading vae from '%s'", sd_ctx_params->vae_path); if (!model_loader.init_from_file(sd_ctx_params->vae_path, "vae.")) { LOG_WARN("loading vae from '%s' failed", sd_ctx_params->vae_path); + external_vae_is_invalid = true; } } @@ -759,10 +761,10 @@ public: first_stage_model->set_conv2d_direct_enabled(true); } if (sd_version_is_sdxl(version) && - (strlen(SAFE_STR(sd_ctx_params->vae_path)) == 0 || sd_ctx_params->force_sdxl_vae_conv_scale)) { + (strlen(SAFE_STR(sd_ctx_params->vae_path)) == 0 || sd_ctx_params->force_sdxl_vae_conv_scale || external_vae_is_invalid)) { float vae_conv_2d_scale = 1.f / 32.f; LOG_WARN( - "No VAE specified with --vae or --force-sdxl-vae-conv-scale flag set, " + "No valid VAE specified with --vae or --force-sdxl-vae-conv-scale flag set, " "using Conv2D scale %.3f", vae_conv_2d_scale); first_stage_model->set_conv2d_scale(vae_conv_2d_scale); diff --git a/otherarch/sdcpp/tokenize_util.cpp b/otherarch/sdcpp/tokenize_util.cpp index bc0ff1d5a..22cf8ae2e 100644 --- a/otherarch/sdcpp/tokenize_util.cpp +++ b/otherarch/sdcpp/tokenize_util.cpp @@ -919,15 +919,21 @@ std::vector token_split(const std::string& text) { // `\s*[\r\n]+|\s+(?!\S)|\s+` if (is_space(cp)) { - std::string token = codepoint_to_utf8(cp); - ++i; + std::string token; + bool saw_new_line = false; while (i < cps.size() && is_space(cps[i])) { token += codepoint_to_utf8(cps[i]); - ++i; + if (cps[i] == U'\r' || cps[i] == U'\n') { - break; + saw_new_line = true; + } else { + if (saw_new_line) { + break; + } } + + ++i; } tokens.push_back(token);