Skip to content

Commit

Permalink
llava override eval batch instead of vector
Browse files Browse the repository at this point in the history
  • Loading branch information
mgonzs13 committed Jan 7, 2025
1 parent 6262e24 commit e005735
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 15 deletions.
4 changes: 2 additions & 2 deletions llama_ros/include/llama_ros/llama.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,8 @@ class Llama {
virtual bool eval_prompt();
bool eval_prompt(std::vector<llama_token> prompt_tokens);
bool eval_token(llama_token token);
virtual bool eval(std::vector<llama_token> tokens);
bool eval(struct llama_batch batch);
bool eval(std::vector<llama_token> tokens);
virtual bool eval(struct llama_batch batch);

std::vector<struct TokenProb> get_probs();
struct CompletionOutput sample();
Expand Down
2 changes: 1 addition & 1 deletion llama_ros/include/llava_ros/llava.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class Llava : public llama_ros::Llama {
bool add_sfx) override;
bool eval_image(struct llava_image_embed *image_embed);
bool eval_prompt();
bool eval(std::vector<llama_token> tokens) override;
bool eval(struct llama_batch batch) override;

struct llava_image_embed *image_embed;
struct clip_ctx *ctx_clip;
Expand Down
13 changes: 1 addition & 12 deletions llama_ros/src/llava_ros/llava.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,21 +265,10 @@ bool Llava::eval_prompt() {
return true;
}

bool Llava::eval(std::vector<llama_token> tokens) {
bool Llava::eval(struct llama_batch batch) {

std::vector<llama_pos> pos;

// create batch
struct llama_batch batch = {
int32_t(tokens.size()), // n_tokens
tokens.data(), // tokens
nullptr, // embd
nullptr, // pos
nullptr, // n_seq_id
nullptr, // seq_id
nullptr, // logits
};

if (clip_is_qwen2vl(this->ctx_clip)) {
pos.resize(batch.n_tokens * 4);
std::fill(pos.begin(), pos.end(), 0);
Expand Down

0 comments on commit e005735

Please sign in to comment.