@@ -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; }
@@ -388,7 +388,7 @@ class llm_graph_result_i {
388388
389389 virtual void set_inputs (const llama_ubatch * ubatch) = 0;
390390
391- virtual bool update (const llm_graph_params & params) = 0;
391+ virtual bool can_reuse (const llm_graph_params & params) = 0;
392392};
393393
394394using llm_graph_result_ptr = std::unique_ptr<llm_graph_result_i>;
@@ -482,20 +482,20 @@ class llm_graph_result : public llm_graph_result_i {
482482 }
483483 }
484484
485- // try to update the existing graph result using the new graph parameters
485+ // try to update the existing graph result using the new graph parameters in order to reuse it
486486 // this can only be done if we determine that the resulting graph using the new graph parameters
487487 // would be identical to the existing graph. in that case, we simply have to update the memory
488488 // contexts of the input tensors of the graph and we can reuse it for another computation
489489 // return true if the graph was updated and can be reused
490- bool update (const llm_graph_params & params) override {
490+ bool can_reuse (const llm_graph_params & params) override {
491491 if (!this ->params .is_same (params)) {
492492 return false ;
493493 }
494494
495495 bool res = true ;
496496
497497 for (auto & input : inputs) {
498- res &= input->update (params);
498+ res &= input->can_reuse (params);
499499 }
500500
501501 return res;
0 commit comments