MCPcopy Create free account
hub / github.com/ARM-software/ComputeLibrary / load_from_file

Method load_from_file

src/runtime/CL/CLTuner.cpp:298–348  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

296}
297
298void CLTuner::load_from_file(const std::string &filename)
299{
300 std::ifstream fs;
301 fs.exceptions(std::ifstream::badbit);
302 fs.open(filename, std::ios::in);
303 if (!fs.is_open())
304 {
305 ARM_COMPUTE_ERROR_VAR("Failed to open '%s' (%s [%d])", filename.c_str(), strerror(errno), errno);
306 }
307 std::string line;
308 bool header_line = true;
309 while (!std::getline(fs, line).fail())
310 {
311 if (header_line)
312 {
313 header_line = false;
314 size_t pos_lws = line.find("lws");
315 size_t pos_wbsm = line.find("wbsm");
316 _tuning_info.tune_wbsm = false;
317 if (pos_lws != std::string::npos || pos_wbsm != std::string::npos)
318 {
319 // The file has in the first line the parameters it has been tuned on
320 if (pos_wbsm != std::string::npos)
321 {
322 _tuning_info.tune_wbsm = true;
323 }
324 // Once the line with the tuning parameter is read we can
325 // read the next one to start collecting the values
326 if (std::getline(fs, line).fail())
327 {
328 break;
329 }
330 }
331 }
332
333 CLTuningParams tuning_params;
334 size_t pos = line.find(";");
335 if (pos == std::string::npos)
336 {
337 ARM_COMPUTE_ERROR_VAR("Malformed row '%s' in %s", line.c_str(), filename.c_str());
338 }
339 std::string kernel_id = line.substr(0, pos);
340 line.erase(0, pos + 1);
341 if (!tuning_params.from_string(_tuning_info, line))
342 {
343 ARM_COMPUTE_ERROR_VAR("Malformed row '%s' in %s", line.c_str(), filename.c_str());
344 }
345 add_tuning_params(kernel_id, tuning_params);
346 }
347 fs.close();
348}
349
350bool CLTuner::save_to_file(const std::string &filename) const
351{

Callers 2

setup_backend_contextMethod · 0.80
mainFunction · 0.80

Calls 5

findMethod · 0.80
from_stringMethod · 0.80
openMethod · 0.45
is_openMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected