@@ -194,20 +194,10 @@ __STATIC_INLINE__ float sd_image_get_f32(sd_image_t image, int iw, int ih, int i
194194    return  value;
195195}
196196
197- #if  0  // kcpp
198- static struct ggml_tensor* get_tensor_from_graph(struct ggml_cgraph* gf, const char* name) {
199-     struct ggml_tensor* res = NULL;
200-     for (int i = 0; i < ggml_graph_n_nodes(gf); i++) {
201-         struct ggml_tensor* node = ggml_graph_node(gf, i);
202-         // printf("%d, %s \n", i, ggml_get_name(node));
203-         if (strcmp(ggml_get_name(node), name) == 0) {
204-             res = node;
205-             break;
206-         }
207-     }
208-     return res;
197+ __STATIC_INLINE__ float  sd_image_get_f32 (sd_image_f32_t  image, int  iw, int  ih, int  ic) {
198+     float  value = *(image.data  + ih * image.width  * image.channel  + iw * image.channel  + ic);
199+     return  value;
209200}
210- #endif 
211201
212202__STATIC_INLINE__ void  print_ggml_tensor (struct  ggml_tensor * tensor, bool  shape_only = false , const  char * mark = " "  ) {
213203    printf (" %s (%s): shape(%zu, %zu, %zu, %zu)\n "  , mark, ggml_type_name (tensor->type ), tensor->ne [0 ], tensor->ne [1 ], tensor->ne [2 ], tensor->ne [3 ]);
@@ -462,28 +452,6 @@ __STATIC_INLINE__ void sd_apply_mask(struct ggml_tensor* image_data,
462452    }
463453}
464454
465- __STATIC_INLINE__ void  sd_mul_images_to_tensor (const  uint8_t * image_data,
466-                                                struct  ggml_tensor * output,
467-                                                int  idx,
468-                                                float * mean = NULL ,
469-                                                float * std  = NULL ) {
470-     int64_t  width    = output->ne [0 ];
471-     int64_t  height   = output->ne [1 ];
472-     int64_t  channels = output->ne [2 ];
473-     GGML_ASSERT (channels == 3  && output->type  == GGML_TYPE_F32);
474-     for  (int  iy = 0 ; iy < height; iy++) {
475-         for  (int  ix = 0 ; ix < width; ix++) {
476-             for  (int  k = 0 ; k < channels; k++) {
477-                 int  value       = *(image_data + iy * width * channels + ix * channels + k);
478-                 float  pixel_val = value / 255 .0f ;
479-                 if  (mean != NULL  && std != NULL )
480-                     pixel_val = (pixel_val - mean[k]) / std[k];
481-                 ggml_tensor_set_f32 (output, pixel_val, ix, iy, k, idx);
482-             }
483-         }
484-     }
485- }
486- 
487455__STATIC_INLINE__ void  sd_image_f32_to_tensor (const  float * image_data,
488456                                              struct  ggml_tensor * output,
489457                                              bool  scale = true ) {
@@ -786,9 +754,11 @@ __STATIC_INLINE__ std::vector<struct ggml_tensor*> ggml_chunk(struct ggml_contex
786754
787755typedef  std::function<void (ggml_tensor*, ggml_tensor*, bool )> on_tile_process;
788756
789- __STATIC_INLINE__ void 
790- sd_tiling_calc_tiles (int  &num_tiles_dim, float & tile_overlap_factor_dim, int  small_dim, int  tile_size, const  float  tile_overlap_factor) {
791- 
757+ __STATIC_INLINE__ void  sd_tiling_calc_tiles (int & num_tiles_dim,
758+                                             float & tile_overlap_factor_dim,
759+                                             int  small_dim,
760+                                             int  tile_size,
761+                                             const  float  tile_overlap_factor) {
792762    int  tile_overlap     = (tile_size * tile_overlap_factor);
793763    int  non_tile_overlap = tile_size - tile_overlap;
794764
0 commit comments