| 77 | } |
| 78 | |
| 79 | static std::vector<tensor_case> tensor_cases_for(const std::string & case_dir) { |
| 80 | std::vector<tensor_case> cases; |
| 81 | const auto meta = load_meta(case_dir + "/meta.txt"); |
| 82 | const int num_slots = meta.count("num_slots") ? std::stoi(meta.at("num_slots")) : 0; |
| 83 | |
| 84 | // Tolerances: pix_proj/obj_ptr/attn_input/sa_l0 are tight (1e-4). |
| 85 | // Memory encoder stages accumulate error through bilinear+conv chain (1e-2). |
| 86 | // Memory attention inherits encoder error non-hermetically (5e-3). |
| 87 | // Propagation accumulates through full pipeline (1e-2). |
| 88 | for (int i = 0; i < num_slots; ++i) { |
| 89 | cases.push_back({"phase7_mem" + std::to_string(i) + "_pix_proj", |
| 90 | "Memory slot " + std::to_string(i) + " pixel projection", 1e-4f}); |
| 91 | cases.push_back({"phase7_mem" + std::to_string(i) + "_fused_input", |
| 92 | "Memory slot " + std::to_string(i) + " fused input", 2e-3f}); |
| 93 | cases.push_back({"phase7_mem" + std::to_string(i) + "_fuser0", |
| 94 | "Memory slot " + std::to_string(i) + " fuser block 0", 1e-2f}); |
| 95 | cases.push_back({"phase7_mem" + std::to_string(i) + "_fuser1", |
| 96 | "Memory slot " + std::to_string(i) + " fuser block 1", 1e-2f}); |
| 97 | cases.push_back({"phase7_mem" + std::to_string(i) + "_output", |
| 98 | "Memory slot " + std::to_string(i) + " encoder output", 1e-2f}); |
| 99 | cases.push_back({"phase7_obj_ptr" + std::to_string(i), |
| 100 | "Memory slot " + std::to_string(i) + " object pointer", 1e-4f}); |
| 101 | } |
| 102 | |
| 103 | cases.push_back({"phase7_mem_attn_input", "Memory attention input", 1e-4f}); |
| 104 | for (int i = 0; i < 4; ++i) { |
| 105 | cases.push_back({"phase7_mem_attn_layer" + std::to_string(i) + "_after_sa", |
| 106 | "Memory attention layer " + std::to_string(i) + " after self-attn", 5e-3f}); |
| 107 | cases.push_back({"phase7_mem_attn_layer" + std::to_string(i) + "_after_ca", |
| 108 | "Memory attention layer " + std::to_string(i) + " after cross-attn", 5e-3f}); |
| 109 | cases.push_back({"phase7_mem_attn_layer" + std::to_string(i) + "_after_ffn", |
| 110 | "Memory attention layer " + std::to_string(i) + " after FFN", 5e-3f}); |
| 111 | } |
| 112 | cases.push_back({"phase7_mem_attn_output", "Memory attention final output", 5e-3f}); |
| 113 | cases.push_back({"phase7_prop_masks", "Propagation mask logits", 1e-2f}); |
| 114 | cases.push_back({"phase7_prop_iou", "Propagation IoU", 1e-3f}); |
| 115 | cases.push_back({"phase7_prop_obj_score", "Propagation object score", 1e-3f}); |
| 116 | cases.push_back({"phase7_prop_sam_token", "Propagation SAM token", 1e-2f}); |
| 117 | return cases; |
| 118 | } |
| 119 | |
| 120 | int main(int argc, char ** argv) { |
| 121 | if (argc < 4) { |