Skip to content

Commit 640bd03

Browse files
committed
llama : fix segfault from unknown model arch name
1 parent e743386 commit 640bd03

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

llama.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -789,6 +789,16 @@ static std::map<llm_arch, std::map<llm_tensor, std::string>> LLM_TENSOR_NAMES =
789789

790790
static llm_arch llm_arch_from_string(const std::string & name) {
791791
for (const auto & kv : LLM_ARCH_NAMES) { // NOLINT
792+
if (kv.second == nullptr) {
793+
// LLM_ARCH_UNKNOWN does not have a name,
794+
// but is somehow still in the LLM_ARCH_NAMES map.
795+
if (kv.first == LLM_ARCH_UNKNOWN) {
796+
// skip string comparison
797+
continue;
798+
}
799+
// known architectures should always have a name
800+
GGML_ASSERT(false && "missing architecture in LLM_ARCH_NAMES");
801+
}
792802
if (kv.second == name) {
793803
return kv.first;
794804
}

0 commit comments

Comments
 (0)