mirror of
https://github.com/leejet/stable-diffusion.cpp.git
synced 2026-11-11 03:24:30 +00:00
fix: use patch token count for the Flux scheduler (#2293)
This commit is contained in:
1 parent
f61053c25d
commit
b43af40461
3 files changed
+14
-1
No files matched your search
@@ -1437,6 +1437,10 @@ namespace Flux {
|
|||||||
return "flux";
|
return "flux";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int get_patch_size() const override {
|
||||||
|
return config.patch_size;
|
||||||
|
}
|
||||||
|
|
||||||
void get_param_tensors(std::map<std::string, ggml_tensor*>& tensors, const std::string& prefix) override {
|
void get_param_tensors(std::map<std::string, ggml_tensor*>& tensors, const std::string& prefix) override {
|
||||||
flux.get_param_tensors(tensors, prefix);
|
flux.get_param_tensors(tensors, prefix);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -237,6 +237,10 @@ public:
|
|||||||
virtual sd::Tensor<float> compute(int n_threads,
|
virtual sd::Tensor<float> compute(int n_threads,
|
||||||
const DiffusionParams& diffusion_params) = 0;
|
const DiffusionParams& diffusion_params) = 0;
|
||||||
|
|
||||||
|
virtual int get_patch_size() const {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
void get_param_tensors(std::map<std::string, ggml_tensor*>& tensors) {
|
void get_param_tensors(std::map<std::string, ggml_tensor*>& tensors) {
|
||||||
get_param_tensors(tensors, prefix);
|
get_param_tensors(tensors, prefix);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2930,7 +2930,12 @@ int StableDiffusionGGML::get_image_channels() const {
|
|||||||
|
|
||||||
int StableDiffusionGGML::get_image_seq_len(int h, int w) {
|
int StableDiffusionGGML::get_image_seq_len(int h, int w) {
|
||||||
int vae_scale_factor = get_vae_scale_factor();
|
int vae_scale_factor = get_vae_scale_factor();
|
||||||
return (h / vae_scale_factor) * (w / vae_scale_factor);
|
int patch_size = diffusion_model != nullptr ? diffusion_model->get_patch_size() : 1;
|
||||||
|
int latent_h = h / vae_scale_factor;
|
||||||
|
int latent_w = w / vae_scale_factor;
|
||||||
|
int tokens_h = (latent_h + patch_size - 1) / patch_size;
|
||||||
|
int tokens_w = (latent_w + patch_size - 1) / patch_size;
|
||||||
|
return tokens_h * tokens_w;
|
||||||
}
|
}
|
||||||
|
|
||||||
sd::Tensor<float> StableDiffusionGGML::generate_init_latent(int width,
|
sd::Tensor<float> StableDiffusionGGML::generate_init_latent(int width,
|
||||||
|
|||||||
Reference in new issue
Block a user