mirror of
				https://github.com/ggml-org/llama.cpp.git
				synced 2025-10-30 08:42:00 +00:00 
			
		
		
		
	qwen2vl: use llama_batch_ext_set_pos
This commit is contained in:
		| @@ -66,18 +66,11 @@ static bool qwen2vl_eval_image_embed(llama_context * ctx_llama, const struct lla | ||||
|         memcpy(&batch_mrope_pos[n_eval * 2], &mrope_pos[img_tokens * 2 + processed], n_eval * sizeof(llama_pos)); | ||||
|         memcpy(&batch_mrope_pos[n_eval * 3], &mrope_pos[img_tokens * 3 + processed], n_eval * sizeof(llama_pos)); | ||||
|  | ||||
|         // TODO: move this to llama_batch_ext API | ||||
|         llama_batch batch = { | ||||
|             int32_t(n_eval),                // n_tokens | ||||
|             nullptr,                        // token | ||||
|             (image_embed->embed+i*n_embd),  // embed | ||||
|             batch_mrope_pos.data(),         // pos | ||||
|             nullptr,  // n_seq_id | ||||
|             nullptr,  // seq_id | ||||
|             nullptr,  // logits | ||||
|         }; | ||||
|         float * batch_embd = image_embed->embed+i*n_embd; | ||||
|         llama_batch_ext_ptr batch(llama_batch_ext_init_from_embd(batch_embd, n_eval, n_embd, 0, 0)); | ||||
|         llama_batch_ext_set_pos(batch.get(), batch_mrope_pos.data(), n_eval); | ||||
|  | ||||
|         if (llama_decode(ctx_llama, batch)) { | ||||
|         if (llama_decode_ext(ctx_llama, batch.get())) { | ||||
|             LOG_ERR("%s : failed to eval\n", __func__); | ||||
|             return false; | ||||
|         } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Xuan Son Nguyen
					Xuan Son Nguyen