@@ -1542,7 +1542,7 @@ class StableDiffusionGGML {
15421542 if (vae_tiling_params.enabled ) {
15431543 // split latent in 32x32 tiles and compute in several steps
15441544 auto on_tiling = [&](ggml_tensor* in, ggml_tensor* out, bool init) {
1545- first_stage_model->compute (n_threads, in, true , &out, nullptr );
1545+ return first_stage_model->compute (n_threads, in, true , &out, nullptr );
15461546 };
15471547 silent_tiling (latents, result, get_vae_scale_factor (), 32 , 0 .5f , on_tiling);
15481548
@@ -1561,7 +1561,7 @@ class StableDiffusionGGML {
15611561 if (vae_tiling_params.enabled ) {
15621562 // split latent in 64x64 tiles and compute in several steps
15631563 auto on_tiling = [&](ggml_tensor* in, ggml_tensor* out, bool init) {
1564- tae_first_stage->compute (n_threads, in, true , &out, nullptr );
1564+ return tae_first_stage->compute (n_threads, in, true , &out, nullptr );
15651565 };
15661566 silent_tiling (latents, result, get_vae_scale_factor (), 64 , 0 .5f , on_tiling);
15671567 } else {
@@ -2530,7 +2530,7 @@ class StableDiffusionGGML {
25302530 LOG_DEBUG (" VAE Tile size: %dx%d" , tile_size_x, tile_size_y);
25312531
25322532 auto on_tiling = [&](ggml_tensor* in, ggml_tensor* out, bool init) {
2533- first_stage_model->compute (n_threads, in, false , &out, work_ctx);
2533+ return first_stage_model->compute (n_threads, in, false , &out, work_ctx);
25342534 };
25352535 sd_tiling_non_square (x, result, vae_scale_factor, tile_size_x, tile_size_y, tile_overlap, on_tiling);
25362536 } else {
@@ -2541,7 +2541,7 @@ class StableDiffusionGGML {
25412541 if (vae_tiling_params.enabled && !encode_video) {
25422542 // split latent in 32x32 tiles and compute in several steps
25432543 auto on_tiling = [&](ggml_tensor* in, ggml_tensor* out, bool init) {
2544- tae_first_stage->compute (n_threads, in, false , &out, nullptr );
2544+ return tae_first_stage->compute (n_threads, in, false , &out, nullptr );
25452545 };
25462546 sd_tiling (x, result, vae_scale_factor, 64 , 0 .5f , on_tiling);
25472547 } else {
@@ -2659,23 +2659,31 @@ class StableDiffusionGGML {
26592659
26602660 // split latent in 32x32 tiles and compute in several steps
26612661 auto on_tiling = [&](ggml_tensor* in, ggml_tensor* out, bool init) {
2662- first_stage_model->compute (n_threads, in, true , &out, nullptr );
2662+ return first_stage_model->compute (n_threads, in, true , &out, nullptr );
26632663 };
26642664 sd_tiling_non_square (x, result, vae_scale_factor, tile_size_x, tile_size_y, tile_overlap, on_tiling);
26652665 } else {
2666- first_stage_model->compute (n_threads, x, true , &result, work_ctx);
2666+ if (!first_stage_model->compute (n_threads, x, true , &result, work_ctx)){
2667+ LOG_ERROR (" Failed to decode latetnts" );
2668+ first_stage_model->free_compute_buffer ();
2669+ return nullptr ;
2670+ }
26672671 }
26682672 first_stage_model->free_compute_buffer ();
26692673 process_vae_output_tensor (result);
26702674 } else {
26712675 if (vae_tiling_params.enabled ) {
26722676 // split latent in 64x64 tiles and compute in several steps
26732677 auto on_tiling = [&](ggml_tensor* in, ggml_tensor* out, bool init) {
2674- tae_first_stage->compute (n_threads, in, true , &out);
2678+ return tae_first_stage->compute (n_threads, in, true , &out);
26752679 };
26762680 sd_tiling (x, result, vae_scale_factor, 64 , 0 .5f , on_tiling);
26772681 } else {
2678- tae_first_stage->compute (n_threads, x, true , &result);
2682+ if (!tae_first_stage->compute (n_threads, x, true , &result)){
2683+ LOG_ERROR (" Failed to decode latetnts" );
2684+ tae_first_stage->free_compute_buffer ();
2685+ return nullptr ;
2686+ }
26792687 }
26802688 tae_first_stage->free_compute_buffer ();
26812689 }
@@ -3440,6 +3448,7 @@ sd_image_t* generate_image_internal(sd_ctx_t* sd_ctx,
34403448 ggml_free (work_ctx);
34413449 return nullptr ;
34423450 }
3451+ memset (result_images, 0 , batch_count * sizeof (sd_image_t ));
34433452
34443453 for (size_t i = 0 ; i < decoded_images.size (); i++) {
34453454 result_images[i].width = width;
0 commit comments