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

Function compare_state_nhwc

tests/test_metal_python_ref_compare.cpp:202–231  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

200}
201
202static metric_row compare_state_nhwc(const sam3_state & state,
203 const std::string & tensor_name,
204 const std::string & ref_path,
205 const std::string & dump_dir) {
206 metric_row row;
207 auto ref = load_ref_f32(ref_path);
208 row.tensor = tensor_name;
209 row.shape = shape_to_string(ref.shape);
210
211 if (ref.data.empty()) {
212 row.note = "missing python ref";
213 return row;
214 }
215 if (!sam3_dump_state_tensor(state, tensor_name, dump_dir + "/" + tensor_name)) {
216 row.note = "missing state tensor";
217 return row;
218 }
219 auto cpp = load_ref_f32(dump_dir + "/" + tensor_name);
220 if (cpp.data.empty()) {
221 row.note = "missing dumped tensor";
222 return row;
223 }
224
225 auto transposed = ggml_dump_to_nhwc_flat(cpp);
226 if ((int) transposed.size() != ref.numel()) {
227 row.note = "numel mismatch";
228 return row;
229 }
230 return compute_metrics(tensor_name, transposed.data(), ref.data.data(), ref.numel(), ref.shape);
231}
232
233static metric_row compare_state_nchw(const sam3_state & state,
234 const std::string & tensor_name,

Callers 1

run_backendFunction · 0.85

Calls 6

load_ref_f32Function · 0.85
shape_to_stringFunction · 0.85
sam3_dump_state_tensorFunction · 0.85
ggml_dump_to_nhwc_flatFunction · 0.85
compute_metricsFunction · 0.85
numelMethod · 0.45

Tested by

no test coverage detected