sd: sync with master-679-f3fd359 (#2257)

This commit is contained in:
Wagner Bruna 2026-06-08 09:42:57 -03:00 committed by GitHub
parent c622a7b96b
commit a53b3f7411
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
130 changed files with 399 additions and 394 deletions

View file

@ -695,9 +695,9 @@ llama-impl.o: src/llama-impl.cpp src/llama-impl.h
budget.o: common/reasoning-budget.cpp common/reasoning-budget.h
$(CXX) $(CXXFLAGS) -c $< -o $@
SDCPP_COMMON_BASENAMES := anima.hpp auto_encoder_kl.hpp avi_writer.h cache_dit.hpp clip.hpp common_block.hpp common_dit.hpp condition_cache_utils.hpp conditioner.hpp control.hpp convert.cpp denoiser.hpp diffusion_model.hpp easycache.hpp ernie_image.hpp esrgan.hpp flux.hpp ggml_extend.hpp ggml_extend_backend.cpp ggml_extend_backend.h ggml_graph_cut.cpp ggml_graph_cut.h gits_noise.inl guidance.cpp guidance.h hidream_o1.hpp image_metadata.cpp image_metadata.h kcpp_sd_extensions.h latent-preview.h layer_registry.cpp layer_registry.h llm.hpp lora.hpp ltx_audio_vae.h ltx_latent_upscaler.hpp ltx_vae.hpp ltxv.hpp mmdit.hpp model.cpp model.h model_io/binary_io.h model_io/gguf_io.cpp model_io/gguf_io.h model_io/gguf_reader_ext.h model_io/pickle_io.cpp model_io/pickle_io.h model_io/safetensors_io.cpp model_io/safetensors_io.h model_io/tensor_storage.h model_io/torch_legacy_io.cpp model_io/torch_legacy_io.h model_io/torch_zip_io.cpp model_io/torch_zip_io.h msf_gif.h name_conversion.cpp name_conversion.h ordered_map.hpp pmid.hpp preprocessing.hpp qwen_image.hpp rng.hpp rng_mt19937.hpp rng_philox.hpp rope.hpp sample-cache.cpp sample-cache.h spectrum.hpp stable-diffusion.cpp stable-diffusion.h t5.hpp tae.hpp tensor.hpp tensor_ggml.hpp thirdparty/LICENSE.darts_clone.txt thirdparty/darts.h thirdparty/miniz.h thirdparty/stb_image_resize.h thirdparty/stb_image_write.h thirdparty/zip.c thirdparty/zip.h tokenizers/bpe_tokenizer.cpp tokenizers/bpe_tokenizer.h tokenizers/clip_tokenizer.cpp tokenizers/clip_tokenizer.h tokenizers/gemma_tokenizer.cpp tokenizers/gemma_tokenizer.h tokenizers/gpt_oss_tokenizer.cpp tokenizers/gpt_oss_tokenizer.h tokenizers/mistral_tokenizer.cpp tokenizers/mistral_tokenizer.h tokenizers/qwen2_tokenizer.cpp tokenizers/qwen2_tokenizer.h tokenizers/t5_unigram_tokenizer.cpp tokenizers/t5_unigram_tokenizer.h tokenizers/tokenize_util.cpp tokenizers/tokenize_util.h tokenizers/tokenizer.cpp tokenizers/tokenizer.h tokenizers/vocab/vocab.h ucache.hpp unet.hpp upscaler.cpp upscaler.h util.cpp util.h vae.hpp wan.hpp z_image.hpp
SDCPP_COMMON_BASENAMES := include/stable-diffusion.h src/conditioning/conditioner.hpp src/core/ggml_extend_backend.cpp src/core/ggml_extend_backend.h src/core/ggml_extend.hpp src/core/ggml_graph_cut.cpp src/core/ggml_graph_cut.h src/core/layer_registry.cpp src/core/layer_registry.h src/core/ordered_map.hpp src/core/rng.hpp src/core/rng_mt19937.hpp src/core/rng_philox.hpp src/core/tensor_ggml.hpp src/core/tensor.hpp src/core/util.cpp src/core/util.h src/kcpp_sd_extensions.h src/model/adapter/lora.hpp src/model/adapter/pmid.hpp src/model/common/block.hpp src/model/common/rope.hpp src/model.cpp src/model/diffusion/anima.hpp src/model/diffusion/control.hpp src/model/diffusion/dit.hpp src/model/diffusion/ernie_image.hpp src/model/diffusion/flux.hpp src/model/diffusion/hidream_o1.hpp src/model/diffusion/ideogram4.hpp src/model/diffusion/lens.hpp src/model/diffusion/ltxv.hpp src/model/diffusion/mmdit.hpp src/model/diffusion/model.hpp src/model/diffusion/pid.hpp src/model/diffusion/qwen_image.hpp src/model/diffusion/unet.hpp src/model/diffusion/wan.hpp src/model/diffusion/z_image.hpp src/model.h src/model_io/binary_io.h src/model_io/gguf_io.cpp src/model_io/gguf_io.h src/model_io/gguf_reader_ext.h src/model_io/pickle_io.cpp src/model_io/pickle_io.h src/model_io/safetensors_io.cpp src/model_io/safetensors_io.h src/model_io/tensor_storage.h src/model_io/torch_legacy_io.cpp src/model_io/torch_legacy_io.h src/model_io/torch_zip_io.cpp src/model_io/torch_zip_io.h src/model/te/clip.hpp src/model/te/llm.hpp src/model/te/t5.hpp src/model/upscaler/esrgan.hpp src/model/upscaler/ltx_latent_upscaler.hpp src/model/vae/auto_encoder_kl.hpp src/model/vae/ltx_audio_vae.hpp src/model/vae/ltx_vae.hpp src/model/vae/tae.hpp src/model/vae/vae.hpp src/model/vae/wan_vae.hpp src/name_conversion.cpp src/name_conversion.h src/runtime/cache_dit.hpp src/runtime/condition_cache_utils.hpp src/runtime/denoiser.hpp src/runtime/easycache.hpp src/runtime/gits_noise.inl src/runtime/guidance.cpp src/runtime/guidance.h src/runtime/latent-preview.h src/runtime/preprocessing.hpp src/runtime/sample-cache.cpp src/runtime/sample-cache.h src/runtime/spectrum.hpp src/runtime/ucache.hpp src/stable-diffusion.cpp src/tokenizers/bpe_tokenizer.cpp src/tokenizers/bpe_tokenizer.h src/tokenizers/clip_tokenizer.cpp src/tokenizers/clip_tokenizer.h src/tokenizers/gemma_tokenizer.cpp src/tokenizers/gemma_tokenizer.h src/tokenizers/gpt_oss_tokenizer.cpp src/tokenizers/gpt_oss_tokenizer.h src/tokenizers/mistral_tokenizer.cpp src/tokenizers/mistral_tokenizer.h src/tokenizers/qwen2_tokenizer.cpp src/tokenizers/qwen2_tokenizer.h src/tokenizers/t5_unigram_tokenizer.cpp src/tokenizers/t5_unigram_tokenizer.h src/tokenizers/tokenizer.cpp src/tokenizers/tokenizer.h src/tokenizers/tokenize_util.cpp src/tokenizers/tokenize_util.h src/tokenizers/vocab/vocab.h src/upscaler.cpp src/upscaler.h
SDCPP_MAIN_BASENAMES := common/common.cpp common/common.h common/log.cpp common/log.h common/media_io.cpp common/media_io.cpp common/media_io.h common/resource_owners.hpp convert.cpp image_metadata.cpp main.cpp tokenizers/vocab/clip_merges.hpp tokenizers/vocab/gemma_merges.hpp tokenizers/vocab/gemma_vocab.hpp tokenizers/vocab/gpt_oss_merges.hpp tokenizers/vocab/gpt_oss_vocab.hpp tokenizers/vocab/mistral_merges.hpp tokenizers/vocab/mistral_vocab.hpp tokenizers/vocab/qwen_merges.hpp tokenizers/vocab/t5.hpp tokenizers/vocab/umt5.hpp tokenizers/vocab/vocab.cpp version.cpp
SDCPP_MAIN_BASENAMES := examples/cli/image_metadata.cpp examples/cli/image_metadata.h examples/cli/main.cpp examples/cli/msf_gif.h examples/common/common.cpp examples/common/common.h examples/common/log.cpp examples/common/log.h examples/common/media_io.cpp examples/common/media_io.h examples/common/resource_owners.hpp src/tokenizers/vocab/clip_merges.hpp src/tokenizers/vocab/gemma2_merges.hpp src/tokenizers/vocab/gemma2_vocab.hpp src/tokenizers/vocab/gemma_merges.hpp src/tokenizers/vocab/gemma_vocab.hpp src/tokenizers/vocab/gpt_oss_merges.hpp src/tokenizers/vocab/gpt_oss_vocab.hpp src/tokenizers/vocab/mistral_merges.hpp src/tokenizers/vocab/mistral_vocab.hpp src/tokenizers/vocab/qwen_merges.hpp src/tokenizers/vocab/t5.hpp src/tokenizers/vocab/umt5.hpp src/tokenizers/vocab/vocab.cpp src/convert.cpp src/version.cpp
SOURCES_SDCOMMON := $(foreach f,$(SDCPP_COMMON_BASENAMES),otherarch/sdcpp/$(f))
@ -712,13 +712,17 @@ otherarch/sdcpp/%.o: $(HEADERS_SDCOMMON)
$(OBJS_SDMAIN): $(HEADERS_SDMAIN)
SDCPP_FLAGS := -I./vendor/nlohmann
otherarch/sdcpp/src/%.o: otherarch/sdcpp/src/%.cpp
$(CXX) -I./otherarch/sdcpp/include -I./otherarch/sdcpp/src -I./otherarch/sdcpp/src/core -I./vendor/nlohmann $(CXXFLAGS) -c $< -o $@
otherarch/sdcpp/%.o: otherarch/sdcpp/%.cpp
$(CXX) $(CXXFLAGS) $(SDCPP_FLAGS) -c $< -o $@
otherarch/sdcpp/examples/%.o: otherarch/sdcpp/examples/%.cpp
$(CXX) -I./otherarch/sdcpp/include -I./otherarch/sdcpp/examples -I./vendor/nlohmann $(CXXFLAGS) -c $< -o $@
otherarch/sdcpp/sdtype_adapter.o: otherarch/sdcpp/sdtype_adapter.cpp
$(CXX) -I./otherarch/sdcpp/include $(CXXFLAGS) -c $< -o $@
otherarch/sdcpp/thirdparty/zip.o: otherarch/sdcpp/thirdparty/zip.c
$(CC) $(CFLAGS) $(SDCPP_FLAGS) -c $< -o $@
$(CC) $(CFLAGS) -c $< -o $@
OBJS_SDTYPE := otherarch/sdcpp/sdtype_adapter.o $(OBJS_SDCOMMON)
@ -759,7 +763,7 @@ clean:
rm -vrf ggml/src/ggml-cuda/*.o
rm -vrf ggml/src/ggml-cuda/template-instances/*.o
rm -vrf llguidance
rm -vf otherarch/sdcpp/*.o otherarch/sdcpp/*/*.o otherarch/sdcpp/*/*/*.o
rm -vf otherarch/sdcpp/*.o otherarch/sdcpp/*/*.o otherarch/sdcpp/*/*/*.o otherarch/sdcpp/*/*/*/*.o
# useful tools
main: tools/completion/completion.cpp common/arg.cpp common/chat.cpp common/preset.cpp common/download.cpp build-info.h ggml.o ggml-cpu.o ggml-ops.o ggml-vec.o ggml-binops.o ggml-unops.o llama.o console.o llavaclip_default.o llava.o ggml-backend.o ggml-backend-meta.o ggml-backend-reg_default.o ggml-repack.o $(OBJS_FULL) $(OBJS)
@ -769,7 +773,7 @@ mainvk: tools/completion/completion.cpp common/arg.cpp common/chat.cpp common/pr
fitparams: tools/fit-params/main.cpp tools/fit-params/fit-params.cpp common/arg.cpp common/chat.cpp common/preset.cpp common/download.cpp build-info.h ggml_v4_vulkan.o ggml-cpu.o ggml-ops.o ggml-vec.o ggml-binops.o ggml-unops.o llama.o console.o llavaclip_vulkan.o llava.o ggml-backend.o ggml-backend-meta.o ggml-backend-reg_vulkan.o ggml-vulkan.o ggml-vulkan-shaders.o ggml-repack.o $(OBJS_FULL) $(OBJS) lib/vulkan-1.lib
$(CXX) $(CXXFLAGS) -DGGML_USE_VULKAN -DSD_USE_VULKAN $(filter-out %.h,$^) -o $@ $(LDFLAGS)
sdmain: $(OBJS_SDCOMMON) $(OBJS_SDMAIN) build-info.h ggml.o ggml-cpu.o ggml-ops.o ggml-vec.o ggml-binops.o ggml-unops.o llama.o console.o llavaclip_default.o llava.o ggml-backend.o ggml-backend-meta.o ggml-backend-reg_default.o ggml-repack.o $(OBJS_FULL) $(OBJS)
$(CXX) $(CXXFLAGS) $(SDCPP_FLAGS) $(filter-out %.h,$^) -o $@ $(LDFLAGS)
$(CXX) $(CXXFLAGS) $(filter-out %.h,$^) -o $@ $(LDFLAGS)
whispermain: otherarch/whispercpp/main.cpp otherarch/whispercpp/whisper.cpp build-info.h ggml.o ggml-cpu.o ggml-ops.o ggml-vec.o ggml-binops.o ggml-unops.o llama.o console.o llavaclip_default.o llava.o ggml-backend.o ggml-backend-meta.o ggml-backend-reg_default.o ggml-repack.o $(OBJS_FULL) $(OBJS)
$(CXX) $(CXXFLAGS) $(filter-out %.h,$^) -o $@ $(LDFLAGS)
ttsmain: tools/tts/tts.cpp common/arg.cpp common/chat.cpp common/preset.cpp common/download.cpp build-info.h ggml.o ggml-cpu.o ggml-ops.o ggml-vec.o ggml-binops.o ggml-unops.o llama.o console.o llavaclip_default.o llava.o ggml-backend.o ggml-backend-meta.o ggml-backend-reg_default.o ggml-repack.o $(OBJS_FULL) $(OBJS)

View file

@ -11,7 +11,7 @@
#ifndef MSF_GIF_IMPL
#define MSF_GIF_IMPL
#endif
#include "./msf_gif.h" //notnullnotvoid/msf_gif
#include "./examples/cli/msf_gif.h" //notnullnotvoid/msf_gif
#ifndef INCLUDE_STB_IMAGE_WRITE_H
#include "stb_image_write.h"

View file

@ -17,9 +17,8 @@
#include "otherarch/utils.h"
#include "model_adapter.h"
// #include "preprocessing.hpp"
#include "stable-diffusion.h"
#include "kcpp_sd_extensions.h"
#include "src/kcpp_sd_extensions.h"
#include "ggml-backend.h"
using namespace kcpp_sd;

View file

@ -1,14 +1,14 @@
#ifndef __CONDITIONER_HPP__
#define __CONDITIONER_HPP__
#ifndef __SD_CONDITIONING_CONDITIONER_HPP__
#define __SD_CONDITIONING_CONDITIONER_HPP__
#include <cmath>
#include <limits>
#include <optional>
#include "clip.hpp"
#include "llm.hpp"
#include "t5.hpp"
#include "tensor_ggml.hpp"
#include "core/tensor_ggml.hpp"
#include "model/te/clip.hpp"
#include "model/te/llm.hpp"
#include "model/te/t5.hpp"
struct SDCondition {
sd::Tensor<float> c_crossattn;
@ -2554,4 +2554,4 @@ struct LTXAVEmbedder : public Conditioner {
}
};
#endif
#endif // __SD_CONDITIONING_CONDITIONER_HPP__

View file

@ -1,5 +1,5 @@
#ifndef __GGML_EXTEND_HPP__
#define __GGML_EXTEND_HPP__
#ifndef __SD_CORE_GGML_EXTEND_HPP__
#define __SD_CORE_GGML_EXTEND_HPP__
#include <assert.h>
#include <inttypes.h>
@ -23,19 +23,19 @@
#include <unordered_map>
#include <vector>
#include "core/ggml_extend_backend.h"
#include "core/ggml_graph_cut.h"
#include "core/layer_registry.h"
#include "ggml-alloc.h"
#include "ggml-backend.h"
#include "ggml.h"
#include "ggml_extend_backend.h"
#include "ggml_graph_cut.h"
#include "layer_registry.h"
#include "core/tensor.hpp"
#include "model.h"
#include "tensor.hpp"
#include "rng.hpp"
#include "tensor_ggml.hpp"
#include "util.h"
#include "core/rng.hpp"
#include "core/tensor_ggml.hpp"
#include "core/util.h"
#define EPS 1e-05f
@ -4145,4 +4145,4 @@ __STATIC_INLINE__ ggml_tensor* ggml_ext_lokr_forward(
}
}
#endif // __GGML_EXTEND__HPP__
#endif // __SD_CORE_GGML_EXTEND_HPP__

View file

@ -1,4 +1,4 @@
#include "ggml_extend_backend.h"
#include "core/ggml_extend_backend.h"
#include <algorithm>
#include <cctype>
@ -8,8 +8,8 @@
#include <stdexcept>
#include <vector>
#include "core/util.h"
#include "stable-diffusion.h"
#include "util.h"
static std::string trim_copy(const std::string& value) {
size_t begin = 0;

View file

@ -1,5 +1,5 @@
#ifndef __SD_GGML_EXTEND_BACKEND_H__
#define __SD_GGML_EXTEND_BACKEND_H__
#ifndef __SD_CORE_GGML_EXTEND_BACKEND_H__
#define __SD_CORE_GGML_EXTEND_BACKEND_H__
#include <cstdint>
#include <cstring>
@ -76,4 +76,4 @@ ggml_backend_t sd_backend_cpu_init();
bool sd_backend_cpu_set_n_threads(ggml_backend_t backend_cpu, int n_threads);
const char* sd_backend_module_name(SDBackendModule module);
void ggml_ext_im_set_f32_1d(const struct ggml_tensor* tensor, int i, float value);
#endif
#endif // __SD_CORE_GGML_EXTEND_BACKEND_H__

View file

@ -1,4 +1,4 @@
#include "ggml_graph_cut.h"
#include "core/ggml_graph_cut.h"
#include <algorithm>
#include <cstring>
@ -8,11 +8,11 @@
#include <stack>
#include <unordered_map>
#include "core/util.h"
#include "ggml-alloc.h"
#include "ggml-backend.h"
#include "util.h"
#include "../ggml/src/ggml-impl.h"
#include "ggml/src/ggml-impl.h"
namespace sd::ggml_graph_cut {

View file

@ -1,5 +1,5 @@
#ifndef __SD_GGML_GRAPH_CUT_H__
#define __SD_GGML_GRAPH_CUT_H__
#ifndef __SD_CORE_GGML_GRAPH_CUT_H__
#define __SD_CORE_GGML_GRAPH_CUT_H__
#include <array>
#include <cstdint>
@ -114,4 +114,4 @@ namespace sd::ggml_graph_cut {
void annotate_residency(Plan& plan, size_t max_graph_vram_bytes);
} // namespace sd::ggml_graph_cut
#endif
#endif // __SD_CORE_GGML_GRAPH_CUT_H__

View file

@ -1,8 +1,8 @@
#include "layer_registry.h"
#include "core/layer_registry.h"
#include <utility>
#include "util.h"
#include "core/util.h"
namespace sd::layer_registry {

View file

@ -1,5 +1,5 @@
#ifndef __LAYER_REGISTRY_H__
#define __LAYER_REGISTRY_H__
#ifndef __SD_CORE_LAYER_REGISTRY_H__
#define __SD_CORE_LAYER_REGISTRY_H__
#include <map>
#include <set>
@ -47,4 +47,4 @@ namespace sd::layer_registry {
} // namespace sd::layer_registry
#endif
#endif // __SD_CORE_LAYER_REGISTRY_H__

View file

@ -1,5 +1,5 @@
#ifndef __ORDERED_MAP_HPP__
#define __ORDERED_MAP_HPP__
#ifndef __SD_CORE_ORDERED_MAP_HPP__
#define __SD_CORE_ORDERED_MAP_HPP__
#include <iostream>
#include <list>
@ -174,4 +174,4 @@ public:
}
};
#endif // __ORDERED_MAP_HPP__
#endif // __SD_CORE_ORDERED_MAP_HPP__

View file

@ -1,5 +1,5 @@
#ifndef __RNG_H__
#define __RNG_H__
#ifndef __SD_CORE_RNG_HPP__
#define __SD_CORE_RNG_HPP__
#include <random>
#include <vector>
@ -32,4 +32,4 @@ public:
}
};
#endif // __RNG_H__
#endif // __SD_CORE_RNG_HPP__

View file

@ -1,10 +1,10 @@
#ifndef __RNG_MT19937_HPP__
#define __RNG_MT19937_HPP__
#ifndef __SD_CORE_RNG_MT19937_HPP__
#define __SD_CORE_RNG_MT19937_HPP__
#include <cmath>
#include <vector>
#include "rng.hpp"
#include "core/rng.hpp"
// RNG imitiating torch cpu randn on CPU.
// Port from pytorch, original license: https://github.com/pytorch/pytorch/blob/d01a7b0241ed1c4cded7e7ca097249feb343f072/LICENSE
@ -144,4 +144,4 @@ public:
}
};
#endif // __RNG_MT19937_HPP__
#endif // __SD_CORE_RNG_MT19937_HPP__

View file

@ -1,10 +1,10 @@
#ifndef __RNG_PHILOX_H__
#define __RNG_PHILOX_H__
#ifndef __SD_CORE_RNG_PHILOX_HPP__
#define __SD_CORE_RNG_PHILOX_HPP__
#include <cmath>
#include <vector>
#include "rng.hpp"
#include "core/rng.hpp"
// RNG imitiating torch cuda randn on CPU.
// Port from: https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/5ef669de080814067961f28357256e8fe27544f4/modules/rng_philox.py
@ -122,4 +122,4 @@ public:
}
};
#endif // __RNG_PHILOX_H__
#endif // __SD_CORE_RNG_PHILOX_HPP__

View file

@ -1,5 +1,5 @@
#ifndef __SD_TENSOR_HPP__
#define __SD_TENSOR_HPP__
#ifndef __SD_CORE_TENSOR_HPP__
#define __SD_CORE_TENSOR_HPP__
#include <algorithm>
#include <cmath>
@ -16,7 +16,7 @@
#include <utility>
#include <vector>
#include "rng.hpp"
#include "core/rng.hpp"
namespace sd {
@ -1661,4 +1661,4 @@ namespace sd {
} // namespace sd
#endif
#endif // __SD_CORE_TENSOR_HPP__

View file

@ -1,5 +1,5 @@
#ifndef __SD_TENSOR_GGML_HPP__
#define __SD_TENSOR_GGML_HPP__
#ifndef __SD_CORE_TENSOR_GGML_HPP__
#define __SD_CORE_TENSOR_GGML_HPP__
#include <array>
#include <cstring>
@ -8,8 +8,8 @@
#include <string>
#include <type_traits>
#include "core/tensor.hpp"
#include "ggml.h"
#include "tensor.hpp"
namespace sd {
@ -124,4 +124,4 @@ namespace sd {
} // namespace sd
#endif
#endif // __SD_CORE_TENSOR_GGML_HPP__

View file

@ -1,4 +1,4 @@
#include "util.h"
#include "core/util.h"
#include <algorithm>
#include <cctype>
#include <cmath>
@ -14,7 +14,7 @@
#include <thread>
#include <unordered_set>
#include <vector>
#include "preprocessing.hpp"
#include "runtime/preprocessing.hpp"
#include <inttypes.h>
#include <cinttypes>

View file

@ -1,5 +1,5 @@
#ifndef __UTIL_H__
#define __UTIL_H__
#ifndef __SD_CORE_UTIL_H__
#define __SD_CORE_UTIL_H__
#include <cstdint>
#include <memory>
@ -7,9 +7,9 @@
#include <utility>
#include <vector>
#include "core/tensor.hpp"
#include "ggml-backend.h"
#include "stable-diffusion.h"
#include "tensor.hpp"
#define SAFE_STR(s) ((s) ? (s) : "")
#define BOOL_STR(b) ((b) ? "true" : "false")
@ -111,4 +111,4 @@ void log_message(const char* format, ...);
// #define LOG_INFO(format, ...) log_printf(SD_LOG_INFO, __FILE__, __LINE__, format, ##__VA_ARGS__)
// #define LOG_WARN(format, ...) log_printf(SD_LOG_WARN, __FILE__, __LINE__, format, ##__VA_ARGS__)
// #define LOG_ERROR(format, ...) log_printf(SD_LOG_ERROR, __FILE__, __LINE__, format, ##__VA_ARGS__)
#endif // __UTIL_H__
#endif // __SD_CORE_UTIL_H__

View file

@ -13,18 +13,18 @@
#include <unordered_map>
#include <vector>
#include "core/util.h"
#include "model.h"
#include "model_io/gguf_io.h"
#include "model_io/safetensors_io.h"
#include "model_io/torch_legacy_io.h"
#include "model_io/torch_zip_io.h"
#include "stable-diffusion.h"
#include "util.h"
#include "core/ggml_extend_backend.h"
#include "ggml-alloc.h"
#include "ggml-backend.h"
#include "ggml.h"
#include "ggml_extend_backend.h"
#include "zip.h"
#include "name_conversion.h"

View file

@ -8,10 +8,10 @@
#include <string>
#include <vector>
#include "core/ordered_map.hpp"
#include "ggml-backend.h"
#include "ggml.h"
#include "model_io/tensor_storage.h"
#include "ordered_map.hpp"
enum SDVersion {
VERSION_SD1,

View file

@ -1,8 +1,8 @@
#ifndef __LORA_HPP__
#define __LORA_HPP__
#ifndef __SD_MODEL_ADAPTER_LORA_HPP__
#define __SD_MODEL_ADAPTER_LORA_HPP__
#include <mutex>
#include "ggml_extend.hpp"
#include "core/ggml_extend.hpp"
#define LORA_GRAPH_BASE_SIZE 10240
@ -914,4 +914,4 @@ public:
}
};
#endif // __LORA_HPP__
#endif // __SD_MODEL_ADAPTER_LORA_HPP__

View file

@ -1,10 +1,11 @@
#ifndef __PMI_HPP__
#define __PMI_HPP__
#ifndef __SD_MODEL_ADAPTER_PMID_HPP__
#define __SD_MODEL_ADAPTER_PMID_HPP__
#include "ggml_extend.hpp"
#include "core/ggml_extend.hpp"
#include "clip.hpp"
#include "lora.hpp"
#include "model/adapter/lora.hpp"
#include "model/common/block.hpp"
#include "model/te/clip.hpp"
struct FuseBlock : public GGMLBlock {
// network hparams
@ -636,4 +637,4 @@ struct PhotoMakerIDEmbed : public GGMLRunner {
}
};
#endif // __PMI_HPP__
#endif // __SD_MODEL_ADAPTER_PMID_HPP__

View file

@ -1,9 +1,9 @@
#ifndef __COMMON_BLOCK_HPP__
#define __COMMON_BLOCK_HPP__
#ifndef __SD_MODEL_COMMON_BLOCK_HPP__
#define __SD_MODEL_COMMON_BLOCK_HPP__
#include "core/ggml_extend.hpp"
#include "core/util.h"
#include "ggml-backend.h"
#include "ggml_extend.hpp"
#include "util.h"
class DownSampleBlock : public GGMLBlock {
protected:
@ -227,6 +227,37 @@ public:
}
};
struct Mlp : public GGMLBlock {
public:
Mlp(int64_t in_features,
int64_t hidden_features = -1,
int64_t out_features = -1,
bool bias = true) {
// act_layer is always lambda: nn.GELU(approximate="tanh")
// norm_layer is always None
// use_conv is always False
if (hidden_features == -1) {
hidden_features = in_features;
}
if (out_features == -1) {
out_features = in_features;
}
blocks["fc1"] = std::shared_ptr<GGMLBlock>(new Linear(in_features, hidden_features, bias));
blocks["fc2"] = std::shared_ptr<GGMLBlock>(new Linear(hidden_features, out_features, bias));
}
ggml_tensor* forward(GGMLRunnerContext* ctx, ggml_tensor* x) {
// x: [N, n_token, in_features]
auto fc1 = std::dynamic_pointer_cast<Linear>(blocks["fc1"]);
auto fc2 = std::dynamic_pointer_cast<Linear>(blocks["fc2"]);
x = fc1->forward(ctx, x);
x = ggml_ext_gelu(ctx->ggml_ctx, x, true);
x = fc2->forward(ctx, x);
return x;
}
};
class FeedForward : public GGMLBlock {
public:
enum class Activation {
@ -603,4 +634,4 @@ public:
}
};
#endif // __COMMON_BLOCK_HPP__
#endif // __SD_MODEL_COMMON_BLOCK_HPP__

View file

@ -1,10 +1,10 @@
#ifndef __ROPE_HPP__
#define __ROPE_HPP__
#ifndef __SD_MODEL_COMMON_ROPE_HPP__
#define __SD_MODEL_COMMON_ROPE_HPP__
#include <algorithm>
#include <cmath>
#include <vector>
#include "ggml_extend.hpp"
#include "core/ggml_extend.hpp"
namespace Rope {
enum class EmbedNDLayout {
@ -902,4 +902,4 @@ namespace Rope {
}
}; // namespace Rope
#endif // __ROPE_HPP__
#endif // __SD_MODEL_COMMON_ROPE_HPP__

View file

@ -1,5 +1,5 @@
#ifndef __ANIMA_HPP__
#define __ANIMA_HPP__
#ifndef __SD_MODEL_DIFFUSION_ANIMA_HPP__
#define __SD_MODEL_DIFFUSION_ANIMA_HPP__
#include <algorithm>
#include <cmath>
@ -7,10 +7,10 @@
#include <utility>
#include <vector>
#include "common_block.hpp"
#include "diffusion_model.hpp"
#include "flux.hpp"
#include "rope.hpp"
#include "model/common/block.hpp"
#include "model/common/rope.hpp"
#include "model/diffusion/flux.hpp"
#include "model/diffusion/model.hpp"
namespace Anima {
constexpr int ANIMA_GRAPH_SIZE = 65536;
@ -715,4 +715,4 @@ namespace Anima {
};
} // namespace Anima
#endif // __ANIMA_HPP__
#endif // __SD_MODEL_DIFFUSION_ANIMA_HPP__

View file

@ -1,8 +1,8 @@
#ifndef __CONTROL_HPP__
#define __CONTROL_HPP__
#ifndef __SD_MODEL_DIFFUSION_CONTROL_HPP__
#define __SD_MODEL_DIFFUSION_CONTROL_HPP__
#include "common_block.hpp"
#include "model.h"
#include "model/common/block.hpp"
#define CONTROL_NET_GRAPH_SIZE 1536
@ -484,4 +484,4 @@ struct ControlNet : public GGMLRunner {
}
};
#endif // __CONTROL_HPP__
#endif // __SD_MODEL_DIFFUSION_CONTROL_HPP__

View file

@ -1,7 +1,7 @@
#ifndef __COMMON_DIT_HPP__
#define __COMMON_DIT_HPP__
#ifndef __SD_MODEL_DIFFUSION_DIT_HPP__
#define __SD_MODEL_DIFFUSION_DIT_HPP__
#include "ggml_extend.hpp"
#include "core/ggml_extend.hpp"
namespace DiT {
inline ggml_tensor* patchify(ggml_context* ctx,
@ -163,4 +163,4 @@ namespace DiT {
}
} // namespace DiT
#endif // __COMMON_DIT_HPP__
#endif // __SD_MODEL_DIFFUSION_DIT_HPP__

View file

@ -1,14 +1,14 @@
#ifndef __SD_ERNIE_IMAGE_HPP__
#define __SD_ERNIE_IMAGE_HPP__
#ifndef __SD_MODEL_DIFFUSION_ERNIE_IMAGE_HPP__
#define __SD_MODEL_DIFFUSION_ERNIE_IMAGE_HPP__
#include <memory>
#include <vector>
#include "common_dit.hpp"
#include "diffusion_model.hpp"
#include "flux.hpp"
#include "qwen_image.hpp"
#include "rope.hpp"
#include "model/common/rope.hpp"
#include "model/diffusion/dit.hpp"
#include "model/diffusion/flux.hpp"
#include "model/diffusion/model.hpp"
#include "model/diffusion/qwen_image.hpp"
namespace ErnieImage {
constexpr int ERNIE_IMAGE_GRAPH_SIZE = 40960;
@ -455,4 +455,4 @@ namespace ErnieImage {
};
} // namespace ErnieImage
#endif // __SD_ERNIE_IMAGE_HPP__
#endif // __SD_MODEL_DIFFUSION_ERNIE_IMAGE_HPP__

View file

@ -1,13 +1,13 @@
#ifndef __FLUX_HPP__
#define __FLUX_HPP__
#ifndef __SD_MODEL_DIFFUSION_FLUX_HPP__
#define __SD_MODEL_DIFFUSION_FLUX_HPP__
#include <memory>
#include <vector>
#include "common_dit.hpp"
#include "diffusion_model.hpp"
#include "model.h"
#include "rope.hpp"
#include "model/common/rope.hpp"
#include "model/diffusion/dit.hpp"
#include "model/diffusion/model.hpp"
#define FLUX_GRAPH_SIZE 10240
@ -1627,4 +1627,4 @@ namespace Flux {
} // namespace Flux
#endif // __FLUX_HPP__
#endif // __SD_MODEL_DIFFUSION_FLUX_HPP__

View file

@ -1,5 +1,5 @@
#ifndef __SD_HIDREAM_O1_H__
#define __SD_HIDREAM_O1_H__
#ifndef __SD_MODEL_DIFFUSION_HIDREAM_O1_HPP__
#define __SD_MODEL_DIFFUSION_HIDREAM_O1_HPP__
#include <algorithm>
#include <array>
@ -10,11 +10,11 @@
#include <utility>
#include <vector>
#include "common_dit.hpp"
#include "conditioner.hpp"
#include "diffusion_model.hpp"
#include "llm.hpp"
#include "util.h"
#include "conditioning/conditioner.hpp"
#include "core/util.h"
#include "model/diffusion/dit.hpp"
#include "model/diffusion/model.hpp"
#include "model/te/llm.hpp"
namespace HiDreamO1 {
constexpr int HIDREAM_O1_GRAPH_SIZE = 32768;
@ -678,4 +678,4 @@ namespace HiDreamO1 {
};
} // namespace HiDreamO1
#endif // __SD_HIDREAM_O1_H__
#endif // __SD_MODEL_DIFFUSION_HIDREAM_O1_HPP__

View file

@ -1,5 +1,5 @@
#ifndef __IDEOGRAM4_HPP__
#define __IDEOGRAM4_HPP__
#ifndef __SD_MODEL_DIFFUSION_IDEOGRAM4_HPP__
#define __SD_MODEL_DIFFUSION_IDEOGRAM4_HPP__
#include <algorithm>
#include <cmath>
@ -8,10 +8,10 @@
#include <string>
#include <vector>
#include "diffusion_model.hpp"
#include "ggml_extend.hpp"
#include "ggml_graph_cut.h"
#include "rope.hpp"
#include "core/ggml_extend.hpp"
#include "core/ggml_graph_cut.h"
#include "model/common/rope.hpp"
#include "model/diffusion/model.hpp"
namespace Ideogram4 {
constexpr int IDEOGRAM4_GRAPH_SIZE = 65536;
@ -528,4 +528,4 @@ namespace Ideogram4 {
};
} // namespace Ideogram4
#endif // __IDEOGRAM4_HPP__
#endif // __SD_MODEL_DIFFUSION_IDEOGRAM4_HPP__

View file

@ -1,14 +1,14 @@
#ifndef __SD_LENS_HPP__
#define __SD_LENS_HPP__
#ifndef __SD_MODEL_DIFFUSION_LENS_HPP__
#define __SD_MODEL_DIFFUSION_LENS_HPP__
#include <memory>
#include <vector>
#include "common_block.hpp"
#include "diffusion_model.hpp"
#include "flux.hpp"
#include "qwen_image.hpp"
#include "rope.hpp"
#include "model/common/block.hpp"
#include "model/common/rope.hpp"
#include "model/diffusion/flux.hpp"
#include "model/diffusion/model.hpp"
#include "model/diffusion/qwen_image.hpp"
namespace Lens {
constexpr int LENS_GRAPH_SIZE = 40960;
@ -423,4 +423,4 @@ namespace Lens {
};
} // namespace Lens
#endif // __SD_LENS_HPP__
#endif // __SD_MODEL_DIFFUSION_LENS_HPP__

View file

@ -1,5 +1,5 @@
#ifndef __SD_LTXV_HPP__
#define __SD_LTXV_HPP__
#ifndef __SD_MODEL_DIFFUSION_LTXV_HPP__
#define __SD_MODEL_DIFFUSION_LTXV_HPP__
#include <algorithm>
#include <cmath>
@ -9,10 +9,10 @@
#include <utility>
#include <vector>
#include "common_block.hpp"
#include "diffusion_model.hpp"
#include "flux.hpp"
#include "rope.hpp"
#include "model/common/block.hpp"
#include "model/common/rope.hpp"
#include "model/diffusion/flux.hpp"
#include "model/diffusion/model.hpp"
namespace LTXV {
@ -2062,4 +2062,4 @@ namespace LTXV {
}; // namespace LTXV
#endif
#endif // __SD_MODEL_DIFFUSION_LTXV_HPP__

View file

@ -1,14 +1,15 @@
#ifndef __MMDIT_HPP__
#define __MMDIT_HPP__
#ifndef __SD_MODEL_DIFFUSION_MMDIT_HPP__
#define __SD_MODEL_DIFFUSION_MMDIT_HPP__
#include <algorithm>
#include <memory>
#include <string>
#include <vector>
#include "diffusion_model.hpp"
#include "ggml_extend.hpp"
#include "core/ggml_extend.hpp"
#include "model.h"
#include "model/common/block.hpp"
#include "model/diffusion/model.hpp"
#define MMDIT_GRAPH_SIZE 10240
@ -134,37 +135,6 @@ struct MMDiTConfig {
}
};
struct Mlp : public GGMLBlock {
public:
Mlp(int64_t in_features,
int64_t hidden_features = -1,
int64_t out_features = -1,
bool bias = true) {
// act_layer is always lambda: nn.GELU(approximate="tanh")
// norm_layer is always None
// use_conv is always False
if (hidden_features == -1) {
hidden_features = in_features;
}
if (out_features == -1) {
out_features = in_features;
}
blocks["fc1"] = std::shared_ptr<GGMLBlock>(new Linear(in_features, hidden_features, bias));
blocks["fc2"] = std::shared_ptr<GGMLBlock>(new Linear(hidden_features, out_features, bias));
}
ggml_tensor* forward(GGMLRunnerContext* ctx, ggml_tensor* x) {
// x: [N, n_token, in_features]
auto fc1 = std::dynamic_pointer_cast<Linear>(blocks["fc1"]);
auto fc2 = std::dynamic_pointer_cast<Linear>(blocks["fc2"]);
x = fc1->forward(ctx, x);
x = ggml_ext_gelu(ctx->ggml_ctx, x, true);
x = fc2->forward(ctx, x);
return x;
}
};
struct PatchEmbed : public GGMLBlock {
// 2D Image to Patch Embedding
protected:
@ -1062,4 +1032,4 @@ struct MMDiTRunner : public DiffusionModelRunner {
}
};
#endif
#endif // __SD_MODEL_DIFFUSION_MMDIT_HPP__

View file

@ -1,12 +1,12 @@
#ifndef __DIFFUSION_MODEL_H__
#define __DIFFUSION_MODEL_H__
#ifndef __SD_MODEL_DIFFUSION_MODEL_HPP__
#define __SD_MODEL_DIFFUSION_MODEL_HPP__
#include <string>
#include <utility>
#include <variant>
#include "ggml_extend.hpp"
#include "tensor_ggml.hpp"
#include "core/ggml_extend.hpp"
#include "core/tensor_ggml.hpp"
struct UNetDiffusionExtra {
int num_video_frames = -1;
@ -104,4 +104,4 @@ public:
const std::string& prefix) = 0;
};
#endif
#endif // __SD_MODEL_DIFFUSION_MODEL_HPP__

View file

@ -1,5 +1,5 @@
#ifndef __SD_PID_HPP__
#define __SD_PID_HPP__
#ifndef __SD_MODEL_DIFFUSION_PID_HPP__
#define __SD_MODEL_DIFFUSION_PID_HPP__
#include <cmath>
#include <cstdlib>
@ -7,10 +7,10 @@
#include <string>
#include <vector>
#include "common_dit.hpp"
#include "ggml_extend.hpp"
#include "mmdit.hpp"
#include "rope.hpp"
#include "core/ggml_extend.hpp"
#include "model/common/rope.hpp"
#include "model/diffusion/dit.hpp"
#include "model/diffusion/mmdit.hpp"
namespace Pid {
constexpr int PID_GRAPH_SIZE = 196608;
@ -844,4 +844,4 @@ namespace Pid {
};
} // namespace Pid
#endif // __SD_PID_HPP__
#endif // __SD_MODEL_DIFFUSION_PID_HPP__

View file

@ -1,11 +1,11 @@
#ifndef __QWEN_IMAGE_HPP__
#define __QWEN_IMAGE_HPP__
#ifndef __SD_MODEL_DIFFUSION_QWEN_IMAGE_HPP__
#define __SD_MODEL_DIFFUSION_QWEN_IMAGE_HPP__
#include <memory>
#include "common_block.hpp"
#include "diffusion_model.hpp"
#include "flux.hpp"
#include "model/common/block.hpp"
#include "model/diffusion/flux.hpp"
#include "model/diffusion/model.hpp"
namespace Qwen {
constexpr int QWEN_IMAGE_GRAPH_SIZE = 20480;
@ -731,4 +731,4 @@ namespace Qwen {
} // namespace name
#endif // __QWEN_IMAGE_HPP__
#endif // __SD_MODEL_DIFFUSION_QWEN_IMAGE_HPP__

View file

@ -1,12 +1,12 @@
#ifndef __UNET_HPP__
#define __UNET_HPP__
#ifndef __SD_MODEL_DIFFUSION_UNET_HPP__
#define __SD_MODEL_DIFFUSION_UNET_HPP__
#include <algorithm>
#include <vector>
#include "common_block.hpp"
#include "diffusion_model.hpp"
#include "model.h"
#include "model/common/block.hpp"
#include "model/diffusion/model.hpp"
/*==================================================== UnetModel =====================================================*/
@ -844,4 +844,4 @@ struct UNetModelRunner : public DiffusionModelRunner {
}
};
#endif // __UNET_HPP__
#endif // __SD_MODEL_DIFFUSION_UNET_HPP__

