#5590·faiss

IndexFastScan::merge_from 会默默地忽略非零 add_id

作者: leemeii创建于 2026年9月7日更新于 2026年9月7日

def find_root(): for parent in HERE.parents: if (parent / "VDBMS/faiss/faiss/IndexFastScan.cpp").is_file(): return parent raise RuntimeError("cannot locate checked-out VDBMSFuzz root")

def now(): return dt.datetime.now(dt.timezone.utc).replace(microsecond=0).isoformat()

def run_process(binary, mode): try: p = subprocess.run([str(binary), mode], cwd=str(HERE), capture_output=True, text=True, timeout=30, check=False) return {"mode": mode, "returncode": p.returncode, "stdout": p.stdout, "stderr": p.stderr, "timed_out": False} except subprocess.TimeoutExpired as exc: return {"mode": mode, "returncode": None, "stdout": exc.stdout or "", "stderr": exc.stderr or "", "timed_out": True}

def write_json(path, value): path.write_text(json.dumps(value, indent=2, sort_keys=True) + "\n")

def main(): ap = argparse.ArgumentParser() ap.add_argument("--trials", type=int, default=10) args = ap.parse_args() if args.trials < 10: raise SystemExit("--trials must be at least 10") root = find_root() build = root / "VDBMS/bug-finder-agent/work/faiss/build-make" static_lib = build / "faiss/libfaiss.a" binary = HERE / "runtime/repro_helper" binary.parent.mkdir(parents=True, exist_ok=True) (HERE / "logs").mkdir(parents=True, exist_ok=True) compile_cmd = ["g++", "-std=c++17", "-O2", "-I", str(root / "VDBMS/faiss"), "-I", str(build), "-o", str(binary), str(HERE / "repro_helper.cpp"), str(static_lib), "-fopenmp", "/lib/x86_64-linux-gnu/libblas.so.3", "/lib/x86_64-linux-gnu/liblapack.so.3"] if not static_lib.is_file(): print("missing audited FAISS static library", file=sys.stderr) return 2 c = subprocess.run(compile_cmd, cwd=str(root), capture_output=True, text=True, check=False) write_json(HERE / "runtime/compile.json", {"command": compile_cmd, "returncode": c.returncode, "stdout": c.stdout, "stderr": c.stderr}) if c.returncode != 0: return 2 started = now() control = run_process(binary, "control") …

内容来源: facebookresearch/faiss