Skip to content

Commit 203f130

Browse files
committed
set vae tile size via env var
1 parent edd6529 commit 203f130

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

stable-diffusion.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1054,6 +1054,20 @@ class StableDiffusionGGML {
10541054
decode ? 3 : C,
10551055
x->ne[3]); // channels
10561056
int64_t t0 = ggml_time_ms();
1057+
1058+
int tile_size = 32;
1059+
// TODO: arg instead of env?
1060+
const char* SD_TILE_SIZE = getenv("SD_TILE_SIZE");
1061+
if (SD_TILE_SIZE != nullptr) {
1062+
std::string sd_tile_size_str = SD_TILE_SIZE;
1063+
try {
1064+
tile_size = std::stoi(sd_tile_size_str);
1065+
} catch (const std::invalid_argument&) {
1066+
LOG_WARN("Invalid");
1067+
} catch (const std::out_of_range&) {
1068+
LOG_WARN("OOR");
1069+
}
1070+
}
10571071
if (!use_tiny_autoencoder) {
10581072
if (decode) {
10591073
ggml_tensor_scale(x, 1.0f / scale_factor);
@@ -1065,7 +1079,7 @@ class StableDiffusionGGML {
10651079
auto on_tiling = [&](ggml_tensor* in, ggml_tensor* out, bool init) {
10661080
first_stage_model->compute(n_threads, in, decode, &out);
10671081
};
1068-
sd_tiling(x, result, 8, 32, 0.5f, on_tiling, decode);
1082+
sd_tiling(x, result, 8, tile_size, 0.5f, on_tiling, decode);
10691083
} else {
10701084
first_stage_model->compute(n_threads, x, decode, &result);
10711085
}

0 commit comments

Comments
 (0)