| 262 | } |
| 263 | |
| 264 | static bool save_ref_f32(const std::string & path, |
| 265 | const std::vector<float> & data, |
| 266 | const std::vector<int> & shape) { |
| 267 | FILE * shape_f = fopen((path + ".shape").c_str(), "w"); |
| 268 | if (!shape_f) { |
| 269 | return false; |
| 270 | } |
| 271 | for (size_t i = 0; i < shape.size(); ++i) { |
| 272 | fprintf(shape_f, "%s%d", i == 0 ? "" : ",", shape[i]); |
| 273 | } |
| 274 | fclose(shape_f); |
| 275 | |
| 276 | FILE * data_f = fopen((path + ".bin").c_str(), "wb"); |
| 277 | if (!data_f) { |
| 278 | return false; |
| 279 | } |
| 280 | const size_t n_written = fwrite(data.data(), sizeof(float), data.size(), data_f); |
| 281 | fclose(data_f); |
| 282 | return n_written == data.size(); |
| 283 | } |
| 284 | |
| 285 | static bool export_dump_as_nchw_ref(const std::string & ggml_dump_path, |
| 286 | const std::string & out_path) { |
no outgoing calls
no test coverage detected