From 6de9506594e1c4c1f2f5c421bf4a0b61efcc5bf3 Mon Sep 17 00:00:00 2001 From: Tianqi Chen Date: Fri, 19 May 2023 18:01:41 -0400 Subject: [PATCH] Fix Windows build (#190) filesystem path cannot be implicitly converted to string --- 3rdparty/tokenizers-cpp | 2 +- cpp/cli_main.cc | 3 ++- cpp/llm_chat.cc | 10 +++++----- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/3rdparty/tokenizers-cpp b/3rdparty/tokenizers-cpp index a3fd734465..470bbd49ff 160000 --- a/3rdparty/tokenizers-cpp +++ b/3rdparty/tokenizers-cpp @@ -1 +1 @@ -Subproject commit a3fd73446596735068355098691aa75f6b926cbd +Subproject commit 470bbd49ffb56bf5ed9a9724cff2caaf2329bd3d diff --git a/cpp/cli_main.cc b/cpp/cli_main.cc index bf78eb3d3d..8d0bd986ae 100644 --- a/cpp/cli_main.cc +++ b/cpp/cli_main.cc @@ -302,7 +302,8 @@ ModelPaths ModelPaths::Find(const std::string& artifact_path, const std::string& std::cout << "Use MLC config: " << config_path << std::endl; // Step 2. Find parameters std::filesystem::path params_json; - if (auto path = FindFile({config_path.parent_path()}, {"ndarray-cache"}, {".json"})) { + if (auto path = FindFile( + {config_path.parent_path().string()}, {"ndarray-cache"}, {".json"})) { params_json = path.value(); } else { std::cerr << "Cannot find \"ndarray-cache.json\" for params: " << config_path.parent_path() diff --git a/cpp/llm_chat.cc b/cpp/llm_chat.cc index 83b462f776..d7ac7d5cb3 100644 --- a/cpp/llm_chat.cc +++ b/cpp/llm_chat.cc @@ -427,11 +427,11 @@ std::unique_ptr TokenizerFromPath(const std::string& _path) { std::filesystem::path vocab_path = path / "vocab.json"; std::filesystem::path added_tokens_path = path / "added_tokens.json"; if (std::filesystem::exists(merges_path) && std::filesystem::exists(vocab_path)) { - std::string vocab = LoadBytesFromFile(vocab_path); - std::string merges = LoadBytesFromFile(merges_path); + std::string vocab = LoadBytesFromFile(vocab_path.string()); + std::string merges = LoadBytesFromFile(merges_path.string()); std::string added_tokens = ""; if (std::filesystem::exists(added_tokens_path)) { - added_tokens = LoadBytesFromFile(added_tokens_path); + added_tokens = LoadBytesFromFile(added_tokens_path.string()); } return Tokenizer::FromBlobByteLevelBPE(vocab, merges, added_tokens); } @@ -441,10 +441,10 @@ std::unique_ptr TokenizerFromPath(const std::string& _path) { huggingface = path.parent_path() / "tokenizer.json"; } if (std::filesystem::exists(sentencepiece)) { - return Tokenizer::FromBlobSentencePiece(LoadBytesFromFile(sentencepiece)); + return Tokenizer::FromBlobSentencePiece(LoadBytesFromFile(sentencepiece.string())); } if (std::filesystem::exists(huggingface)) { - return Tokenizer::FromBlobJSON(LoadBytesFromFile(huggingface)); + return Tokenizer::FromBlobJSON(LoadBytesFromFile(huggingface.string())); } LOG(FATAL) << "Cannot find any tokenizer under: " << _path; }