facebook/regnet-x-032 on Ascend NPU
1. 简介
本文档记录了 facebook/regnet-x-032 模型在华为昇腾 NPU (Ascend910) 上的适配过程和验证结果。
RegNet-X 是 Meta 提出的基于规则的网络架构,通过设计空间搜索得到的高效卷积神经网络。X 变体使用标准卷积操作。
2. 验证环境
- 硬件: 华为昇腾 910 NPU
- 软件: CANN 8.5.1, PyTorch 2.x, torch_npu
- 操作系统: Linux
- 模型来源: ModelScope (facebook/regnet-x-032)
- 权重格式: pytorch_model.bin
3. 推理运行
pip install -r requirements.txt
python inference.py
推理结果 (NPU Top-5):
- Top-1: handkerchief, hankie, hanky, hankey (0.8345)
- Top-2: window shade (0.0916)
- Top-3: window screen (0.0175)
- Top-4: dam, dike, dyke (0.0143)
- Top-5: quilt, comforter, comfort, puff (0.0074)
日志保存在 logs/inference.log。
4. 精度验证
对单张测试图片进行 CPU 与 NPU 一致性验证:
| 指标 | 数值 |
|---|
| max_abs_error | 0.006929 |
| mean_abs_error | 0.001070 |
| relative_error | 0.0549% |
| cosine_similarity | 1.000000 |
| threshold | 1.0% |
| 结果 | PASS |
- CPU Top-1: handkerchief, hankie, hanky, hankey
- NPU Top-1: handkerchief, hankie, hanky, hankey
- CPU Top-5: handkerchief, hankie, hanky, hankey, window shade, window screen, dam, dike, dyke, quilt, comforter, comfort, puff
- NPU Top-5: handkerchief, hankie, hanky, hankey, window shade, window screen, dam, dike, dyke, quilt, comforter, comfort, puff
- Top-1 match: True
- Top-5 match: True
5. 性能参考
| 指标 | 数值 |
|---|
| avg_latency | 8.33 ms |
| min_latency | 8.25 ms |
| max_latency | 8.38 ms |
| throughput | 120.09 images/sec |
6. 精度评测说明
本项目包含单图 smoke consistency 验证,非官方 ImageNet 完整验证集评测。详细指标见第 4 节。
7. 自验证截图
详见 screenshots/self_verification.png 和 screenshots/self_verification.txt。
8. 日志文件
logs/env_check.log - NPU 环境检查
logs/inference.log - 推理结果
logs/accuracy.log - 精度验证
logs/benchmark.log - 性能测试
9. 注意事项
- 本适配使用 ModelScope snapshot_download 下载权重,避免直接从 HuggingFace 下载
- 模型使用 transformers AutoModelForImageClassification 加载
- 精度验证采用单图 smoke test,非完整 ImageNet 验证集评测
- NPU 推理结果与 CPU 结果高度一致,相对误差 < 1.0%
10. 标签
#NPU #Ascend #Ascend910 #RegNet #ImageClassification #facebook