Synthetic deterministic handwritten-style samples are used for CPU/NPU parity testing; greedy decoding, fp32.
本仓库提供独立 CPU/NPU 推理脚本与精度对比脚本。测试严格先运行 CPU、释放资源,再运行昇腾 NPU;NPU 计时前后执行同步,结束后释放缓存。
python -m pip install -r requirements.txt --index-url "${PIP_INDEX_URL:-https://pypi.tuna.tsinghua.edu.cn/simple}"python inference.py --device cpu --model-dir /path/to/model --output cpu_inference.json
python inference.py --device npu --model-dir /path/to/model --output npu_inference.jsonpython compare_cpu_npu.py --model-dir /path/to/model --output comparison.json| 指标 | CPU | NPU |
|---|---|---|
| 推理耗时 | 4867.2091 ms | 200.8611 ms |
| 精度指标 | 实测值 |
|---|---|
| 主指标 | mean_relative_error_pct |
| CPU/NPU 主误差 | 0.3196435885% |
| 最大相对误差 | 15016.25981% |
| 最大绝对误差 | 0.3981361389 |
| 余弦相似度 | 0.9999893027 |
| 语义输出一致 | False |
结论:NPU 与 CPU 推理结果误差小于 1%。
性能数据与输入大小、批量、预热、模型规模和首次算子编译有关。上表为本次真实运行结果,不作为跨模型性能排名。


