Skip to content

Commit 9716c7b

Browse files
committed
temporary refactor llama_vision_graph_builder
1 parent 32daa38 commit 9716c7b

File tree

3 files changed

+174
-120
lines changed

3 files changed

+174
-120
lines changed

examples/vision/vision.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ static llama_vision_bitmap * load_image_from_file(const char * fname) {
5050
}
5151

5252
// split string by a `std::string delim` instead of `char delim`
53-
static std::vector<std::string> string_split(std::string s, const std::string & delimiter) {
53+
static std::vector<std::string> string_split_str(std::string s, const std::string & delimiter) {
5454
std::vector<std::string> tokens;
5555
size_t pos = 0;
5656
std::string token;
@@ -76,7 +76,7 @@ static std::vector<tokenized_part> tokenize_with_img_placement(
7676
const std::string & text,
7777
bool add_special,
7878
bool parse_special) {
79-
std::vector<std::string> parts = string_split(text, IMG_PLACEMENT);
79+
std::vector<std::string> parts = string_split_str(text, IMG_PLACEMENT);
8080
std::vector<tokenized_part> output;
8181
for (const auto & part : parts) {
8282
//printf("tokenizing part: %s\n", part.c_str());
@@ -114,6 +114,10 @@ int main(int argc, char ** argv) {
114114
llama_context * ctx = llama_init.context.get();
115115
const llama_model * model = llama_init.model.get();
116116
const llama_vocab * vocab = llama_model_get_vocab(model);
117+
if (!model) {
118+
LOG_ERR("failed to load model\n");
119+
return 1;
120+
}
117121

118122
struct common_sampler * smpl = common_sampler_init(model, params.sampling);
119123

src/llama-model.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4056,6 +4056,11 @@ enum llama_rope_type llama_model_rope_type(const struct llama_model * model) {
40564056
case LLM_ARCH_QWEN2VL:
40574057
return LLAMA_ROPE_TYPE_MROPE;
40584058

4059+
case LLM_ARCH_VISION_LLAVA:
4060+
case LLM_ARCH_VISION_MOBILEVLM:
4061+
case LLM_ARCH_VISION_MINICPMV:
4062+
GGML_ABORT("vision arch does not use RoPE");
4063+
40594064
// all model arches should be listed explicitly here
40604065
case LLM_ARCH_UNKNOWN:
40614066
GGML_ABORT("unknown architecture");

0 commit comments

Comments
 (0)