| 598 | } |
| 599 | |
| 600 | TopNPredictionsAccessor::TopNPredictionsAccessor(const std::string &labels_path, |
| 601 | size_t top_n, |
| 602 | std::ostream &output_stream) |
| 603 | : _labels(), _output_stream(output_stream), _top_n(top_n) |
| 604 | { |
| 605 | _labels.clear(); |
| 606 | |
| 607 | std::ifstream ifs; |
| 608 | |
| 609 | try |
| 610 | { |
| 611 | ifs.exceptions(std::ifstream::badbit); |
| 612 | ifs.open(labels_path, std::ios::in | std::ios::binary); |
| 613 | |
| 614 | for (std::string line; !std::getline(ifs, line).fail();) |
| 615 | { |
| 616 | _labels.emplace_back(line); |
| 617 | } |
| 618 | } |
| 619 | catch (const std::ifstream::failure &e) |
| 620 | { |
| 621 | ARM_COMPUTE_ERROR_VAR("Accessing %s: %s", labels_path.c_str(), e.what()); |
| 622 | } |
| 623 | } |
| 624 | |
| 625 | template <typename T> |
| 626 | void TopNPredictionsAccessor::access_predictions_tensor(ITensor &tensor) |