| 322 | {} |
| 323 | |
| 324 | std::vector<const void*> FileComparisonExecutor::Execute() |
| 325 | { |
| 326 | std::string filesToCompare = this->m_Params.m_ComparisonFile; |
| 327 | if (filesToCompare.empty()) |
| 328 | { |
| 329 | throw InvalidArgumentException("The file(s) to compare was not set."); |
| 330 | } |
| 331 | // filesToCompare is one or more files containing output tensors. Iterate and read in the tensors. |
| 332 | // We'll assume the string follows the same comma seperated format as write-outputs-to-file. |
| 333 | std::stringstream ss(filesToCompare); |
| 334 | std::vector<std::string> fileNames; |
| 335 | std::string errorString; |
| 336 | while (ss.good()) |
| 337 | { |
| 338 | std::string substr; |
| 339 | getline(ss, substr, ','); |
| 340 | // Check the file exist. |
| 341 | if (!ghc::filesystem::exists(substr)) |
| 342 | { |
| 343 | errorString += substr + " "; |
| 344 | } |
| 345 | else |
| 346 | { |
| 347 | fileNames.push_back(substr); |
| 348 | } |
| 349 | } |
| 350 | if (!errorString.empty()) |
| 351 | { |
| 352 | throw FileNotFoundException("The following file(s) to compare could not be found: " + errorString); |
| 353 | } |
| 354 | // Read in the tensors into m_OutputTensorsVec |
| 355 | OutputTensors outputs; |
| 356 | std::vector<const void*> results; |
| 357 | for (auto file : fileNames) |
| 358 | { |
| 359 | Tensor t; |
| 360 | if (file.find(".npy") == std::string::npos) |
| 361 | { |
| 362 | t = ReadTensorFromFile(file); |
| 363 | } |
| 364 | else |
| 365 | { |
| 366 | t = ReadTensorFromNumpyFile(file); |
| 367 | } |
| 368 | |
| 369 | outputs.push_back({ 0, Tensor(t.GetInfo(), t.GetMemoryArea()) }); |
| 370 | results.push_back(t.GetMemoryArea()); |
| 371 | } |
| 372 | m_OutputTensorsVec.push_back(outputs); |
| 373 | return results; |
| 374 | } |
| 375 | |
| 376 | void FileComparisonExecutor::PrintNetworkInfo() |
| 377 | { |
nothing calls this directly
no test coverage detected