@@ -1558,7 +1558,7 @@ class StableDiffusionGGML {
15581558 if (vae_tiling_params.enabled ) {
15591559 // split latent in 32x32 tiles and compute in several steps
15601560 auto on_tiling = [&](ggml_tensor* in, ggml_tensor* out, bool init) {
1561- first_stage_model->compute (n_threads, in, true , &out, nullptr );
1561+ return first_stage_model->compute (n_threads, in, true , &out, nullptr );
15621562 };
15631563 silent_tiling (latents, result, get_vae_scale_factor (), 32 , 0 .5f , on_tiling);
15641564
@@ -1577,7 +1577,7 @@ class StableDiffusionGGML {
15771577 if (vae_tiling_params.enabled ) {
15781578 // split latent in 64x64 tiles and compute in several steps
15791579 auto on_tiling = [&](ggml_tensor* in, ggml_tensor* out, bool init) {
1580- tae_first_stage->compute (n_threads, in, true , &out, nullptr );
1580+ return tae_first_stage->compute (n_threads, in, true , &out, nullptr );
15811581 };
15821582 silent_tiling (latents, result, get_vae_scale_factor (), 64 , 0 .5f , on_tiling);
15831583 } else {
@@ -2546,7 +2546,7 @@ class StableDiffusionGGML {
25462546 LOG_DEBUG (" VAE Tile size: %dx%d" , tile_size_x, tile_size_y);
25472547
25482548 auto on_tiling = [&](ggml_tensor* in, ggml_tensor* out, bool init) {
2549- first_stage_model->compute (n_threads, in, false , &out, work_ctx);
2549+ return first_stage_model->compute (n_threads, in, false , &out, work_ctx);
25502550 };
25512551 sd_tiling_non_square (x, result, vae_scale_factor, tile_size_x, tile_size_y, tile_overlap, on_tiling);
25522552 } else {
@@ -2557,7 +2557,7 @@ class StableDiffusionGGML {
25572557 if (vae_tiling_params.enabled && !encode_video) {
25582558 // split latent in 32x32 tiles and compute in several steps
25592559 auto on_tiling = [&](ggml_tensor* in, ggml_tensor* out, bool init) {
2560- tae_first_stage->compute (n_threads, in, false , &out, nullptr );
2560+ return tae_first_stage->compute (n_threads, in, false , &out, nullptr );
25612561 };
25622562 sd_tiling (x, result, vae_scale_factor, 64 , 0 .5f , on_tiling);
25632563 } else {
@@ -2675,23 +2675,31 @@ class StableDiffusionGGML {
26752675
26762676 // split latent in 32x32 tiles and compute in several steps
26772677 auto on_tiling = [&](ggml_tensor* in, ggml_tensor* out, bool init) {
2678- first_stage_model->compute (n_threads, in, true , &out, nullptr );
2678+ return first_stage_model->compute (n_threads, in, true , &out, nullptr );
26792679 };
26802680 sd_tiling_non_square (x, result, vae_scale_factor, tile_size_x, tile_size_y, tile_overlap, on_tiling);
26812681 } else {
2682- first_stage_model->compute (n_threads, x, true , &result, work_ctx);
2682+ if (!first_stage_model->compute (n_threads, x, true , &result, work_ctx)){
2683+ LOG_ERROR (" Failed to decode latetnts" );
2684+ first_stage_model->free_compute_buffer ();
2685+ return nullptr ;
2686+ }
26832687 }
26842688 first_stage_model->free_compute_buffer ();
26852689 process_vae_output_tensor (result);
26862690 } else {
26872691 if (vae_tiling_params.enabled ) {
26882692 // split latent in 64x64 tiles and compute in several steps
26892693 auto on_tiling = [&](ggml_tensor* in, ggml_tensor* out, bool init) {
2690- tae_first_stage->compute (n_threads, in, true , &out);
2694+ return tae_first_stage->compute (n_threads, in, true , &out);
26912695 };
26922696 sd_tiling (x, result, vae_scale_factor, 64 , 0 .5f , on_tiling);
26932697 } else {
2694- tae_first_stage->compute (n_threads, x, true , &result);
2698+ if (!tae_first_stage->compute (n_threads, x, true , &result)){
2699+ LOG_ERROR (" Failed to decode latetnts" );
2700+ tae_first_stage->free_compute_buffer ();
2701+ return nullptr ;
2702+ }
26952703 }
26962704 tae_first_stage->free_compute_buffer ();
26972705 }
@@ -3461,6 +3469,7 @@ sd_image_t* generate_image_internal(sd_ctx_t* sd_ctx,
34613469 ggml_free (work_ctx);
34623470 return nullptr ;
34633471 }
3472+ memset (result_images, 0 , batch_count * sizeof (sd_image_t ));
34643473
34653474 for (size_t i = 0 ; i < decoded_images.size (); i++) {
34663475 result_images[i].width = width;
0 commit comments