@@ -1427,9 +1427,31 @@ class StableDiffusionGGML {
14271427 x->ne [3 ]); // channels
14281428 int64_t t0 = ggml_time_ms ();
14291429
1430+ // TODO: args instead of env for tile size / overlap?
1431+
1432+ float tile_overlap = 0 .5f ;
1433+ const char * SD_TILE_OVERLAP = getenv (" SD_TILE_OVERLAP" );
1434+ if (SD_TILE_OVERLAP != nullptr ) {
1435+ std::string sd_tile_overlap_str = SD_TILE_OVERLAP;
1436+ try {
1437+ tile_overlap = std::stof (sd_tile_overlap_str);
1438+ if (tile_overlap < 0.0 ) {
1439+ LOG_WARN (" SD_TILE_OVERLAP too low, setting it to 0.0" );
1440+ tile_overlap = 0.0 ;
1441+ }
1442+ else if (tile_overlap > 0.95 ) {
1443+ LOG_WARN (" SD_TILE_OVERLAP too high, setting it to 0.95" );
1444+ tile_overlap = 0.95 ;
1445+ }
1446+ } catch (const std::invalid_argument&) {
1447+ LOG_WARN (" SD_TILE_OVERLAP is invalid, keeping the default" );
1448+ } catch (const std::out_of_range&) {
1449+ LOG_WARN (" SD_TILE_OVERLAP is out of range, keeping the default" );
1450+ }
1451+ }
1452+
14301453 int tile_size_x = 32 ;
14311454 int tile_size_y = 32 ;
1432- // TODO: arg instead of env?
14331455 const char * SD_TILE_SIZE = getenv (" SD_TILE_SIZE" );
14341456 if (SD_TILE_SIZE != nullptr ) {
14351457 // format is AxB, or just A (equivalent to AxA)
@@ -1484,23 +1506,12 @@ class StableDiffusionGGML {
14841506 tile_size_x = tmp_x;
14851507 tile_size_y = tmp_y;
14861508 } catch (const std::invalid_argument&) {
1487- LOG_WARN (" Invalid" );
1488- } catch (const std::out_of_range&) {
1489- LOG_WARN (" OOR" );
1490- }
1491- }
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" );
1509+ LOG_WARN (" SD_TILE_SIZE is invalid, keeping the default" );
15001510 } catch (const std::out_of_range&) {
1501- LOG_WARN (" OOR " );
1511+ LOG_WARN (" SD_TILE_SIZE is out of range, keeping the default " );
15021512 }
15031513 }
1514+
15041515 if (!decode){
15051516 // TODO: also use and arg for this one?
15061517 // to keep the compute buffer size consistent
0 commit comments