CANN/AsNumpy:昇腾NPU原生NumPy库
【免费下载链接】asnumpy哈尔滨工业大学计算学部苏统华、王甜甜老师团队联合华为CANN团队开发的华为昇腾NPU原生Numpy仓库项目地址: https://gitcode.com/cann/asnumpyAsNumpyNumPy for Ascend NPUDocs | Installation | Quick Start | Examples | Architecture | Issues | OpenBOATAsNumpy is a lightweight Python library for scientific computing on Ascend NPU, fully compatible with the NumPy API. It wraps Huawei CANN operators through a pybind11 binding layer, exposing them via theNPUArraydata structure that mirrorsnumpy.ndarray. Developed by the AISS Group and the ISE Group at Harbin Institute of Technology, in collaboration with the Huawei CANN team.import numpy as np import asnumpy as ap # Generate data on CPU m1 np.random.normal(0, 1, (3000, 3000)).astype(np.float32) m2 np.random.normal(0, 1, (3000, 3000)).astype(np.float32) # Transfer to NPU m1_npu ap.ndarray.from_numpy(m1) m2_npu ap.ndarray.from_numpy(m2) # Compute on NPU — same API as NumPy result ap.multiply(m1_npu, m2_npu) # Transfer back to CPU print(result.to_numpy())FeaturesInstallationQuick StartPerformanceRoadmapContributingResourcesLicenseAcknowledgementsFeaturesNumPy-compatible API— function names and signatures match NumPy; migrate existing code with minimal changesAscend 910B native acceleration— operators run directly on NPU via CANN ACLNN without framework overheadAutomatic resource management—NPUArraydestructor releases device memory automatically (RAII)Bidirectional data transfer—from_numpy()andto_numpy()for seamless CPU↔NPU exchangeBroadcasting support— built-inGetBroadcastShape()follows NumPy broadcasting semanticsOperator extensibility— missing CANN operators are supplemented by OpenBOATInstallationRequirements:GCC 11.2, CMake 3.26, Python 3.9, CANN 8.2.RC1.alpha003, Ascend 910B NPU.Set the CANN environment variable before building:export ASCEND_TOOLKIT_HOME/usr/local/Ascend/ascend-toolkit/latestUsing uv (recommended)git clone --recursive https://link.gitcode.com/i/2eec800a7724c906f2ab331896f4bf05.git cd asnumpy uv syncUsing pipgit clone --recursive https://link.gitcode.com/i/2eec800a7724c906f2ab331896f4bf05.git cd asnumpy # Upgrade pip, setuptools, and wheel to their latest versions pip install --upgrade pip setuptools wheel # Install the build package, which provides a simple build front-end for Python packages pip install build # Build the current Python project (create source distribution and wheel) python -m build # Install all generated wheel (.whl) files from the dist/ directory pip install dist/*.whlVerify the installationimport asnumpy as ap arr ap.ones((1000, 1000), dtypeap.float32) print(arr.shape) # (1000, 1000)Quick StartA minimal example is shown above. For a full side-by-side comparison of NumPy vs AsNumpy code and more usage patterns, see the Quick Start guide.Runnable scripts are inexamples/.PerformanceAt 3000×3000float32,ap.multiply()runs128.70× fasterthannp.multiply()on the same machine.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×Full test environment, controlled variables, and reproduction instructions: benchmarks.md.RoadmapReleaseQuarterKey Deliverablesv0.3.026Q1Documentation site (Docsify GitCode Pages), CI/CD pipeline with hardware whitelist, code quality overhaul (spdlog, clang-format), PyPI releasev0.4.026Q2Mathematical functions 100% API coverage, Ascend 950 validation, triton-ascend operator integration (10 ops), memory pool (experimental)v0.5.026Q2Linear algebra full coverage, triton-ascend operator library expanded to 20 ops, multi-NPU distributed computing researchContributingContributions are welcome. Small fixes can be submitted directly as pull requests. For larger features, please open an issue first to discuss the design.See the Developer Guide for build instructions, coding conventions, and how to add new operators.ResourcesDocumentationQuick StartArchitectureBenchmarksFAQDeveloper GuideExamplesIssue TrackerOpenBOAT Operator LibraryLicenseApache License, Version 2.0 — see LICENSE.AsNumpy is designed based on NumPys API (see NumPy license).AsNumpy is being developed and maintained by the School of Computer Science, Harbin Institute of Technology in deep collaboration with the Huawei CANN team, together with community contributors.AcknowledgementsAISS Group, School of Computer Science, Harbin Institute of Technology — Prof. Su Tonghuas teamISE Group, School of Computer Science, Harbin Institute of Technology — Prof. Wang Tiantians teamHuawei CANN teamIf AsNumpy is useful to you, please give us a star.【免费下载链接】asnumpy哈尔滨工业大学计算学部苏统华、王甜甜老师团队联合华为CANN团队开发的华为昇腾NPU原生Numpy仓库项目地址: https://gitcode.com/cann/asnumpy创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考