Skip to content

Commit d1e7175

Browse files
Fix editorconfig trailing whitespace errors
- Remove trailing whitespace from CMakeLists.txt lines 200, 208 - Remove trailing whitespace from common/arg.cpp lines 77, 80, 100, 126, 134, 142, 183, 197, 205, 209, 214, 221, 231 - Remove trailing whitespace from tests/test-arg-parser.cpp lines 182, 198, 203, 219, 226, 231, 234, 237, 240 Co-Authored-By: Jaime Mizrachi <[email protected]>
1 parent 1af90f6 commit d1e7175

File tree

3 files changed

+14
-24
lines changed

3 files changed

+14
-24
lines changed

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,15 +197,15 @@ if (LLAMA_YAML_CPP)
197197
if (PkgConfig_FOUND)
198198
pkg_check_modules(YAML_CPP QUIET yaml-cpp)
199199
endif()
200-
200+
201201
if (NOT YAML_CPP_FOUND)
202202
find_package(yaml-cpp QUIET)
203203
if (yaml-cpp_FOUND)
204204
set(YAML_CPP_LIBRARIES yaml-cpp)
205205
set(YAML_CPP_INCLUDE_DIRS ${yaml-cpp_INCLUDE_DIRS})
206206
endif()
207207
endif()
208-
208+
209209
if (NOT YAML_CPP_FOUND AND NOT yaml-cpp_FOUND)
210210
message(STATUS "yaml-cpp not found, disabling YAML config support")
211211
set(LLAMA_YAML_CPP OFF)

