]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
Fix type casting for unaccounted memory calculation (#22424)
authorrankaiyx <redacted>
Mon, 27 Apr 2026 12:31:13 +0000 (20:31 +0800)
committerGitHub <redacted>
Mon, 27 Apr 2026 12:31:13 +0000 (14:31 +0200)
common/fit.cpp

index 4b952889070b810c9e908f32559309bfe7ca0a8a..aca3f4d407488bd77a8c45f03b87b84c9900f5dd 100644 (file)
@@ -856,7 +856,7 @@ void common_memory_breakdown_print(const struct llama_context * ctx) {
         ggml_backend_dev_memory(dev, &free, &total);
 
         const size_t self = mb.model + mb.context + mb.compute;
-        const size_t unaccounted = total - self - free;
+        const int64_t unaccounted = static_cast<int64_t>(total) - static_cast<int64_t>(free) - static_cast<int64_t>(self);
 
         table_data.push_back({
             template_gpu,
@@ -867,7 +867,7 @@ void common_memory_breakdown_print(const struct llama_context * ctx) {
             std::to_string(mb.model / MiB),
             std::to_string(mb.context / MiB),
             std::to_string(mb.compute / MiB),
-            std::to_string(unaccounted / MiB)});
+            std::to_string(unaccounted / static_cast<int64_t>(MiB))});
     }
 
     // print memory breakdown for host: