Skip to content

Commit 6232bce

Browse files
committed
do not actually need to unique_ptr here
1 parent fd07765 commit 6232bce

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

gpt4all-backend/llmodel.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ bool LLModel::Implementation::isImplementation(const Dlhandle &dl) {
7979

8080
static bool s_scanned = false;
8181

82-
const std::vector<std::unique_ptr<LLModel::Implementation>> &LLModel::Implementation::implementationList() {
83-
static std::vector<std::unique_ptr<LLModel::Implementation>> s_impl_libs;
82+
const std::vector<LLModel::Implementation> &LLModel::Implementation::implementationList() {
83+
static std::vector<LLModel::Implementation> s_impl_libs;
8484

8585
if(s_scanned) { return s_impl_libs; }
8686
std::string impl_name_re = "(bert|llama|gptj|llamamodel-mainline)";
@@ -109,7 +109,7 @@ const std::vector<std::unique_ptr<LLModel::Implementation>> &LLModel::Implementa
109109
if (!Implementation::isImplementation(dl)) {
110110
continue;
111111
}
112-
s_impl_libs.emplace_back(std::make_unique<Implementation>(std::move(dl)));
112+
s_impl_libs.emplace_back(Implementation(std::move(dl)));
113113
} catch (...) {}
114114
}
115115
}
@@ -122,9 +122,9 @@ const std::vector<std::unique_ptr<LLModel::Implementation>> &LLModel::Implementa
122122

123123
const LLModel::Implementation* LLModel::Implementation::implementation(const char *fname, const std::string& buildVariant) {
124124
for (const auto& i : implementationList()) {
125-
if (buildVariant != i->m_buildVariant) continue;
126-
if (!i->m_magicMatch(fname)) continue;
127-
return i.get();
125+
if (buildVariant != i.m_buildVariant) continue;
126+
if (!i.m_magicMatch(fname)) continue;
127+
return &i;
128128
}
129129
return nullptr;
130130
}

gpt4all-backend/llmodel.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#include <fstream>
99
#include <cstdint>
1010
#include <limits>
11-
#include <memory>
1211

1312
#define LLMODEL_MAX_PROMPT_BATCH 128
1413

@@ -27,7 +26,7 @@ class LLModel {
2726
std::string_view buildVariant() const { return m_buildVariant; }
2827

2928
static bool isImplementation(const Dlhandle&);
30-
static const std::vector<std::unique_ptr<Implementation>>& implementationList();
29+
static const std::vector<Implementation>& implementationList();
3130
static const Implementation *implementation(const char *fname, const std::string& buildVariant);
3231
static LLModel *construct(const std::string &modelPath, std::string buildVariant = "auto");
3332
static void setImplementationsSearchPath(const std::string& path);

0 commit comments

Comments
 (0)