|
31 | 31 | #include <mutex> |
32 | 32 | #include <queue> |
33 | 33 | #include <chrono> |
34 | | -#include <set> |
| 34 | +#include <unordered_set> |
35 | 35 | #include <optional> |
36 | 36 |
|
37 | 37 | #include "ggml-impl.h" |
@@ -101,17 +101,17 @@ int32_t ggml_cann_get_device() { |
101 | 101 | std::optional<std::string> get_env(const std::string& name) { |
102 | 102 | const char* val = std::getenv(name.c_str()); |
103 | 103 | 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; |
105 | 107 | } |
106 | 108 |
|
107 | 109 | /** |
108 | 110 | * @brief Verify whether the environment variable is a valid value. |
109 | 111 | */ |
110 | 112 | 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(); |
115 | 115 | } |
116 | 116 |
|
117 | 117 | /** |
@@ -753,7 +753,6 @@ struct ggml_cann_pool_vmm : public ggml_cann_pool { |
753 | 753 | std::unique_ptr<ggml_cann_pool> ggml_backend_cann_context::new_pool_for_device( |
754 | 754 | int device) { |
755 | 755 | 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); |
757 | 756 |
|
758 | 757 | if (mem_pool_type == "prio") { |
759 | 758 | GGML_LOG_INFO("%s: device %d use buffer pool with priority queue\n", __func__, device); |
|
0 commit comments