View file

@ -1,14 +1,14 @@
#ifndef __WAN_HPP__
#define __WAN_HPP__
#ifndef __SD_MODEL_DIFFUSION_WAN_HPP__
#define __SD_MODEL_DIFFUSION_WAN_HPP__
#include <map>
#include <memory>
#include <utility>
#include "common_block.hpp"
#include "diffusion_model.hpp"
#include "flux.hpp"
#include "rope.hpp"
#include "model/common/block.hpp"
#include "model/common/rope.hpp"
#include "model/diffusion/flux.hpp"
#include "model/diffusion/model.hpp"
namespace WAN {
@ -1058,4 +1058,4 @@ namespace WAN {
} // namespace WAN
#endif // __WAN_HPP__
#endif // __SD_MODEL_DIFFUSION_WAN_HPP__

View file

@ -1,14 +1,14 @@
#ifndef __Z_IMAGE_HPP__
#define __Z_IMAGE_HPP__
#ifndef __SD_MODEL_DIFFUSION_Z_IMAGE_HPP__
#define __SD_MODEL_DIFFUSION_Z_IMAGE_HPP__
#include <algorithm>
#include "diffusion_model.hpp"
#include "flux.hpp"
#include "ggml_extend.hpp"
#include "mmdit.hpp"
#include "core/ggml_extend.hpp"
#include "model/diffusion/flux.hpp"
#include "model/diffusion/mmdit.hpp"
#include "model/diffusion/model.hpp"
// Ref: https://github.com/Alpha-VLLM/Lumina-Image-2.0/blob/main/models/model.py
// Ref: https://github.com/Alpha-VLLM/Lumina-Image-2.0/blob/main/model/model.py
// Ref: https://github.com/huggingface/diffusers/pull/12703
#ifndef MIN
@ -739,4 +739,4 @@ namespace ZImage {
} // namespace ZImage
#endif // __Z_IMAGE_HPP__
#endif // __SD_MODEL_DIFFUSION_Z_IMAGE_HPP__

View file

@ -1,13 +1,13 @@
#ifndef __CLIP_HPP__
#define __CLIP_HPP__
#ifndef __SD_MODEL_TE_CLIP_HPP__
#define __SD_MODEL_TE_CLIP_HPP__
#include "ggml_extend.hpp"
#include "core/ggml_extend.hpp"
#include "model.h"
#include "tokenizers/clip_tokenizer.h"
/*================================================ FrozenCLIPEmbedder ================================================*/
// Ref: https://github.com/huggingface/transformers/blob/main/src/transformers/models/clip/modeling_clip.py
// Ref: https://github.com/huggingface/transformers/blob/main/src/transformers/model/clip/modeling_clip.py
struct CLIPMLP : public GGMLBlock {
protected:
@ -579,4 +579,4 @@ struct CLIPTextModelRunner : public GGMLRunner {
}
};
#endif // __CLIP_HPP__
#endif // __SD_MODEL_TE_CLIP_HPP__

View file

@ -1,5 +1,5 @@
#ifndef __LLM_HPP__
#define __LLM_HPP__
#ifndef __SD_MODEL_TE_LLM_HPP__
#define __SD_MODEL_TE_LLM_HPP__
#include <algorithm>
#include <array>
@ -18,9 +18,9 @@
#include <utility>
#include <vector>
#include "ggml_extend.hpp"
#include "core/ggml_extend.hpp"
#include "json.hpp"
#include "rope.hpp"
#include "model/common/rope.hpp"
#include "tokenizers/bpe_tokenizer.h"
#include "tokenizers/gemma_tokenizer.h"
#include "tokenizers/gpt_oss_tokenizer.h"
@ -2100,4 +2100,4 @@ namespace LLM {
};
}; // LLM
#endif // __LLM_HPP__
#endif // __SD_MODEL_TE_LLM_HPP__

