diff --git a/torch_modules/src/Submodule.cpp b/torch_modules/src/Submodule.cpp index 31e43c7937d2d7645f9fea0375b21f11f552a690..0cfa723132875b825590c52b099d4334547a7fcd 100644 --- a/torch_modules/src/Submodule.cpp +++ b/torch_modules/src/Submodule.cpp @@ -7,9 +7,12 @@ void Submodule::setFirstInputIndex(std::size_t firstInputIndex) void Submodule::loadPretrainedW2vEmbeddings(torch::nn::Embedding & embeddings, std::filesystem::path path) { - if (!std::filesystem::exists(path)) + if (path.empty()) return; + if (!std::filesystem::exists(path)) + util::myThrow(fmt::format("pretrained word2vec file '{}' do not exist", path.string())); + torch::NoGradGuard no_grad; auto originalState = getDict().getState();