@@ -1457,6 +1457,18 @@ class StableDiffusionGGML {
14571457 LOG_WARN (" OOR" );
14581458 }
14591459 }
1460+ float tile_overlap = 0 .5f ;
1461+ const char * SD_TILE_OVERLAP = getenv (" SD_TILE_OVERLAP" );
1462+ if (SD_TILE_OVERLAP != nullptr ) {
1463+ std::string sd_tile_overlap_str = SD_TILE_OVERLAP;
1464+ try {
1465+ tile_overlap = std::stof (sd_tile_overlap_str);
1466+ } catch (const std::invalid_argument&) {
1467+ LOG_WARN (" Invalid" );
1468+ } catch (const std::out_of_range&) {
1469+ LOG_WARN (" OOR" );
1470+ }
1471+ }
14601472 if (!decode){
14611473 // TODO: also use and arg for this one?
14621474 // to keep the compute buffer size consistent
@@ -1473,11 +1485,14 @@ class StableDiffusionGGML {
14731485 if (SD_TILE_SIZE != nullptr ) {
14741486 LOG_INFO (" VAE Tile size: %dx%d" , tile_size_x, tile_size_y);
14751487 }
1488+ if (SD_TILE_OVERLAP != nullptr ) {
1489+ LOG_INFO (" VAE Tile overlap: %.2f" , tile_overlap);
1490+ }
14761491 // split latent in 32x32 tiles and compute in several steps
14771492 auto on_tiling = [&](ggml_tensor* in, ggml_tensor* out, bool init) {
14781493 first_stage_model->compute (n_threads, in, decode, &out);
14791494 };
1480- sd_tiling_non_square (x, result, 8 , tile_size_x, tile_size_y, 0 . 5f , on_tiling);
1495+ sd_tiling_non_square (x, result, 8 , tile_size_x, tile_size_y, tile_overlap , on_tiling);
14811496 } else {
14821497 first_stage_model->compute (n_threads, x, decode, &result);
14831498 }
0 commit comments