CANN/asnumpy 基准测试

📅 2026/7/9 13:43:24 👁️ 阅读次数 📝 编程学习
CANN/asnumpy 基准测试

Benchmarks

【免费下载链接】asnumpy哈尔滨工业大学计算学部苏统华、王甜甜老师团队联合华为CANN团队开发的华为昇腾NPU原生Numpy仓库项目地址: https://gitcode.com/cann/asnumpy

Back to README | Reproduce:examples/03_multiply.py

This document contains the full performance benchmark comparing AsNumpy (NPU) against NumPy (CPU) on themultiply()operation.

Test Environment

ItemAsNumpy (NPU)NumPy (CPU)
ProcessorAscend 910B NPUServer CPU (AArch64) on the same machine
NPU RuntimeCANN 8.2.RC1.alpha003
PythonPython 3.9+
Library versionAsNumpy 0.2.0NumPy 1.26+
Data typefloat32
Operationmultiply() — element-wise multiplication
Timertime.perf_counter() (high-resolution)

Controlled Variables

  • Both sides useidentical input data: arrays are generated by NumPy and transferred to NPU viafrom_numpy()before timing starts.
  • Data transfer time is excluded: only themultiply()computation is timed.
  • Results are single-run wall-clock times (no warmup, no averaging).

Results

ShapeAsNumpy (NPU)NumPy (CPU)Speedup
(500, 500)1.9355 s0.1708 s0.09×
(1000, 1000)0.0692 s0.7029 s10.16×
(2000, 2000)0.1033 s3.8387 s37.17×
(3000, 3000)0.1115 s14.3567 s128.70×

Key observation:For small tensors (500×500), NPU launch overhead dominates and CPU is faster. As tensor size grows, NPU's massive parallelism takes over — reaching128.70× speedupat 3000×3000.

Reproducing the Results

Run the benchmark script from the project root:

python examples/03_multiply.py

The script tests all four shapes with 50 iterations each, reports average and minimum times, and verifies numerical correctness against NumPy (relative diff < 1e-4).

【免费下载链接】asnumpy哈尔滨工业大学计算学部苏统华、王甜甜老师团队联合华为CANN团队开发的华为昇腾NPU原生Numpy仓库项目地址: https://gitcode.com/cann/asnumpy

创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考