View file

@ -1,5 +1,5 @@
#ifndef __T5_HPP__
#define __T5_HPP__
#ifndef __SD_MODEL_TE_T5_HPP__
#define __SD_MODEL_TE_T5_HPP__
#include <cfloat>
#include <limits>
@ -10,7 +10,7 @@
#include <string>
#include <unordered_map>
#include "ggml_extend.hpp"
#include "core/ggml_extend.hpp"
#include "model.h"
#include "tokenizers/t5_unigram_tokenizer.h"
@ -610,4 +610,4 @@ struct T5Embedder {
}
};
#endif // __T5_HPP__
#endif // __SD_MODEL_TE_T5_HPP__

View file

@ -1,7 +1,7 @@
#ifndef __ESRGAN_HPP__
#define __ESRGAN_HPP__
#ifndef __SD_MODEL_UPSCALER_ESRGAN_HPP__
#define __SD_MODEL_UPSCALER_ESRGAN_HPP__
#include "ggml_extend.hpp"
#include "core/ggml_extend.hpp"
#include "model.h"
/*
@ -372,4 +372,4 @@ struct ESRGAN : public GGMLRunner {
}
};
#endif // __ESRGAN_HPP__
#endif // __SD_MODEL_UPSCALER_ESRGAN_HPP__

View file

@ -1,5 +1,5 @@
#ifndef __SD_LTX_LATENT_UPSCALER_HPP__
#define __SD_LTX_LATENT_UPSCALER_HPP__
#ifndef __SD_MODEL_UPSCALER_LTX_LATENT_UPSCALER_HPP__
#define __SD_MODEL_UPSCALER_LTX_LATENT_UPSCALER_HPP__
#include <cinttypes>
#include <cmath>
@ -11,11 +11,11 @@
#include <utility>
#include <vector>
#include "common_dit.hpp"
#include "ggml_extend.hpp"
#include "ggml_graph_cut.h"
#include "core/ggml_extend.hpp"
#include "core/ggml_graph_cut.h"
#include "core/util.h"
#include "model.h"
#include "util.h"
#include "model/diffusion/dit.hpp"
namespace LTXVUpsampler {
constexpr int LTX_UPSAMPLER_GRAPH_SIZE = 10240;
@ -548,4 +548,4 @@ namespace LTXVUpsampler {
} // namespace LTXVUpsampler
#endif // __SD_LTX_LATENT_UPSCALER_HPP__
#endif // __SD_MODEL_UPSCALER_LTX_LATENT_UPSCALER_HPP__

View file

@ -1,7 +1,7 @@
#ifndef __AUTO_ENCODER_KL_HPP__
#define __AUTO_ENCODER_KL_HPP__
#ifndef __SD_MODEL_VAE_AUTO_ENCODER_KL_HPP__
#define __SD_MODEL_VAE_AUTO_ENCODER_KL_HPP__
#include "vae.hpp"
#include "model/vae/vae.hpp"
/*================================================== AutoEncoderKL ===================================================*/
@ -886,4 +886,4 @@ struct AutoEncoderKL : public VAE {
};
};
#endif // __AUTO_ENCODER_KL_HPP__
#endif // __SD_MODEL_VAE_AUTO_ENCODER_KL_HPP__

