Skip to content

Distribute and run LLMs with a single file.

Fix output path in llamafile-quantize

Justine Tunneyc8cd8e1ee910
diff --git a/llama.cpp/quantize/quantize.cpp b/llama.cpp/quantize/quantize.cpp
index 975d590f..5264180a 100644
--- a/llama.cpp/quantize/quantize.cpp
+++ b/llama.cpp/quantize/quantize.cpp
@@ -40,6 +40,13 @@ static const std::vector<struct quant_option> QUANT_OPTIONS = {
};
+static bool is_integer_str(const char *s) {
+ if (*s == '-') ++s;
+ if (!*s) return false;
+ while (isdigit(*s)) ++s;
+ return !*s;
+}
+
static bool try_parse_ftype(const std::string & ftype_str_in, llama_ftype & ftype, std::string & ftype_str_out) {
std::string ftype_str;
@@ -53,9 +60,7 @@ static bool try_parse_ftype(const std::string & ftype_str_in, llama_ftype & ftyp
return true;
}
}
-#ifndef _LIBCPP_NO_EXCEPTIONS
- try {
-#endif
+ if (is_integer_str(ftype_str.c_str())) {
int ftype_int = std::stoi(ftype_str);
for (auto & it : QUANT_OPTIONS) {
if (it.ftype == ftype_int) {
@@ -64,12 +69,7 @@ static bool try_parse_ftype(const std::string & ftype_str_in, llama_ftype & ftyp
return true;
}
}
-#ifndef _LIBCPP_NO_EXCEPTIONS
- }
- catch (...) {
- // stoi failed
}
-#endif
return false;
}