@@ -1489,6 +1489,18 @@ class StableDiffusionGGML {
14891489 LOG_WARN (" OOR" );
14901490 }
14911491 }
1492+ float tile_overlap = 0 .5f ;
1493+ const char * SD_TILE_OVERLAP = getenv (" SD_TILE_OVERLAP" );
1494+ if (SD_TILE_OVERLAP != nullptr ) {
1495+ std::string sd_tile_overlap_str = SD_TILE_OVERLAP;
1496+ try {
1497+ tile_overlap = std::stof (sd_tile_overlap_str);
1498+ } catch (const std::invalid_argument&) {
1499+ LOG_WARN (" Invalid" );
1500+ } catch (const std::out_of_range&) {
1501+ LOG_WARN (" OOR" );
1502+ }
1503+ }
14921504 if (!decode){
14931505 // TODO: also use and arg for this one?
14941506 // to keep the compute buffer size consistent
@@ -1505,11 +1517,14 @@ class StableDiffusionGGML {
15051517 if (SD_TILE_SIZE != nullptr ) {
15061518 LOG_INFO (" VAE Tile size: %dx%d" , tile_size_x, tile_size_y);
15071519 }
1520+ if (SD_TILE_OVERLAP != nullptr ) {
1521+ LOG_INFO (" VAE Tile overlap: %.2f" , tile_overlap);
1522+ }
15081523 // split latent in 32x32 tiles and compute in several steps
15091524 auto on_tiling = [&](ggml_tensor* in, ggml_tensor* out, bool init) {
15101525 first_stage_model->compute (n_threads, in, decode, &out);
15111526 };
1512- sd_tiling_non_square (x, result, 8 , tile_size_x, tile_size_y, 0 . 5f , on_tiling);
1527+ sd_tiling_non_square (x, result, 8 , tile_size_x, tile_size_y, tile_overlap , on_tiling);
15131528 } else {
15141529 first_stage_model->compute (n_threads, x, decode, &result);
15151530 }
0 commit comments