| 104 | } |
| 105 | |
| 106 | void readDataFromFile(const std::string &filename, std::vector<char> &data, size_t data_size) |
| 107 | { |
| 108 | assert(data.size() == data_size); // FIX_CALLER_UNLESS |
| 109 | |
| 110 | std::ifstream fs(filename, std::ifstream::binary); |
| 111 | if (fs.fail()) |
| 112 | throw std::runtime_error("Cannot open file \"" + filename + "\".\n"); |
| 113 | if (fs.read(data.data(), data_size).fail()) |
| 114 | throw std::runtime_error("Failed to read data from file \"" + filename + "\".\n"); |
| 115 | if (fs.peek() != EOF) |
| 116 | throw std::runtime_error("Input tensor size mismatches with \"" + filename + "\".\n"); |
| 117 | } |
| 118 | |
| 119 | std::vector<uint8_t> genRandomBoolData(std::mt19937 &gen, uint32_t num_elements) |
| 120 | { |
no test coverage detected