From a53b3f74113ced3173945086432aa4360c2f027f Mon Sep 17 00:00:00 2001 From: Wagner Bruna Date: Mon, 8 Jun 2026 09:42:57 -0300 Subject: [PATCH] sd: sync with master-679-f3fd359 (#2257) --- Makefile | 20 +++--- otherarch/sdcpp/avi_writer.h | 2 +- .../{ => examples/cli}/image_metadata.cpp | 0 .../sdcpp/{ => examples/cli}/image_metadata.h | 0 otherarch/sdcpp/{ => examples/cli}/main.cpp | 0 otherarch/sdcpp/{ => examples/cli}/msf_gif.h | 0 .../sdcpp/{ => examples}/common/common.cpp | 0 .../sdcpp/{ => examples}/common/common.h | 0 otherarch/sdcpp/{ => examples}/common/log.cpp | 0 otherarch/sdcpp/{ => examples}/common/log.h | 0 .../sdcpp/{ => examples}/common/media_io.cpp | 0 .../sdcpp/{ => examples}/common/media_io.h | 0 .../{ => examples}/common/resource_owners.hpp | 0 .../sdcpp/{ => include}/stable-diffusion.h | 0 otherarch/sdcpp/sdtype_adapter.cpp | 3 +- .../{ => src/conditioning}/conditioner.hpp | 14 ++-- otherarch/sdcpp/{ => src}/convert.cpp | 0 .../sdcpp/{ => src/core}/ggml_extend.hpp | 20 +++--- .../{ => src/core}/ggml_extend_backend.cpp | 4 +- .../{ => src/core}/ggml_extend_backend.h | 6 +- .../sdcpp/{ => src/core}/ggml_graph_cut.cpp | 6 +- .../sdcpp/{ => src/core}/ggml_graph_cut.h | 6 +- .../sdcpp/{ => src/core}/layer_registry.cpp | 4 +- .../sdcpp/{ => src/core}/layer_registry.h | 6 +- .../sdcpp/{ => src/core}/ordered_map.hpp | 6 +- otherarch/sdcpp/{ => src/core}/rng.hpp | 6 +- .../sdcpp/{ => src/core}/rng_mt19937.hpp | 8 +-- otherarch/sdcpp/{ => src/core}/rng_philox.hpp | 8 +-- otherarch/sdcpp/{ => src/core}/tensor.hpp | 8 +-- .../sdcpp/{ => src/core}/tensor_ggml.hpp | 8 +-- otherarch/sdcpp/{ => src/core}/util.cpp | 4 +- otherarch/sdcpp/{ => src/core}/util.h | 8 +-- .../sdcpp/{ => src}/kcpp_sd_extensions.h | 0 otherarch/sdcpp/{ => src}/model.cpp | 4 +- otherarch/sdcpp/{ => src}/model.h | 2 +- .../sdcpp/{ => src/model/adapter}/lora.hpp | 8 +-- .../sdcpp/{ => src/model/adapter}/pmid.hpp | 13 ++-- .../model/common/block.hpp} | 41 +++++++++-- .../sdcpp/{ => src/model/common}/rope.hpp | 8 +-- .../sdcpp/{ => src/model/diffusion}/anima.hpp | 14 ++-- .../{ => src/model/diffusion}/control.hpp | 8 +-- .../model/diffusion/dit.hpp} | 8 +-- .../{ => src/model/diffusion}/ernie_image.hpp | 16 ++--- .../sdcpp/{ => src/model/diffusion}/flux.hpp | 12 ++-- .../{ => src/model/diffusion}/hidream_o1.hpp | 16 ++--- .../{ => src/model/diffusion}/ideogram4.hpp | 14 ++-- .../sdcpp/{ => src/model/diffusion}/lens.hpp | 16 ++--- .../sdcpp/{ => src/model/diffusion}/ltxv.hpp | 14 ++-- .../sdcpp/{ => src/model/diffusion}/mmdit.hpp | 42 ++--------- .../model/diffusion/model.hpp} | 10 +-- .../sdcpp/{ => src/model/diffusion}/pid.hpp | 14 ++-- .../{ => src/model/diffusion}/qwen_image.hpp | 12 ++-- .../sdcpp/{ => src/model/diffusion}/unet.hpp | 10 +-- .../sdcpp/{ => src/model/diffusion}/wan.hpp | 14 ++-- .../{ => src/model/diffusion}/z_image.hpp | 16 ++--- otherarch/sdcpp/{ => src/model/te}/clip.hpp | 10 +-- otherarch/sdcpp/{ => src/model/te}/llm.hpp | 10 +-- otherarch/sdcpp/{ => src/model/te}/t5.hpp | 8 +-- .../sdcpp/{ => src/model/upscaler}/esrgan.hpp | 8 +-- .../model/upscaler}/ltx_latent_upscaler.hpp | 14 ++-- .../{ => src/model/vae}/auto_encoder_kl.hpp | 8 +-- .../model/vae/ltx_audio_vae.hpp} | 8 +-- .../sdcpp/{ => src/model/vae}/ltx_vae.hpp | 12 ++-- otherarch/sdcpp/{ => src/model/vae}/tae.hpp | 10 +-- otherarch/sdcpp/{ => src/model/vae}/vae.hpp | 10 +-- .../sdcpp/{ => src/model/vae}/wan_vae.hpp | 10 +-- .../sdcpp/{ => src}/model_io/binary_io.h | 0 .../sdcpp/{ => src}/model_io/gguf_io.cpp | 2 +- otherarch/sdcpp/{ => src}/model_io/gguf_io.h | 0 .../{ => src}/model_io/gguf_reader_ext.h | 2 +- .../sdcpp/{ => src}/model_io/pickle_io.cpp | 2 +- .../sdcpp/{ => src}/model_io/pickle_io.h | 0 .../{ => src}/model_io/safetensors_io.cpp | 2 +- .../sdcpp/{ => src}/model_io/safetensors_io.h | 0 .../sdcpp/{ => src}/model_io/tensor_storage.h | 0 .../{ => src}/model_io/torch_legacy_io.cpp | 2 +- .../{ => src}/model_io/torch_legacy_io.h | 0 .../sdcpp/{ => src}/model_io/torch_zip_io.cpp | 0 .../sdcpp/{ => src}/model_io/torch_zip_io.h | 0 otherarch/sdcpp/{ => src}/name_conversion.cpp | 2 +- otherarch/sdcpp/{ => src}/name_conversion.h | 0 .../sdcpp/{ => src/runtime}/cache_dit.hpp | 12 ++-- .../runtime}/condition_cache_utils.hpp | 8 +-- .../sdcpp/{ => src/runtime}/denoiser.hpp | 14 ++-- .../sdcpp/{ => src/runtime}/easycache.hpp | 14 ++-- .../sdcpp/{ => src/runtime}/gits_noise.inl | 0 .../sdcpp/{ => src/runtime}/guidance.cpp | 4 +- otherarch/sdcpp/{ => src/runtime}/guidance.h | 8 +-- .../sdcpp/{ => src/runtime}/latent-preview.h | 2 +- .../sdcpp/{ => src/runtime}/preprocessing.hpp | 8 +-- .../sdcpp/{ => src/runtime}/sample-cache.cpp | 2 +- .../sdcpp/{ => src/runtime}/sample-cache.h | 20 +++--- .../sdcpp/{ => src/runtime}/spectrum.hpp | 10 +-- otherarch/sdcpp/{ => src/runtime}/ucache.hpp | 14 ++-- .../sdcpp/{ => src}/stable-diffusion.cpp | 72 +++++++++---------- .../{ => src}/tokenizers/bpe_tokenizer.cpp | 2 +- .../{ => src}/tokenizers/bpe_tokenizer.h | 0 .../{ => src}/tokenizers/clip_tokenizer.cpp | 2 +- .../{ => src}/tokenizers/clip_tokenizer.h | 0 .../{ => src}/tokenizers/gemma_tokenizer.cpp | 2 +- .../{ => src}/tokenizers/gemma_tokenizer.h | 0 .../tokenizers/gpt_oss_tokenizer.cpp | 2 +- .../{ => src}/tokenizers/gpt_oss_tokenizer.h | 0 .../tokenizers/mistral_tokenizer.cpp | 2 +- .../{ => src}/tokenizers/mistral_tokenizer.h | 0 .../{ => src}/tokenizers/qwen2_tokenizer.cpp | 2 +- .../{ => src}/tokenizers/qwen2_tokenizer.h | 0 .../tokenizers/t5_unigram_tokenizer.cpp | 2 +- .../tokenizers/t5_unigram_tokenizer.h | 0 .../{ => src}/tokenizers/tokenize_util.cpp | 0 .../{ => src}/tokenizers/tokenize_util.h | 0 .../sdcpp/{ => src}/tokenizers/tokenizer.cpp | 2 +- .../sdcpp/{ => src}/tokenizers/tokenizer.h | 0 .../tokenizers/vocab/clip_merges.hpp | 0 .../tokenizers/vocab/gemma2_merges.hpp | 0 .../tokenizers/vocab/gemma2_vocab.hpp | 0 .../tokenizers/vocab/gemma_merges.hpp | 0 .../tokenizers/vocab/gemma_vocab.hpp | 0 .../tokenizers/vocab/gpt_oss_merges.hpp | 0 .../tokenizers/vocab/gpt_oss_vocab.hpp | 0 .../tokenizers/vocab/mistral_merges.hpp | 0 .../tokenizers/vocab/mistral_vocab.hpp | 0 .../tokenizers/vocab/qwen_merges.hpp | 0 .../sdcpp/{ => src}/tokenizers/vocab/t5.hpp | 0 .../sdcpp/{ => src}/tokenizers/vocab/umt5.hpp | 0 .../{ => src}/tokenizers/vocab/vocab.cpp | 0 .../sdcpp/{ => src}/tokenizers/vocab/vocab.h | 0 otherarch/sdcpp/{ => src}/upscaler.cpp | 4 +- otherarch/sdcpp/{ => src}/upscaler.h | 6 +- otherarch/sdcpp/{ => src}/version.cpp | 0 130 files changed, 399 insertions(+), 394 deletions(-) rename otherarch/sdcpp/{ => examples/cli}/image_metadata.cpp (100%) rename otherarch/sdcpp/{ => examples/cli}/image_metadata.h (100%) rename otherarch/sdcpp/{ => examples/cli}/main.cpp (100%) rename otherarch/sdcpp/{ => examples/cli}/msf_gif.h (100%) rename otherarch/sdcpp/{ => examples}/common/common.cpp (100%) rename otherarch/sdcpp/{ => examples}/common/common.h (100%) rename otherarch/sdcpp/{ => examples}/common/log.cpp (100%) rename otherarch/sdcpp/{ => examples}/common/log.h (100%) rename otherarch/sdcpp/{ => examples}/common/media_io.cpp (100%) rename otherarch/sdcpp/{ => examples}/common/media_io.h (100%) rename otherarch/sdcpp/{ => examples}/common/resource_owners.hpp (100%) rename otherarch/sdcpp/{ => include}/stable-diffusion.h (100%) rename otherarch/sdcpp/{ => src/conditioning}/conditioner.hpp (99%) rename otherarch/sdcpp/{ => src}/convert.cpp (100%) rename otherarch/sdcpp/{ => src/core}/ggml_extend.hpp (99%) rename otherarch/sdcpp/{ => src/core}/ggml_extend_backend.cpp (99%) rename otherarch/sdcpp/{ => src/core}/ggml_extend_backend.h (94%) rename otherarch/sdcpp/{ => src/core}/ggml_graph_cut.cpp (99%) rename otherarch/sdcpp/{ => src/core}/ggml_graph_cut.h (97%) rename otherarch/sdcpp/{ => src/core}/layer_registry.cpp (98%) rename otherarch/sdcpp/{ => src/core}/layer_registry.h (93%) rename otherarch/sdcpp/{ => src/core}/ordered_map.hpp (97%) rename otherarch/sdcpp/{ => src/core}/rng.hpp (89%) rename otherarch/sdcpp/{ => src/core}/rng_mt19937.hpp (97%) rename otherarch/sdcpp/{ => src/core}/rng_philox.hpp (97%) rename otherarch/sdcpp/{ => src/core}/tensor.hpp (99%) rename otherarch/sdcpp/{ => src/core}/tensor_ggml.hpp (96%) rename otherarch/sdcpp/{ => src/core}/util.cpp (99%) rename otherarch/sdcpp/{ => src/core}/util.h (97%) rename otherarch/sdcpp/{ => src}/kcpp_sd_extensions.h (100%) rename otherarch/sdcpp/{ => src}/model.cpp (99%) rename otherarch/sdcpp/{ => src}/model.h (99%) rename otherarch/sdcpp/{ => src/model/adapter}/lora.hpp (99%) rename otherarch/sdcpp/{ => src/model/adapter}/pmid.hpp (99%) rename otherarch/sdcpp/{common_block.hpp => src/model/common/block.hpp} (95%) rename otherarch/sdcpp/{ => src/model/common}/rope.hpp (99%) rename otherarch/sdcpp/{ => src/model/diffusion}/anima.hpp (99%) rename otherarch/sdcpp/{ => src/model/diffusion}/control.hpp (99%) rename otherarch/sdcpp/{common_dit.hpp => src/model/diffusion/dit.hpp} (98%) rename otherarch/sdcpp/{ => src/model/diffusion}/ernie_image.hpp (98%) rename otherarch/sdcpp/{ => src/model/diffusion}/flux.hpp (99%) rename otherarch/sdcpp/{ => src/model/diffusion}/hidream_o1.hpp (99%) rename otherarch/sdcpp/{ => src/model/diffusion}/ideogram4.hpp (98%) rename otherarch/sdcpp/{ => src/model/diffusion}/lens.hpp (98%) rename otherarch/sdcpp/{ => src/model/diffusion}/ltxv.hpp (99%) rename otherarch/sdcpp/{ => src/model/diffusion}/mmdit.hpp (97%) rename otherarch/sdcpp/{diffusion_model.hpp => src/model/diffusion/model.hpp} (95%) rename otherarch/sdcpp/{ => src/model/diffusion}/pid.hpp (99%) rename otherarch/sdcpp/{ => src/model/diffusion}/qwen_image.hpp (99%) rename otherarch/sdcpp/{ => src/model/diffusion}/unet.hpp (99%) rename otherarch/sdcpp/{ => src/model/diffusion}/wan.hpp (99%) rename otherarch/sdcpp/{ => src/model/diffusion}/z_image.hpp (99%) rename otherarch/sdcpp/{ => src/model/te}/clip.hpp (99%) rename otherarch/sdcpp/{ => src/model/te}/llm.hpp (99%) rename otherarch/sdcpp/{ => src/model/te}/t5.hpp (97%) rename otherarch/sdcpp/{ => src/model/upscaler}/esrgan.hpp (99%) rename otherarch/sdcpp/{ => src/model/upscaler}/ltx_latent_upscaler.hpp (98%) rename otherarch/sdcpp/{ => src/model/vae}/auto_encoder_kl.hpp (99%) rename otherarch/sdcpp/{ltx_audio_vae.h => src/model/vae/ltx_audio_vae.hpp} (99%) rename otherarch/sdcpp/{ => src/model/vae}/ltx_vae.hpp (99%) rename otherarch/sdcpp/{ => src/model/vae}/tae.hpp (99%) rename otherarch/sdcpp/{ => src/model/vae}/vae.hpp (98%) rename otherarch/sdcpp/{ => src/model/vae}/wan_vae.hpp (99%) rename otherarch/sdcpp/{ => src}/model_io/binary_io.h (100%) rename otherarch/sdcpp/{ => src}/model_io/gguf_io.cpp (99%) rename otherarch/sdcpp/{ => src}/model_io/gguf_io.h (100%) rename otherarch/sdcpp/{ => src}/model_io/gguf_reader_ext.h (99%) rename otherarch/sdcpp/{ => src}/model_io/pickle_io.cpp (99%) rename otherarch/sdcpp/{ => src}/model_io/pickle_io.h (100%) rename otherarch/sdcpp/{ => src}/model_io/safetensors_io.cpp (99%) rename otherarch/sdcpp/{ => src}/model_io/safetensors_io.h (100%) rename otherarch/sdcpp/{ => src}/model_io/tensor_storage.h (100%) rename otherarch/sdcpp/{ => src}/model_io/torch_legacy_io.cpp (99%) rename otherarch/sdcpp/{ => src}/model_io/torch_legacy_io.h (100%) rename otherarch/sdcpp/{ => src}/model_io/torch_zip_io.cpp (100%) rename otherarch/sdcpp/{ => src}/model_io/torch_zip_io.h (100%) rename otherarch/sdcpp/{ => src}/name_conversion.cpp (99%) rename otherarch/sdcpp/{ => src}/name_conversion.h (100%) rename otherarch/sdcpp/{ => src/runtime}/cache_dit.hpp (99%) rename otherarch/sdcpp/{ => src/runtime}/condition_cache_utils.hpp (91%) rename otherarch/sdcpp/{ => src/runtime}/denoiser.hpp (99%) rename otherarch/sdcpp/{ => src/runtime}/easycache.hpp (97%) rename otherarch/sdcpp/{ => src/runtime}/gits_noise.inl (100%) rename otherarch/sdcpp/{ => src/runtime}/guidance.cpp (99%) rename otherarch/sdcpp/{ => src/runtime}/guidance.h (95%) rename otherarch/sdcpp/{ => src/runtime}/latent-preview.h (99%) rename otherarch/sdcpp/{ => src/runtime}/preprocessing.hpp (98%) rename otherarch/sdcpp/{ => src/runtime}/sample-cache.cpp (99%) rename otherarch/sdcpp/{ => src/runtime}/sample-cache.h (82%) rename otherarch/sdcpp/{ => src/runtime}/spectrum.hpp (97%) rename otherarch/sdcpp/{ => src/runtime}/ucache.hpp (98%) rename otherarch/sdcpp/{ => src}/stable-diffusion.cpp (99%) rename otherarch/sdcpp/{ => src}/tokenizers/bpe_tokenizer.cpp (99%) rename otherarch/sdcpp/{ => src}/tokenizers/bpe_tokenizer.h (100%) rename otherarch/sdcpp/{ => src}/tokenizers/clip_tokenizer.cpp (99%) rename otherarch/sdcpp/{ => src}/tokenizers/clip_tokenizer.h (100%) rename otherarch/sdcpp/{ => src}/tokenizers/gemma_tokenizer.cpp (99%) rename otherarch/sdcpp/{ => src}/tokenizers/gemma_tokenizer.h (100%) rename otherarch/sdcpp/{ => src}/tokenizers/gpt_oss_tokenizer.cpp (99%) rename otherarch/sdcpp/{ => src}/tokenizers/gpt_oss_tokenizer.h (100%) rename otherarch/sdcpp/{ => src}/tokenizers/mistral_tokenizer.cpp (99%) rename otherarch/sdcpp/{ => src}/tokenizers/mistral_tokenizer.h (100%) rename otherarch/sdcpp/{ => src}/tokenizers/qwen2_tokenizer.cpp (99%) rename otherarch/sdcpp/{ => src}/tokenizers/qwen2_tokenizer.h (100%) rename otherarch/sdcpp/{ => src}/tokenizers/t5_unigram_tokenizer.cpp (99%) rename otherarch/sdcpp/{ => src}/tokenizers/t5_unigram_tokenizer.h (100%) rename otherarch/sdcpp/{ => src}/tokenizers/tokenize_util.cpp (100%) rename otherarch/sdcpp/{ => src}/tokenizers/tokenize_util.h (100%) rename otherarch/sdcpp/{ => src}/tokenizers/tokenizer.cpp (99%) rename otherarch/sdcpp/{ => src}/tokenizers/tokenizer.h (100%) rename otherarch/sdcpp/{ => src}/tokenizers/vocab/clip_merges.hpp (100%) rename otherarch/sdcpp/{ => src}/tokenizers/vocab/gemma2_merges.hpp (100%) rename otherarch/sdcpp/{ => src}/tokenizers/vocab/gemma2_vocab.hpp (100%) rename otherarch/sdcpp/{ => src}/tokenizers/vocab/gemma_merges.hpp (100%) rename otherarch/sdcpp/{ => src}/tokenizers/vocab/gemma_vocab.hpp (100%) rename otherarch/sdcpp/{ => src}/tokenizers/vocab/gpt_oss_merges.hpp (100%) rename otherarch/sdcpp/{ => src}/tokenizers/vocab/gpt_oss_vocab.hpp (100%) rename otherarch/sdcpp/{ => src}/tokenizers/vocab/mistral_merges.hpp (100%) rename otherarch/sdcpp/{ => src}/tokenizers/vocab/mistral_vocab.hpp (100%) rename otherarch/sdcpp/{ => src}/tokenizers/vocab/qwen_merges.hpp (100%) rename otherarch/sdcpp/{ => src}/tokenizers/vocab/t5.hpp (100%) rename otherarch/sdcpp/{ => src}/tokenizers/vocab/umt5.hpp (100%) rename otherarch/sdcpp/{ => src}/tokenizers/vocab/vocab.cpp (100%) rename otherarch/sdcpp/{ => src}/tokenizers/vocab/vocab.h (100%) rename otherarch/sdcpp/{ => src}/upscaler.cpp (99%) rename otherarch/sdcpp/{ => src}/upscaler.h (92%) rename otherarch/sdcpp/{ => src}/version.cpp (100%) diff --git a/Makefile b/Makefile index 657d30342..396c7c7ab 100644 --- a/Makefile +++ b/Makefile @@ -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) diff --git a/otherarch/sdcpp/avi_writer.h b/otherarch/sdcpp/avi_writer.h index 4cf499dde..d454ee0ba 100644 --- a/otherarch/sdcpp/avi_writer.h +++ b/otherarch/sdcpp/avi_writer.h @@ -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" diff --git a/otherarch/sdcpp/image_metadata.cpp b/otherarch/sdcpp/examples/cli/image_metadata.cpp similarity index 100% rename from otherarch/sdcpp/image_metadata.cpp rename to otherarch/sdcpp/examples/cli/image_metadata.cpp diff --git a/otherarch/sdcpp/image_metadata.h b/otherarch/sdcpp/examples/cli/image_metadata.h similarity index 100% rename from otherarch/sdcpp/image_metadata.h rename to otherarch/sdcpp/examples/cli/image_metadata.h diff --git a/otherarch/sdcpp/main.cpp b/otherarch/sdcpp/examples/cli/main.cpp similarity index 100% rename from otherarch/sdcpp/main.cpp rename to otherarch/sdcpp/examples/cli/main.cpp diff --git a/otherarch/sdcpp/msf_gif.h b/otherarch/sdcpp/examples/cli/msf_gif.h similarity index 100% rename from otherarch/sdcpp/msf_gif.h rename to otherarch/sdcpp/examples/cli/msf_gif.h diff --git a/otherarch/sdcpp/common/common.cpp b/otherarch/sdcpp/examples/common/common.cpp similarity index 100% rename from otherarch/sdcpp/common/common.cpp rename to otherarch/sdcpp/examples/common/common.cpp diff --git a/otherarch/sdcpp/common/common.h b/otherarch/sdcpp/examples/common/common.h similarity index 100% rename from otherarch/sdcpp/common/common.h rename to otherarch/sdcpp/examples/common/common.h diff --git a/otherarch/sdcpp/common/log.cpp b/otherarch/sdcpp/examples/common/log.cpp similarity index 100% rename from otherarch/sdcpp/common/log.cpp rename to otherarch/sdcpp/examples/common/log.cpp diff --git a/otherarch/sdcpp/common/log.h b/otherarch/sdcpp/examples/common/log.h similarity index 100% rename from otherarch/sdcpp/common/log.h rename to otherarch/sdcpp/examples/common/log.h diff --git a/otherarch/sdcpp/common/media_io.cpp b/otherarch/sdcpp/examples/common/media_io.cpp similarity index 100% rename from otherarch/sdcpp/common/media_io.cpp rename to otherarch/sdcpp/examples/common/media_io.cpp diff --git a/otherarch/sdcpp/common/media_io.h b/otherarch/sdcpp/examples/common/media_io.h similarity index 100% rename from otherarch/sdcpp/common/media_io.h rename to otherarch/sdcpp/examples/common/media_io.h diff --git a/otherarch/sdcpp/common/resource_owners.hpp b/otherarch/sdcpp/examples/common/resource_owners.hpp similarity index 100% rename from otherarch/sdcpp/common/resource_owners.hpp rename to otherarch/sdcpp/examples/common/resource_owners.hpp diff --git a/otherarch/sdcpp/stable-diffusion.h b/otherarch/sdcpp/include/stable-diffusion.h similarity index 100% rename from otherarch/sdcpp/stable-diffusion.h rename to otherarch/sdcpp/include/stable-diffusion.h diff --git a/otherarch/sdcpp/sdtype_adapter.cpp b/otherarch/sdcpp/sdtype_adapter.cpp index e8e0420bd..d172736c7 100644 --- a/otherarch/sdcpp/sdtype_adapter.cpp +++ b/otherarch/sdcpp/sdtype_adapter.cpp @@ -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; diff --git a/otherarch/sdcpp/conditioner.hpp b/otherarch/sdcpp/src/conditioning/conditioner.hpp similarity index 99% rename from otherarch/sdcpp/conditioner.hpp rename to otherarch/sdcpp/src/conditioning/conditioner.hpp index 862bfc871..78c3e8fe6 100644 --- a/otherarch/sdcpp/conditioner.hpp +++ b/otherarch/sdcpp/src/conditioning/conditioner.hpp @@ -1,14 +1,14 @@ -#ifndef __CONDITIONER_HPP__ -#define __CONDITIONER_HPP__ +#ifndef __SD_CONDITIONING_CONDITIONER_HPP__ +#define __SD_CONDITIONING_CONDITIONER_HPP__ #include #include #include -#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 c_crossattn; @@ -2554,4 +2554,4 @@ struct LTXAVEmbedder : public Conditioner { } }; -#endif +#endif // __SD_CONDITIONING_CONDITIONER_HPP__ diff --git a/otherarch/sdcpp/convert.cpp b/otherarch/sdcpp/src/convert.cpp similarity index 100% rename from otherarch/sdcpp/convert.cpp rename to otherarch/sdcpp/src/convert.cpp diff --git a/otherarch/sdcpp/ggml_extend.hpp b/otherarch/sdcpp/src/core/ggml_extend.hpp similarity index 99% rename from otherarch/sdcpp/ggml_extend.hpp rename to otherarch/sdcpp/src/core/ggml_extend.hpp index 72ffaf3d9..3c6aa49f4 100644 --- a/otherarch/sdcpp/ggml_extend.hpp +++ b/otherarch/sdcpp/src/core/ggml_extend.hpp @@ -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 #include @@ -23,19 +23,19 @@ #include #include +#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__ diff --git a/otherarch/sdcpp/ggml_extend_backend.cpp b/otherarch/sdcpp/src/core/ggml_extend_backend.cpp similarity index 99% rename from otherarch/sdcpp/ggml_extend_backend.cpp rename to otherarch/sdcpp/src/core/ggml_extend_backend.cpp index 5e95eae5a..d085129db 100644 --- a/otherarch/sdcpp/ggml_extend_backend.cpp +++ b/otherarch/sdcpp/src/core/ggml_extend_backend.cpp @@ -1,4 +1,4 @@ -#include "ggml_extend_backend.h" +#include "core/ggml_extend_backend.h" #include #include @@ -8,8 +8,8 @@ #include #include +#include "core/util.h" #include "stable-diffusion.h" -#include "util.h" static std::string trim_copy(const std::string& value) { size_t begin = 0; diff --git a/otherarch/sdcpp/ggml_extend_backend.h b/otherarch/sdcpp/src/core/ggml_extend_backend.h similarity index 94% rename from otherarch/sdcpp/ggml_extend_backend.h rename to otherarch/sdcpp/src/core/ggml_extend_backend.h index 972fbee73..fc071ffda 100644 --- a/otherarch/sdcpp/ggml_extend_backend.h +++ b/otherarch/sdcpp/src/core/ggml_extend_backend.h @@ -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 #include @@ -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__ diff --git a/otherarch/sdcpp/ggml_graph_cut.cpp b/otherarch/sdcpp/src/core/ggml_graph_cut.cpp similarity index 99% rename from otherarch/sdcpp/ggml_graph_cut.cpp rename to otherarch/sdcpp/src/core/ggml_graph_cut.cpp index 2009eaf00..c77a45448 100644 --- a/otherarch/sdcpp/ggml_graph_cut.cpp +++ b/otherarch/sdcpp/src/core/ggml_graph_cut.cpp @@ -1,4 +1,4 @@ -#include "ggml_graph_cut.h" +#include "core/ggml_graph_cut.h" #include #include @@ -8,11 +8,11 @@ #include #include +#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 { diff --git a/otherarch/sdcpp/ggml_graph_cut.h b/otherarch/sdcpp/src/core/ggml_graph_cut.h similarity index 97% rename from otherarch/sdcpp/ggml_graph_cut.h rename to otherarch/sdcpp/src/core/ggml_graph_cut.h index 9668bc38e..7919acadd 100644 --- a/otherarch/sdcpp/ggml_graph_cut.h +++ b/otherarch/sdcpp/src/core/ggml_graph_cut.h @@ -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 #include @@ -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__ diff --git a/otherarch/sdcpp/layer_registry.cpp b/otherarch/sdcpp/src/core/layer_registry.cpp similarity index 98% rename from otherarch/sdcpp/layer_registry.cpp rename to otherarch/sdcpp/src/core/layer_registry.cpp index c4ff18814..65771ee9e 100644 --- a/otherarch/sdcpp/layer_registry.cpp +++ b/otherarch/sdcpp/src/core/layer_registry.cpp @@ -1,8 +1,8 @@ -#include "layer_registry.h" +#include "core/layer_registry.h" #include -#include "util.h" +#include "core/util.h" namespace sd::layer_registry { diff --git a/otherarch/sdcpp/layer_registry.h b/otherarch/sdcpp/src/core/layer_registry.h similarity index 93% rename from otherarch/sdcpp/layer_registry.h rename to otherarch/sdcpp/src/core/layer_registry.h index 2dc755349..c0b980d0b 100644 --- a/otherarch/sdcpp/layer_registry.h +++ b/otherarch/sdcpp/src/core/layer_registry.h @@ -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 #include @@ -47,4 +47,4 @@ namespace sd::layer_registry { } // namespace sd::layer_registry -#endif +#endif // __SD_CORE_LAYER_REGISTRY_H__ diff --git a/otherarch/sdcpp/ordered_map.hpp b/otherarch/sdcpp/src/core/ordered_map.hpp similarity index 97% rename from otherarch/sdcpp/ordered_map.hpp rename to otherarch/sdcpp/src/core/ordered_map.hpp index 3fbdca5d5..fc4755b87 100644 --- a/otherarch/sdcpp/ordered_map.hpp +++ b/otherarch/sdcpp/src/core/ordered_map.hpp @@ -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 #include @@ -174,4 +174,4 @@ public: } }; -#endif // __ORDERED_MAP_HPP__ \ No newline at end of file +#endif // __SD_CORE_ORDERED_MAP_HPP__ \ No newline at end of file diff --git a/otherarch/sdcpp/rng.hpp b/otherarch/sdcpp/src/core/rng.hpp similarity index 89% rename from otherarch/sdcpp/rng.hpp rename to otherarch/sdcpp/src/core/rng.hpp index accc40887..20ffec7de 100644 --- a/otherarch/sdcpp/rng.hpp +++ b/otherarch/sdcpp/src/core/rng.hpp @@ -1,5 +1,5 @@ -#ifndef __RNG_H__ -#define __RNG_H__ +#ifndef __SD_CORE_RNG_HPP__ +#define __SD_CORE_RNG_HPP__ #include #include @@ -32,4 +32,4 @@ public: } }; -#endif // __RNG_H__ \ No newline at end of file +#endif // __SD_CORE_RNG_HPP__ \ No newline at end of file diff --git a/otherarch/sdcpp/rng_mt19937.hpp b/otherarch/sdcpp/src/core/rng_mt19937.hpp similarity index 97% rename from otherarch/sdcpp/rng_mt19937.hpp rename to otherarch/sdcpp/src/core/rng_mt19937.hpp index 734554bfc..85da05cfe 100644 --- a/otherarch/sdcpp/rng_mt19937.hpp +++ b/otherarch/sdcpp/src/core/rng_mt19937.hpp @@ -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 #include -#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__ \ No newline at end of file +#endif // __SD_CORE_RNG_MT19937_HPP__ \ No newline at end of file diff --git a/otherarch/sdcpp/rng_philox.hpp b/otherarch/sdcpp/src/core/rng_philox.hpp similarity index 97% rename from otherarch/sdcpp/rng_philox.hpp rename to otherarch/sdcpp/src/core/rng_philox.hpp index 58da07034..8258ed950 100644 --- a/otherarch/sdcpp/rng_philox.hpp +++ b/otherarch/sdcpp/src/core/rng_philox.hpp @@ -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 #include -#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__ \ No newline at end of file +#endif // __SD_CORE_RNG_PHILOX_HPP__ \ No newline at end of file diff --git a/otherarch/sdcpp/tensor.hpp b/otherarch/sdcpp/src/core/tensor.hpp similarity index 99% rename from otherarch/sdcpp/tensor.hpp rename to otherarch/sdcpp/src/core/tensor.hpp index 9d054353a..ba5dc137a 100644 --- a/otherarch/sdcpp/tensor.hpp +++ b/otherarch/sdcpp/src/core/tensor.hpp @@ -1,5 +1,5 @@ -#ifndef __SD_TENSOR_HPP__ -#define __SD_TENSOR_HPP__ +#ifndef __SD_CORE_TENSOR_HPP__ +#define __SD_CORE_TENSOR_HPP__ #include #include @@ -16,7 +16,7 @@ #include #include -#include "rng.hpp" +#include "core/rng.hpp" namespace sd { @@ -1661,4 +1661,4 @@ namespace sd { } // namespace sd -#endif +#endif // __SD_CORE_TENSOR_HPP__ diff --git a/otherarch/sdcpp/tensor_ggml.hpp b/otherarch/sdcpp/src/core/tensor_ggml.hpp similarity index 96% rename from otherarch/sdcpp/tensor_ggml.hpp rename to otherarch/sdcpp/src/core/tensor_ggml.hpp index c6e9d4ac9..774574f79 100644 --- a/otherarch/sdcpp/tensor_ggml.hpp +++ b/otherarch/sdcpp/src/core/tensor_ggml.hpp @@ -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 #include @@ -8,8 +8,8 @@ #include #include +#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__ diff --git a/otherarch/sdcpp/util.cpp b/otherarch/sdcpp/src/core/util.cpp similarity index 99% rename from otherarch/sdcpp/util.cpp rename to otherarch/sdcpp/src/core/util.cpp index 20fb5bd6a..950254431 100644 --- a/otherarch/sdcpp/util.cpp +++ b/otherarch/sdcpp/src/core/util.cpp @@ -1,4 +1,4 @@ -#include "util.h" +#include "core/util.h" #include #include #include @@ -14,7 +14,7 @@ #include #include #include -#include "preprocessing.hpp" +#include "runtime/preprocessing.hpp" #include #include diff --git a/otherarch/sdcpp/util.h b/otherarch/sdcpp/src/core/util.h similarity index 97% rename from otherarch/sdcpp/util.h rename to otherarch/sdcpp/src/core/util.h index 572ddc74e..a271c1f71 100644 --- a/otherarch/sdcpp/util.h +++ b/otherarch/sdcpp/src/core/util.h @@ -1,5 +1,5 @@ -#ifndef __UTIL_H__ -#define __UTIL_H__ +#ifndef __SD_CORE_UTIL_H__ +#define __SD_CORE_UTIL_H__ #include #include @@ -7,9 +7,9 @@ #include #include +#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__ diff --git a/otherarch/sdcpp/kcpp_sd_extensions.h b/otherarch/sdcpp/src/kcpp_sd_extensions.h similarity index 100% rename from otherarch/sdcpp/kcpp_sd_extensions.h rename to otherarch/sdcpp/src/kcpp_sd_extensions.h diff --git a/otherarch/sdcpp/model.cpp b/otherarch/sdcpp/src/model.cpp similarity index 99% rename from otherarch/sdcpp/model.cpp rename to otherarch/sdcpp/src/model.cpp index 7ae657d88..d73050b24 100644 --- a/otherarch/sdcpp/model.cpp +++ b/otherarch/sdcpp/src/model.cpp @@ -13,18 +13,18 @@ #include #include +#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" diff --git a/otherarch/sdcpp/model.h b/otherarch/sdcpp/src/model.h similarity index 99% rename from otherarch/sdcpp/model.h rename to otherarch/sdcpp/src/model.h index d0af38829..e35ae0575 100644 --- a/otherarch/sdcpp/model.h +++ b/otherarch/sdcpp/src/model.h @@ -8,10 +8,10 @@ #include #include +#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, diff --git a/otherarch/sdcpp/lora.hpp b/otherarch/sdcpp/src/model/adapter/lora.hpp similarity index 99% rename from otherarch/sdcpp/lora.hpp rename to otherarch/sdcpp/src/model/adapter/lora.hpp index f8861c316..8fdde0524 100644 --- a/otherarch/sdcpp/lora.hpp +++ b/otherarch/sdcpp/src/model/adapter/lora.hpp @@ -1,8 +1,8 @@ -#ifndef __LORA_HPP__ -#define __LORA_HPP__ +#ifndef __SD_MODEL_ADAPTER_LORA_HPP__ +#define __SD_MODEL_ADAPTER_LORA_HPP__ #include -#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__ diff --git a/otherarch/sdcpp/pmid.hpp b/otherarch/sdcpp/src/model/adapter/pmid.hpp similarity index 99% rename from otherarch/sdcpp/pmid.hpp rename to otherarch/sdcpp/src/model/adapter/pmid.hpp index 6e3d5e611..410ca726a 100644 --- a/otherarch/sdcpp/pmid.hpp +++ b/otherarch/sdcpp/src/model/adapter/pmid.hpp @@ -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__ diff --git a/otherarch/sdcpp/common_block.hpp b/otherarch/sdcpp/src/model/common/block.hpp similarity index 95% rename from otherarch/sdcpp/common_block.hpp rename to otherarch/sdcpp/src/model/common/block.hpp index e6c0b06bd..69db0a906 100644 --- a/otherarch/sdcpp/common_block.hpp +++ b/otherarch/sdcpp/src/model/common/block.hpp @@ -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(new Linear(in_features, hidden_features, bias)); + blocks["fc2"] = std::shared_ptr(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(blocks["fc1"]); + auto fc2 = std::dynamic_pointer_cast(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__ diff --git a/otherarch/sdcpp/rope.hpp b/otherarch/sdcpp/src/model/common/rope.hpp similarity index 99% rename from otherarch/sdcpp/rope.hpp rename to otherarch/sdcpp/src/model/common/rope.hpp index fb3e4ac55..3ab2551d0 100644 --- a/otherarch/sdcpp/rope.hpp +++ b/otherarch/sdcpp/src/model/common/rope.hpp @@ -1,10 +1,10 @@ -#ifndef __ROPE_HPP__ -#define __ROPE_HPP__ +#ifndef __SD_MODEL_COMMON_ROPE_HPP__ +#define __SD_MODEL_COMMON_ROPE_HPP__ #include #include #include -#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__ diff --git a/otherarch/sdcpp/anima.hpp b/otherarch/sdcpp/src/model/diffusion/anima.hpp similarity index 99% rename from otherarch/sdcpp/anima.hpp rename to otherarch/sdcpp/src/model/diffusion/anima.hpp index 71f187641..49c2e45ae 100644 --- a/otherarch/sdcpp/anima.hpp +++ b/otherarch/sdcpp/src/model/diffusion/anima.hpp @@ -1,5 +1,5 @@ -#ifndef __ANIMA_HPP__ -#define __ANIMA_HPP__ +#ifndef __SD_MODEL_DIFFUSION_ANIMA_HPP__ +#define __SD_MODEL_DIFFUSION_ANIMA_HPP__ #include #include @@ -7,10 +7,10 @@ #include #include -#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__ diff --git a/otherarch/sdcpp/control.hpp b/otherarch/sdcpp/src/model/diffusion/control.hpp similarity index 99% rename from otherarch/sdcpp/control.hpp rename to otherarch/sdcpp/src/model/diffusion/control.hpp index a38f5d14c..c442fb925 100644 --- a/otherarch/sdcpp/control.hpp +++ b/otherarch/sdcpp/src/model/diffusion/control.hpp @@ -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__ diff --git a/otherarch/sdcpp/common_dit.hpp b/otherarch/sdcpp/src/model/diffusion/dit.hpp similarity index 98% rename from otherarch/sdcpp/common_dit.hpp rename to otherarch/sdcpp/src/model/diffusion/dit.hpp index c25302ff6..c18518564 100644 --- a/otherarch/sdcpp/common_dit.hpp +++ b/otherarch/sdcpp/src/model/diffusion/dit.hpp @@ -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__ diff --git a/otherarch/sdcpp/ernie_image.hpp b/otherarch/sdcpp/src/model/diffusion/ernie_image.hpp similarity index 98% rename from otherarch/sdcpp/ernie_image.hpp rename to otherarch/sdcpp/src/model/diffusion/ernie_image.hpp index 0a0f2c950..09bcba3b1 100644 --- a/otherarch/sdcpp/ernie_image.hpp +++ b/otherarch/sdcpp/src/model/diffusion/ernie_image.hpp @@ -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 #include -#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__ diff --git a/otherarch/sdcpp/flux.hpp b/otherarch/sdcpp/src/model/diffusion/flux.hpp similarity index 99% rename from otherarch/sdcpp/flux.hpp rename to otherarch/sdcpp/src/model/diffusion/flux.hpp index 4027f8fe0..a337f99c5 100644 --- a/otherarch/sdcpp/flux.hpp +++ b/otherarch/sdcpp/src/model/diffusion/flux.hpp @@ -1,13 +1,13 @@ -#ifndef __FLUX_HPP__ -#define __FLUX_HPP__ +#ifndef __SD_MODEL_DIFFUSION_FLUX_HPP__ +#define __SD_MODEL_DIFFUSION_FLUX_HPP__ #include #include -#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__ diff --git a/otherarch/sdcpp/hidream_o1.hpp b/otherarch/sdcpp/src/model/diffusion/hidream_o1.hpp similarity index 99% rename from otherarch/sdcpp/hidream_o1.hpp rename to otherarch/sdcpp/src/model/diffusion/hidream_o1.hpp index bf64d2f4f..3d384def2 100644 --- a/otherarch/sdcpp/hidream_o1.hpp +++ b/otherarch/sdcpp/src/model/diffusion/hidream_o1.hpp @@ -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 #include @@ -10,11 +10,11 @@ #include #include -#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__ diff --git a/otherarch/sdcpp/ideogram4.hpp b/otherarch/sdcpp/src/model/diffusion/ideogram4.hpp similarity index 98% rename from otherarch/sdcpp/ideogram4.hpp rename to otherarch/sdcpp/src/model/diffusion/ideogram4.hpp index 46193adca..5149ff72d 100644 --- a/otherarch/sdcpp/ideogram4.hpp +++ b/otherarch/sdcpp/src/model/diffusion/ideogram4.hpp @@ -1,5 +1,5 @@ -#ifndef __IDEOGRAM4_HPP__ -#define __IDEOGRAM4_HPP__ +#ifndef __SD_MODEL_DIFFUSION_IDEOGRAM4_HPP__ +#define __SD_MODEL_DIFFUSION_IDEOGRAM4_HPP__ #include #include @@ -8,10 +8,10 @@ #include #include -#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__ diff --git a/otherarch/sdcpp/lens.hpp b/otherarch/sdcpp/src/model/diffusion/lens.hpp similarity index 98% rename from otherarch/sdcpp/lens.hpp rename to otherarch/sdcpp/src/model/diffusion/lens.hpp index 072c9e08d..740ff8249 100644 --- a/otherarch/sdcpp/lens.hpp +++ b/otherarch/sdcpp/src/model/diffusion/lens.hpp @@ -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 #include -#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__ diff --git a/otherarch/sdcpp/ltxv.hpp b/otherarch/sdcpp/src/model/diffusion/ltxv.hpp similarity index 99% rename from otherarch/sdcpp/ltxv.hpp rename to otherarch/sdcpp/src/model/diffusion/ltxv.hpp index a430d75c1..947a2de3d 100644 --- a/otherarch/sdcpp/ltxv.hpp +++ b/otherarch/sdcpp/src/model/diffusion/ltxv.hpp @@ -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 #include @@ -9,10 +9,10 @@ #include #include -#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__ diff --git a/otherarch/sdcpp/mmdit.hpp b/otherarch/sdcpp/src/model/diffusion/mmdit.hpp similarity index 97% rename from otherarch/sdcpp/mmdit.hpp rename to otherarch/sdcpp/src/model/diffusion/mmdit.hpp index 326bd0797..3c234054e 100644 --- a/otherarch/sdcpp/mmdit.hpp +++ b/otherarch/sdcpp/src/model/diffusion/mmdit.hpp @@ -1,14 +1,15 @@ -#ifndef __MMDIT_HPP__ -#define __MMDIT_HPP__ +#ifndef __SD_MODEL_DIFFUSION_MMDIT_HPP__ +#define __SD_MODEL_DIFFUSION_MMDIT_HPP__ #include #include #include #include -#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(new Linear(in_features, hidden_features, bias)); - blocks["fc2"] = std::shared_ptr(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(blocks["fc1"]); - auto fc2 = std::dynamic_pointer_cast(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__ diff --git a/otherarch/sdcpp/diffusion_model.hpp b/otherarch/sdcpp/src/model/diffusion/model.hpp similarity index 95% rename from otherarch/sdcpp/diffusion_model.hpp rename to otherarch/sdcpp/src/model/diffusion/model.hpp index 80c115449..b386711b7 100644 --- a/otherarch/sdcpp/diffusion_model.hpp +++ b/otherarch/sdcpp/src/model/diffusion/model.hpp @@ -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 #include #include -#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__ diff --git a/otherarch/sdcpp/pid.hpp b/otherarch/sdcpp/src/model/diffusion/pid.hpp similarity index 99% rename from otherarch/sdcpp/pid.hpp rename to otherarch/sdcpp/src/model/diffusion/pid.hpp index 39ab004dc..ac5851516 100644 --- a/otherarch/sdcpp/pid.hpp +++ b/otherarch/sdcpp/src/model/diffusion/pid.hpp @@ -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 #include @@ -7,10 +7,10 @@ #include #include -#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__ diff --git a/otherarch/sdcpp/qwen_image.hpp b/otherarch/sdcpp/src/model/diffusion/qwen_image.hpp similarity index 99% rename from otherarch/sdcpp/qwen_image.hpp rename to otherarch/sdcpp/src/model/diffusion/qwen_image.hpp index de52c880b..e481ca595 100644 --- a/otherarch/sdcpp/qwen_image.hpp +++ b/otherarch/sdcpp/src/model/diffusion/qwen_image.hpp @@ -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 -#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__ diff --git a/otherarch/sdcpp/unet.hpp b/otherarch/sdcpp/src/model/diffusion/unet.hpp similarity index 99% rename from otherarch/sdcpp/unet.hpp rename to otherarch/sdcpp/src/model/diffusion/unet.hpp index 4cecb87c7..f1a96f9d3 100644 --- a/otherarch/sdcpp/unet.hpp +++ b/otherarch/sdcpp/src/model/diffusion/unet.hpp @@ -1,12 +1,12 @@ -#ifndef __UNET_HPP__ -#define __UNET_HPP__ +#ifndef __SD_MODEL_DIFFUSION_UNET_HPP__ +#define __SD_MODEL_DIFFUSION_UNET_HPP__ #include #include -#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__ diff --git a/otherarch/sdcpp/wan.hpp b/otherarch/sdcpp/src/model/diffusion/wan.hpp similarity index 99% rename from otherarch/sdcpp/wan.hpp rename to otherarch/sdcpp/src/model/diffusion/wan.hpp index 57917c189..f3410956d 100644 --- a/otherarch/sdcpp/wan.hpp +++ b/otherarch/sdcpp/src/model/diffusion/wan.hpp @@ -1,14 +1,14 @@ -#ifndef __WAN_HPP__ -#define __WAN_HPP__ +#ifndef __SD_MODEL_DIFFUSION_WAN_HPP__ +#define __SD_MODEL_DIFFUSION_WAN_HPP__ #include #include #include -#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__ diff --git a/otherarch/sdcpp/z_image.hpp b/otherarch/sdcpp/src/model/diffusion/z_image.hpp similarity index 99% rename from otherarch/sdcpp/z_image.hpp rename to otherarch/sdcpp/src/model/diffusion/z_image.hpp index be884c752..9eeec07f0 100644 --- a/otherarch/sdcpp/z_image.hpp +++ b/otherarch/sdcpp/src/model/diffusion/z_image.hpp @@ -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 -#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__ diff --git a/otherarch/sdcpp/clip.hpp b/otherarch/sdcpp/src/model/te/clip.hpp similarity index 99% rename from otherarch/sdcpp/clip.hpp rename to otherarch/sdcpp/src/model/te/clip.hpp index a3567324c..7b7c883e0 100644 --- a/otherarch/sdcpp/clip.hpp +++ b/otherarch/sdcpp/src/model/te/clip.hpp @@ -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__ diff --git a/otherarch/sdcpp/llm.hpp b/otherarch/sdcpp/src/model/te/llm.hpp similarity index 99% rename from otherarch/sdcpp/llm.hpp rename to otherarch/sdcpp/src/model/te/llm.hpp index 927c7c8b5..9e9bfe19c 100644 --- a/otherarch/sdcpp/llm.hpp +++ b/otherarch/sdcpp/src/model/te/llm.hpp @@ -1,5 +1,5 @@ -#ifndef __LLM_HPP__ -#define __LLM_HPP__ +#ifndef __SD_MODEL_TE_LLM_HPP__ +#define __SD_MODEL_TE_LLM_HPP__ #include #include @@ -18,9 +18,9 @@ #include #include -#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__ diff --git a/otherarch/sdcpp/t5.hpp b/otherarch/sdcpp/src/model/te/t5.hpp similarity index 97% rename from otherarch/sdcpp/t5.hpp rename to otherarch/sdcpp/src/model/te/t5.hpp index c6fa5375b..335969bbf 100644 --- a/otherarch/sdcpp/t5.hpp +++ b/otherarch/sdcpp/src/model/te/t5.hpp @@ -1,5 +1,5 @@ -#ifndef __T5_HPP__ -#define __T5_HPP__ +#ifndef __SD_MODEL_TE_T5_HPP__ +#define __SD_MODEL_TE_T5_HPP__ #include #include @@ -10,7 +10,7 @@ #include #include -#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__ diff --git a/otherarch/sdcpp/esrgan.hpp b/otherarch/sdcpp/src/model/upscaler/esrgan.hpp similarity index 99% rename from otherarch/sdcpp/esrgan.hpp rename to otherarch/sdcpp/src/model/upscaler/esrgan.hpp index a651007de..9d9d04168 100644 --- a/otherarch/sdcpp/esrgan.hpp +++ b/otherarch/sdcpp/src/model/upscaler/esrgan.hpp @@ -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__ diff --git a/otherarch/sdcpp/ltx_latent_upscaler.hpp b/otherarch/sdcpp/src/model/upscaler/ltx_latent_upscaler.hpp similarity index 98% rename from otherarch/sdcpp/ltx_latent_upscaler.hpp rename to otherarch/sdcpp/src/model/upscaler/ltx_latent_upscaler.hpp index ea4a830c6..b608d6cd0 100644 --- a/otherarch/sdcpp/ltx_latent_upscaler.hpp +++ b/otherarch/sdcpp/src/model/upscaler/ltx_latent_upscaler.hpp @@ -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 #include @@ -11,11 +11,11 @@ #include #include -#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__ diff --git a/otherarch/sdcpp/auto_encoder_kl.hpp b/otherarch/sdcpp/src/model/vae/auto_encoder_kl.hpp similarity index 99% rename from otherarch/sdcpp/auto_encoder_kl.hpp rename to otherarch/sdcpp/src/model/vae/auto_encoder_kl.hpp index 13396e737..49472ff47 100644 --- a/otherarch/sdcpp/auto_encoder_kl.hpp +++ b/otherarch/sdcpp/src/model/vae/auto_encoder_kl.hpp @@ -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__ diff --git a/otherarch/sdcpp/ltx_audio_vae.h b/otherarch/sdcpp/src/model/vae/ltx_audio_vae.hpp similarity index 99% rename from otherarch/sdcpp/ltx_audio_vae.h rename to otherarch/sdcpp/src/model/vae/ltx_audio_vae.hpp index 51fb19898..662c41222 100644 --- a/otherarch/sdcpp/ltx_audio_vae.h +++ b/otherarch/sdcpp/src/model/vae/ltx_audio_vae.hpp @@ -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 #include @@ -7,7 +7,7 @@ #include #include -#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__ diff --git a/otherarch/sdcpp/ltx_vae.hpp b/otherarch/sdcpp/src/model/vae/ltx_vae.hpp similarity index 99% rename from otherarch/sdcpp/ltx_vae.hpp rename to otherarch/sdcpp/src/model/vae/ltx_vae.hpp index f1865e4f7..17d1f9b2a 100644 --- a/otherarch/sdcpp/ltx_vae.hpp +++ b/otherarch/sdcpp/src/model/vae/ltx_vae.hpp @@ -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 #include @@ -9,9 +9,9 @@ #include #include -#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__ diff --git a/otherarch/sdcpp/tae.hpp b/otherarch/sdcpp/src/model/vae/tae.hpp similarity index 99% rename from otherarch/sdcpp/tae.hpp rename to otherarch/sdcpp/src/model/vae/tae.hpp index f43ef48fb..fcb62c2ea 100644 --- a/otherarch/sdcpp/tae.hpp +++ b/otherarch/sdcpp/src/model/vae/tae.hpp @@ -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__ diff --git a/otherarch/sdcpp/vae.hpp b/otherarch/sdcpp/src/model/vae/vae.hpp similarity index 98% rename from otherarch/sdcpp/vae.hpp rename to otherarch/sdcpp/src/model/vae/vae.hpp index cc4cd967f..bd0ce6c4e 100644 --- a/otherarch/sdcpp/vae.hpp +++ b/otherarch/sdcpp/src/model/vae/vae.hpp @@ -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__ diff --git a/otherarch/sdcpp/wan_vae.hpp b/otherarch/sdcpp/src/model/vae/wan_vae.hpp similarity index 99% rename from otherarch/sdcpp/wan_vae.hpp rename to otherarch/sdcpp/src/model/vae/wan_vae.hpp index 7c2039ad7..4bc21a849 100644 --- a/otherarch/sdcpp/wan_vae.hpp +++ b/otherarch/sdcpp/src/model/vae/wan_vae.hpp @@ -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 #include #include -#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__ diff --git a/otherarch/sdcpp/model_io/binary_io.h b/otherarch/sdcpp/src/model_io/binary_io.h similarity index 100% rename from otherarch/sdcpp/model_io/binary_io.h rename to otherarch/sdcpp/src/model_io/binary_io.h diff --git a/otherarch/sdcpp/model_io/gguf_io.cpp b/otherarch/sdcpp/src/model_io/gguf_io.cpp similarity index 99% rename from otherarch/sdcpp/model_io/gguf_io.cpp rename to otherarch/sdcpp/src/model_io/gguf_io.cpp index 378694d8e..c701d01f3 100644 --- a/otherarch/sdcpp/model_io/gguf_io.cpp +++ b/otherarch/sdcpp/src/model_io/gguf_io.cpp @@ -5,9 +5,9 @@ #include #include +#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) { diff --git a/otherarch/sdcpp/model_io/gguf_io.h b/otherarch/sdcpp/src/model_io/gguf_io.h similarity index 100% rename from otherarch/sdcpp/model_io/gguf_io.h rename to otherarch/sdcpp/src/model_io/gguf_io.h diff --git a/otherarch/sdcpp/model_io/gguf_reader_ext.h b/otherarch/sdcpp/src/model_io/gguf_reader_ext.h similarity index 99% rename from otherarch/sdcpp/model_io/gguf_reader_ext.h rename to otherarch/sdcpp/src/model_io/gguf_reader_ext.h index 60cde37cc..d4da419db 100644 --- a/otherarch/sdcpp/model_io/gguf_reader_ext.h +++ b/otherarch/sdcpp/src/model_io/gguf_reader_ext.h @@ -6,8 +6,8 @@ #include #include +#include "core/util.h" #include "ggml.h" -#include "util.h" struct GGUFTensorInfo { std::string name; diff --git a/otherarch/sdcpp/model_io/pickle_io.cpp b/otherarch/sdcpp/src/model_io/pickle_io.cpp similarity index 99% rename from otherarch/sdcpp/model_io/pickle_io.cpp rename to otherarch/sdcpp/src/model_io/pickle_io.cpp index 3a978178a..1ea7a902c 100644 --- a/otherarch/sdcpp/model_io/pickle_io.cpp +++ b/otherarch/sdcpp/src/model_io/pickle_io.cpp @@ -8,7 +8,7 @@ #include #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 diff --git a/otherarch/sdcpp/model_io/pickle_io.h b/otherarch/sdcpp/src/model_io/pickle_io.h similarity index 100% rename from otherarch/sdcpp/model_io/pickle_io.h rename to otherarch/sdcpp/src/model_io/pickle_io.h diff --git a/otherarch/sdcpp/model_io/safetensors_io.cpp b/otherarch/sdcpp/src/model_io/safetensors_io.cpp similarity index 99% rename from otherarch/sdcpp/model_io/safetensors_io.cpp rename to otherarch/sdcpp/src/model_io/safetensors_io.cpp index 889352218..39131dbd8 100644 --- a/otherarch/sdcpp/model_io/safetensors_io.cpp +++ b/otherarch/sdcpp/src/model_io/safetensors_io.cpp @@ -7,8 +7,8 @@ #include #include "binary_io.h" +#include "core/util.h" #include "json.hpp" -#include "util.h" static constexpr size_t ST_HEADER_SIZE_LEN = 8; diff --git a/otherarch/sdcpp/model_io/safetensors_io.h b/otherarch/sdcpp/src/model_io/safetensors_io.h similarity index 100% rename from otherarch/sdcpp/model_io/safetensors_io.h rename to otherarch/sdcpp/src/model_io/safetensors_io.h diff --git a/otherarch/sdcpp/model_io/tensor_storage.h b/otherarch/sdcpp/src/model_io/tensor_storage.h similarity index 100% rename from otherarch/sdcpp/model_io/tensor_storage.h rename to otherarch/sdcpp/src/model_io/tensor_storage.h diff --git a/otherarch/sdcpp/model_io/torch_legacy_io.cpp b/otherarch/sdcpp/src/model_io/torch_legacy_io.cpp similarity index 99% rename from otherarch/sdcpp/model_io/torch_legacy_io.cpp rename to otherarch/sdcpp/src/model_io/torch_legacy_io.cpp index 816547252..0b0c78f8f 100644 --- a/otherarch/sdcpp/model_io/torch_legacy_io.cpp +++ b/otherarch/sdcpp/src/model_io/torch_legacy_io.cpp @@ -7,8 +7,8 @@ #include #include +#include "core/util.h" #include "pickle_io.h" -#include "util.h" // torch.save format background: // diff --git a/otherarch/sdcpp/model_io/torch_legacy_io.h b/otherarch/sdcpp/src/model_io/torch_legacy_io.h similarity index 100% rename from otherarch/sdcpp/model_io/torch_legacy_io.h rename to otherarch/sdcpp/src/model_io/torch_legacy_io.h diff --git a/otherarch/sdcpp/model_io/torch_zip_io.cpp b/otherarch/sdcpp/src/model_io/torch_zip_io.cpp similarity index 100% rename from otherarch/sdcpp/model_io/torch_zip_io.cpp rename to otherarch/sdcpp/src/model_io/torch_zip_io.cpp diff --git a/otherarch/sdcpp/model_io/torch_zip_io.h b/otherarch/sdcpp/src/model_io/torch_zip_io.h similarity index 100% rename from otherarch/sdcpp/model_io/torch_zip_io.h rename to otherarch/sdcpp/src/model_io/torch_zip_io.h diff --git a/otherarch/sdcpp/name_conversion.cpp b/otherarch/sdcpp/src/name_conversion.cpp similarity index 99% rename from otherarch/sdcpp/name_conversion.cpp rename to otherarch/sdcpp/src/name_conversion.cpp index a9cae0a87..55628b0f9 100644 --- a/otherarch/sdcpp/name_conversion.cpp +++ b/otherarch/sdcpp/src/name_conversion.cpp @@ -1,8 +1,8 @@ #include #include +#include "core/util.h" #include "name_conversion.h" -#include "util.h" void replace_with_name_map(std::string& name, const std::vector>& name_map) { for (auto kv : name_map) { diff --git a/otherarch/sdcpp/name_conversion.h b/otherarch/sdcpp/src/name_conversion.h similarity index 100% rename from otherarch/sdcpp/name_conversion.h rename to otherarch/sdcpp/src/name_conversion.h diff --git a/otherarch/sdcpp/cache_dit.hpp b/otherarch/sdcpp/src/runtime/cache_dit.hpp similarity index 99% rename from otherarch/sdcpp/cache_dit.hpp rename to otherarch/sdcpp/src/runtime/cache_dit.hpp index dad67d458..bec6e8115 100644 --- a/otherarch/sdcpp/cache_dit.hpp +++ b/otherarch/sdcpp/src/runtime/cache_dit.hpp @@ -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 #include @@ -8,9 +8,9 @@ #include #include -#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__ diff --git a/otherarch/sdcpp/condition_cache_utils.hpp b/otherarch/sdcpp/src/runtime/condition_cache_utils.hpp similarity index 91% rename from otherarch/sdcpp/condition_cache_utils.hpp rename to otherarch/sdcpp/src/runtime/condition_cache_utils.hpp index 903d64e3f..8003df124 100644 --- a/otherarch/sdcpp/condition_cache_utils.hpp +++ b/otherarch/sdcpp/src/runtime/condition_cache_utils.hpp @@ -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 -#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__ diff --git a/otherarch/sdcpp/denoiser.hpp b/otherarch/sdcpp/src/runtime/denoiser.hpp similarity index 99% rename from otherarch/sdcpp/denoiser.hpp rename to otherarch/sdcpp/src/runtime/denoiser.hpp index 365b1dbd5..7c98a1ff1 100644 --- a/otherarch/sdcpp/denoiser.hpp +++ b/otherarch/sdcpp/src/runtime/denoiser.hpp @@ -1,5 +1,5 @@ -#ifndef __DENOISER_HPP__ -#define __DENOISER_HPP__ +#ifndef __SD_RUNTIME_DENOISER_HPP__ +#define __SD_RUNTIME_DENOISER_HPP__ #include #include @@ -8,10 +8,10 @@ #include #include -#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 sample_k_diffusion(sample_method_t method, } } -#endif // __DENOISER_HPP__ +#endif // __SD_RUNTIME_DENOISER_HPP__ diff --git a/otherarch/sdcpp/easycache.hpp b/otherarch/sdcpp/src/runtime/easycache.hpp similarity index 97% rename from otherarch/sdcpp/easycache.hpp rename to otherarch/sdcpp/src/runtime/easycache.hpp index 409a464e5..75ae3ddad 100644 --- a/otherarch/sdcpp/easycache.hpp +++ b/otherarch/sdcpp/src/runtime/easycache.hpp @@ -1,15 +1,15 @@ -#ifndef __EASYCACHE_HPP__ -#define __EASYCACHE_HPP__ +#ifndef __SD_RUNTIME_EASYCACHE_HPP__ +#define __SD_RUNTIME_EASYCACHE_HPP__ #include #include #include #include -#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__ diff --git a/otherarch/sdcpp/gits_noise.inl b/otherarch/sdcpp/src/runtime/gits_noise.inl similarity index 100% rename from otherarch/sdcpp/gits_noise.inl rename to otherarch/sdcpp/src/runtime/gits_noise.inl diff --git a/otherarch/sdcpp/guidance.cpp b/otherarch/sdcpp/src/runtime/guidance.cpp similarity index 99% rename from otherarch/sdcpp/guidance.cpp rename to otherarch/sdcpp/src/runtime/guidance.cpp index 2cb305a59..f945c3cda 100644 --- a/otherarch/sdcpp/guidance.cpp +++ b/otherarch/sdcpp/src/runtime/guidance.cpp @@ -1,4 +1,4 @@ -#include "guidance.h" +#include "runtime/guidance.h" #include #include @@ -6,7 +6,7 @@ #include #include -#include "util.h" +#include "core/util.h" namespace sd::guidance { diff --git a/otherarch/sdcpp/guidance.h b/otherarch/sdcpp/src/runtime/guidance.h similarity index 95% rename from otherarch/sdcpp/guidance.h rename to otherarch/sdcpp/src/runtime/guidance.h index 26b79de9c..aeba06fd0 100644 --- a/otherarch/sdcpp/guidance.h +++ b/otherarch/sdcpp/src/runtime/guidance.h @@ -1,11 +1,11 @@ -#ifndef __SD_GUIDANCE_H__ -#define __SD_GUIDANCE_H__ +#ifndef __SD_RUNTIME_GUIDANCE_H__ +#define __SD_RUNTIME_GUIDANCE_H__ #include #include #include -#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__ diff --git a/otherarch/sdcpp/latent-preview.h b/otherarch/sdcpp/src/runtime/latent-preview.h similarity index 99% rename from otherarch/sdcpp/latent-preview.h rename to otherarch/sdcpp/src/runtime/latent-preview.h index 7b90b3703..152399081 100644 --- a/otherarch/sdcpp/latent-preview.h +++ b/otherarch/sdcpp/src/runtime/latent-preview.h @@ -1,8 +1,8 @@ #include #include #include +#include "core/tensor.hpp" #include "ggml.h" -#include "tensor.hpp" const float ltxav_latent_rgb_proj[128][3] = { {-0.0293802f, -0.0362516f, -0.0291386f}, diff --git a/otherarch/sdcpp/preprocessing.hpp b/otherarch/sdcpp/src/runtime/preprocessing.hpp similarity index 98% rename from otherarch/sdcpp/preprocessing.hpp rename to otherarch/sdcpp/src/runtime/preprocessing.hpp index 57ab0cec7..b39a9a9d0 100644 --- a/otherarch/sdcpp/preprocessing.hpp +++ b/otherarch/sdcpp/src/runtime/preprocessing.hpp @@ -1,10 +1,10 @@ -#ifndef __PREPROCESSING_HPP__ -#define __PREPROCESSING_HPP__ +#ifndef __SD_RUNTIME_PREPROCESSING_HPP__ +#define __SD_RUNTIME_PREPROCESSING_HPP__ #include #include -#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__ diff --git a/otherarch/sdcpp/sample-cache.cpp b/otherarch/sdcpp/src/runtime/sample-cache.cpp similarity index 99% rename from otherarch/sdcpp/sample-cache.cpp rename to otherarch/sdcpp/src/runtime/sample-cache.cpp index 5739178de..bfa3d4487 100644 --- a/otherarch/sdcpp/sample-cache.cpp +++ b/otherarch/sdcpp/src/runtime/sample-cache.cpp @@ -1,4 +1,4 @@ -#include "sample-cache.h" +#include "runtime/sample-cache.h" namespace sd_sample { diff --git a/otherarch/sdcpp/sample-cache.h b/otherarch/sdcpp/src/runtime/sample-cache.h similarity index 82% rename from otherarch/sdcpp/sample-cache.h rename to otherarch/sdcpp/src/runtime/sample-cache.h index 398ad0657..cb0fe7bc5 100644 --- a/otherarch/sdcpp/sample-cache.h +++ b/otherarch/sdcpp/src/runtime/sample-cache.h @@ -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 -#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__ diff --git a/otherarch/sdcpp/spectrum.hpp b/otherarch/sdcpp/src/runtime/spectrum.hpp similarity index 97% rename from otherarch/sdcpp/spectrum.hpp rename to otherarch/sdcpp/src/runtime/spectrum.hpp index add1796ff..7246d6f09 100644 --- a/otherarch/sdcpp/spectrum.hpp +++ b/otherarch/sdcpp/src/runtime/spectrum.hpp @@ -1,12 +1,12 @@ -#ifndef __SPECTRUM_HPP__ -#define __SPECTRUM_HPP__ +#ifndef __SD_RUNTIME_SPECTRUM_HPP__ +#define __SD_RUNTIME_SPECTRUM_HPP__ #include #include #include -#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__ diff --git a/otherarch/sdcpp/ucache.hpp b/otherarch/sdcpp/src/runtime/ucache.hpp similarity index 98% rename from otherarch/sdcpp/ucache.hpp rename to otherarch/sdcpp/src/runtime/ucache.hpp index 3d785c5e3..187e1e789 100644 --- a/otherarch/sdcpp/ucache.hpp +++ b/otherarch/sdcpp/src/runtime/ucache.hpp @@ -1,15 +1,15 @@ -#ifndef __UCACHE_HPP__ -#define __UCACHE_HPP__ +#ifndef __SD_RUNTIME_UCACHE_HPP__ +#define __SD_RUNTIME_UCACHE_HPP__ #include #include #include #include -#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__ diff --git a/otherarch/sdcpp/stable-diffusion.cpp b/otherarch/sdcpp/src/stable-diffusion.cpp similarity index 99% rename from otherarch/sdcpp/stable-diffusion.cpp rename to otherarch/sdcpp/src/stable-diffusion.cpp index 7c50ba070..f47a800ed 100644 --- a/otherarch/sdcpp/stable-diffusion.cpp +++ b/otherarch/sdcpp/src/stable-diffusion.cpp @@ -3,49 +3,49 @@ #include #include -#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); diff --git a/otherarch/sdcpp/tokenizers/bpe_tokenizer.cpp b/otherarch/sdcpp/src/tokenizers/bpe_tokenizer.cpp similarity index 99% rename from otherarch/sdcpp/tokenizers/bpe_tokenizer.cpp rename to otherarch/sdcpp/src/tokenizers/bpe_tokenizer.cpp index ed4e18781..896975a21 100644 --- a/otherarch/sdcpp/tokenizers/bpe_tokenizer.cpp +++ b/otherarch/sdcpp/src/tokenizers/bpe_tokenizer.cpp @@ -3,8 +3,8 @@ #include #include +#include "core/util.h" #include "tokenize_util.h" -#include "util.h" std::vector> BPETokenizer::bytes_to_unicode() { std::vector> byte_unicode_pairs; diff --git a/otherarch/sdcpp/tokenizers/bpe_tokenizer.h b/otherarch/sdcpp/src/tokenizers/bpe_tokenizer.h similarity index 100% rename from otherarch/sdcpp/tokenizers/bpe_tokenizer.h rename to otherarch/sdcpp/src/tokenizers/bpe_tokenizer.h diff --git a/otherarch/sdcpp/tokenizers/clip_tokenizer.cpp b/otherarch/sdcpp/src/tokenizers/clip_tokenizer.cpp similarity index 99% rename from otherarch/sdcpp/tokenizers/clip_tokenizer.cpp rename to otherarch/sdcpp/src/tokenizers/clip_tokenizer.cpp index 70d637724..d11c18c31 100644 --- a/otherarch/sdcpp/tokenizers/clip_tokenizer.cpp +++ b/otherarch/sdcpp/src/tokenizers/clip_tokenizer.cpp @@ -6,9 +6,9 @@ #include #include +#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) { diff --git a/otherarch/sdcpp/tokenizers/clip_tokenizer.h b/otherarch/sdcpp/src/tokenizers/clip_tokenizer.h similarity index 100% rename from otherarch/sdcpp/tokenizers/clip_tokenizer.h rename to otherarch/sdcpp/src/tokenizers/clip_tokenizer.h diff --git a/otherarch/sdcpp/tokenizers/gemma_tokenizer.cpp b/otherarch/sdcpp/src/tokenizers/gemma_tokenizer.cpp similarity index 99% rename from otherarch/sdcpp/tokenizers/gemma_tokenizer.cpp rename to otherarch/sdcpp/src/tokenizers/gemma_tokenizer.cpp index acac8ccd8..a7b67ef14 100644 --- a/otherarch/sdcpp/tokenizers/gemma_tokenizer.cpp +++ b/otherarch/sdcpp/src/tokenizers/gemma_tokenizer.cpp @@ -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 { diff --git a/otherarch/sdcpp/tokenizers/gemma_tokenizer.h b/otherarch/sdcpp/src/tokenizers/gemma_tokenizer.h similarity index 100% rename from otherarch/sdcpp/tokenizers/gemma_tokenizer.h rename to otherarch/sdcpp/src/tokenizers/gemma_tokenizer.h diff --git a/otherarch/sdcpp/tokenizers/gpt_oss_tokenizer.cpp b/otherarch/sdcpp/src/tokenizers/gpt_oss_tokenizer.cpp similarity index 99% rename from otherarch/sdcpp/tokenizers/gpt_oss_tokenizer.cpp rename to otherarch/sdcpp/src/tokenizers/gpt_oss_tokenizer.cpp index 8ec109a6b..9779734ce 100644 --- a/otherarch/sdcpp/tokenizers/gpt_oss_tokenizer.cpp +++ b/otherarch/sdcpp/src/tokenizers/gpt_oss_tokenizer.cpp @@ -1,7 +1,7 @@ #include "gpt_oss_tokenizer.h" +#include "core/util.h" #include "json.hpp" -#include "util.h" #include "vocab/vocab.h" void GPTOSSTokenizer::load_from_merges(const std::string& merges_utf8_str, const std::string& vocab_utf8_str) { diff --git a/otherarch/sdcpp/tokenizers/gpt_oss_tokenizer.h b/otherarch/sdcpp/src/tokenizers/gpt_oss_tokenizer.h similarity index 100% rename from otherarch/sdcpp/tokenizers/gpt_oss_tokenizer.h rename to otherarch/sdcpp/src/tokenizers/gpt_oss_tokenizer.h diff --git a/otherarch/sdcpp/tokenizers/mistral_tokenizer.cpp b/otherarch/sdcpp/src/tokenizers/mistral_tokenizer.cpp similarity index 99% rename from otherarch/sdcpp/tokenizers/mistral_tokenizer.cpp rename to otherarch/sdcpp/src/tokenizers/mistral_tokenizer.cpp index 9b0624e3a..cc418710b 100644 --- a/otherarch/sdcpp/tokenizers/mistral_tokenizer.cpp +++ b/otherarch/sdcpp/src/tokenizers/mistral_tokenizer.cpp @@ -1,8 +1,8 @@ #include "mistral_tokenizer.h" +#include "core/util.h" #include "ggml.h" #include "json.hpp" -#include "util.h" #include "vocab/vocab.h" void MistralTokenizer::load_from_merges(const std::string& merges_utf8_str, const std::string& vocab_utf8_str) { diff --git a/otherarch/sdcpp/tokenizers/mistral_tokenizer.h b/otherarch/sdcpp/src/tokenizers/mistral_tokenizer.h similarity index 100% rename from otherarch/sdcpp/tokenizers/mistral_tokenizer.h rename to otherarch/sdcpp/src/tokenizers/mistral_tokenizer.h diff --git a/otherarch/sdcpp/tokenizers/qwen2_tokenizer.cpp b/otherarch/sdcpp/src/tokenizers/qwen2_tokenizer.cpp similarity index 99% rename from otherarch/sdcpp/tokenizers/qwen2_tokenizer.cpp rename to otherarch/sdcpp/src/tokenizers/qwen2_tokenizer.cpp index 46ee31172..79e683e7b 100644 --- a/otherarch/sdcpp/tokenizers/qwen2_tokenizer.cpp +++ b/otherarch/sdcpp/src/tokenizers/qwen2_tokenizer.cpp @@ -1,6 +1,6 @@ #include "qwen2_tokenizer.h" -#include "util.h" +#include "core/util.h" #include "vocab/vocab.h" void Qwen2Tokenizer::load_from_merges(const std::string& merges_utf8_str) { diff --git a/otherarch/sdcpp/tokenizers/qwen2_tokenizer.h b/otherarch/sdcpp/src/tokenizers/qwen2_tokenizer.h similarity index 100% rename from otherarch/sdcpp/tokenizers/qwen2_tokenizer.h rename to otherarch/sdcpp/src/tokenizers/qwen2_tokenizer.h diff --git a/otherarch/sdcpp/tokenizers/t5_unigram_tokenizer.cpp b/otherarch/sdcpp/src/tokenizers/t5_unigram_tokenizer.cpp similarity index 99% rename from otherarch/sdcpp/tokenizers/t5_unigram_tokenizer.cpp rename to otherarch/sdcpp/src/tokenizers/t5_unigram_tokenizer.cpp index 8ed4df539..64e9e0712 100644 --- a/otherarch/sdcpp/tokenizers/t5_unigram_tokenizer.cpp +++ b/otherarch/sdcpp/src/tokenizers/t5_unigram_tokenizer.cpp @@ -6,9 +6,9 @@ #include #include +#include "core/util.h" #include "json.hpp" #include "tokenize_util.h" -#include "util.h" #include "vocab/vocab.h" // Port from: https://github.com/google/sentencepiece/blob/master/src/unigram_model.h diff --git a/otherarch/sdcpp/tokenizers/t5_unigram_tokenizer.h b/otherarch/sdcpp/src/tokenizers/t5_unigram_tokenizer.h similarity index 100% rename from otherarch/sdcpp/tokenizers/t5_unigram_tokenizer.h rename to otherarch/sdcpp/src/tokenizers/t5_unigram_tokenizer.h diff --git a/otherarch/sdcpp/tokenizers/tokenize_util.cpp b/otherarch/sdcpp/src/tokenizers/tokenize_util.cpp similarity index 100% rename from otherarch/sdcpp/tokenizers/tokenize_util.cpp rename to otherarch/sdcpp/src/tokenizers/tokenize_util.cpp diff --git a/otherarch/sdcpp/tokenizers/tokenize_util.h b/otherarch/sdcpp/src/tokenizers/tokenize_util.h similarity index 100% rename from otherarch/sdcpp/tokenizers/tokenize_util.h rename to otherarch/sdcpp/src/tokenizers/tokenize_util.h diff --git a/otherarch/sdcpp/tokenizers/tokenizer.cpp b/otherarch/sdcpp/src/tokenizers/tokenizer.cpp similarity index 99% rename from otherarch/sdcpp/tokenizers/tokenizer.cpp rename to otherarch/sdcpp/src/tokenizers/tokenizer.cpp index 556cadd84..cb40e9b4e 100644 --- a/otherarch/sdcpp/tokenizers/tokenizer.cpp +++ b/otherarch/sdcpp/src/tokenizers/tokenizer.cpp @@ -4,7 +4,7 @@ #include #include -#include "util.h" +#include "core/util.h" void Tokenizer::add_special_token(const std::string& token) { special_tokens.push_back(token); diff --git a/otherarch/sdcpp/tokenizers/tokenizer.h b/otherarch/sdcpp/src/tokenizers/tokenizer.h similarity index 100% rename from otherarch/sdcpp/tokenizers/tokenizer.h rename to otherarch/sdcpp/src/tokenizers/tokenizer.h diff --git a/otherarch/sdcpp/tokenizers/vocab/clip_merges.hpp b/otherarch/sdcpp/src/tokenizers/vocab/clip_merges.hpp similarity index 100% rename from otherarch/sdcpp/tokenizers/vocab/clip_merges.hpp rename to otherarch/sdcpp/src/tokenizers/vocab/clip_merges.hpp diff --git a/otherarch/sdcpp/tokenizers/vocab/gemma2_merges.hpp b/otherarch/sdcpp/src/tokenizers/vocab/gemma2_merges.hpp similarity index 100% rename from otherarch/sdcpp/tokenizers/vocab/gemma2_merges.hpp rename to otherarch/sdcpp/src/tokenizers/vocab/gemma2_merges.hpp diff --git a/otherarch/sdcpp/tokenizers/vocab/gemma2_vocab.hpp b/otherarch/sdcpp/src/tokenizers/vocab/gemma2_vocab.hpp similarity index 100% rename from otherarch/sdcpp/tokenizers/vocab/gemma2_vocab.hpp rename to otherarch/sdcpp/src/tokenizers/vocab/gemma2_vocab.hpp diff --git a/otherarch/sdcpp/tokenizers/vocab/gemma_merges.hpp b/otherarch/sdcpp/src/tokenizers/vocab/gemma_merges.hpp similarity index 100% rename from otherarch/sdcpp/tokenizers/vocab/gemma_merges.hpp rename to otherarch/sdcpp/src/tokenizers/vocab/gemma_merges.hpp diff --git a/otherarch/sdcpp/tokenizers/vocab/gemma_vocab.hpp b/otherarch/sdcpp/src/tokenizers/vocab/gemma_vocab.hpp similarity index 100% rename from otherarch/sdcpp/tokenizers/vocab/gemma_vocab.hpp rename to otherarch/sdcpp/src/tokenizers/vocab/gemma_vocab.hpp diff --git a/otherarch/sdcpp/tokenizers/vocab/gpt_oss_merges.hpp b/otherarch/sdcpp/src/tokenizers/vocab/gpt_oss_merges.hpp similarity index 100% rename from otherarch/sdcpp/tokenizers/vocab/gpt_oss_merges.hpp rename to otherarch/sdcpp/src/tokenizers/vocab/gpt_oss_merges.hpp diff --git a/otherarch/sdcpp/tokenizers/vocab/gpt_oss_vocab.hpp b/otherarch/sdcpp/src/tokenizers/vocab/gpt_oss_vocab.hpp similarity index 100% rename from otherarch/sdcpp/tokenizers/vocab/gpt_oss_vocab.hpp rename to otherarch/sdcpp/src/tokenizers/vocab/gpt_oss_vocab.hpp diff --git a/otherarch/sdcpp/tokenizers/vocab/mistral_merges.hpp b/otherarch/sdcpp/src/tokenizers/vocab/mistral_merges.hpp similarity index 100% rename from otherarch/sdcpp/tokenizers/vocab/mistral_merges.hpp rename to otherarch/sdcpp/src/tokenizers/vocab/mistral_merges.hpp diff --git a/otherarch/sdcpp/tokenizers/vocab/mistral_vocab.hpp b/otherarch/sdcpp/src/tokenizers/vocab/mistral_vocab.hpp similarity index 100% rename from otherarch/sdcpp/tokenizers/vocab/mistral_vocab.hpp rename to otherarch/sdcpp/src/tokenizers/vocab/mistral_vocab.hpp diff --git a/otherarch/sdcpp/tokenizers/vocab/qwen_merges.hpp b/otherarch/sdcpp/src/tokenizers/vocab/qwen_merges.hpp similarity index 100% rename from otherarch/sdcpp/tokenizers/vocab/qwen_merges.hpp rename to otherarch/sdcpp/src/tokenizers/vocab/qwen_merges.hpp diff --git a/otherarch/sdcpp/tokenizers/vocab/t5.hpp b/otherarch/sdcpp/src/tokenizers/vocab/t5.hpp similarity index 100% rename from otherarch/sdcpp/tokenizers/vocab/t5.hpp rename to otherarch/sdcpp/src/tokenizers/vocab/t5.hpp diff --git a/otherarch/sdcpp/tokenizers/vocab/umt5.hpp b/otherarch/sdcpp/src/tokenizers/vocab/umt5.hpp similarity index 100% rename from otherarch/sdcpp/tokenizers/vocab/umt5.hpp rename to otherarch/sdcpp/src/tokenizers/vocab/umt5.hpp diff --git a/otherarch/sdcpp/tokenizers/vocab/vocab.cpp b/otherarch/sdcpp/src/tokenizers/vocab/vocab.cpp similarity index 100% rename from otherarch/sdcpp/tokenizers/vocab/vocab.cpp rename to otherarch/sdcpp/src/tokenizers/vocab/vocab.cpp diff --git a/otherarch/sdcpp/tokenizers/vocab/vocab.h b/otherarch/sdcpp/src/tokenizers/vocab/vocab.h similarity index 100% rename from otherarch/sdcpp/tokenizers/vocab/vocab.h rename to otherarch/sdcpp/src/tokenizers/vocab/vocab.h diff --git a/otherarch/sdcpp/upscaler.cpp b/otherarch/sdcpp/src/upscaler.cpp similarity index 99% rename from otherarch/sdcpp/upscaler.cpp rename to otherarch/sdcpp/src/upscaler.cpp index cef26e36d..54c56850a 100644 --- a/otherarch/sdcpp/upscaler.cpp +++ b/otherarch/sdcpp/src/upscaler.cpp @@ -1,8 +1,8 @@ #include "upscaler.h" -#include "ggml_extend.hpp" +#include "core/ggml_extend.hpp" +#include "core/util.h" #include "model.h" #include "stable-diffusion.h" -#include "util.h" #include diff --git a/otherarch/sdcpp/upscaler.h b/otherarch/sdcpp/src/upscaler.h similarity index 92% rename from otherarch/sdcpp/upscaler.h rename to otherarch/sdcpp/src/upscaler.h index e2197694d..c9fce1844 100644 --- a/otherarch/sdcpp/upscaler.h +++ b/otherarch/sdcpp/src/upscaler.h @@ -1,10 +1,10 @@ #ifndef __SD_UPSCALER_H__ #define __SD_UPSCALER_H__ -#include "esrgan.hpp" -#include "ggml_extend_backend.h" +#include "core/ggml_extend_backend.h" +#include "core/tensor.hpp" +#include "model/upscaler/esrgan.hpp" #include "stable-diffusion.h" -#include "tensor.hpp" #include #include diff --git a/otherarch/sdcpp/version.cpp b/otherarch/sdcpp/src/version.cpp similarity index 100% rename from otherarch/sdcpp/version.cpp rename to otherarch/sdcpp/src/version.cpp