Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove avx2 check since we have it at cortex-cpp layer #78

Merged
merged 2 commits into from
Jun 9, 2024
Merged
Changes from 1 commit
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
Next Next commit
fix: remove avx2 check since we have it at cortex-cpp layer
sangjanai committed Jun 9, 2024
commit 3b5f095e7980cf82383f5ca213987e8e62c94492
17 changes: 1 addition & 16 deletions src/llama_engine.cc
Original file line number Diff line number Diff line change
@@ -151,22 +151,7 @@ void LlamaEngine::HandleEmbedding(

void LlamaEngine::LoadModel(
std::shared_ptr<Json::Value> jsonBody,
std::function<void(Json::Value&&, Json::Value&&)>&& callback) {
if (!llama_utils::isAVX2Supported() && ggml_cpu_has_avx2()) {
LOG_ERROR << "AVX2 is not supported by your processor";
Json::Value jsonResp;
jsonResp["message"] =
"AVX2 is not supported by your processor, please download and replace "
"the correct Nitro asset version";
Json::Value status;
status["is_done"] = false;
status["has_error"] = true;
status["is_stream"] = false;
status["status_code"] = k500InternalServerError;
callback(std::move(status), std::move(jsonResp));
return;
}

std::function<void(Json::Value&&, Json::Value&&)>&& callback) {
auto model_id = llama_utils::GetModelId(*jsonBody);
if (model_id.empty()) {
LOG_INFO << "Model id is empty in request";
29 changes: 0 additions & 29 deletions src/llama_utils.h
Original file line number Diff line number Diff line change
@@ -132,35 +132,6 @@ inline std::string generate_random_string(std::size_t length) {
return random_string;
}

#if (defined(__GNUC__) || defined(__clang__)) && \
(defined(__x86_64__) || defined(__i386__))
#include <cpuid.h>
inline bool isAVX2Supported() {
unsigned eax, ebx, ecx, edx;
if (__get_cpuid_max(0, nullptr) < 7)
return false;

__get_cpuid_count(7, 0, &eax, &ebx, &ecx, &edx);
return (ebx & (1 << 5)) != 0;
}
#elif defined(_MSC_VER) && defined(_M_X64) || defined(_M_IX86)
#include <intrin.h>
inline bool isAVX2Supported() {
int cpuInfo[4];
__cpuid(cpuInfo, 0);
int nIds = cpuInfo[0];
if (nIds >= 7) {
__cpuidex(cpuInfo, 7, 0);
return (cpuInfo[1] & (1 << 5)) != 0;
}
return false;
}
#else
inline bool isAVX2Supported() {
return false;
}
#endif

inline void ltrim(std::string& s) {
s.erase(s.begin(), std::find_if(s.begin(), s.end(), [](unsigned char ch) {
return !std::isspace(ch);