Skip to content

Commit 8c3df5e

Browse files
committed
fix according to review
1 parent e720075 commit 8c3df5e

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

ggml/src/ggml-cann/ggml-cann.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
#include <mutex>
3232
#include <queue>
3333
#include <chrono>
34-
#include <set>
34+
#include <unordered_set>
3535
#include <optional>
3636

3737
#include "ggml-impl.h"
@@ -101,17 +101,17 @@ int32_t ggml_cann_get_device() {
101101
std::optional<std::string> get_env(const std::string& name) {
102102
const char* val = std::getenv(name.c_str());
103103
if (!val) return std::nullopt;
104-
return std::string(val);
104+
std::string res = std::string(val);
105+
std::transform(res.begin(), res.end(), res.begin(), ::tolower);
106+
return res;
105107
}
106108

107109
/**
108110
* @brief Verify whether the environment variable is a valid value.
109111
*/
110112
bool parse_bool(const std::string& value) {
111-
std::string res = value;
112-
std::transform(res.begin(), res.end(), res.begin(), ::tolower);
113-
std::set<std::string> valid_values = {"on", "1", "yes", "y", "enable", "true"};
114-
return valid_values.find(res) != valid_values.end();
113+
std::unordered_set<std::string> valid_values = {"on", "1", "yes", "y", "enable", "true"};
114+
return valid_values.find(value) != valid_values.end();
115115
}
116116

117117
/**
@@ -753,7 +753,6 @@ struct ggml_cann_pool_vmm : public ggml_cann_pool {
753753
std::unique_ptr<ggml_cann_pool> ggml_backend_cann_context::new_pool_for_device(
754754
int device) {
755755
std::string mem_pool_type = get_env("GGML_CANN_MEM_POOL").value_or("");
756-
std::transform(mem_pool_type.begin(), mem_pool_type.end(), mem_pool_type.begin(), ::tolower);
757756

758757
if (mem_pool_type == "prio") {
759758
GGML_LOG_INFO("%s: device %d use buffer pool with priority queue\n", __func__, device);

0 commit comments

Comments
 (0)