当前位置: 首页 > news >正文

CANN/asnumpy-docs 架构设计

Architecture

【免费下载链接】asnumpy-docs项目地址: https://gitcode.com/cann/asnumpy-docs

This document describes the internal architecture of AsNumpy, including the three-layer design, the coreNPUArraydata structure, the API module layout, and the NPU extension strategy via OpenBOAT.

Three-Layer Architecture

AsNumpy is built on three layers that cleanly separate concerns:

+------------------------------------------+ | Python Frontend (asnumpy/*.py) | | - __init__.py 122+ exported symbols | | - array.py array creation (10 fn) | | - math.py math ops (80+ fn) | | - linalg/ linear algebra | | - random/ random sampling | | - logic.py logic functions (16 fn) | | - nn.py neural network (softmax) | | - statistics.py statistics (mean) | +------------------------------------------+ | pybind11 binding layer (python/*.cpp) PYBIND11_MODULE(asnumpy_core, ...) | +------------------------------------------+ | C++ Core (src/, include/) | | - NPUArray core data structure | | - namespace asnumpy operator impls | | - Ascend ACL / ACLNN operator wrappers | | - CANN Runtime device management | +------------------------------------------+ | Huawei CANN (ascendcl, runtime, nnopbase, opapi) | +------------------------------------------+ | Ascend NPU Hardware (910B) | +------------------------------------------+

NPUArray Design

NPUArrayis the core data structure of AsNumpy. It is designed around three principles:

Compatibility

NPUArrayexposes the same interface asnumpy.ndarrayat the Python level. Functions are named identically (add,multiply,matmul, …) so existing NumPy code can be migrated by changing the import and adding data transfer calls.

Encapsulation

Internally,NPUArrayholds:

  • dtype— element type (aclDtype)
  • shape— dimension sizes
  • strides— memory layout
  • tensorPtr— pointer to the underlyingaclTensor
  • devicePtr(private) — raw device memory address, exposed viadevice_address()

Users never interact with these fields directly; the Python layer presents a clean ndarray-like interface.

Resource Management

NPUArrayfollows RAII: the destructor automatically callsaclDestroyTensorandaclrtFree, eliminating manual memory management. All four C++ value semantics are implemented (copy constructor, move constructor, copy assignment, move assignment).

Data transfer:

  • FromNumpy— usesACL_MEMCPY_HOST_TO_DEVICE
  • ToNumpy— usesACL_MEMCPY_DEVICE_TO_HOST;float16/BF16require specialuint16_tunpacking

API Architecture

AsNumpy's API is divided intofunctional modulesandfoundation modules:

Functional modulescover the primary scientific computing domains:

ModulePythonC++ namespaceStatus
Math (arithmetic, trig, exp, log)math.pyasnumpy::Complete
Linear algebralinalg/globalIn progress
Random samplingrandom/globalIn progress
Logic functionslogic.pyasnumpy::Complete
Array creationarray.pyglobalComplete
Sortingsorting.pyglobalComplete
Neural networknn.pyasnumpy::Complete (softmax)
Statisticsstatistics.pyasnumpy::Complete (mean)
I/Oio.pydelegated to NumPyComplete

Foundation modulessupport the functional layer:

ModuleRole
NPUArray(src/utils/)Core data structure
CANN driver(src/cann/)Device initialization and lifecycle
dtypes(src/dtypes/)Data type registration
pybind11 bindings(python/)Python-C++ interface

NPU Extension Module

CANN's built-in operators are primarily designed for deep learning (training and inference). AsNumpy targets general scientific computing — data analysis, numerical methods, signal processing — which requires a broader operator set than CANN alone provides.

The gap:CANN built-in operators cannot cover all of NumPy's API surface.

The strategy:

  • Wrap existing CANN built-in operators directly
  • Develop missing operators manually (Ascend C)
  • Supplement with the OpenBOAT open-source operator library

The value:This three-pronged approach progressively closes the compatibility gap toward the goal of covering the top 100 most-used NumPy APIs by v1.0.

OpenBOAT

OpenBOATis an open-source Ascend C operator library built and maintained by theAISS Group, School of Computer Science, Harbin Institute of Technology(led by Prof. Su Tonghua).

AttributeDetail
Project URLhttps://link.gitcode.com/i/12691f46a888c7311bb4fce1e088b7f9
TeamAISS Group, HIT — Prof. Su Tonghua
TechnologyHuawei Ascend C programming language
Role in AsNumpyProvides operator implementations not covered by CANN built-ins, enabling broader NumPy API compatibility

AsNumpy and OpenBOAT are developed by the same research group, ensuring tight integration and coordinated roadmap planning.

【免费下载链接】asnumpy-docs项目地址: https://gitcode.com/cann/asnumpy-docs

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

http://www.jsqmd.com/news/853209/

相关文章:

  • Kafka-UI:3分钟快速上手,轻松管理你的Apache Kafka集群
  • ESP32任务阻塞导致看门狗报错?手把手教你用menuconfig调整超时时间
  • 浏览器资源嗅探扩展架构:基于网络请求拦截的流媒体下载技术方案
  • MATLAB图像处理实战:用RGB、HSV、YCbCr模型给照片换个风格(附完整代码)
  • WorkBuddy帮我优化服务器JVM,GC频率提升了1000倍,程序员离失业还有多远
  • 日常吃香蕉的实用功效:从三餐到应急的场景解读 - 奔跑123
  • CANN/asc-devkit:Transpose数据转换API文档
  • JSBSim性能优化:多线程、实时仿真与内存管理技巧
  • 新电脑到手别急着用!Win11磁盘分区、软件安装位置迁移保姆级避坑指南
  • 深度解密Il2CppDumper:Unity逆向工程的高效实战指南
  • 3分钟掌握Cursor Pro永久激活:免费解锁AI编程助手完整指南
  • 深圳市火灵鸟技术有限公司|5G全景执法装备国家高新技术企业 - 品牌优选官
  • 远程协助控制软件下载 远程控制app推荐无界趣连2.0
  • 从安装到创作:Redream完整入门教程,让AI绘图小白变高手
  • 私人健身与教练预约|基于SprinBoot+vue的私人健身与教练预约管理系统(源码+数据库+文档)
  • 长沙小程序开发领域深度研究 主流趋势详细解读 - 软件测评师
  • 图像修复新标杆:NAFNet如何用更简单的架构实现更好的效果?
  • 猫抓浏览器扩展终极指南:一键捕获网页视频与M3U8流媒体的完整教程
  • cann/asc-devkit Asin缓冲区因子大小接口
  • ops-collections多线程并发优化终极指南:如何充分利用昇腾硬件资源提升10倍性能 [特殊字符]
  • CANN/asc-devkit SetFmatrix API
  • CANN/asc-devkit获取KFC工作空间内存地址API
  • CSS渐变完全掌握:从基础到高级技巧
  • CANN/asc-devkit ReduceMin临时空间接口
  • CANN/asc-devkit SetCurBufSize函数文档
  • CANN/asnumpy随机抽样API
  • 如何通过智能菜单栏管理让Mac界面焕然一新:Hidden Bar深度使用指南
  • Internetarchive元数据管理实战:掌握metadata操作的最佳实践
  • MaxBot抢票机器人:2025终极自动化抢票神器指南,5步轻松搞定热门门票
  • 别再死磕理论了!用SolidWorks从零到一,手把手教你搭建一个能动的三自由度机械臂模型