View file

@ -1,5 +1,5 @@
#ifndef __SD_LTX_AUDIO_VAE_H__
#define __SD_LTX_AUDIO_VAE_H__
#ifndef __SD_MODEL_VAE_LTX_AUDIO_VAE_HPP__
#define __SD_MODEL_VAE_LTX_AUDIO_VAE_HPP__
#include <cmath>
#include <limits>
@ -7,7 +7,7 @@
#include <string>
#include <vector>
#include "ggml_extend.hpp"
#include "core/ggml_extend.hpp"
namespace LTXV {
@ -1095,4 +1095,4 @@ namespace LTXV {
} // namespace LTXV
#endif // __SD_LTX_AUDIO_VAE_H__
#endif // __SD_MODEL_VAE_LTX_AUDIO_VAE_HPP__

View file

@ -1,5 +1,5 @@
#ifndef __SD_LTX_VAE_HPP__
#define __SD_LTX_VAE_HPP__
#ifndef __SD_MODEL_VAE_LTX_VAE_HPP__
#define __SD_MODEL_VAE_LTX_VAE_HPP__
#include <algorithm>
#include <fstream>
@ -9,9 +9,9 @@
#include <utility>
#include <vector>
#include "ltxv.hpp"
#include "vae.hpp"
#include "wan_vae.hpp"
#include "model/diffusion/ltxv.hpp"
#include "model/vae/vae.hpp"
#include "model/vae/wan_vae.hpp"
namespace LTXVAE {
@ -1552,4 +1552,4 @@ struct LTXVideoVAE : public VAE {
}
};
#endif // __SD_LTX_VAE_HPP__
#endif // __SD_MODEL_VAE_LTX_VAE_HPP__

View file

@ -1,13 +1,13 @@
#ifndef __TAE_HPP__
#define __TAE_HPP__
#ifndef __SD_MODEL_VAE_TAE_HPP__
#define __SD_MODEL_VAE_TAE_HPP__
#include "ggml_extend.hpp"
#include "core/ggml_extend.hpp"
#include "model.h"
/*
=================================== TinyAutoEncoder ===================================
References:
https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/autoencoders/vae.py
https://github.com/huggingface/diffusers/blob/main/src/diffusers/model/autoencoders/vae.py
https://github.com/madebyollin/taesd/blob/main/taesd.py
*/
@ -750,4 +750,4 @@ struct TinyVideoAutoEncoder : public VAE {
}
};
#endif // __TAE_HPP__
#endif // __SD_MODEL_VAE_TAE_HPP__

