]> git.djapps.eu Git - pkg/ggml/sources/ggml/commitdiff
sam : add default case for unsupported prompt types (#1263)
authorDaniel Bevenius <redacted>
Fri, 6 Jun 2025 16:58:10 +0000 (18:58 +0200)
committerGitHub <redacted>
Fri, 6 Jun 2025 16:58:10 +0000 (18:58 +0200)
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 |     }();
      |     ^
```

examples/sam/sam.cpp

index 299318f5fc2ce2e57ce93a2bb2da7f1f5ca25a07..92c7971f8a5338054b99187469ccb41e4a37a188 100644 (file)
@@ -1460,7 +1460,7 @@ prompt_encoder_result sam_encode_prompt(
     ggml_set_name(inp, "prompt_input");
     ggml_set_input(inp);
 
-    auto * embd_prompt_sparse = [&]() {
+    auto * embd_prompt_sparse = [&]() -> struct ggml_tensor * {
         switch (prompt.prompt_type) {
         case SAM_PROMPT_TYPE_POINT: {
             // PromptEncoder._embed_points
@@ -1495,6 +1495,10 @@ prompt_encoder_result sam_encode_prompt(
 
             return corner_embd;
         } break;
+        default: {
+            fprintf(stderr, "%s: unsupported prompt type %d\n", __func__, prompt.prompt_type);
+            return nullptr;
+        } break;
         }
     }();