Skip to content

Commit a1761cd

Browse files
authored
sam : add default case for unsupported prompt types (#1263)
This commit adds a default case in the `embed_prompt_sparse` lambda function. The motivation for this change is that currently the following warning is generated when compiling: ```console /ggml/examples/sam/sam.cpp: In lambda function: /ggml/examples/sam/sam.cpp:1499:5: warning: control reaches end of non-void function [-Wreturn-type] 1499 | }(); | ^ ```
1 parent 988abe2 commit a1761cd

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

examples/sam/sam.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1460,7 +1460,7 @@ prompt_encoder_result sam_encode_prompt(
14601460
ggml_set_name(inp, "prompt_input");
14611461
ggml_set_input(inp);
14621462

1463-
auto * embd_prompt_sparse = [&]() {
1463+
auto * embd_prompt_sparse = [&]() -> struct ggml_tensor * {
14641464
switch (prompt.prompt_type) {
14651465
case SAM_PROMPT_TYPE_POINT: {
14661466
// PromptEncoder._embed_points
@@ -1495,6 +1495,10 @@ prompt_encoder_result sam_encode_prompt(
14951495

14961496
return corner_embd;
14971497
} break;
1498+
default: {
1499+
fprintf(stderr, "%s: unsupported prompt type %d\n", __func__, prompt.prompt_type);
1500+
return nullptr;
1501+
} break;
14981502
}
14991503
}();
15001504

0 commit comments

Comments
 (0)