Read a prompt file with uint32 length prefix + N int32 token IDs.
| 156 | std::ifstream f(path, std::ios::binary | std::ios::ate); |
| 157 | if (!f) return {}; |
| 158 | const auto sz = (size_t)f.tellg(); |
| 159 | f.seekg(0); |
| 160 | std::vector<int32_t> ids(sz / sizeof(int32_t)); |
| 161 | if (!ids.empty()) { |
| 162 | f.read(reinterpret_cast<char *>(ids.data()), |
| 163 | (std::streamsize)ids.size() * sizeof(int32_t)); |
| 164 | if (!f) return {}; |
| 165 | } |
| 166 | return ids; |
| 167 | } |
| 168 | |
| 169 | // Read a prompt file with uint32 length prefix + N int32 token IDs. |
| 170 | static std::vector<int32_t> read_counted_i32(const std::string & path) { |
| 171 | std::ifstream f(path, std::ios::binary); |
| 172 | if (!f) return {}; |
| 173 | uint32_t n = 0; |
| 174 | f.read(reinterpret_cast<char *>(&n), sizeof(n)); |
no test coverage detected