|
26 | 26 |
|
27 | 27 | #include "backend_model.h"
|
28 | 28 |
|
| 29 | +#include <map> |
29 | 30 | #include <vector>
|
30 | 31 |
|
31 | 32 | #include "backend_config.h"
|
@@ -259,65 +260,23 @@ TritonModel::ResolveBackendConfigs(
|
259 | 260 | {
|
260 | 261 | const auto& global_itr = backend_cmdline_config_map.find(std::string());
|
261 | 262 | const auto& specific_itr = backend_cmdline_config_map.find(backend_name);
|
262 |
| - if (specific_itr == backend_cmdline_config_map.end() && |
263 |
| - global_itr != backend_cmdline_config_map.end()) { |
264 |
| - for (auto setting : global_itr->second) { |
265 |
| - config.push_back(setting); |
| 263 | + std::map<std::string, std::string> lconfig; |
| 264 | + if (global_itr != backend_cmdline_config_map.end()) { |
| 265 | + // Accumulate all global settings |
| 266 | + for (auto& setting : global_itr->second){ |
| 267 | + lconfig[setting.first] = setting.second; |
266 | 268 | }
|
267 |
| - } else if ( |
268 |
| - specific_itr != backend_cmdline_config_map.end() && |
269 |
| - global_itr == backend_cmdline_config_map.end()) { |
270 |
| - for (auto setting : specific_itr->second) { |
271 |
| - config.push_back(setting); |
272 |
| - } |
273 |
| - } else if ( |
274 |
| - specific_itr != backend_cmdline_config_map.end() && |
275 |
| - global_itr != backend_cmdline_config_map.end()) { |
276 |
| - triton::common::BackendCmdlineConfig global_backend_config = |
277 |
| - global_itr->second; |
278 |
| - triton::common::BackendCmdlineConfig specific_backend_config = |
279 |
| - specific_itr->second; |
280 |
| - |
281 |
| - std::sort(global_backend_config.begin(), global_backend_config.end()); |
282 |
| - std::sort(specific_backend_config.begin(), specific_backend_config.end()); |
283 |
| - |
284 |
| - size_t global_index = 0; |
285 |
| - size_t specific_index = 0; |
286 |
| - while (global_index < global_backend_config.size() && |
287 |
| - specific_index < specific_backend_config.size()) { |
288 |
| - auto& current_global_setting = global_backend_config.at(global_index); |
289 |
| - auto& current_specific_setting = |
290 |
| - specific_backend_config.at(specific_index); |
291 |
| - if (current_specific_setting.first.compare( |
292 |
| - current_global_setting.first) == 0) { |
293 |
| - // specific setting overrides global setting |
294 |
| - config.push_back(current_specific_setting); |
295 |
| - ++global_index; |
296 |
| - ++specific_index; |
297 |
| - } else if ( |
298 |
| - current_specific_setting.first.compare(current_global_setting.first) < |
299 |
| - 0) { |
300 |
| - config.push_back(current_specific_setting); |
301 |
| - ++specific_index; |
302 |
| - } else { |
303 |
| - config.push_back(current_global_setting); |
304 |
| - ++global_index; |
305 |
| - } |
306 |
| - } |
307 |
| - |
308 |
| - // add the rest of the global configs |
309 |
| - if (global_index < global_backend_config.size()) { |
310 |
| - auto& current_global_setting = global_backend_config.at(global_index); |
311 |
| - config.push_back(current_global_setting); |
312 |
| - } |
313 |
| - |
314 |
| - // add the rest of the specific settings |
315 |
| - if (specific_index < specific_backend_config.size()) { |
316 |
| - auto& current_specific_setting = |
317 |
| - specific_backend_config.at(specific_index); |
318 |
| - config.push_back(current_specific_setting); |
| 269 | + } |
| 270 | + if (specific_itr != backend_cmdline_config_map.end()) { |
| 271 | + // Accumulate backend specific settings and override |
| 272 | + // global settings with specific configs if needed |
| 273 | + for (auto& setting : specific_itr->second){ |
| 274 | + lconfig[setting.first] = setting.second; |
319 | 275 | }
|
320 |
| - } // else empty config |
| 276 | + } |
| 277 | + for (auto& final_setting : lconfig){ |
| 278 | + config.emplace_back(final_setting); |
| 279 | + } |
321 | 280 |
|
322 | 281 | return Status::Success;
|
323 | 282 | }
|
|
0 commit comments