From e0ed724e2859d9c3a6e914361efde28824dabe1f Mon Sep 17 00:00:00 2001 From: leejet Date: Sat, 24 Oct 2026 01:23:42 +0800 Subject: [PATCH] chore: format code --- examples/server/async_jobs.cpp | 8 +- examples/server/model_catalog.cpp | 2 +- examples/server/routes_openai.cpp | 34 +-- examples/server/routes_sdapi.cpp | 2 +- examples/server/routes_sdcpp.cpp | 34 +-- llvm.sh | 270 +++++++++++++++++++++++ src/conditioning/conditioner.hpp | 44 ++-- src/core/backend_fit.cpp | 6 +- src/core/ggml_runner.cpp | 2 +- src/core/segment_graph_bindings.cpp | 2 +- src/extensions/photomaker_extension.cpp | 12 +- src/model/common/rope.hpp | 2 +- src/model/diffusion/boogu.hpp | 28 +-- src/model/diffusion/flux3.hpp | 2 +- src/model/diffusion/hidream_o1.hpp | 6 +- src/model/diffusion/hunyuan.hpp | 6 +- src/model/diffusion/krea2.hpp | 18 +- src/model/diffusion/lingbot_video.hpp | 24 +- src/model/diffusion/llada_image.hpp | 2 +- src/model/diffusion/ltxv.hpp | 10 +- src/model/diffusion/ming_image.hpp | 2 +- src/model/diffusion/minimax_h3.hpp | 32 +-- src/model/diffusion/pid.hpp | 2 +- src/model/diffusion/pixart.hpp | 8 +- src/model/diffusion/qwen_image_2_1.hpp | 8 +- src/model/diffusion/sensenova_u1.h | 2 +- src/model/integrations/anima.cpp | 12 +- src/model/integrations/boogu_image.cpp | 20 +- src/model/integrations/ernie_image.cpp | 18 +- src/model/integrations/fibo2.cpp | 4 +- src/model/integrations/flux2.cpp | 22 +- src/model/integrations/flux3.cpp | 4 +- src/model/integrations/hidream_o1.cpp | 12 +- src/model/integrations/hunyuan_video.cpp | 20 +- src/model/integrations/ideogram4.cpp | 18 +- src/model/integrations/iris.cpp | 4 +- src/model/integrations/krea2.cpp | 18 +- src/model/integrations/lens.cpp | 18 +- src/model/integrations/lingbot_video.cpp | 8 +- src/model/integrations/llada_image.cpp | 20 +- src/model/integrations/longcat.cpp | 22 +- src/model/integrations/ltxav.cpp | 16 +- src/model/integrations/mage_flow.cpp | 18 +- src/model/integrations/ming_image.cpp | 4 +- src/model/integrations/minimax_h3.cpp | 18 +- src/model/integrations/minit2i.cpp | 10 +- src/model/integrations/moss_image.cpp | 2 +- src/model/integrations/pid.cpp | 18 +- src/model/integrations/pixart.cpp | 20 +- src/model/integrations/qwen_image.cpp | 12 +- src/model/integrations/sd.cpp | 8 +- src/model/integrations/sd3.cpp | 12 +- src/model/integrations/sensenova_u1.cpp | 6 +- src/model/integrations/wan.cpp | 18 +- src/model/integrations/z_image.cpp | 20 +- src/model/integrations/z_image_l2p.cpp | 18 +- src/model/te/llada_image_te.hpp | 4 +- src/model/vae/ltx_audio_vae.hpp | 6 +- src/model/vae/ltx_vae.hpp | 22 +- src/model/vae/minimax_h3_audio_vae.hpp | 20 +- src/model/vae/minimax_h3_vae.hpp | 4 +- src/model_loader.cpp | 2 +- src/model_manager.cpp | 28 +-- src/pipeline/diffusion_engine.cpp | 26 +-- src/pipeline/image.cpp | 8 +- src/pipeline/model_builders.cpp | 12 +- src/pipeline/video.cpp | 22 +- src/runtime/cache_dit.hpp | 2 +- src/runtime/guidance.cpp | 8 +- 69 files changed, 711 insertions(+), 441 deletions(-) create mode 100644 llvm.sh diff --git a/examples/server/async_jobs.cpp b/examples/server/async_jobs.cpp index 3e40e506..943316e9 100644 --- a/examples/server/async_jobs.cpp +++ b/examples/server/async_jobs.cpp @@ -234,11 +234,11 @@ json make_async_job_json(const AsyncJobManager& manager, const AsyncGenerationJo job.status == AsyncJobStatus::Cancelled) { result["result"] = nullptr; result["error"] = { - {"code", + {"code", job.error_code.empty() - ? (job.status == AsyncJobStatus::Cancelled ? "cancelled" : "generation_failed") - : job.error_code}, - {"message", job.error_message}, + ? (job.status == AsyncJobStatus::Cancelled ? "cancelled" : "generation_failed") + : job.error_code}, + {"message", job.error_message}, }; } else { result["result"] = nullptr; diff --git a/examples/server/model_catalog.cpp b/examples/server/model_catalog.cpp index 8efe624b..eef68561 100644 --- a/examples/server/model_catalog.cpp +++ b/examples/server/model_catalog.cpp @@ -19,7 +19,7 @@ struct ModelSlot { const char* id; const char* label; std::vector categories; - std::string SDContextParams::*field; + std::string SDContextParams::* field; }; static const ModelSlot k_model_slots[] = { diff --git a/examples/server/routes_openai.cpp b/examples/server/routes_openai.cpp index ae1fb705..409c88de 100644 --- a/examples/server/routes_openai.cpp +++ b/examples/server/routes_openai.cpp @@ -163,11 +163,11 @@ static bool build_openai_edit_request(const httplib::Request& req, int img_h = 0; int resolved_channel = 0; uint8_t* raw_pixels = load_image_from_memory( - reinterpret_cast(bytes.data()), - static_cast(bytes.size()), - img_w, img_h, resolved_channel, - 0, 0, - 0); + reinterpret_cast(bytes.data()), + static_cast(bytes.size()), + img_w, img_h, resolved_channel, + 0, 0, + 0); if (raw_pixels == nullptr) { continue; } @@ -301,12 +301,12 @@ void register_openai_api_endpoints(httplib::Server& svr, ServerRuntime& rt) { : request.output_format == "webp" ? EncodedImageFormat::WEBP : EncodedImageFormat::PNG, - results[i].data, - results[i].width, - results[i].height, - results[i].channel, - params, - request.output_compression); + results[i].data, + results[i].width, + results[i].height, + results[i].channel, + params, + request.output_compression); if (image_bytes.empty()) { LOG_ERROR("write image to mem failed"); continue; @@ -371,12 +371,12 @@ void register_openai_api_endpoints(httplib::Server& svr, ServerRuntime& rt) { request.gen_params.seed + i / images_per_batch) : ""; auto image_bytes = encode_image_to_vector(request.output_format == "jpeg" ? EncodedImageFormat::JPEG : EncodedImageFormat::PNG, - results[i].data, - results[i].width, - results[i].height, - results[i].channel, - params, - request.output_compression); + results[i].data, + results[i].width, + results[i].height, + results[i].channel, + params, + request.output_compression); json item; item["b64_json"] = base64_encode(image_bytes); out["data"].push_back(item); diff --git a/examples/server/routes_sdapi.cpp b/examples/server/routes_sdapi.cpp index 014b0b5f..ef9a6feb 100644 --- a/examples/server/routes_sdapi.cpp +++ b/examples/server/routes_sdapi.cpp @@ -543,7 +543,7 @@ static void preview_callback(int step, int frame_count, sd_image_t* frames, bool std::lock_guard lock(g_preview.mutex); g_preview.b64 = std::move(b64); g_preview.step = static_cast(std::min(step < 0 ? -static_cast(step) : step, - std::max(0, info.total_steps))); + std::max(0, info.total_steps))); g_preview.total = std::max(0, info.total_steps); g_preview.job_no = std::max(0, info.sample_pass - 1); } diff --git a/examples/server/routes_sdcpp.cpp b/examples/server/routes_sdcpp.cpp index f82144c4..29eed7e1 100644 --- a/examples/server/routes_sdcpp.cpp +++ b/examples/server/routes_sdcpp.cpp @@ -381,8 +381,8 @@ static json make_capabilities_json(ServerRuntime& runtime) { json top_level_defaults = json::object(); json top_level_output_formats = json::array(); json top_level_features = { - {"cancel_queued", true}, - {"cancel_generating", true}, + {"cancel_queued", true}, + {"cancel_generating", true}, }; std::string current_mode = ""; if (supports_img) { @@ -410,14 +410,14 @@ static json make_capabilities_json(ServerRuntime& runtime) { result["defaults"] = top_level_defaults; result["defaults_by_mode"] = defaults_by_mode; result["limits"] = { - {"min_width", 64}, - {"max_width", k_max_generation_dimension}, - {"min_height", 64}, - {"max_height", k_max_generation_dimension}, - {"max_batch_count", 8}, - {"max_queue_size", manager.max_pending_jobs}, - {"max_upscale_width", k_max_upscale_dimension}, - {"max_upscale_height", k_max_upscale_dimension}, + {"min_width", 64}, + {"max_width", k_max_generation_dimension}, + {"min_height", 64}, + {"max_height", k_max_generation_dimension}, + {"max_batch_count", 8}, + {"max_queue_size", manager.max_pending_jobs}, + {"max_upscale_width", k_max_upscale_dimension}, + {"max_upscale_height", k_max_upscale_dimension}, }; result["samplers"] = samplers; result["schedulers"] = schedulers; @@ -520,7 +520,7 @@ void register_sdcpp_api_endpoints(httplib::Server& svr, ServerRuntime& rt) { const bool valid = value.is_number_unsigned() ? value.get() <= static_cast(std::numeric_limits::max()) : value.is_number_integer() && value.get() >= std::numeric_limits::min() && - value.get() <= std::numeric_limits::max(); + value.get() <= std::numeric_limits::max(); if (!valid) { res.status = 400; res.set_content(json({{"error", std::string(key) + " must be a 32-bit integer"}}).dump(), "application/json"); @@ -631,12 +631,12 @@ void register_sdcpp_api_endpoints(httplib::Server& svr, ServerRuntime& rt) { auto image_bytes = encode_image_to_vector(format == "jpeg" ? EncodedImageFormat::JPEG : format == "webp" ? EncodedImageFormat::WEBP : EncodedImageFormat::PNG, - result.data, - result.width, - result.height, - result.channel, - "", - compression); + result.data, + result.width, + result.height, + result.channel, + "", + compression); if (image_bytes.empty()) { res.status = 500; res.set_content(R"({"error":"the result could not be encoded"})", "application/json"); diff --git a/llvm.sh b/llvm.sh new file mode 100644 index 00000000..6f8f2cd2 --- /dev/null +++ b/llvm.sh @@ -0,0 +1,270 @@ +#!/bin/bash +################################################################################ +# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +# See https://llvm.org/LICENSE.txt for license information. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +################################################################################ +# +# This script will install the llvm toolchain on the different +# Debian and Ubuntu versions + +# This script is stored on: +# https://github.com/opencollab/llvm-jenkins.debian.net/blob/master/llvm.sh + +set -euxo pipefail + +info() { printf "[info] %s\n" "$*"; } +warn() { printf "[warn] %s\n" "$*" >&2; } +# error MESSAGE [EXIT_CODE] — default exit code is 1 +error() { + local msg="$1" + local code="${2:-1}" + printf "[error] %s\n" "$msg" >&2 + exit "$code" +} + +usage() { + set +x + echo "Usage: $0 [llvm_major_version] [all] [OPTIONS]" 1>&2 + echo -e "all\t\t\tInstall all packages." 1>&2 + echo -e "-n=code_name\t\tSpecifies the distro codename, for example bionic" 1>&2 + echo -e "-h\t\t\tPrints this help." 1>&2 + echo -e "-m=repo_base_url\tSpecifies the base URL from which to download." 1>&2 + exit $# +} + +CURRENT_LLVM_STABLE=22 +BASE_URL="https://apt.llvm.org" + +NEW_DEBIAN_DISTROS=("trixie" "forky" "unstable") +# Set default values for commandline arguments +# We default to the current stable branch of LLVM +LLVM_VERSION=$CURRENT_LLVM_STABLE +ALL=0 +DISTRO=$(lsb_release -is) +VERSION_CODENAME=$(lsb_release -cs) +VERSION=$(lsb_release -sr) +UBUNTU_CODENAME="" +CODENAME_FROM_ARGUMENTS="" +# Obtain VERSION_CODENAME and UBUNTU_CODENAME (for Ubuntu and its derivatives) +source /etc/os-release +DISTRO=${DISTRO,,} + +# Downloader abstraction: prefer wget, fall back to curl +download_key() { + local url="$1" + if command -v wget &>/dev/null; then + wget -qO- --retry-connrefused --waitretry=1 --tries=3 "$url" + elif command -v curl &>/dev/null; then + curl --proto '=https' --tlsv1.2 -sSf --retry 3 "$url" + else + error "Neither wget nor curl found. Install one and retry." 4 + fi +} + +check_url() { + local url="$1" + if command -v wget &>/dev/null; then + wget -q --method=HEAD --timeout=15 --tries=3 "$url" &>/dev/null + elif command -v curl &>/dev/null; then + curl --proto '=https' --tlsv1.2 -sSf --head --retry 2 "$url" >/dev/null 2>&1 + else + return 1 + fi +} + +# Check if this is a new Debian distro +is_new_debian=0 +if [[ "${DISTRO}" == "debian" ]]; then + for new_distro in "${NEW_DEBIAN_DISTROS[@]}"; do + if [[ "${VERSION_CODENAME}" == "${new_distro}" ]]; then + is_new_debian=1 + break + fi + done +fi + +# Check for required tools +needed_binaries=(lsb_release wget gpg) +# add-apt-repository is not needed for newer Debian distros +if [[ $is_new_debian -eq 0 ]]; then + needed_binaries+=(add-apt-repository) +fi + +missing_binaries=() +for binary in "${needed_binaries[@]}"; do + if ! command -v "$binary" &>/dev/null; then + if [[ "$binary" == "wget" ]] && command -v curl &>/dev/null; then + continue + fi + missing_binaries+=("$binary") + fi +done + +if [[ ${#missing_binaries[@]} -gt 0 ]] ; then + error "Missing required tools: ${missing_binaries[*]} +(hint: apt install lsb-release wget software-properties-common gnupg) +curl is also supported as an alternative to wget" 4 +fi + +case ${DISTRO} in + debian) + # Debian Forky has a workaround because of + # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1038383 + if [[ "${VERSION}" == "unstable" ]] || [[ "${VERSION}" == "testing" ]] || [[ "${VERSION_CODENAME}" == "forky" ]]; then + CODENAME=unstable + LINKNAME= + else + # "stable" Debian release + CODENAME=${VERSION_CODENAME} + LINKNAME=-${CODENAME} + fi + ;; + *) + # ubuntu and its derivatives + if [[ -n "${UBUNTU_CODENAME}" ]]; then + CODENAME=${UBUNTU_CODENAME} + if [[ -n "${CODENAME}" ]]; then + LINKNAME=-${CODENAME} + fi + fi + ;; +esac + +# check for long options +for arg in "$@"; do + case "${arg}" in + (--help|-h) usage ;; + (--version) usage error ;; + (--) break ;; + esac +done + +# read optional command line arguments +if [ "$#" -ge 1 ] && [ "${1::1}" != "-" ]; then + if [ "$1" != "all" ]; then + LLVM_VERSION=$1 + else + # special case for ./llvm.sh all + ALL=1 + fi + OPTIND=2 + if [ "$#" -ge 2 ]; then + if [ "$2" == "all" ]; then + # Install all packages + ALL=1 + OPTIND=3 + fi + fi +fi + +while getopts ":hm:n:" arg; do + case $arg in + h) + usage + ;; + m) + BASE_URL=${OPTARG} + ;; + n) + CODENAME=${OPTARG} + if [[ "${CODENAME}" == "unstable" ]]; then + # link name does not apply to unstable repository + LINKNAME= + else + LINKNAME=-${CODENAME} + fi + CODENAME_FROM_ARGUMENTS="true" + ;; + esac +done + +if [[ $EUID -ne 0 ]]; then + error "This script must be run as root!" +fi + +declare -A LLVM_VERSION_PATTERNS +LLVM_VERSION_PATTERNS[9]="-9" +LLVM_VERSION_PATTERNS[10]="-10" +LLVM_VERSION_PATTERNS[11]="-11" +LLVM_VERSION_PATTERNS[12]="-12" +LLVM_VERSION_PATTERNS[13]="-13" +LLVM_VERSION_PATTERNS[14]="-14" +LLVM_VERSION_PATTERNS[15]="-15" +LLVM_VERSION_PATTERNS[16]="-16" +LLVM_VERSION_PATTERNS[17]="-17" +LLVM_VERSION_PATTERNS[18]="-18" +LLVM_VERSION_PATTERNS[19]="-19" +LLVM_VERSION_PATTERNS[20]="-20" +LLVM_VERSION_PATTERNS[21]="-21" +LLVM_VERSION_PATTERNS[22]="-22" +LLVM_VERSION_PATTERNS[23]="-23" +LLVM_VERSION_PATTERNS[24]="" + +if [ ! ${LLVM_VERSION_PATTERNS[$LLVM_VERSION]+_} ]; then + error "This script does not support LLVM version $LLVM_VERSION" 3 +fi + +LLVM_VERSION_STRING=${LLVM_VERSION_PATTERNS[$LLVM_VERSION]} + +# join the repository name +if [[ -n "${CODENAME}" ]]; then + REPO_NAME="deb ${BASE_URL}/${CODENAME}/ llvm-toolchain${LINKNAME}${LLVM_VERSION_STRING} main" + # check if the repository exists for the distro and version + if ! check_url "${BASE_URL}/${CODENAME}/"; then + if [[ -n "${CODENAME_FROM_ARGUMENTS}" ]]; then + error "Specified codename '${CODENAME}' is not supported by this script." 2 + else + error "Distribution '${DISTRO}' in version '${VERSION}' is not supported by this script." 2 + fi + fi +fi + + +# install everything + +if [[ ! -f /etc/apt/trusted.gpg.d/apt.llvm.org.asc ]]; then + GPG_KEY_URL="https://apt.llvm.org/llvm-snapshot.gpg.key" + if ! check_url "$GPG_KEY_URL"; then + error "GPG key not reachable at $GPG_KEY_URL" 2 + fi + download_key "$GPG_KEY_URL" | tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc +fi + +if [[ -z "`apt-key list 2> /dev/null | grep -i llvm`" ]]; then + # Delete the key in the old format + apt-key del AF4F7421 || true +fi + + +# Add repository based on distribution +if [[ "${VERSION_CODENAME}" == "bookworm" ]]; then + # add it twice to workaround: + # https://github.com/llvm/llvm-project/issues/62475 + add-apt-repository -y "${REPO_NAME}" + add-apt-repository -y "${REPO_NAME}" +elif [[ $is_new_debian -eq 1 ]]; then + # workaround missing add-apt-repository in newer Debian and use new source.list format + SOURCES_FILE="/etc/apt/sources.list.d/http_apt_llvm_org_${CODENAME}_-${VERSION_CODENAME}.sources" + TEXT_TO_ADD="Types: deb +Architectures: amd64 arm64 +Signed-By: /etc/apt/trusted.gpg.d/apt.llvm.org.asc +URIs: ${BASE_URL}/${CODENAME}/ +Suites: llvm-toolchain${LINKNAME}${LLVM_VERSION_STRING} +Components: main" + echo "$TEXT_TO_ADD" | tee -a "$SOURCES_FILE" > /dev/null +else + add-apt-repository -y "${REPO_NAME}" +fi + +apt-get update +PKG="clang-$LLVM_VERSION lldb-$LLVM_VERSION lld-$LLVM_VERSION clangd-$LLVM_VERSION" +if [[ $ALL -eq 1 ]]; then + # same as in test-install.sh + # No worries if we have dups + PKG="$PKG clang-tidy-$LLVM_VERSION clang-format-$LLVM_VERSION clang-tools-$LLVM_VERSION llvm-$LLVM_VERSION-dev lld-$LLVM_VERSION lldb-$LLVM_VERSION llvm-$LLVM_VERSION-tools libomp-$LLVM_VERSION-dev libc++-$LLVM_VERSION-dev libc++abi-$LLVM_VERSION-dev libclang-common-$LLVM_VERSION-dev libclang-$LLVM_VERSION-dev libclang-cpp$LLVM_VERSION-dev liblldb-$LLVM_VERSION-dev libunwind-$LLVM_VERSION-dev" + if test $LLVM_VERSION -gt 14; then + PKG="$PKG libclang-rt-$LLVM_VERSION-dev libpolly-$LLVM_VERSION-dev" + fi +fi +apt-get install -y $PKG diff --git a/src/conditioning/conditioner.hpp b/src/conditioning/conditioner.hpp index a146716d..c7ef70f5 100644 --- a/src/conditioning/conditioner.hpp +++ b/src/conditioning/conditioner.hpp @@ -1833,11 +1833,11 @@ struct AnimaConditioner : public Conditioner { std::shared_ptr weight_manager = nullptr, const TokenizerConfig& tokenizers = {}) { llm = std::make_shared(LLM::LLMArch::QWEN3, - backend, - tensor_storage_map, - "text_encoders.llm", - false, - weight_manager); + backend, + tensor_storage_map, + "text_encoders.llm", + false, + weight_manager); qwen_tokenizer = tokenizers.create(TokenizerConfig::MAIN, llm->config.vocab_size, 151643); if (!qwen_tokenizer) { qwen_tokenizer = std::make_shared(); @@ -2026,11 +2026,11 @@ struct LLMEmbedder : public Conditioner { arch = LLM::LLMArch::QWEN3_5; } llm = std::make_shared(arch, - backend, - tensor_storage_map, - "text_encoders.llm", - enable_vision, - weight_manager); + backend, + tensor_storage_map, + "text_encoders.llm", + enable_vision, + weight_manager); int pad_id = 151643; if (arch == LLM::LLMArch::MISTRAL_SMALL_3_2 || arch == LLM::LLMArch::MINISTRAL_3_3B) { pad_id = 11; @@ -3312,7 +3312,7 @@ struct LLMEmbedder : public Conditioner { for (const auto& [index, image_embed] : image_embeds) { int64_t begin = std::max(0, index - 1); int64_t end = std::min(static_cast(tags.size()), - index + image_embed.shape()[1] + 1); + index + image_embed.shape()[1] + 1); std::fill(tags.begin() + begin, tags.begin() + end, 0); } int64_t tag_count = static_cast(tags.size()); @@ -3492,9 +3492,9 @@ struct LLaDAImageEmbedder : public Conditioner { // <|endoftext|> doubles as the pad token in LLaDA2's tokenizer.json. tokenizer = tokenizers.create(TokenizerConfig::MAIN, llm->config.vocab_size, 156892); query_former = std::make_shared(backend, - tensor_storage_map, - query_former_prefix, - weight_manager); + tensor_storage_map, + query_former_prefix, + weight_manager); text_projection = std::make_shared(backend, tensor_storage_map, text_projection_prefix, @@ -3696,20 +3696,20 @@ struct LTXAVEmbedder : public Conditioner { LLM::LLMArch arch = detect_gemma_arch(tensor_storage_map, llm_prefix); LOG_INFO("ltxav text encoder: %s", arch == LLM::LLMArch::GEMMA4_12B ? "gemma 4" : "gemma 3"); llm = std::make_shared(arch, - backend, - tensor_storage_map, - llm_prefix, - false, - weight_manager); + backend, + tensor_storage_map, + llm_prefix, + false, + weight_manager); tokenizer = tokenizers.create(TokenizerConfig::MAIN, llm->config.vocab_size, 0, true); if (!tokenizer) { tokenizer = std::make_shared(); } dual_projection = tensor_storage_map.find(projector_prefix + ".video_aggregate_embed.weight") != tensor_storage_map.end(); projector = std::make_shared(backend, - tensor_storage_map, - projector_prefix, - weight_manager); + tensor_storage_map, + projector_prefix, + weight_manager); } void get_param_tensors(std::map& tensors) override { diff --git a/src/core/backend_fit.cpp b/src/core/backend_fit.cpp index 84667ef3..91dfedb4 100644 --- a/src/core/backend_fit.cpp +++ b/src/core/backend_fit.cpp @@ -183,7 +183,7 @@ namespace sd::backend_fit { vm_statistics64_data_t stats{}; mach_msg_type_number_t count = HOST_VM_INFO64_COUNT; const bool ok = host_page_size(host, &page_size) == KERN_SUCCESS && - host_statistics64(host, HOST_VM_INFO64, (host_info64_t)&stats, &count) == KERN_SUCCESS; + host_statistics64(host, HOST_VM_INFO64, (host_info64_t)&stats, &count) == KERN_SUCCESS; mach_port_deallocate(mach_task_self(), host); if (ok) { return ((int64_t)stats.free_count + stats.inactive_count) * page_size; @@ -262,10 +262,10 @@ namespace sd::backend_fit { const auto& runtime_devices = plan.runtimes[ci].devices; const bool fits_runtime = !runtime_devices.empty() && - std::all_of(runtime_devices.begin(), runtime_devices.end(), [&](size_t di) { + std::all_of(runtime_devices.begin(), runtime_devices.end(), [&](size_t di) { const int64_t headroom = headroom_for(ci, di); return headroom <= remaining[di] && comp.params_bytes <= remaining[di] - headroom; - }); + }); if (fits_runtime) { decision.params_location = ParamsLocation::MAIN_GPU; decision.params_device = runtime_devices.front(); diff --git a/src/core/ggml_runner.cpp b/src/core/ggml_runner.cpp index 4c156ed4..1efcb9fa 100644 --- a/src/core/ggml_runner.cpp +++ b/src/core/ggml_runner.cpp @@ -896,7 +896,7 @@ std::optional> GGMLRunner::execute_graph(ggml_cgraph* graph, int n const bool last = index + 1 == plan.segments.size(); auto fail_segment = [&](const char* phase) { LOG_ERROR("%s segment %zu/%zu (%s) failed during %s", get_desc().c_str(), - index + 1, plan.segments.size(), segment.group_name.c_str(), phase); + index + 1, plan.segments.size(), segment.group_name.c_str(), phase); return std::nullopt; }; cut_cache_.prune(segment.live_cut_names); diff --git a/src/core/segment_graph_bindings.cpp b/src/core/segment_graph_bindings.cpp index 3c40a3b0..ba72116f 100644 --- a/src/core/segment_graph_bindings.cpp +++ b/src/core/segment_graph_bindings.cpp @@ -112,7 +112,7 @@ namespace sd { input_tensor->data = cached_tensor->data == nullptr ? nullptr : static_cast(static_cast(cached_tensor->data) + - input_tensor->view_offs); + input_tensor->view_offs); input_tensor->extra = cached_tensor->extra; } else { input_tensor->buffer = cached_tensor->buffer; diff --git a/src/extensions/photomaker_extension.cpp b/src/extensions/photomaker_extension.cpp index f904c8f7..59b9a2c2 100644 --- a/src/extensions/photomaker_extension.cpp +++ b/src/extensions/photomaker_extension.cpp @@ -154,12 +154,12 @@ struct PhotoMakerExtension : public GenerationExtension { PMVersion pm_version = std::strstr(model_path.c_str(), "v2") != nullptr ? PM_VERSION_2 : PM_VERSION_1; pmid_model = std::make_shared(ctx.backend_for(SDBackendModule::PHOTOMAKER), - ctx.tensor_storage_map, - "pmid", - ctx.version, - pm_version, - 20.f, - ctx.model_manager); + ctx.tensor_storage_map, + "pmid", + ctx.version, + pm_version, + 20.f, + ctx.model_manager); pmid_model->set_scale_overrides(ctx.params->linear_scale, ctx.params->attn_scale); if (pm_version == PM_VERSION_2) { LOG_INFO("using PhotoMaker Version 2"); diff --git a/src/model/common/rope.hpp b/src/model/common/rope.hpp index 93e457d4..63584bc5 100644 --- a/src/model/common/rope.hpp +++ b/src/model/common/rope.hpp @@ -660,7 +660,7 @@ namespace Rope { const int axes_dim_num = static_cast(axes_dim.size()); auto make_image_ids = [=, &result](int image_h, int image_w, int image_index) { std::vector> image_ids(static_cast(bs) * image_h * image_w, - std::vector(axes_dim_num, 0.f)); + std::vector(axes_dim_num, 0.f)); result.positions.append_image(image_h, image_w); int h_start = -(image_h - image_h / 2); int w_start = -(image_w - image_w / 2); diff --git a/src/model/diffusion/boogu.hpp b/src/model/diffusion/boogu.hpp index 1ca13709..3ee6714f 100644 --- a/src/model/diffusion/boogu.hpp +++ b/src/model/diffusion/boogu.hpp @@ -543,18 +543,18 @@ namespace Boogu { blocks["x_embedder"] = std::make_shared(this->config.patch_size * this->config.patch_size * this->config.in_channels, this->config.hidden_size, true); blocks["ref_image_patch_embedder"] = std::make_shared(this->config.patch_size * this->config.patch_size * this->config.in_channels, this->config.hidden_size, true); blocks["time_caption_embed"] = std::make_shared(this->config.hidden_size, - this->config.instruction_feat_dim, - 256, - this->config.norm_eps, - this->config.timestep_scale); + this->config.instruction_feat_dim, + 256, + this->config.norm_eps, + this->config.timestep_scale); for (int i = 0; i < this->config.num_refiner_layers; i++) { blocks["noise_refiner." + std::to_string(i)] = std::make_shared(this->config.hidden_size, - this->config.num_attention_heads, - this->config.num_kv_heads, - this->config.multiple_of, - this->config.norm_eps, - true); + this->config.num_attention_heads, + this->config.num_kv_heads, + this->config.multiple_of, + this->config.norm_eps, + true); blocks["ref_image_refiner." + std::to_string(i)] = std::make_shared(this->config.hidden_size, this->config.num_attention_heads, this->config.num_kv_heads, @@ -562,11 +562,11 @@ namespace Boogu { this->config.norm_eps, true); blocks["context_refiner." + std::to_string(i)] = std::make_shared(this->config.hidden_size, - this->config.num_attention_heads, - this->config.num_kv_heads, - this->config.multiple_of, - this->config.norm_eps, - false); + this->config.num_attention_heads, + this->config.num_kv_heads, + this->config.multiple_of, + this->config.norm_eps, + false); } for (int i = 0; i < this->config.num_double_stream_layers; i++) { diff --git a/src/model/diffusion/flux3.hpp b/src/model/diffusion/flux3.hpp index 952587b0..352ed949 100644 --- a/src/model/diffusion/flux3.hpp +++ b/src/model/diffusion/flux3.hpp @@ -243,7 +243,7 @@ namespace Flux3 { set_backend_tensor_data(pe, pe_values.data()); auto runner_ctx = get_context(); auto out = model.forward(&runner_ctx, x, text, references, make_input(*params.timesteps), make_input(zero), - config.flow_map ? make_input(*extra->target_timestep) : nullptr, pe); + config.flow_map ? make_input(*extra->target_timestep) : nullptr, pe); ggml_build_forward_expand(gf, out); return gf; }; diff --git a/src/model/diffusion/hidream_o1.hpp b/src/model/diffusion/hidream_o1.hpp index ca1559bc..90bfb51b 100644 --- a/src/model/diffusion/hidream_o1.hpp +++ b/src/model/diffusion/hidream_o1.hpp @@ -238,10 +238,10 @@ namespace HiDreamO1 { blocks["language_model"] = std::make_shared(this->config.llm); blocks["t_embedder1"] = std::make_shared(this->config.llm.hidden_size); blocks["x_embedder"] = std::make_shared(this->config.patch_size * this->config.patch_size * 3, - this->config.llm.hidden_size / 4, - this->config.llm.hidden_size); + this->config.llm.hidden_size / 4, + this->config.llm.hidden_size); blocks["final_layer2"] = std::make_shared(this->config.llm.hidden_size, - this->config.patch_size * this->config.patch_size * 3); + this->config.patch_size * this->config.patch_size * 3); } std::shared_ptr text_model() { diff --git a/src/model/diffusion/hunyuan.hpp b/src/model/diffusion/hunyuan.hpp index c106b9cd..54c7eff1 100644 --- a/src/model/diffusion/hunyuan.hpp +++ b/src/model/diffusion/hunyuan.hpp @@ -302,9 +302,9 @@ namespace Hunyuan { int64_t head_dim = this->config.hidden_size / this->config.num_heads; blocks["txt_in"] = std::make_shared(this->config.context_in_dim, this->config.num_heads, head_dim, 2); blocks["img_in"] = std::make_shared(static_cast(224) /*Not used*/, - this->config.patch_size, - this->config.in_channels, - this->config.hidden_size); + this->config.patch_size, + this->config.in_channels, + this->config.hidden_size); blocks["time_in"] = std::make_shared(256, this->config.hidden_size); if (this->config.vec_in_dim > 0) { blocks["vector_in"] = std::make_shared(this->config.vec_in_dim, this->config.hidden_size); diff --git a/src/model/diffusion/krea2.hpp b/src/model/diffusion/krea2.hpp index e58df410..47a7a340 100644 --- a/src/model/diffusion/krea2.hpp +++ b/src/model/diffusion/krea2.hpp @@ -73,9 +73,9 @@ namespace Krea2 { int64_t dim_head = head_dim(); int64_t unit = dim_head / 16; axes_dim = { - static_cast(dim_head - 12 * unit), - static_cast(6 * unit), - static_cast(6 * unit), + static_cast(dim_head - 12 * unit), + static_cast(6 * unit), + static_cast(6 * unit), }; axes_dim_sum = axes_dim[0] + axes_dim[1] + axes_dim[2]; } @@ -387,10 +387,10 @@ namespace Krea2 { this->config.mlp_multiplier, this->config.norm_eps); blocks["refiner_blocks." + std::to_string(i)] = std::make_shared(this->config.text_dim, - this->config.text_heads, - this->config.text_kv_heads, - this->config.mlp_multiplier, - this->config.norm_eps); + this->config.text_heads, + this->config.text_kv_heads, + this->config.mlp_multiplier, + this->config.norm_eps); } blocks["projector"] = std::make_shared(this->config.text_layers, 1, false); } @@ -613,8 +613,8 @@ namespace Krea2 { explicit Krea2Model(Krea2Config config) : config(std::move(config)) { blocks["first"] = std::make_shared(this->config.patch_size * this->config.patch_size * this->config.in_channels, - this->config.features, - true); + this->config.features, + true); blocks["tmlp"] = std::make_shared(this->config); blocks["txtfusion"] = std::make_shared(this->config); blocks["txtmlp"] = std::make_shared(this->config); diff --git a/src/model/diffusion/lingbot_video.hpp b/src/model/diffusion/lingbot_video.hpp index 1a93b458..fd43dfc4 100644 --- a/src/model/diffusion/lingbot_video.hpp +++ b/src/model/diffusion/lingbot_video.hpp @@ -442,10 +442,10 @@ namespace LingBotVideo { : hidden_size(config.hidden_size) { blocks["norm1"] = std::make_shared(config.hidden_size, config.norm_eps); blocks["attn"] = std::make_shared(config.hidden_size, - config.num_attention_heads, - config.qkv_bias, - config.out_bias, - config.norm_eps); + config.num_attention_heads, + config.qkv_bias, + config.out_bias, + config.norm_eps); blocks["norm_post_attn"] = std::make_shared(config.hidden_size, config.norm_eps); blocks["norm2"] = std::make_shared(config.hidden_size, config.norm_eps); if (sparse) { @@ -509,14 +509,14 @@ namespace LingBotVideo { int64_t patch_dim = config.patch_t * config.patch_h * config.patch_w * config.in_channels; blocks["patch_embedder"] = std::make_shared(patch_dim, config.hidden_size, config.patch_embed_bias); blocks["time_embedder"] = std::make_shared(config.freq_dim, - config.hidden_size, - config.hidden_size, - 0, - config.timestep_mlp_bias); + config.hidden_size, + config.hidden_size, + 0, + config.timestep_mlp_bias); blocks["time_modulation.1"] = std::make_shared(config.hidden_size, 6 * config.hidden_size, true); blocks["text_embedder"] = std::make_shared(config.text_dim, - config.hidden_size, - config.norm_eps); + config.hidden_size, + config.norm_eps); for (int i = 0; i < config.depth; i++) { bool sparse = config.sparse_layers.find(i) != config.sparse_layers.end(); blocks["blocks." + std::to_string(i)] = std::make_shared(config, sparse); @@ -524,8 +524,8 @@ namespace LingBotVideo { blocks["norm_out"] = std::make_shared(config.hidden_size, config.norm_eps, false); blocks["norm_out_modulation.1"] = std::make_shared(config.hidden_size, 2 * config.hidden_size, true); blocks["proj_out"] = std::make_shared(config.hidden_size, - config.patch_t * config.patch_h * config.patch_w * config.out_channels, - true); + config.patch_t * config.patch_h * config.patch_w * config.out_channels, + true); } ggml_tensor* forward(GGMLRunnerContext* ctx, diff --git a/src/model/diffusion/llada_image.hpp b/src/model/diffusion/llada_image.hpp index e69c3ecd..85ec08ea 100644 --- a/src/model/diffusion/llada_image.hpp +++ b/src/model/diffusion/llada_image.hpp @@ -463,7 +463,7 @@ namespace LLaDAImage { static_cast(x->ne[0]), config.patch_size, static_cast(context->ne[1]), - semantic != nullptr ? static_cast(semantic->ne[1]) : 0, + semantic != nullptr ? static_cast(semantic->ne[1]) : 0, ZImage::SEQ_MULTI_OF, config.theta, config.axes_dim)); diff --git a/src/model/diffusion/ltxv.hpp b/src/model/diffusion/ltxv.hpp index e10d5e82..17b882cf 100644 --- a/src/model/diffusion/ltxv.hpp +++ b/src/model/diffusion/ltxv.hpp @@ -597,9 +597,9 @@ namespace LTXV { : embedding_dim(embedding_dim), embedding_coefficient(embedding_coefficient) { blocks["emb.timestep_embedder"] = std::make_shared(embedding_dim); blocks["linear"] = std::make_shared(embedding_dim, - embedding_coefficient * embedding_dim, - true, - true); + embedding_coefficient * embedding_dim, + true, + true); } std::pair forward(GGMLRunnerContext* ctx, @@ -1257,7 +1257,7 @@ namespace LTXV { v_context, attn2.get(), v_table, - cross_attention_adaln ? params["prompt_scale_shift_table"] : nullptr, + cross_attention_adaln ? params["prompt_scale_shift_table"] : nullptr, v_timestep, v_prompt_timestep, v_dim, @@ -1275,7 +1275,7 @@ namespace LTXV { a_context, audio_attn2.get(), a_table, - cross_attention_adaln ? params["audio_prompt_scale_shift_table"] : nullptr, + cross_attention_adaln ? params["audio_prompt_scale_shift_table"] : nullptr, a_timestep, a_prompt_timestep, a_dim, diff --git a/src/model/diffusion/ming_image.hpp b/src/model/diffusion/ming_image.hpp index f19be990..2754aa94 100644 --- a/src/model/diffusion/ming_image.hpp +++ b/src/model/diffusion/ming_image.hpp @@ -109,7 +109,7 @@ namespace MingImage { const int64_t n_txt = context->ne[1] + direct->ne[1]; const int64_t n_img = ((x->ne[0] + config.patch_size - 1) / config.patch_size) * ((x->ne[1] + config.patch_size - 1) / config.patch_size); - auto padded = finish_rope_pe(Rope::gen_z_image_pe( + auto padded = finish_rope_pe(Rope::gen_z_image_pe( static_cast(x->ne[1]), static_cast(x->ne[0]), config.patch_size, 1, static_cast(n_txt), ZImage::SEQ_MULTI_OF, {}, Rope::RefIndexMode::FIXED, config.theta, config.axes_dim)); diff --git a/src/model/diffusion/minimax_h3.hpp b/src/model/diffusion/minimax_h3.hpp index 3e8f0fd8..e93c70f3 100644 --- a/src/model/diffusion/minimax_h3.hpp +++ b/src/model/diffusion/minimax_h3.hpp @@ -235,9 +235,9 @@ namespace MiniMaxH3 { blocks["norm1"] = std::make_shared(config.hidden_size, config.norm_eps); blocks["norm2"] = std::make_shared(config.hidden_size, config.norm_eps); blocks["attn"] = std::make_shared(config.hidden_size, - config.num_attention_heads, - config.attention_head_dim, - config.qk_norm_eps); + config.num_attention_heads, + config.attention_head_dim, + config.qk_norm_eps); blocks["mlp"] = std::make_shared(config.hidden_size, config.ffn_hidden_size); } @@ -392,11 +392,11 @@ namespace MiniMaxH3 { blocks["norm1"] = std::make_shared(config.hidden_size, config.norm_eps); blocks["norm2"] = std::make_shared(config.hidden_size, config.norm_eps); blocks["attn"] = std::make_shared(config.hidden_size, - config.num_attention_heads, - config.attention_head_dim, - config.qk_norm_eps); + config.num_attention_heads, + config.attention_head_dim, + config.qk_norm_eps); blocks["mlp"] = std::make_shared(config.hidden_size, - config.ffn_hidden_size); + config.ffn_hidden_size); blocks["adaln_proj"] = std::make_shared(config.time_embed_dim, config.hidden_size, 6, @@ -483,8 +483,8 @@ namespace MiniMaxH3 { auto row = modulation_row(ctx->ggml_ctx, mods, config.hidden_size, 2, 1, segment.modulation_row); auto value = norm->forward(ctx, ggml_ext_slice(ctx->ggml_ctx, x, 1, segment.start, segment.end)); return ggml_add(ctx->ggml_ctx, - ggml_add(ctx->ggml_ctx, value, ggml_mul(ctx->ggml_ctx, value, row[1])), - row[0]); + ggml_add(ctx->ggml_ctx, value, ggml_mul(ctx->ggml_ctx, value, row[1])), + row[0]); }; return {video_out->forward(ctx, apply(video)), audio_out->forward(ctx, apply(audio))}; @@ -847,10 +847,10 @@ namespace MiniMaxH3 { const auto& condition = condition_videos[index]; auto axes = condition_spatial_axes(condition); int64_t count = condition.shape()[2] * - static_cast(axes.first.size() * axes.second.size()); - bool is_first = keyframe_indices.empty() || keyframe_indices[static_cast(index)] == 0; - float keyframe_t = is_first ? static_cast(text_len) - : static_cast(text_len) + video_duration - FRAME_RESCALE; + static_cast(axes.first.size() * axes.second.size()); + bool is_first = keyframe_indices.empty() || keyframe_indices[static_cast(index)] == 0; + float keyframe_t = is_first ? static_cast(text_len) + : static_cast(text_len) + video_duration - FRAME_RESCALE; for (int64_t t = 0; t < condition.shape()[2]; ++t) { for (float h : axes.first) { for (float w : axes.second) { @@ -904,9 +904,9 @@ namespace MiniMaxH3 { if (block.kind != MiniMaxH3ReferenceKind::AUDIO) { GGML_ASSERT(ref_video != nullptr); - auto axes = condition_spatial_axes(*ref_video); - int64_t count = ref_video->shape()[2] * - static_cast(axes.first.size() * axes.second.size()); + auto axes = condition_spatial_axes(*ref_video); + int64_t count = ref_video->shape()[2] * + static_cast(axes.first.size() * axes.second.size()); float video_end = append_video_positions(*ref_video, cursor); layout.sequence_segments.push_back({row, row + count, diff --git a/src/model/diffusion/pid.hpp b/src/model/diffusion/pid.hpp index 6edc8342..8aa9dc16 100644 --- a/src/model/diffusion/pid.hpp +++ b/src/model/diffusion/pid.hpp @@ -644,7 +644,7 @@ namespace Pid { int64_t effective_down_factor = config.lq_latent_down_factor / unpatchify_factor; float z_to_patch_ratio = static_cast(config.lq_sr_scale * effective_down_factor) / - static_cast(config.patch_size); + static_cast(config.patch_size); GGML_ASSERT(z_to_patch_ratio >= 1.0f); if (lq_latent->ne[0] != target_pW || lq_latent->ne[1] != target_pH) { lq_latent = ggml_interpolate(ctx->ggml_ctx, diff --git a/src/model/diffusion/pixart.hpp b/src/model/diffusion/pixart.hpp index cc062919..c7e29b78 100644 --- a/src/model/diffusion/pixart.hpp +++ b/src/model/diffusion/pixart.hpp @@ -224,9 +224,9 @@ namespace PixArt { PixArtModel(const PixArtConfig& config) : config(config) { blocks["x_embedder.proj"] = std::make_shared(config.in_channels, - config.hidden_size, - std::pair{static_cast(config.patch_size), static_cast(config.patch_size)}, - std::pair{static_cast(config.patch_size), static_cast(config.patch_size)}); + config.hidden_size, + std::pair{static_cast(config.patch_size), static_cast(config.patch_size)}, + std::pair{static_cast(config.patch_size), static_cast(config.patch_size)}); blocks["t_embedder"] = std::make_shared(ADALN_EMBED_DIM, config.hidden_size); blocks["t_block.1"] = std::make_shared(config.hidden_size, 6 * config.hidden_size); blocks["y_embedder.y_proj.fc1"] = std::make_shared(config.caption_channels, config.hidden_size); @@ -237,7 +237,7 @@ namespace PixArt { } blocks["final_layer.norm_final"] = std::make_shared(config.hidden_size, 1e-6f, false); blocks["final_layer.linear"] = std::make_shared(config.hidden_size, - config.patch_size * config.patch_size * config.out_channels); + config.patch_size * config.patch_size * config.out_channels); } ggml_tensor* forward(GGMLRunnerContext* ctx, diff --git a/src/model/diffusion/qwen_image_2_1.hpp b/src/model/diffusion/qwen_image_2_1.hpp index 1d37d6af..ec434773 100644 --- a/src/model/diffusion/qwen_image_2_1.hpp +++ b/src/model/diffusion/qwen_image_2_1.hpp @@ -486,8 +486,8 @@ namespace Qwen { } QwenImage21PrefixCache cache; if (prefix_cache_enabled && !prefix_cache_disabled && extra != nullptr && extra->prefix_id != 0 && layout.prefix_length > 0) { - cache.name = "qwen_image_2_1.prefix." + std::to_string(extra->prefix_id) + - ".circular." + std::to_string(circular_x_enabled) + std::to_string(circular_y_enabled); + cache.name = "qwen_image_2_1.prefix." + std::to_string(extra->prefix_id) + + ".circular." + std::to_string(circular_x_enabled) + std::to_string(circular_y_enabled); cache.prefix_length = layout.prefix_length; if (prefix_cache_type != GGML_TYPE_COUNT) { cache.type = prefix_cache_type; @@ -536,7 +536,7 @@ namespace Qwen { auto build = [&]() { auto graph = new_graph_custom(QWEN_IMAGE_GRAPH_SIZE * 2); auto pe = ggml_new_tensor_4d(compute_ctx, GGML_TYPE_F32, 2, 2, config.head_dim / 2, - layout.positions.size() - (cached ? layout.prefix_length : 0)); + layout.positions.size() - (cached ? layout.prefix_length : 0)); set_backend_tensor_data(pe, pe_data.data()); std::vector masks, ref_inputs; for (const auto& mask : mask_data) { @@ -549,7 +549,7 @@ namespace Qwen { } auto ctx = get_context(graph); auto out = model.forward(&ctx, make_input(x), make_input(*inputs.timesteps), cached ? nullptr : make_input(context), - ref_inputs, pe, layout, masks, checked_cache); + ref_inputs, pe, layout, masks, checked_cache); if (!flash_attn_used) { return static_cast(nullptr); } diff --git a/src/model/diffusion/sensenova_u1.h b/src/model/diffusion/sensenova_u1.h index 1702ed85..302df6b2 100644 --- a/src/model/diffusion/sensenova_u1.h +++ b/src/model/diffusion/sensenova_u1.h @@ -563,7 +563,7 @@ namespace SenseNovaU1 { blocks["language_model.model"] = std::make_shared(config); blocks["fm_modules.vision_model_mot_gen.embeddings"] = std::make_shared(config); blocks["fm_modules.timestep_embedder"] = std::make_shared(config.hidden_size, - config.timestep_embedding_size); + config.timestep_embedding_size); if (config.add_noise_scale_embedding) { blocks["fm_modules.noise_scale_embedder"] = std::make_shared(config.hidden_size, config.timestep_embedding_size); diff --git a/src/model/integrations/anima.cpp b/src/model/integrations/anima.cpp index 0c4600e7..2f9b2bab 100644 --- a/src/model/integrations/anima.cpp +++ b/src/model/integrations/anima.cpp @@ -9,13 +9,13 @@ static bool build_anima(const sd::model_builders::Context& ctx, const TokenizerC const auto version = ctx.version; const auto& weight_manager = ctx.weight_manager; result.conditioner = std::make_shared(ctx.backends.runtime_backend(SDBackendModule::TE), - tensor_storage_map, - weight_manager, - tokenizers); + tensor_storage_map, + weight_manager, + tokenizers); result.diffusion = std::make_shared(ctx.backends.runtime_backend(SDBackendModule::DIFFUSION), - tensor_storage_map, - "model.diffusion_model", - weight_manager); + tensor_storage_map, + "model.diffusion_model", + weight_manager); return true; } diff --git a/src/model/integrations/boogu_image.cpp b/src/model/integrations/boogu_image.cpp index 616cab2f..3d6e8c06 100644 --- a/src/model/integrations/boogu_image.cpp +++ b/src/model/integrations/boogu_image.cpp @@ -9,17 +9,17 @@ static bool build_boogu_image(const sd::model_builders::Context& ctx, const Toke const auto version = ctx.version; const auto& weight_manager = ctx.weight_manager; result.conditioner = std::make_shared(ctx.backends.runtime_backend(SDBackendModule::TE), - tensor_storage_map, - version, - "", - true, - weight_manager, - tokenizers); + tensor_storage_map, + version, + "", + true, + weight_manager, + tokenizers); result.diffusion = std::make_shared(ctx.backends.runtime_backend(SDBackendModule::DIFFUSION), - tensor_storage_map, - "model.diffusion_model", - version, - weight_manager); + tensor_storage_map, + "model.diffusion_model", + version, + weight_manager); return true; } diff --git a/src/model/integrations/ernie_image.cpp b/src/model/integrations/ernie_image.cpp index 65d431fc..f1d185cd 100644 --- a/src/model/integrations/ernie_image.cpp +++ b/src/model/integrations/ernie_image.cpp @@ -9,16 +9,16 @@ static bool build_ernie_image(const sd::model_builders::Context& ctx, const Toke const auto version = ctx.version; const auto& weight_manager = ctx.weight_manager; result.conditioner = std::make_shared(ctx.backends.runtime_backend(SDBackendModule::TE), - tensor_storage_map, - version, - "", - false, - weight_manager, - tokenizers); + tensor_storage_map, + version, + "", + false, + weight_manager, + tokenizers); result.diffusion = std::make_shared(ctx.backends.runtime_backend(SDBackendModule::DIFFUSION), - tensor_storage_map, - "model.diffusion_model", - weight_manager); + tensor_storage_map, + "model.diffusion_model", + weight_manager); return true; } diff --git a/src/model/integrations/fibo2.cpp b/src/model/integrations/fibo2.cpp index 15cfaf72..d16a0cf8 100644 --- a/src/model/integrations/fibo2.cpp +++ b/src/model/integrations/fibo2.cpp @@ -10,9 +10,9 @@ static bool build_fibo2(const sd::model_builders::Context& ctx, const TokenizerC const auto version = ctx.version; const auto& weight_manager = ctx.weight_manager; result.conditioner = std::make_shared(ctx.backends.runtime_backend(SDBackendModule::TE), - tensor_storage_map, weight_manager, tokenizers); + tensor_storage_map, weight_manager, tokenizers); result.diffusion = std::make_shared(ctx.backends.runtime_backend(SDBackendModule::DIFFUSION), - tensor_storage_map, "model.diffusion_model", weight_manager); + tensor_storage_map, "model.diffusion_model", weight_manager); return true; } diff --git a/src/model/integrations/flux2.cpp b/src/model/integrations/flux2.cpp index a868edd9..d895df2e 100644 --- a/src/model/integrations/flux2.cpp +++ b/src/model/integrations/flux2.cpp @@ -11,18 +11,18 @@ static bool build_flux2(const sd::model_builders::Context& ctx, const TokenizerC const auto& weight_manager = ctx.weight_manager; bool is_chroma = false; result.conditioner = std::make_shared(ctx.backends.runtime_backend(SDBackendModule::TE), - tensor_storage_map, - version, - "", - false, - weight_manager, - tokenizers); + tensor_storage_map, + version, + "", + false, + weight_manager, + tokenizers); result.diffusion = std::make_shared(ctx.backends.runtime_backend(SDBackendModule::DIFFUSION), - tensor_storage_map, - "model.diffusion_model", - version, - weight_manager, - sd_ctx_params->model_args); + tensor_storage_map, + "model.diffusion_model", + version, + weight_manager, + sd_ctx_params->model_args); return true; } diff --git a/src/model/integrations/flux3.cpp b/src/model/integrations/flux3.cpp index cccb38ea..9ee8d3db 100644 --- a/src/model/integrations/flux3.cpp +++ b/src/model/integrations/flux3.cpp @@ -9,9 +9,9 @@ static bool build_flux3(const sd::model_builders::Context& ctx, const TokenizerC const auto version = ctx.version; const auto& weight_manager = ctx.weight_manager; result.conditioner = std::make_shared(ctx.backends.runtime_backend(SDBackendModule::TE), - tensor_storage_map, version, "", false, weight_manager, tokenizers); + tensor_storage_map, version, "", false, weight_manager, tokenizers); result.diffusion = std::make_shared(ctx.backends.runtime_backend(SDBackendModule::DIFFUSION), - tensor_storage_map, "model.diffusion_model", weight_manager); + tensor_storage_map, "model.diffusion_model", weight_manager); return true; } diff --git a/src/model/integrations/hidream_o1.cpp b/src/model/integrations/hidream_o1.cpp index 0e283e0a..66f6a9fc 100644 --- a/src/model/integrations/hidream_o1.cpp +++ b/src/model/integrations/hidream_o1.cpp @@ -9,13 +9,13 @@ static bool build_hidream_o1(const sd::model_builders::Context& ctx, const Token const auto version = ctx.version; const auto& weight_manager = ctx.weight_manager; result.conditioner = std::make_shared(ctx.backends.runtime_backend(SDBackendModule::TE), - tensor_storage_map, - weight_manager, - tokenizers); + tensor_storage_map, + weight_manager, + tokenizers); result.diffusion = std::make_shared(ctx.backends.runtime_backend(SDBackendModule::DIFFUSION), - tensor_storage_map, - "model", - weight_manager); + tensor_storage_map, + "model", + weight_manager); return true; } diff --git a/src/model/integrations/hunyuan_video.cpp b/src/model/integrations/hunyuan_video.cpp index c90e7616..85bb741f 100644 --- a/src/model/integrations/hunyuan_video.cpp +++ b/src/model/integrations/hunyuan_video.cpp @@ -9,17 +9,17 @@ static bool build_hunyuan_video(const sd::model_builders::Context& ctx, const To const auto version = ctx.version; const auto& weight_manager = ctx.weight_manager; result.conditioner = std::make_shared(ctx.backends.runtime_backend(SDBackendModule::TE), - tensor_storage_map, - version, - "", - false, - weight_manager, - tokenizers); + tensor_storage_map, + version, + "", + false, + weight_manager, + tokenizers); result.diffusion = std::make_shared(ctx.backends.runtime_backend(SDBackendModule::DIFFUSION), - tensor_storage_map, - "model.diffusion_model", - version, - weight_manager); + tensor_storage_map, + "model.diffusion_model", + version, + weight_manager); return true; } diff --git a/src/model/integrations/ideogram4.cpp b/src/model/integrations/ideogram4.cpp index 2b544924..77baef27 100644 --- a/src/model/integrations/ideogram4.cpp +++ b/src/model/integrations/ideogram4.cpp @@ -9,16 +9,16 @@ static bool build_ideogram4(const sd::model_builders::Context& ctx, const Tokeni const auto version = ctx.version; const auto& weight_manager = ctx.weight_manager; result.conditioner = std::make_shared(ctx.backends.runtime_backend(SDBackendModule::TE), - tensor_storage_map, - version, - "", - false, - weight_manager, - tokenizers); + tensor_storage_map, + version, + "", + false, + weight_manager, + tokenizers); result.diffusion = std::make_shared(ctx.backends.runtime_backend(SDBackendModule::DIFFUSION), - tensor_storage_map, - "model.diffusion_model", - weight_manager); + tensor_storage_map, + "model.diffusion_model", + weight_manager); return true; } diff --git a/src/model/integrations/iris.cpp b/src/model/integrations/iris.cpp index 9414efc7..a75c88ca 100644 --- a/src/model/integrations/iris.cpp +++ b/src/model/integrations/iris.cpp @@ -9,9 +9,9 @@ static bool build_iris(const sd::model_builders::Context& ctx, const TokenizerCo const auto version = ctx.version; const auto& weight_manager = ctx.weight_manager; result.conditioner = std::make_shared(ctx.backends.runtime_backend(SDBackendModule::TE), - tensor_storage_map, version, "", false, weight_manager, tokenizers); + tensor_storage_map, version, "", false, weight_manager, tokenizers); result.diffusion = std::make_shared(ctx.backends.runtime_backend(SDBackendModule::DIFFUSION), - tensor_storage_map, "model.diffusion_model", weight_manager); + tensor_storage_map, "model.diffusion_model", weight_manager); return true; } diff --git a/src/model/integrations/krea2.cpp b/src/model/integrations/krea2.cpp index f492b7c4..36704453 100644 --- a/src/model/integrations/krea2.cpp +++ b/src/model/integrations/krea2.cpp @@ -9,16 +9,16 @@ static bool build_krea2(const sd::model_builders::Context& ctx, const TokenizerC const auto version = ctx.version; const auto& weight_manager = ctx.weight_manager; result.conditioner = std::make_shared(ctx.backends.runtime_backend(SDBackendModule::TE), - tensor_storage_map, - version, - "", - true, - weight_manager, - tokenizers); + tensor_storage_map, + version, + "", + true, + weight_manager, + tokenizers); result.diffusion = std::make_shared(ctx.backends.runtime_backend(SDBackendModule::DIFFUSION), - tensor_storage_map, - "model.diffusion_model", - weight_manager); + tensor_storage_map, + "model.diffusion_model", + weight_manager); return true; } diff --git a/src/model/integrations/lens.cpp b/src/model/integrations/lens.cpp index d2f50264..da66d2cd 100644 --- a/src/model/integrations/lens.cpp +++ b/src/model/integrations/lens.cpp @@ -9,16 +9,16 @@ static bool build_lens(const sd::model_builders::Context& ctx, const TokenizerCo const auto version = ctx.version; const auto& weight_manager = ctx.weight_manager; result.conditioner = std::make_shared(ctx.backends.runtime_backend(SDBackendModule::TE), - tensor_storage_map, - version, - "", - false, - weight_manager, - tokenizers); + tensor_storage_map, + version, + "", + false, + weight_manager, + tokenizers); result.diffusion = std::make_shared(ctx.backends.runtime_backend(SDBackendModule::DIFFUSION), - tensor_storage_map, - "model.diffusion_model", - weight_manager); + tensor_storage_map, + "model.diffusion_model", + weight_manager); return true; } diff --git a/src/model/integrations/lingbot_video.cpp b/src/model/integrations/lingbot_video.cpp index bafa75e8..d4cc6cc5 100644 --- a/src/model/integrations/lingbot_video.cpp +++ b/src/model/integrations/lingbot_video.cpp @@ -23,10 +23,10 @@ static bool build_lingbot_video(const sd::model_builders::Context& ctx, const To weight_manager, tokenizers); result.diffusion = std::make_shared(ctx.backends.runtime_backend(SDBackendModule::DIFFUSION), - tensor_storage_map, - "model.diffusion_model", - weight_manager, - sd_ctx_params->model_args); + tensor_storage_map, + "model.diffusion_model", + weight_manager, + sd_ctx_params->model_args); return true; } diff --git a/src/model/integrations/llada_image.cpp b/src/model/integrations/llada_image.cpp index 2770ba69..58c47e8f 100644 --- a/src/model/integrations/llada_image.cpp +++ b/src/model/integrations/llada_image.cpp @@ -9,17 +9,17 @@ static bool build_llada_image(const sd::model_builders::Context& ctx, const Toke const auto version = ctx.version; const auto& weight_manager = ctx.weight_manager; result.conditioner = std::make_shared(ctx.backends.runtime_backend(SDBackendModule::TE), - tensor_storage_map, - "text_encoders.llm", - "queryformer", - "text_projection", - "sigvq", - weight_manager, - tokenizers); + tensor_storage_map, + "text_encoders.llm", + "queryformer", + "text_projection", + "sigvq", + weight_manager, + tokenizers); result.diffusion = std::make_shared(ctx.backends.runtime_backend(SDBackendModule::DIFFUSION), - tensor_storage_map, - "model.diffusion_model", - weight_manager); + tensor_storage_map, + "model.diffusion_model", + weight_manager); return true; } diff --git a/src/model/integrations/longcat.cpp b/src/model/integrations/longcat.cpp index e1141f29..d371710c 100644 --- a/src/model/integrations/longcat.cpp +++ b/src/model/integrations/longcat.cpp @@ -9,18 +9,18 @@ static bool build_longcat(const sd::model_builders::Context& ctx, const Tokenize const auto version = ctx.version; const auto& weight_manager = ctx.weight_manager; result.conditioner = std::make_shared(ctx.backends.runtime_backend(SDBackendModule::TE), - tensor_storage_map, - version, - "", - true, - weight_manager, - tokenizers); + tensor_storage_map, + version, + "", + true, + weight_manager, + tokenizers); result.diffusion = std::make_shared(ctx.backends.runtime_backend(SDBackendModule::DIFFUSION), - tensor_storage_map, - "model.diffusion_model", - version, - weight_manager, - sd_ctx_params->model_args); + tensor_storage_map, + "model.diffusion_model", + version, + weight_manager, + sd_ctx_params->model_args); return true; } diff --git a/src/model/integrations/ltxav.cpp b/src/model/integrations/ltxav.cpp index 9be11321..99952392 100644 --- a/src/model/integrations/ltxav.cpp +++ b/src/model/integrations/ltxav.cpp @@ -9,15 +9,15 @@ static bool build_ltxav(const sd::model_builders::Context& ctx, const TokenizerC const auto version = ctx.version; const auto& weight_manager = ctx.weight_manager; result.conditioner = std::make_shared(ctx.backends.runtime_backend(SDBackendModule::TE), - tensor_storage_map, - "text_encoders.llm", - "text_embedding_projection", - weight_manager, - tokenizers); + tensor_storage_map, + "text_encoders.llm", + "text_embedding_projection", + weight_manager, + tokenizers); result.diffusion = std::make_shared(ctx.backends.runtime_backend(SDBackendModule::DIFFUSION), - tensor_storage_map, - "model.diffusion_model", - weight_manager); + tensor_storage_map, + "model.diffusion_model", + weight_manager); return true; } diff --git a/src/model/integrations/mage_flow.cpp b/src/model/integrations/mage_flow.cpp index 68ec704e..000fa157 100644 --- a/src/model/integrations/mage_flow.cpp +++ b/src/model/integrations/mage_flow.cpp @@ -9,16 +9,16 @@ static bool build_mage_flow(const sd::model_builders::Context& ctx, const Tokeni const auto version = ctx.version; const auto& weight_manager = ctx.weight_manager; result.conditioner = std::make_shared(ctx.backends.runtime_backend(SDBackendModule::TE), - tensor_storage_map, - version, - "", - true, - weight_manager, - tokenizers); + tensor_storage_map, + version, + "", + true, + weight_manager, + tokenizers); result.diffusion = std::make_shared(ctx.backends.runtime_backend(SDBackendModule::DIFFUSION), - tensor_storage_map, - "model.diffusion_model", - weight_manager); + tensor_storage_map, + "model.diffusion_model", + weight_manager); return true; } diff --git a/src/model/integrations/ming_image.cpp b/src/model/integrations/ming_image.cpp index 31c69f94..8587df8c 100644 --- a/src/model/integrations/ming_image.cpp +++ b/src/model/integrations/ming_image.cpp @@ -9,9 +9,9 @@ static bool build_ming_image(const sd::model_builders::Context& ctx, const Token const auto version = ctx.version; const auto& weight_manager = ctx.weight_manager; result.conditioner = std::make_shared(ctx.backends.runtime_backend(SDBackendModule::TE), - tensor_storage_map, weight_manager, tokenizers); + tensor_storage_map, weight_manager, tokenizers); result.diffusion = std::make_shared(ctx.backends.runtime_backend(SDBackendModule::DIFFUSION), - tensor_storage_map, "model.diffusion_model", weight_manager); + tensor_storage_map, "model.diffusion_model", weight_manager); return true; } diff --git a/src/model/integrations/minimax_h3.cpp b/src/model/integrations/minimax_h3.cpp index bc023f68..2569b626 100644 --- a/src/model/integrations/minimax_h3.cpp +++ b/src/model/integrations/minimax_h3.cpp @@ -9,16 +9,16 @@ static bool build_minimax_h3(const sd::model_builders::Context& ctx, const Token const auto version = ctx.version; const auto& weight_manager = ctx.weight_manager; result.conditioner = std::make_shared(ctx.backends.runtime_backend(SDBackendModule::TE), - tensor_storage_map, - version, - "", - true, - weight_manager, - tokenizers); + tensor_storage_map, + version, + "", + true, + weight_manager, + tokenizers); result.diffusion = std::make_shared(ctx.backends.runtime_backend(SDBackendModule::DIFFUSION), - tensor_storage_map, - "model.diffusion_model", - weight_manager); + tensor_storage_map, + "model.diffusion_model", + weight_manager); return true; } diff --git a/src/model/integrations/minit2i.cpp b/src/model/integrations/minit2i.cpp index 96cb1d4c..fb305943 100644 --- a/src/model/integrations/minit2i.cpp +++ b/src/model/integrations/minit2i.cpp @@ -9,12 +9,12 @@ static bool build_minit2i(const sd::model_builders::Context& ctx, const Tokenize const auto version = ctx.version; const auto& weight_manager = ctx.weight_manager; result.conditioner = std::make_shared(ctx.backends.runtime_backend(SDBackendModule::TE), - tensor_storage_map, - weight_manager); + tensor_storage_map, + weight_manager); result.diffusion = std::make_shared(ctx.backends.runtime_backend(SDBackendModule::DIFFUSION), - tensor_storage_map, - "model.diffusion_model.model.net", - weight_manager); + tensor_storage_map, + "model.diffusion_model.model.net", + weight_manager); return true; } diff --git a/src/model/integrations/moss_image.cpp b/src/model/integrations/moss_image.cpp index 63921058..4a85d169 100644 --- a/src/model/integrations/moss_image.cpp +++ b/src/model/integrations/moss_image.cpp @@ -11,7 +11,7 @@ static bool build_moss_image(const sd::model_builders::Context& ctx, ctx.tensor_storage_map, ctx.version, "", false, ctx.weight_manager, tokenizers); runners.diffusion = std::make_shared(ctx.backends.runtime_backend(SDBackendModule::DIFFUSION), - ctx.tensor_storage_map, "model.diffusion_model", ctx.weight_manager); + ctx.tensor_storage_map, "model.diffusion_model", ctx.weight_manager); return true; } diff --git a/src/model/integrations/pid.cpp b/src/model/integrations/pid.cpp index 93145d15..d307fb6b 100644 --- a/src/model/integrations/pid.cpp +++ b/src/model/integrations/pid.cpp @@ -9,16 +9,16 @@ static bool build_pid(const sd::model_builders::Context& ctx, const TokenizerCon const auto version = ctx.version; const auto& weight_manager = ctx.weight_manager; result.conditioner = std::make_shared(ctx.backends.runtime_backend(SDBackendModule::TE), - tensor_storage_map, - version, - "", - false, - weight_manager, - tokenizers); + tensor_storage_map, + version, + "", + false, + weight_manager, + tokenizers); result.diffusion = std::make_shared(ctx.backends.runtime_backend(SDBackendModule::DIFFUSION), - tensor_storage_map, - "model.diffusion_model.net", - weight_manager); + tensor_storage_map, + "model.diffusion_model.net", + weight_manager); return true; } diff --git a/src/model/integrations/pixart.cpp b/src/model/integrations/pixart.cpp index 199c76ce..d0a4aa70 100644 --- a/src/model/integrations/pixart.cpp +++ b/src/model/integrations/pixart.cpp @@ -31,17 +31,17 @@ static bool build_pixart(const sd::model_builders::Context& ctx, const Tokenizer const auto version = ctx.version; const auto& weight_manager = ctx.weight_manager; result.conditioner = std::make_shared(ctx.backends.runtime_backend(SDBackendModule::TE), - tensor_storage_map, - true, - 0, - false, - weight_manager, - sd_ctx_params->model_args); + tensor_storage_map, + true, + 0, + false, + weight_manager, + sd_ctx_params->model_args); result.diffusion = std::make_shared(ctx.backends.runtime_backend(SDBackendModule::DIFFUSION), - tensor_storage_map, - "model.diffusion_model", - weight_manager, - sd_ctx_params->model_args); + tensor_storage_map, + "model.diffusion_model", + weight_manager, + sd_ctx_params->model_args); return true; } diff --git a/src/model/integrations/qwen_image.cpp b/src/model/integrations/qwen_image.cpp index 5c37fb1b..49505bb7 100644 --- a/src/model/integrations/qwen_image.cpp +++ b/src/model/integrations/qwen_image.cpp @@ -11,12 +11,12 @@ static bool build_qwen_image(const sd::model_builders::Context& ctx, const Token const auto& weight_manager = ctx.weight_manager; bool enable_vision = version != VERSION_QWEN_IMAGE_LAYERED; result.conditioner = std::make_shared(ctx.backends.runtime_backend(SDBackendModule::TE), - tensor_storage_map, - version, - "", - enable_vision, - weight_manager, - tokenizers); + tensor_storage_map, + version, + "", + enable_vision, + weight_manager, + tokenizers); if (version == VERSION_QWEN_IMAGE_2_1) { result.diffusion = std::make_shared(ctx.backends.runtime_backend(SDBackendModule::DIFFUSION), tensor_storage_map, diff --git a/src/model/integrations/sd.cpp b/src/model/integrations/sd.cpp index f85c4449..a36ff8e3 100644 --- a/src/model/integrations/sd.cpp +++ b/src/model/integrations/sd.cpp @@ -34,10 +34,10 @@ static bool build_sd(const sd::model_builders::Context& ctx, const TokenizerConf weight_manager, tokenizers); result.diffusion = std::make_shared(ctx.backends.runtime_backend(SDBackendModule::DIFFUSION), - tensor_storage_map, - "model.diffusion_model", - version, - weight_manager); + tensor_storage_map, + "model.diffusion_model", + version, + weight_manager); return true; } static prediction_t detect_sdxl_prediction(const String2TensorStorage& weights) { diff --git a/src/model/integrations/sd3.cpp b/src/model/integrations/sd3.cpp index 519a6804..f9c2ad78 100644 --- a/src/model/integrations/sd3.cpp +++ b/src/model/integrations/sd3.cpp @@ -9,13 +9,13 @@ static bool build_sd3(const sd::model_builders::Context& ctx, const TokenizerCon const auto version = ctx.version; const auto& weight_manager = ctx.weight_manager; result.conditioner = std::make_shared(ctx.backends.runtime_backend(SDBackendModule::TE), - tensor_storage_map, - weight_manager, - tokenizers); + tensor_storage_map, + weight_manager, + tokenizers); result.diffusion = std::make_shared(ctx.backends.runtime_backend(SDBackendModule::DIFFUSION), - tensor_storage_map, - "model.diffusion_model", - weight_manager); + tensor_storage_map, + "model.diffusion_model", + weight_manager); return true; } diff --git a/src/model/integrations/sensenova_u1.cpp b/src/model/integrations/sensenova_u1.cpp index 75acce02..900f222e 100644 --- a/src/model/integrations/sensenova_u1.cpp +++ b/src/model/integrations/sensenova_u1.cpp @@ -10,9 +10,9 @@ static bool build_sensenova_u1(const sd::model_builders::Context& ctx, const Tok const auto& weight_manager = ctx.weight_manager; result.conditioner = std::make_shared(); result.diffusion = std::make_shared(ctx.backends.runtime_backend(SDBackendModule::DIFFUSION), - tensor_storage_map, - "", - weight_manager); + tensor_storage_map, + "", + weight_manager); return true; } diff --git a/src/model/integrations/wan.cpp b/src/model/integrations/wan.cpp index f0e5216e..2daada29 100644 --- a/src/model/integrations/wan.cpp +++ b/src/model/integrations/wan.cpp @@ -10,16 +10,16 @@ static bool build_wan(const sd::model_builders::Context& ctx, const TokenizerCon const auto version = ctx.version; const auto& weight_manager = ctx.weight_manager; result.conditioner = std::make_shared(ctx.backends.runtime_backend(SDBackendModule::TE), - tensor_storage_map, - true, - 0, - true, - weight_manager); + tensor_storage_map, + true, + 0, + true, + weight_manager); result.diffusion = std::make_shared(ctx.backends.runtime_backend(SDBackendModule::DIFFUSION), - tensor_storage_map, - "model.diffusion_model", - version, - weight_manager); + tensor_storage_map, + "model.diffusion_model", + version, + weight_manager); if (strlen(SAFE_STR(sd_ctx_params->high_noise_diffusion_model_path)) > 0) { result.high_noise_diffusion = std::make_shared(ctx.backends.runtime_backend(SDBackendModule::DIFFUSION), tensor_storage_map, diff --git a/src/model/integrations/z_image.cpp b/src/model/integrations/z_image.cpp index 3ba31bfd..29054d47 100644 --- a/src/model/integrations/z_image.cpp +++ b/src/model/integrations/z_image.cpp @@ -9,17 +9,17 @@ static bool build_z_image(const sd::model_builders::Context& ctx, const Tokenize const auto version = ctx.version; const auto& weight_manager = ctx.weight_manager; result.conditioner = std::make_shared(ctx.backends.runtime_backend(SDBackendModule::TE), - tensor_storage_map, - version, - "", - false, - weight_manager, - tokenizers); + tensor_storage_map, + version, + "", + false, + weight_manager, + tokenizers); result.diffusion = std::make_shared(ctx.backends.runtime_backend(SDBackendModule::DIFFUSION), - tensor_storage_map, - "model.diffusion_model", - version, - weight_manager); + tensor_storage_map, + "model.diffusion_model", + version, + weight_manager); return true; } diff --git a/src/model/integrations/z_image_l2p.cpp b/src/model/integrations/z_image_l2p.cpp index 5ba88dcc..d8104f85 100644 --- a/src/model/integrations/z_image_l2p.cpp +++ b/src/model/integrations/z_image_l2p.cpp @@ -9,16 +9,16 @@ static bool build_z_image_l2p(const sd::model_builders::Context& ctx, const Toke const auto version = ctx.version; const auto& weight_manager = ctx.weight_manager; result.conditioner = std::make_shared(ctx.backends.runtime_backend(SDBackendModule::TE), - tensor_storage_map, - version, - "", - false, - weight_manager, - tokenizers); + tensor_storage_map, + version, + "", + false, + weight_manager, + tokenizers); result.diffusion = std::make_shared(ctx.backends.runtime_backend(SDBackendModule::DIFFUSION), - tensor_storage_map, - "model.diffusion_model", - weight_manager); + tensor_storage_map, + "model.diffusion_model", + weight_manager); return true; } diff --git a/src/model/te/llada_image_te.hpp b/src/model/te/llada_image_te.hpp index 1c97a452..2da78413 100644 --- a/src/model/te/llada_image_te.hpp +++ b/src/model/te/llada_image_te.hpp @@ -347,8 +347,8 @@ namespace LLaDAImageTE { blocks["visual.blocks." + std::to_string(i)] = std::make_shared(config); } blocks["vqmodel.quant_conv"] = std::make_shared(config.hidden_size, - config.codebook_embed_dim, - std::make_pair(1, 1)); + config.codebook_embed_dim, + std::make_pair(1, 1)); blocks["prior_projector.net.0.proj"] = std::make_shared(config.semantic_embed_dim, config.semantic_embed_dim, true); blocks["prior_projector.net.2"] = std::make_shared(config.semantic_embed_dim, config.semantic_embed_dim, true); } diff --git a/src/model/vae/ltx_audio_vae.hpp b/src/model/vae/ltx_audio_vae.hpp index 97c43414..a05ce86a 100644 --- a/src/model/vae/ltx_audio_vae.hpp +++ b/src/model/vae/ltx_audio_vae.hpp @@ -1087,9 +1087,9 @@ namespace LTXV { auto& tensor_storage_map = model_loader.get_tensor_storage_map(); auto ltx_audio_vae = std::make_shared(backend, - tensor_storage_map, - prefix, - model_manager); + tensor_storage_map, + prefix, + model_manager); if (!model_manager->set_loader(std::move(model_loader)) || !model_manager->register_runner_params(ModelComponent::AudioVAE, diff --git a/src/model/vae/ltx_vae.hpp b/src/model/vae/ltx_vae.hpp index f680f200..3fa42a16 100644 --- a/src/model/vae/ltx_vae.hpp +++ b/src/model/vae/ltx_vae.hpp @@ -497,12 +497,12 @@ namespace LTXVAE { GGML_ASSERT(out_channels % factor == 0); blocks["conv"] = std::make_shared(in_channels, - out_channels / factor, - 3, - std::tuple{1, 1, 1}, - 1, - true, - force_conv_prec_f32); + out_channels / factor, + 3, + std::tuple{1, 1, 1}, + 1, + true, + force_conv_prec_f32); blocks["skip_downsample"] = std::make_shared(in_channels, out_channels, factor_t, factor_s); blocks["conv_downsample"] = std::make_shared(out_channels / factor, out_channels, factor_t, factor_s); } @@ -1077,11 +1077,11 @@ namespace LTXVAE { patch_size); } blocks["decoder"] = std::make_shared(version, - tensor_storage_map, - prefix, - patch_size, - false, - timestep_conditioning); + tensor_storage_map, + prefix, + patch_size, + false, + timestep_conditioning); blocks["per_channel_statistics"] = std::make_shared(); } diff --git a/src/model/vae/minimax_h3_audio_vae.hpp b/src/model/vae/minimax_h3_audio_vae.hpp index 59c30a27..02829a4d 100644 --- a/src/model/vae/minimax_h3_audio_vae.hpp +++ b/src/model/vae/minimax_h3_audio_vae.hpp @@ -76,10 +76,10 @@ namespace MiniMaxH3 { blocks["block.2"] = std::make_shared(in_channels, 9); blocks["block.3"] = std::make_shared(in_channels); blocks["block.4"] = std::make_shared(in_channels, - out_channels, - 2 * stride, - stride, - static_cast(std::ceil(stride / 2.f))); + out_channels, + 2 * stride, + stride, + static_cast(std::ceil(stride / 2.f))); } ggml_tensor* forward(GGMLRunnerContext* ctx, ggml_tensor* x) { @@ -300,12 +300,12 @@ namespace MiniMaxH3 { } blocks["activation_post"] = std::make_shared(channels); blocks["conv_post"] = std::make_shared(channels, - 1, - 7, - 1, - 3, - 1, - false); + 1, + 7, + 1, + 3, + 1, + false); } ggml_tensor* forward(GGMLRunnerContext* ctx, ggml_tensor* x) { diff --git a/src/model/vae/minimax_h3_vae.hpp b/src/model/vae/minimax_h3_vae.hpp index 98cf19c1..d397a40d 100644 --- a/src/model/vae/minimax_h3_vae.hpp +++ b/src/model/vae/minimax_h3_vae.hpp @@ -449,8 +449,8 @@ namespace MiniMaxH3VAE { MiniMaxH3VideoVAE() { blocks["encoder"] = std::make_shared(); blocks["quant_conv"] = std::make_shared(48, - 48, - std::tuple{1, 1, 1}); + 48, + std::tuple{1, 1, 1}); blocks["post_quant_conv"] = std::make_shared(24, 24, std::tuple{1, 1, 1}); diff --git a/src/model_loader.cpp b/src/model_loader.cpp index a0f50081..63d681de 100644 --- a/src/model_loader.cpp +++ b/src/model_loader.cpp @@ -340,7 +340,7 @@ bool ModelLoader::init_from_safetensors_index_file(const std::string& file_path, const auto expected = (std::filesystem::u8path(file_path).parent_path() / std::filesystem::u8path(entry.value().get())) .lexically_normal(); - bool found = false; + bool found = false; for (const auto& shard : parsed_tensor_names_) { if (std::filesystem::u8path(shard.first).lexically_normal() == expected) { found = shard.second.count(entry.key()) != 0; diff --git a/src/model_manager.cpp b/src/model_manager.cpp index 921989df..243811d9 100644 --- a/src/model_manager.cpp +++ b/src/model_manager.cpp @@ -568,7 +568,7 @@ bool ModelManager::stage_tensors_to_compute_backend(const std::vector& states // The temporary runner is destroyed before this manager call returns. auto borrowed_manager = std::shared_ptr(this, [](ModelManager*) {}); auto lora = std::make_shared(id, compute_backend, target->params_backend, - borrowed_manager, lora_spec.file_id, lora_version_, - target->residency_mode); + borrowed_manager, lora_spec.file_id, lora_version_, + target->residency_mode); LoraModel::filter_t lora_tensor_filter = nullptr; if (!lora_spec.tensor_name_prefix_filter.empty()) { @@ -1409,8 +1409,8 @@ bool ModelManager::assign_compute_backend(const std::vector& tenso const bool params_follow_compute = state->params_follow_compute_backend || state->residency_mode == ResidencyMode::Disk; - const bool compute_changes = state->compute_backend != compute_backend; - const bool params_changes = params_follow_compute && state->params_backend != compute_backend; + const bool compute_changes = state->compute_backend != compute_backend; + const bool params_changes = params_follow_compute && state->params_backend != compute_backend; if (!compute_changes && !params_changes) { continue; } @@ -1501,7 +1501,7 @@ size_t ModelManager::compute_backend_resident_bytes(ggml_backend_t compute_backe ? buffer_type != nullptr && ggml_backend_buft_get_device(buffer_type) == compute_device : std::any_of(split_devices->second.begin(), split_devices->second.end(), [&](const auto& entry) { return ggml_backend_get_device(entry.first) == compute_device; - }); + }); if (!on_device) { return; } @@ -1782,10 +1782,10 @@ ModelManager::CapacityCheck ModelManager::check_capacity( const size_t resident = add(weights_resident, add(other_runtime, request.runtime_resident_bytes)); if (log_details) { LOG_WARN("model manager memory on %s: reported free %.2f MB / total %.2f MB, tracked weights %.2f MB / other runtime %.2f MB / current runtime %.2f MB", - ggml_backend_name(backend), - free_bytes / (1024.0 * 1024.0), total_bytes / (1024.0 * 1024.0), - weights_resident / (1024.0 * 1024.0), other_runtime / (1024.0 * 1024.0), - request.runtime_resident_bytes / (1024.0 * 1024.0)); + ggml_backend_name(backend), + free_bytes / (1024.0 * 1024.0), total_bytes / (1024.0 * 1024.0), + weights_resident / (1024.0 * 1024.0), other_runtime / (1024.0 * 1024.0), + request.runtime_resident_bytes / (1024.0 * 1024.0)); } if (free_bytes == 0 && total_bytes == 0) { return SIZE_MAX; @@ -1797,7 +1797,7 @@ ModelManager::CapacityCheck ModelManager::check_capacity( } // A wrapped report may reflect real pressure; reclaim before accepting the tracked estimate. LOG_VERBOSE("ignoring impossible free memory report on %s (%.2f MB free / %.2f MB total), using tracked residency", - ggml_backend_name(backend), free_bytes / (1024.0 * 1024.0), total_bytes / (1024.0 * 1024.0)); + ggml_backend_name(backend), free_bytes / (1024.0 * 1024.0), total_bytes / (1024.0 * 1024.0)); free_bytes = total_bytes; result.requires_reclamation = true; } @@ -1907,9 +1907,9 @@ bool ModelManager::ensure_compute_backend_capacity( } const bool reloadable = state->residency_mode == ResidencyMode::Disk || state->compute_backend != state->params_backend; - const bool resident = state->compute_backend == state->params_backend - ? state->loaded_to_params_backend - : state->staged_to_compute_backend; + const bool resident = state->compute_backend == state->params_backend + ? state->loaded_to_params_backend + : state->staged_to_compute_backend; if (reloadable && resident) { eviction_states.insert(state); } diff --git a/src/pipeline/diffusion_engine.cpp b/src/pipeline/diffusion_engine.cpp index a33d6767..b0dc84b8 100644 --- a/src/pipeline/diffusion_engine.cpp +++ b/src/pipeline/diffusion_engine.cpp @@ -407,7 +407,7 @@ bool StableDiffusionGGML::register_row_split_runner_params(ModelComponent compon size_t free_bytes = 0, total_bytes = 0; ggml_backend_dev_memory(dev, &free_bytes, &total_bytes); int64_t usable_bytes = std::max((int64_t)free_bytes - compute_headroom_bytes, - (int64_t)free_bytes / 8); + (int64_t)free_bytes / 8); tensor_split[reg_index] = usable_bytes > 0 ? (float)((double)usable_bytes / (1024.0 * 1024.0)) : 1.0f; } @@ -511,8 +511,8 @@ bool StableDiffusionGGML::register_layer_split_runner_params(ModelComponent comp model->set_runtime_backends(module_backends); model->set_graph_cut_layer_split_backend_vram_limits(layer_split_vram_limits_for_backends(module_backends)); model->set_graph_cut_layer_split_enabled(true); - const bool params_follow_runtime = backend_manager.params_backend_follows_runtime(module) || - backend_manager.params_backend_is_disk(module); + const bool params_follow_runtime = backend_manager.params_backend_follows_runtime(module) || + backend_manager.params_backend_is_disk(module); ggml_backend_t initial_params_backend = params_follow_runtime ? module_backends[0] : params_backend_for(module); if (initial_params_backend == nullptr) { return false; @@ -1593,8 +1593,8 @@ std::shared_ptr StableDiffusionGGML::load_lora_model(const ModelManag ? ModelManager::ResidencyMode::Disk : ModelManager::ResidencyMode::ParamBackend; auto lora = std::make_shared(lora_log_id(lora_spec), backend_for(module), params_backend_for(module), - model_manager, lora_spec.file_id, version, mode, - backend_manager.params_backend_follows_runtime(module)); + model_manager, lora_spec.file_id, version, mode, + backend_manager.params_backend_follows_runtime(module)); LoraModel::filter_t lora_tensor_filter = module_filter; if (!lora_spec.tensor_name_prefix_filter.empty()) { lora_tensor_filter = [module_filter, prefix = lora_spec.tensor_name_prefix_filter](const std::string& tensor_name) { @@ -2008,11 +2008,11 @@ void StableDiffusionGGML::preview_image(int step, : sd::ops::slice(latents, 2, 0, channels) : latents; if (preview_mode == PREVIEW_PROJ) { - int patch_sz = 1; - const float(*latent_rgb_proj)[3] = nullptr; - float* latent_rgb_bias = nullptr; - const float* latent_alpha_proj = nullptr; - float latent_alpha_bias = 1.f; + int patch_sz = 1; + const float (*latent_rgb_proj)[3] = nullptr; + float* latent_rgb_bias = nullptr; + const float* latent_alpha_proj = nullptr; + float latent_alpha_bias = 1.f; if (channels == 128) { if (sd_version_uses_flux2_vae(version)) { @@ -2294,8 +2294,8 @@ sd::Tensor StableDiffusionGGML::sample(const std::shared_ptris_enabled(); }); - using QwenPrefixInputs = std::tuple*, const sd::Tensor*, - const std::vector>*>; + using QwenPrefixInputs = std::tuple*, const sd::Tensor*, + const std::vector>*>; std::vector qwen_prefix_inputs; RunnerEndOnExit sample_control_runner_end{!control_image.empty() && control_net != nullptr ? control_net.get() : nullptr}; @@ -2596,7 +2596,7 @@ sd::Tensor StableDiffusionGGML::sample(const std::shared_ptr(&diffusion_params.extra); if (extra != nullptr) { auto key = std::make_tuple(diffusion_params.context, extra->image_slots, - diffusion_params.ref_image_params.pass_to_dit ? diffusion_params.ref_latents : nullptr); + diffusion_params.ref_image_params.pass_to_dit ? diffusion_params.ref_latents : nullptr); auto entry = std::find(qwen_prefix_inputs.begin(), qwen_prefix_inputs.end(), key); extra->prefix_id = static_cast(entry - qwen_prefix_inputs.begin()) + 1; if (entry == qwen_prefix_inputs.end()) { diff --git a/src/pipeline/image.cpp b/src/pipeline/image.cpp index 4b5905f0..38ca95c0 100644 --- a/src/pipeline/image.cpp +++ b/src/pipeline/image.cpp @@ -939,10 +939,10 @@ namespace sd::pipeline { } LOG_INFO("hires fix: loading model upscaler from '%s'", request.hires.model_path); hires_upscaler = std::make_unique(sd->n_threads, - false, - request.hires.upscale_tile_size, - sd->backend_spec, - sd->params_backend_spec); + false, + request.hires.upscale_tile_size, + sd->backend_spec, + sd->params_backend_spec); const size_t max_graph_vram_bytes = sd->max_graph_vram_bytes_for_module(SDBackendModule::UPSCALER); hires_upscaler->set_max_graph_vram_bytes(max_graph_vram_bytes); if (!hires_upscaler->load_from_file(request.hires.model_path, diff --git a/src/pipeline/model_builders.cpp b/src/pipeline/model_builders.cpp index 2202314f..b630a72c 100644 --- a/src/pipeline/model_builders.cpp +++ b/src/pipeline/model_builders.cpp @@ -184,12 +184,12 @@ namespace sd::model_builders { weight_manager); } else { auto model = std::make_shared(ctx.backends.runtime_backend(SDBackendModule::VAE), - tensor_storage_map, - "first_stage_model", - false, - false, - vae_version, - weight_manager); + tensor_storage_map, + "first_stage_model", + false, + false, + vae_version, + weight_manager); const auto* definition = find_model_definition(version); if (definition && definition->configure_vae) { definition->configure_vae(ctx, options, *model); diff --git a/src/pipeline/video.cpp b/src/pipeline/video.cpp index 5470bf96..9aef07b1 100644 --- a/src/pipeline/video.cpp +++ b/src/pipeline/video.cpp @@ -689,8 +689,8 @@ namespace sd::pipeline { int source_index = std::min(reference.frame_count - 1, static_cast(std::floor(frame * source_fps / 24.0))); auto source = ensure_image_tensor_channels( - sd_image_to_tensor(reference.frames[source_index]), - 3); + sd_image_to_tensor(reference.frames[source_index]), + 3); if (source.empty()) { LOG_ERROR("invalid frame %d in MiniMax-H3 reference video %d", source_index + 1, @@ -818,7 +818,7 @@ namespace sd::pipeline { keyframes.shape()[2], 1, 1}, - conditioned_mask); + conditioned_mask); latents.denoise_mask = sd::ops::concat(latents.denoise_mask, keyframe_mask, 2); latents.video_positions = build_ltxv_video_positions(latents.init_latent.shape()[0], latents.init_latent.shape()[1], @@ -1106,10 +1106,10 @@ namespace sd::pipeline { inactive.shape()[1], inactive.shape()[2]}); // [t, h/vae_scale_factor, vae_scale_factor, w/vae_scale_factor, vae_scale_factor] mask_context = mask_context.permute({1, 3, 4, 0, 2}) // [vae_scale_factor, vae_scale_factor, t, h/vae_scale_factor, w/vae_scale_factor] - .reshape({inactive.shape()[0], - inactive.shape()[1], - inactive.shape()[2], - request->vae_scale_factor * request->vae_scale_factor}); // [vae_scale_factor*vae_scale_factor, t, h/vae_scale_factor, w/vae_scale_factor] + .reshape({inactive.shape()[0], + inactive.shape()[1], + inactive.shape()[2], + request->vae_scale_factor * request->vae_scale_factor}); // [vae_scale_factor*vae_scale_factor, t, h/vae_scale_factor, w/vae_scale_factor] if (!ref_image_latent.empty()) { vace_context = sd::ops::concat(ref_image_latent, vace_context, 2); // [b, 2*c, t+1, h/vae_scale_factor, w/vae_scale_factor] @@ -1387,9 +1387,9 @@ namespace sd::pipeline { auto& upsampler = scope.runner; upsampler = std::make_unique(sd->backend_for(SDBackendModule::UPSCALER), - model_manager->loader().get_tensor_storage_map(), - prefix, - model_manager); + model_manager->loader().get_tensor_storage_map(), + prefix, + model_manager); const size_t max_graph_vram_bytes = sd->max_graph_vram_bytes_for_module(SDBackendModule::UPSCALER); upsampler->set_max_graph_vram_bytes(max_graph_vram_bytes); if (upsampler->model == nullptr) { @@ -1869,7 +1869,7 @@ namespace sd::pipeline { x_t, std::move(noise), embeds.cond, - hires_request.use_uncond ? embeds.uncond : SDCondition(), + hires_request.use_uncond ? embeds.uncond : SDCondition(), embeds.img_uncond, sd::Tensor(), 0.f, diff --git a/src/runtime/cache_dit.hpp b/src/runtime/cache_dit.hpp index 273aa0ef..666e61ca 100644 --- a/src/runtime/cache_dit.hpp +++ b/src/runtime/cache_dit.hpp @@ -842,7 +842,7 @@ struct CacheDitConditionState { const float* input_data = input.data(); float diff = CacheDitState::calculate_residual_diff( - it->second.prev_input.data(), input_data, ne); + it->second.prev_input.data(), input_data, ne); float effective_threshold = config.residual_diff_threshold; if (config.Fn_compute_blocks > 0) { diff --git a/src/runtime/guidance.cpp b/src/runtime/guidance.cpp index bfb773b0..854b5566 100644 --- a/src/runtime/guidance.cpp +++ b/src/runtime/guidance.cpp @@ -164,8 +164,8 @@ namespace sd::guidance { if (has_tensor(input.pred_img_uncond)) { const sd::Tensor& pred_img_uncond = *input.pred_img_uncond; output.pred = pred_img_uncond + - image_guidance_scale_ * (pred_uncond - pred_img_uncond) + - guidance_scale * (pred_cond - pred_uncond); + image_guidance_scale_ * (pred_uncond - pred_img_uncond) + + guidance_scale * (pred_cond - pred_uncond); } else { output.pred = pred_uncond + guidance_scale * (pred_cond - pred_uncond); @@ -224,8 +224,8 @@ namespace sd::guidance { if (has_tensor(input.pred_img_uncond)) { const sd::Tensor& pred_img_uncond = *input.pred_img_uncond; output.pred = pred_img_uncond + - image_guidance_scale_ * (pred_uncond - pred_img_uncond) + - guidance_scale * (pred_cond - pred_uncond); + image_guidance_scale_ * (pred_uncond - pred_img_uncond) + + guidance_scale * (pred_cond - pred_uncond); } else { output.pred = pred_uncond + guidance_scale * (pred_cond - pred_uncond); }