@@ -377,6 +377,12 @@ __STATIC_INLINE__ void copy_ggml_tensor(struct ggml_tensor* dst, struct ggml_ten
377377 ggml_free (ctx);
378378}
379379
380+ __STATIC_INLINE__ ggml_tensor* ggml_ext_dup_and_cpy_tensor (ggml_context* ctx, ggml_tensor* src) {
381+ ggml_tensor* dup = ggml_dup_tensor (ctx, src);
382+ copy_ggml_tensor (dup, src);
383+ return dup;
384+ }
385+
380386__STATIC_INLINE__ float sigmoid (float x) {
381387 return 1 / (1 .0f + expf (-x));
382388}
@@ -637,7 +643,7 @@ __STATIC_INLINE__ struct ggml_tensor* ggml_ext_tensor_concat(struct ggml_context
637643}
638644
639645// convert values from [0, 1] to [-1, 1]
640- __STATIC_INLINE__ void process_vae_input_tensor (struct ggml_tensor * src) {
646+ __STATIC_INLINE__ void scale_to_minus1_1 (struct ggml_tensor * src) {
641647 int64_t nelements = ggml_nelements (src);
642648 float * data = (float *)src->data ;
643649 for (int i = 0 ; i < nelements; i++) {
@@ -647,7 +653,7 @@ __STATIC_INLINE__ void process_vae_input_tensor(struct ggml_tensor* src) {
647653}
648654
649655// convert values from [-1, 1] to [0, 1]
650- __STATIC_INLINE__ void process_vae_output_tensor (struct ggml_tensor * src) {
656+ __STATIC_INLINE__ void scale_to_0_1 (struct ggml_tensor * src) {
651657 int64_t nelements = ggml_nelements (src);
652658 float * data = (float *)src->data ;
653659 for (int i = 0 ; i < nelements; i++) {
@@ -834,7 +840,8 @@ __STATIC_INLINE__ void sd_tiling_non_square(ggml_tensor* input,
834840 const float tile_overlap_factor,
835841 const bool circular_x,
836842 const bool circular_y,
837- on_tile_process on_processing) {
843+ on_tile_process on_processing,
844+ bool slient = false ) {
838845 output = ggml_set_f32 (output, 0 );
839846
840847 int input_width = (int )input->ne [0 ];
@@ -864,8 +871,10 @@ __STATIC_INLINE__ void sd_tiling_non_square(ggml_tensor* input,
864871 float tile_overlap_factor_y;
865872 sd_tiling_calc_tiles (num_tiles_y, tile_overlap_factor_y, small_height, p_tile_size_y, tile_overlap_factor, circular_y);
866873
867- LOG_DEBUG (" num tiles : %d, %d " , num_tiles_x, num_tiles_y);
868- LOG_DEBUG (" optimal overlap : %f, %f (targeting %f)" , tile_overlap_factor_x, tile_overlap_factor_y, tile_overlap_factor);
874+ if (!slient) {
875+ LOG_DEBUG (" num tiles : %d, %d " , num_tiles_x, num_tiles_y);
876+ LOG_DEBUG (" optimal overlap : %f, %f (targeting %f)" , tile_overlap_factor_x, tile_overlap_factor_y, tile_overlap_factor);
877+ }
869878
870879 int tile_overlap_x = (int32_t )(p_tile_size_x * tile_overlap_factor_x);
871880 int non_tile_overlap_x = p_tile_size_x - tile_overlap_x;
@@ -896,7 +905,9 @@ __STATIC_INLINE__ void sd_tiling_non_square(ggml_tensor* input,
896905 params.mem_buffer = nullptr ;
897906 params.no_alloc = false ;
898907
899- LOG_DEBUG (" tile work buffer size: %.2f MB" , params.mem_size / 1024 .f / 1024 .f );
908+ if (!slient) {
909+ LOG_DEBUG (" tile work buffer size: %.2f MB" , params.mem_size / 1024 .f / 1024 .f );
910+ }
900911
901912 // draft context
902913 struct ggml_context * tiles_ctx = ggml_init (params);
@@ -909,8 +920,10 @@ __STATIC_INLINE__ void sd_tiling_non_square(ggml_tensor* input,
909920 ggml_tensor* input_tile = ggml_new_tensor_4d (tiles_ctx, GGML_TYPE_F32, input_tile_size_x, input_tile_size_y, input->ne [2 ], input->ne [3 ]);
910921 ggml_tensor* output_tile = ggml_new_tensor_4d (tiles_ctx, GGML_TYPE_F32, output_tile_size_x, output_tile_size_y, output->ne [2 ], output->ne [3 ]);
911922 int num_tiles = num_tiles_x * num_tiles_y;
912- LOG_DEBUG (" processing %i tiles" , num_tiles);
913- pretty_progress (0 , num_tiles, 0 .0f );
923+ if (!slient) {
924+ LOG_DEBUG (" processing %i tiles" , num_tiles);
925+ pretty_progress (0 , num_tiles, 0 .0f );
926+ }
914927 int tile_count = 1 ;
915928 bool last_y = false , last_x = false ;
916929 float last_time = 0 .0f ;
@@ -960,8 +973,10 @@ __STATIC_INLINE__ void sd_tiling_non_square(ggml_tensor* input,
960973 }
961974 last_x = false ;
962975 }
963- if (tile_count < num_tiles) {
964- pretty_progress (num_tiles, num_tiles, last_time);
976+ if (!slient) {
977+ if (tile_count < num_tiles) {
978+ pretty_progress (num_tiles, num_tiles, last_time);
979+ }
965980 }
966981 ggml_free (tiles_ctx);
967982}
0 commit comments