MCPcopy Create free account
hub / github.com/PABannier/sam3.cpp / load_ref

Function load_ref

tests/test_phase3.cpp:38–67  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

36};
37
38static 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
69struct compare_result {
70 float max_diff = 0.0f;

Callers 4

test_ropeFunction · 0.70
test_sinusoidal_peFunction · 0.70
test_encode_imageFunction · 0.70

Calls 1

numelMethod · 0.45

Tested by

no test coverage detected