Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/gguf/types/GgufTensorInfoTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,16 @@ export function resolveGgmlTypeOption(option?: keyof typeof GgmlType | GgmlType)

if (typeof option === "number" && Object.hasOwn(GgmlType, option))
return option as GgmlType;
else if (typeof option === "string" && Object.hasOwn(GgmlType, option))
return GgmlType[option as keyof typeof GgmlType];
else if (typeof option === "string") {
// GgmlType enum keys are conventionally uppercase (e.g. "Q8_0",
// "F16", "BF16"). Accept lowercase / mixed-case inputs so config
// files and CLI flags don't silently fall through to the default.
// Prior behaviour treated e.g. "q8_0" as unrecognised and returned
// undefined — callers then fell back to F16 with no warning.
const upper = option.toUpperCase();
if (Object.hasOwn(GgmlType, upper))
return GgmlType[upper as keyof typeof GgmlType];
}

return undefined;
}