Skip to content

mtmd : Fix 32-bit narrowing issue in export-lora and mtmd clip #14503

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

kiwi142857
Copy link

Summary

Fixes narrowing conversion errors when building on 32-bit platforms due to implicit conversion from long long to size_t in initializer lists.

Under C++11 rules, non-constant expressions in initializer lists that narrow types will cause compile errors. This affects both export-lora.cpp and clip.cpp:

gguf_get_n_tensors(...) * ggml_tensor_overhead(); // returns long long

On 32-bit platforms, this cannot be implicitly converted to size_t (unsigned int) in an initializer list.

Fix

Added static_cast<size_t> to silence narrowing warnings and ensure type safety across 32/64-bit platforms.

Files affected

•tools/export-lora/export-lora.cpp
•tools/mtmd/clip.cpp

Notes

•This change is non-functional: it only impacts build correctness.
•Confirmed to compile cleanly on both 32-bit and 64-bit targets using clang.

@ngxson ngxson changed the title [fix] Fix 32-bit narrowing issue in export-lora and mtmd clip mtmd : Fix 32-bit narrowing issue in export-lora and mtmd clip Jul 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants