Skip to content

Commit 42401c7

Browse files
authored
Fix type casting for unaccounted memory calculation (#22424)
1 parent e940b3d commit 42401c7

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

common/fit.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -856,7 +856,7 @@ void common_memory_breakdown_print(const struct llama_context * ctx) {
856856
ggml_backend_dev_memory(dev, &free, &total);
857857

858858
const size_t self = mb.model + mb.context + mb.compute;
859-
const size_t unaccounted = total - self - free;
859+
const int64_t unaccounted = static_cast<int64_t>(total) - static_cast<int64_t>(free) - static_cast<int64_t>(self);
860860

861861
table_data.push_back({
862862
template_gpu,
@@ -867,7 +867,7 @@ void common_memory_breakdown_print(const struct llama_context * ctx) {
867867
std::to_string(mb.model / MiB),
868868
std::to_string(mb.context / MiB),
869869
std::to_string(mb.compute / MiB),
870-
std::to_string(unaccounted / MiB)});
870+
std::to_string(unaccounted / static_cast<int64_t>(MiB))});
871871
}
872872

873873
// print memory breakdown for host:

0 commit comments

Comments
 (0)