File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -79,6 +79,10 @@ struct ggml_metal_op {
7979        assert (use_fusion);
8080        assert (i0 >= 0  && i0 < n_nodes ());
8181
82+         if  (i0 + n_ops > n_nodes ()) {
83+             return  false ;
84+         }
85+ 
8286        return  ggml_can_fuse_ext (gf, idxs.data () + i0, ops, n_ops);
8387    }
8488
@@ -2290,7 +2294,7 @@ int ggml_metal_op_bin(ggml_metal_op_t ctx, int idx) {
22902294
22912295        //  note: in metal, we sometimes encode the graph in parallel so we have to avoid fusing ops
22922296        //        across splits. idx_end indicates the last node in the current split
2293-         for  (n_fuse = 0 ; n_fuse <= 6  && idx + n_fuse +  1  < ctx-> n_nodes () ; ++n_fuse) {
2297+         for  (n_fuse = 0 ; n_fuse <= 6 ; ++n_fuse) {
22942298            if  (!ctx->can_fuse (idx + n_fuse, fops + n_fuse, 2 )) {
22952299                break ;
22962300            }
@@ -2527,7 +2531,7 @@ int ggml_metal_op_norm(ggml_metal_op_t ctx, int idx) {
25272531        fops[1 ] = GGML_OP_MUL;
25282532        fops[2 ] = GGML_OP_ADD;
25292533
2530-         for  (n_fuse = 0 ; n_fuse <= 1  && idx + n_fuse +  1  < ctx-> n_nodes () ; ++n_fuse) {
2534+         for  (n_fuse = 0 ; n_fuse <= 1 ; ++n_fuse) {
25312535            if  (!ctx->can_fuse (idx + n_fuse, fops + n_fuse, 2 )) {
25322536                break ;
25332537            }
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments