| 36 | }; |
| 37 | |
| 38 | static ref_tensor load_ref(const std::string & path) { |
| 39 | ref_tensor t; |
| 40 | { |
| 41 | std::ifstream f(path + ".shape"); |
| 42 | if (!f) { |
| 43 | fprintf(stderr, " [SKIP] %s.shape not found\n", path.c_str()); |
| 44 | return t; |
| 45 | } |
| 46 | std::string line; |
| 47 | std::getline(f, line); |
| 48 | size_t pos = 0; |
| 49 | while (pos < line.size()) { |
| 50 | size_t end = line.find(',', pos); |
| 51 | if (end == std::string::npos) end = line.size(); |
| 52 | t.shape.push_back(std::stoi(line.substr(pos, end - pos))); |
| 53 | pos = end + 1; |
| 54 | } |
| 55 | } |
| 56 | { |
| 57 | std::ifstream f(path + ".bin", std::ios::binary); |
| 58 | if (!f) { |
| 59 | fprintf(stderr, " [SKIP] %s.bin not found\n", path.c_str()); |
| 60 | t.shape.clear(); |
| 61 | return t; |
| 62 | } |
| 63 | t.data.resize(t.numel()); |
| 64 | f.read(reinterpret_cast<char *>(t.data.data()), t.numel() * sizeof(float)); |
| 65 | } |
| 66 | return t; |
| 67 | } |
| 68 | |
| 69 | struct compare_result { |
| 70 | float max_diff = 0.0f; |
no test coverage detected