common/arg.cpp

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,9 @@ static bool common_params_load_from_yaml(const std::string & config_file, common
7474
if (config_file.empty()) {
7575
return true;
7676
}
77-
77+
7878
try {
7979
YAML::Node config = YAML::LoadFile(config_file);
80-
8180
// Model parameters
8281
if (config["model"]) {
8382
params.model.path = config["model"].as<std::string>();
@@ -97,7 +96,7 @@ static bool common_params_load_from_yaml(const std::string & config_file, common
9796
if (config["hf_token"]) {
9897
params.hf_token = config["hf_token"].as<std::string>();
9998
}
100-
99+
101100
// Context and prediction parameters
102101
if (config["ctx_size"]) {
103102
params.n_ctx = config["ctx_size"].as<int32_t>();
@@ -123,23 +122,23 @@ static bool common_params_load_from_yaml(const std::string & config_file, common
123122
if (config["sequences"]) {
124123
params.n_sequences = config["sequences"].as<int32_t>();
125124
}
126-
125+
127126
// CPU parameters
128127
if (config["threads"]) {
129128
params.cpuparams.n_threads = config["threads"].as<int>();
130129
}
131130
if (config["threads_batch"]) {
132131
params.cpuparams_batch.n_threads = config["threads_batch"].as<int>();
133132
}
134-
133+
135134
// GPU parameters
136135
if (config["n_gpu_layers"]) {
137136
params.n_gpu_layers = config["n_gpu_layers"].as<int32_t>();
138137
}
139138
if (config["main_gpu"]) {
140139
params.main_gpu = config["main_gpu"].as<int32_t>();
141140
}
142-
141+
143142
// Sampling parameters
144143
if (config["seed"]) {
145144
params.sampling.seed = config["seed"].as<uint32_t>();
@@ -180,7 +179,7 @@ static bool common_params_load_from_yaml(const std::string & config_file, common
180179
if (config["mirostat_eta"]) {
181180
params.sampling.mirostat_eta = config["mirostat_eta"].as<float>();
182181
}
183-
182+
184183
// Prompt and system parameters
185184
if (config["prompt"]) {
186185
params.prompt = config["prompt"].as<std::string>();
@@ -194,31 +193,31 @@ static bool common_params_load_from_yaml(const std::string & config_file, common
194193
if (config["prompt_cache"]) {
195194
params.path_prompt_cache = config["prompt_cache"].as<std::string>();
196195
}
197-
196+
198197
// Input/Output parameters
199198
if (config["input_prefix"]) {
200199
params.input_prefix = config["input_prefix"].as<std::string>();
201200
}
202201
if (config["input_suffix"]) {
203202
params.input_suffix = config["input_suffix"].as<std::string>();
204203
}
205-
204+
206205
if (config["verbose"]) {
207206
params.verbosity = config["verbose"].as<int32_t>();
208207
}
209-
208+
210209
if (config["conversation"]) {
211210
bool conv = config["conversation"].as<bool>();
212211
params.conversation_mode = conv ? COMMON_CONVERSATION_MODE_ENABLED : COMMON_CONVERSATION_MODE_DISABLED;
213212
}
214-
213+
215214
if (config["interactive"]) {
216215
params.interactive = config["interactive"].as<bool>();
217216
}
218217
if (config["interactive_first"]) {
219218
params.interactive_first = config["interactive_first"].as<bool>();
220219
}
221-
220+
222221
if (config["antiprompt"]) {
223222
if (config["antiprompt"].IsSequence()) {
224223
for (const auto & item : config["antiprompt"]) {
@@ -228,7 +227,7 @@ static bool common_params_load_from_yaml(const std::string & config_file, common
228227
params.antiprompt.push_back(config["antiprompt"].as<std::string>());
229228
}
230229
}
231-
230+
232231
return true;
233232
} catch (const YAML::Exception & e) {
234233
fprintf(stderr, "Error parsing YAML config file '%s': %s\n", config_file.c_str(), e.what());

tests/test-arg-parser.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,6 @@ int main(void) {
179179

180180
#ifdef LLAMA_YAML_CPP
181181
printf("test-arg-parser: testing YAML config functionality\n\n");
182-
183182
std::string yaml_content = R"(
184183
model: "test_model.gguf"
185184
threads: 8
@@ -195,12 +194,10 @@ conversation: true
195194
- "User:"
196195
- "Stop"
197196
)";
198-
199197
std::string temp_config = "/tmp/test_config.yaml";
200198
std::ofstream config_file(temp_config);
201199
config_file << yaml_content;
202200
config_file.close();
203-
204201
argv = {"binary_name", "--config", temp_config.c_str()};
205202
assert(true == common_params_parse(argv.size(), list_str_to_char(argv).data(), params, LLAMA_EXAMPLE_COMMON));
206203
assert(params.model.path == "test_model.gguf");
@@ -216,28 +213,22 @@ conversation: true
216213
assert(params.antiprompt.size() == 2);
217214
assert(params.antiprompt[0] == "User:");
218215
assert(params.antiprompt[1] == "Stop");
219-
220216
argv = {"binary_name", "--config", temp_config.c_str(), "-t", "16", "--ctx-size", "8192"};
221217
assert(true == common_params_parse(argv.size(), list_str_to_char(argv).data(), params, LLAMA_EXAMPLE_COMMON));
222218
assert(params.model.path == "test_model.gguf"); // from config
223219
assert(params.cpuparams.n_threads == 16); // overridden by CLI
224220
assert(params.n_ctx == 8192); // overridden by CLI
225221
assert(params.sampling.temp == 0.7f); // from config
226-
227222
std::string invalid_yaml = "/tmp/invalid_config.yaml";
228223
std::ofstream invalid_file(invalid_yaml);
229224
invalid_file << "invalid: yaml: content: [unclosed";
230225
invalid_file.close();
231-
232226
argv = {"binary_name", "--config", invalid_yaml.c_str()};
233227
assert(false == common_params_parse(argv.size(), list_str_to_char(argv).data(), params, LLAMA_EXAMPLE_COMMON));
234-
235228
argv = {"binary_name", "--config", "/tmp/nonexistent_config.yaml"};
236229
assert(false == common_params_parse(argv.size(), list_str_to_char(argv).data(), params, LLAMA_EXAMPLE_COMMON));
237-
238230
std::remove(temp_config.c_str());
239231
std::remove(invalid_yaml.c_str());
240-
241232
printf("test-arg-parser: YAML config tests passed\n\n");
242233
#else
243234
printf("test-arg-parser: YAML config support not compiled, skipping YAML tests\n\n");

0 commit comments

Comments
 (0)