@@ -83,7 +83,7 @@ class llm_graph_input_i {
8383
8484 // return true if the resulting input tensors using the provided graph parameters would be
8585 // the same as the previous input tensors that we have currently stored in the object
86- virtual bool update (const llm_graph_params & params) {
86+ virtual bool can_reuse (const llm_graph_params & params) {
8787 // returning false here by default will prevent from reusing the graph if the check
8888 // for the input type has not been implemented yet
8989 GGML_UNUSED (params);
@@ -100,7 +100,7 @@ class llm_graph_input_embd : public llm_graph_input_i {
100100
101101 void set_input (const llama_ubatch * ubatch) override ;
102102
103- bool update (const llm_graph_params & params) override ;
103+ bool can_reuse (const llm_graph_params & params) override ;
104104
105105 ggml_tensor * tokens = nullptr ; // I32 [n_batch]
106106 ggml_tensor * embd = nullptr ; // F32 [n_embd, n_batch]
@@ -113,7 +113,7 @@ class llm_graph_input_pos : public llm_graph_input_i {
113113
114114 void set_input (const llama_ubatch * ubatch) override ;
115115
116- bool update (const llm_graph_params & params) override ;
116+ bool can_reuse (const llm_graph_params & params) override ;
117117
118118 ggml_tensor * pos = nullptr ; // I32 [n_batch]
119119
@@ -173,7 +173,7 @@ class llm_graph_input_out_ids : public llm_graph_input_i {
173173
174174 void set_input (const llama_ubatch * ubatch) override ;
175175
176- bool update (const llm_graph_params & params) override ;
176+ bool can_reuse (const llm_graph_params & params) override ;
177177
178178 ggml_tensor * out_ids; // I32 [n_outputs]
179179
@@ -265,7 +265,7 @@ class llm_graph_input_attn_kv_unified : public llm_graph_input_i {
265265
266266 void set_input (const llama_ubatch * ubatch) override ;
267267
268- bool update (const llm_graph_params & params) override ;
268+ bool can_reuse (const llm_graph_params & params) override ;
269269
270270 ggml_tensor * get_k_idxs () const { return self_k_idxs; }
271271 ggml_tensor * get_v_idxs () const { return self_v_idxs; }
@@ -298,7 +298,7 @@ class llm_graph_input_attn_kv_unified_iswa : public llm_graph_input_i {
298298
299299 void set_input (const llama_ubatch * ubatch) override ;
300300
301- bool update (const llm_graph_params & params) override ;
301+ bool can_reuse (const llm_graph_params & params) override ;
302302
303303 ggml_tensor * get_k_idxs () const { return self_k_idxs; }
304304 ggml_tensor * get_v_idxs () const { return self_v_idxs; }
@@ -410,7 +410,7 @@ class llm_graph_result_i {
410410
411411 virtual void set_inputs (const llama_ubatch * ubatch) = 0;
412412
413- virtual bool update (const llm_graph_params & params) = 0;
413+ virtual bool can_reuse (const llm_graph_params & params) = 0;
414414};
415415
416416using llm_graph_result_ptr = std::unique_ptr<llm_graph_result_i>;
@@ -504,20 +504,20 @@ class llm_graph_result : public llm_graph_result_i {
504504 }
505505 }
506506
507- // try to update the existing graph result using the new graph parameters
507+ // try to update the existing graph result using the new graph parameters in order to reuse it
508508 // this can only be done if we determine that the resulting graph using the new graph parameters
509509 // would be identical to the existing graph. in that case, we simply have to update the memory
510510 // contexts of the input tensors of the graph and we can reuse it for another computation
511511 // return true if the graph was updated and can be reused
512- bool update (const llm_graph_params & params) override {
512+ bool can_reuse (const llm_graph_params & params) override {
513513 if (!this ->params .is_same (params)) {
514514 return false ;
515515 }
516516
517517 bool res = true ;
518518
519519 for (auto & input : inputs) {
520- res &= input->update (params);
520+ res &= input->can_reuse (params);
521521 }
522522
523523 return res;
0 commit comments