View file

@ -1,8 +1,8 @@
#ifndef __VAE_HPP__
#define __VAE_HPP__
#ifndef __SD_MODEL_VAE_VAE_HPP__
#define __SD_MODEL_VAE_VAE_HPP__
#include "common_block.hpp"
#include "tensor_ggml.hpp"
#include "core/tensor_ggml.hpp"
#include "model/common/block.hpp"
struct VAE : public GGMLRunner {
protected:
@ -258,4 +258,4 @@ struct FakeVAE : public VAE {
}
};
#endif // __VAE_HPP__
#endif // __SD_MODEL_VAE_VAE_HPP__

View file

@ -1,12 +1,12 @@
#ifndef __WAN_VAE_HPP__
#define __WAN_VAE_HPP__
#ifndef __SD_MODEL_VAE_WAN_VAE_HPP__
#define __SD_MODEL_VAE_WAN_VAE_HPP__
#include <map>
#include <memory>
#include <utility>
#include "common_block.hpp"
#include "vae.hpp"
#include "model/common/block.hpp"
#include "model/vae/vae.hpp"
namespace WAN {
@ -1358,4 +1358,4 @@ namespace WAN {
} // namespace WAN
#endif // __WAN_VAE_HPP__
#endif // __SD_MODEL_VAE_WAN_VAE_HPP__

View file

@ -5,9 +5,9 @@
#include <string>
#include <vector>
#include "core/util.h"
#include "gguf.h"
#include "gguf_reader_ext.h"
#include "util.h"
static void set_error(std::string* error, const std::string& message) {
if (error != nullptr) {

View file

@ -6,8 +6,8 @@
#include <string>
#include <vector>
#include "core/util.h"
#include "ggml.h"
#include "util.h"
struct GGUFTensorInfo {
std::string name;

View file

@ -8,7 +8,7 @@
#include <vector>
#include "binary_io.h"
#include "util.h"
#include "core/util.h"
// $ python -m pickletools sd-v1-4/archive/data.pkl | head -n 100
// 0: \x80 PROTO 2

View file

@ -7,8 +7,8 @@
#include <vector>
#include "binary_io.h"
#include "core/util.h"
#include "json.hpp"
#include "util.h"
static constexpr size_t ST_HEADER_SIZE_LEN = 8;

View file

@ -7,8 +7,8 @@
#include <unordered_map>
#include <vector>
#include "core/util.h"
#include "pickle_io.h"
#include "util.h"
// torch.save format background:
//

View file

@ -1,8 +1,8 @@
#include <unordered_map>
#include <unordered_set>
#include "core/util.h"
#include "name_conversion.h"
#include "util.h"
void replace_with_name_map(std::string& name, const std::vector<std::pair<std::string, std::string>>& name_map) {
for (auto kv : name_map) {

View file

@ -1,5 +1,5 @@
#ifndef __CACHE_DIT_HPP__
#define __CACHE_DIT_HPP__
#ifndef __SD_RUNTIME_CACHE_DIT_HPP__
#define __SD_RUNTIME_CACHE_DIT_HPP__
#include <algorithm>
#include <cmath>
@ -8,9 +8,9 @@
#include <unordered_map>
#include <vector>
#include "condition_cache_utils.hpp"
#include "ggml_extend.hpp"
#include "tensor.hpp"
#include "core/ggml_extend.hpp"
#include "core/tensor.hpp"
#include "runtime/condition_cache_utils.hpp"
struct DBCacheConfig {
bool enabled = false;
@ -893,4 +893,4 @@ struct CacheDitConditionState {
}
};
#endif
#endif // __SD_RUNTIME_CACHE_DIT_HPP__

View file

@ -1,9 +1,9 @@
#ifndef __CONDITION_CACHE_UTILS_HPP__
#define __CONDITION_CACHE_UTILS_HPP__
#ifndef __SD_RUNTIME_CONDITION_CACHE_UTILS_HPP__
#define __SD_RUNTIME_CONDITION_CACHE_UTILS_HPP__
#include <vector>
#include "tensor.hpp"
#include "core/tensor.hpp"
namespace sd {
@ -61,4 +61,4 @@ namespace sd {
} // namespace sd
#endif // __CONDITION_CACHE_UTILS_HPP__
#endif // __SD_RUNTIME_CONDITION_CACHE_UTILS_HPP__

View file

@ -1,5 +1,5 @@
#ifndef __DENOISER_HPP__
#define __DENOISER_HPP__
#ifndef __SD_RUNTIME_DENOISER_HPP__
#define __SD_RUNTIME_DENOISER_HPP__
#include <algorithm>
#include <cctype>
@ -8,10 +8,10 @@
#include <string>
#include <utility>
#include "ggml_extend.hpp"
#include "gits_noise.inl"
#include "guidance.h"
#include "tensor.hpp"
#include "core/ggml_extend.hpp"
#include "core/tensor.hpp"
#include "runtime/gits_noise.inl"
#include "runtime/guidance.h"
/*================================================= CompVisDenoiser ==================================================*/
@ -1902,4 +1902,4 @@ static sd::Tensor<float> sample_k_diffusion(sample_method_t method,
}
}
#endif // __DENOISER_HPP__
#endif // __SD_RUNTIME_DENOISER_HPP__

View file

@ -1,15 +1,15 @@
#ifndef __EASYCACHE_HPP__
#define __EASYCACHE_HPP__
#ifndef __SD_RUNTIME_EASYCACHE_HPP__
#define __SD_RUNTIME_EASYCACHE_HPP__
#include <cmath>
#include <limits>
#include <unordered_map>
#include <vector>
#include "condition_cache_utils.hpp"
#include "denoiser.hpp"
#include "ggml_extend.hpp"
#include "tensor.hpp"
#include "core/ggml_extend.hpp"
#include "core/tensor.hpp"
#include "runtime/condition_cache_utils.hpp"
#include "runtime/denoiser.hpp"
struct EasyCacheConfig {
bool enabled = false;
@ -258,4 +258,4 @@ struct EasyCacheState {
}
};
#endif
#endif // __SD_RUNTIME_EASYCACHE_HPP__

View file

@ -1,4 +1,4 @@
#include "guidance.h"
#include "runtime/guidance.h"
#include <algorithm>
#include <cmath>
@ -6,7 +6,7 @@
#include <string>
#include <utility>
#include "util.h"
#include "core/util.h"
namespace sd::guidance {

View file

@ -1,11 +1,11 @@
#ifndef __SD_GUIDANCE_H__
#define __SD_GUIDANCE_H__
#ifndef __SD_RUNTIME_GUIDANCE_H__
#define __SD_RUNTIME_GUIDANCE_H__
#include <cstddef>
#include <functional>
#include <vector>
#include "tensor.hpp"
#include "core/tensor.hpp"
namespace sd::guidance {
@ -93,4 +93,4 @@ namespace sd::guidance {
} // namespace sd::guidance
#endif // __SD_GUIDANCE_H__
#endif // __SD_RUNTIME_GUIDANCE_H__

View file

@ -1,8 +1,8 @@
#include <algorithm>
#include <cstddef>
#include <cstdint>
#include "core/tensor.hpp"
#include "ggml.h"
#include "tensor.hpp"
const float ltxav_latent_rgb_proj[128][3] = {
{-0.0293802f, -0.0362516f, -0.0291386f},

View file

@ -1,10 +1,10 @@
#ifndef __PREPROCESSING_HPP__
#define __PREPROCESSING_HPP__
#ifndef __SD_RUNTIME_PREPROCESSING_HPP__
#define __SD_RUNTIME_PREPROCESSING_HPP__
#include <cmath>
#include <limits>
#include "ggml_extend.hpp"
#include "core/ggml_extend.hpp"
#define M_PI_ 3.14159265358979323846f
@ -331,4 +331,4 @@ bool preprocess_canny(sd_image_t img, float high_threshold, float low_threshold,
return true;
}
#endif // __PREPROCESSING_HPP__
#endif // __SD_RUNTIME_PREPROCESSING_HPP__

View file

@ -1,4 +1,4 @@
#include "sample-cache.h"
#include "runtime/sample-cache.h"
namespace sd_sample {

View file

@ -1,16 +1,16 @@
#ifndef __SAMPLE_CACHE_H__
#define __SAMPLE_CACHE_H__
#ifndef __SD_RUNTIME_SAMPLE_CACHE_H__
#define __SD_RUNTIME_SAMPLE_CACHE_H__
#include <vector>
#include "cache_dit.hpp"
#include "denoiser.hpp"
#include "easycache.hpp"
#include "core/tensor.hpp"
#include "core/util.h"
#include "model.h"
#include "spectrum.hpp"
#include "tensor.hpp"
#include "ucache.hpp"
#include "util.h"
#include "runtime/cache_dit.hpp"
#include "runtime/denoiser.hpp"
#include "runtime/easycache.hpp"
#include "runtime/spectrum.hpp"
#include "runtime/ucache.hpp"
namespace sd_sample {
@ -58,4 +58,4 @@ namespace sd_sample {
} // namespace sd_sample
#endif // __SAMPLE_CACHE_H__
#endif // __SD_RUNTIME_SAMPLE_CACHE_H__

View file

@ -1,12 +1,12 @@
#ifndef __SPECTRUM_HPP__
#define __SPECTRUM_HPP__
#ifndef __SD_RUNTIME_SPECTRUM_HPP__
#define __SD_RUNTIME_SPECTRUM_HPP__
#include <cmath>
#include <cstring>
#include <vector>
#include "ggml_extend.hpp"
#include "tensor.hpp"
#include "core/ggml_extend.hpp"
#include "core/tensor.hpp"
struct SpectrumConfig {
float w = 0.40f;
@ -184,4 +184,4 @@ private:
}
};
#endif // __SPECTRUM_HPP__
#endif // __SD_RUNTIME_SPECTRUM_HPP__

View file

@ -1,15 +1,15 @@
#ifndef __UCACHE_HPP__
#define __UCACHE_HPP__
#ifndef __SD_RUNTIME_UCACHE_HPP__
#define __SD_RUNTIME_UCACHE_HPP__
#include <cmath>
#include <limits>
#include <unordered_map>
#include <vector>
#include "condition_cache_utils.hpp"
#include "denoiser.hpp"
#include "ggml_extend.hpp"
#include "tensor.hpp"
#include "core/ggml_extend.hpp"
#include "core/tensor.hpp"
#include "runtime/condition_cache_utils.hpp"
#include "runtime/denoiser.hpp"
struct UCacheConfig {
bool enabled = false;
@ -420,4 +420,4 @@ struct UCacheState {
}
};
#endif // __UCACHE_HPP__
#endif // __SD_RUNTIME_UCACHE_HPP__

View file

@ -3,49 +3,49 @@
#include <cstdlib>
#include <filesystem>
#include "ggml_extend.hpp"
#include "ggml_graph_cut.h"
#include "core/ggml_extend.hpp"
#include "core/ggml_graph_cut.h"
#include "core/rng.hpp"
#include "core/rng_mt19937.hpp"
#include "core/rng_philox.hpp"
#include "core/util.h"
#include "model.h"
#include "rng.hpp"
#include "rng_mt19937.hpp"
#include "rng_philox.hpp"
#include "stable-diffusion.h"
#include "util.h"
#include "anima.hpp"
#include "auto_encoder_kl.hpp"
#include "conditioner.hpp"
#include "control.hpp"
#include "denoiser.hpp"
#include "diffusion_model.hpp"
#include "ernie_image.hpp"
#include "esrgan.hpp"
#include "flux.hpp"
#include "guidance.h"
#include "hidream_o1.hpp"
#include "ideogram4.hpp"
#include "lens.hpp"
#include "lora.hpp"
#include "ltx_audio_vae.h"
#include "ltx_latent_upscaler.hpp"
#include "ltx_vae.hpp"
#include "ltxv.hpp"
#include "mmdit.hpp"
#include "pid.hpp"
#include "pmid.hpp"
#include "qwen_image.hpp"
#include "sample-cache.h"
#include "tae.hpp"
#include "unet.hpp"
#include "conditioning/conditioner.hpp"
#include "model/adapter/lora.hpp"
#include "model/adapter/pmid.hpp"
#include "model/diffusion/anima.hpp"
#include "model/diffusion/control.hpp"
#include "model/diffusion/ernie_image.hpp"
#include "model/diffusion/flux.hpp"
#include "model/diffusion/hidream_o1.hpp"
#include "model/diffusion/ideogram4.hpp"
#include "model/diffusion/lens.hpp"
#include "model/diffusion/ltxv.hpp"
#include "model/diffusion/mmdit.hpp"
#include "model/diffusion/model.hpp"
#include "model/diffusion/pid.hpp"
#include "model/diffusion/qwen_image.hpp"
#include "model/diffusion/unet.hpp"
#include "model/diffusion/wan.hpp"
#include "model/diffusion/z_image.hpp"
#include "model/upscaler/esrgan.hpp"
#include "model/upscaler/ltx_latent_upscaler.hpp"
#include "model/vae/auto_encoder_kl.hpp"
#include "model/vae/ltx_audio_vae.hpp"
#include "model/vae/ltx_vae.hpp"
#include "model/vae/tae.hpp"
#include "model/vae/vae.hpp"
#include "model/vae/wan_vae.hpp"
#include "runtime/denoiser.hpp"
#include "runtime/guidance.h"
#include "runtime/sample-cache.h"
#include "upscaler.h"
#include "vae.hpp"
#include "wan.hpp"
#include "wan_vae.hpp"
#include "z_image.hpp"
#include "latent-preview.h"
#include "name_conversion.h"
#include "runtime/latent-preview.h"
const char* sd_vae_format_name(enum sd_vae_format_t format);
static SDVersion sd_vae_format_to_version(enum sd_vae_format_t format, SDVersion fallback);

View file

@ -3,8 +3,8 @@
#include <algorithm>
#include <sstream>
#include "core/util.h"
#include "tokenize_util.h"
#include "util.h"
std::vector<std::pair<int, std::u32string>> BPETokenizer::bytes_to_unicode() {
std::vector<std::pair<int, std::u32string>> byte_unicode_pairs;

View file

@ -6,9 +6,9 @@
#include <regex>
#include <set>
#include "core/util.h"
#include "ggml.h"
#include "tokenize_util.h"
#include "util.h"
#include "vocab/vocab.h"
CLIPTokenizer::CLIPTokenizer(int pad_token_id, const std::string& merges_utf8_str) {

View file

@ -1,8 +1,8 @@
#include "gemma_tokenizer.h"
#include "core/util.h"
#include "ggml.h"
#include "json.hpp"
#include "util.h"
#include "vocab/vocab.h"
std::string GemmaTokenizer::normalize(const std::string& text) const {

Some files were not shown because too many files have changed in this diff Show more