uxlfoundation/oneDNN
GitHub: uxlfoundation/oneDNN
oneDNN 是一个开源跨平台深度学习性能库,为 CPU 和 GPU 上的神经网络推理与训练提供高度优化的基础构建块。
Stars: 3990 | Forks: 1131
[][UXL Foundation]
# oneAPI Deep Neural Network Library (oneDNN)
[](https://www.bestpractices.dev/projects/8762)
[](https://securityscorecards.dev/viewer/?uri=github.com/uxlfoundation/oneDNN)
oneAPI Deep Neural Network Library (oneDNN) 是一个开源的跨平台性能库,包含用于深度学习应用的基础构建块。
oneDNN 项目是 [UXL Foundation] 的一部分,并且是 oneDNN 组件的 [oneAPI specification] 实现。
该库针对基于 Intel 64/AMD64 架构的处理器、基于 Arm(R) 64 位架构 (AArch64) 的处理器以及 Intel Graphics 进行了优化。
oneDNN 对以下架构提供实验性支持:NVIDIA\* GPU、AMD\* GPU、OpenPOWER\* Power ISA (PPC64)、IBMz\* (s390x) 和 RISC-V。
oneDNN 面向深度学习应用程序和框架开发者,旨在提升应用在 CPU 和 GPU 上的性能。
深度学习从业者应使用以下启用了 oneDNN 的应用程序之一:
* [Apache SINGA](https://singa.apache.org)
* [DeepLearning4J\*](https://deeplearning4j.konduit.ai)
* [Flashlight\*](https://github.com/flashlight/flashlight)
* [llama.cpp](https://github.com/ggml-org/llama.cpp)
* [ONNX Runtime](https://onnxruntime.ai)
* [OpenNMT CTranslate2](https://github.com/OpenNMT/CTranslate2)
* [OpenVINO(TM) toolkit](https://github.com/openvinotoolkit/openvino)
* [PaddlePaddle\*](http://www.paddlepaddle.org)
* [PyTorch\*](https://pytorch.org)
* [Tensorflow\*](https://www.tensorflow.org)
## 目录
- [文档](#documentation)
- [系统要求](#system-requirements)
- [安装](#installation)
- [已验证配置](#validated-configurations)
- [治理](#governance)
- [支持](#support)
- [贡献](#contributing)
- [许可证](#license)
- [安全](#security)
- [商标信息](#trademark-information)
## 文档
* [oneDNN Developer Guide and Reference] 解释了编程模型、支持的功能和实现细节,并包含带有注释的示例。
* [API Reference] 提供了库 API 的全面参考。
* [Release Notes] 说明了每个 oneDNN 版本中实现的新功能、性能优化和改进。
## 系统要求
oneDNN 支持基于以下架构的平台:
- [Intel 64 or AMD64](https://en.wikipedia.org/wiki/X86-64),
- [Arm 64-bit Architecture (AArch64)](https://developer.arm.com/architectures/cpu-architecture/a-profile).
- [OpenPOWER](https://openpowerfoundation.org/) / [IBM Power ISA](https://en.wikipedia.org/wiki/Power_ISA).
- [IBMz z/Architecture (s390x)](https://en.wikipedia.org/wiki/Z/Architecture).
- [RISC-V 64-bit (RV64)](https://en.wikipedia.org/wiki/RISC-V).
该库针对以下 CPU 进行了优化:
* Intel 64/AMD64 架构
* Intel Atom(R) 处理器(至少需要 Intel SSE4.1 支持)
* Intel Core(TM) 处理器(至少需要 Intel SSE4.1 支持)
* Intel Xeon(R) 处理器 E3、E5 和 E7 家族(原 Sandy Bridge、Ivy Bridge、Haswell 和 Broadwell)
* Intel Xeon Scalable 处理器(原 Skylake、Cascade Lake、Cooper Lake、Ice Lake、Sapphire Rapids 和 Emerald Rapids)
* Intel Xeon CPU Max 系列(原 Sapphire Rapids HBM)
* Intel Core Ultra 处理器(原 Meteor Lake、Arrow Lake、Lunar Lake 和 Panther Lake)
* Intel Xeon 6 处理器(原 Sierra Forest 和 Granite Rapids)
* 支持 Intel AVX10.2 指令集的未来 Intel Core 处理器(代号 Nova Lake)
* 支持 Intel AVX10.2 指令集的未来 Intel Xeon 处理器(代号 Diamond Rapids)
* AArch64 架构
* Arm Neoverse(TM) N1 和 V1 处理器
在基于 Intel 64 或 AMD64 架构的 CPU 上,oneDNN 会在运行时检测指令集架构 (ISA),并使用即时 (JIT) 代码生成来部署针对最新支持 ISA 优化的代码。未来的 ISA 可能会在库中默认处于初始禁用状态,需要使用运行时控制来启用它们。有关更多详细信息,请参见 [CPU dispatcher control]。
该库针对以下 GPU 进行了优化:
* Intel 独立显卡:
* Intel Iris Xe MAX Graphics(原 DG1)
* Intel Arc(TM) A-Series Graphics(原 Alchemist)
* Intel Data Center GPU Flex Series(原 Arctic Sound)
* Intel Data Center GPU Max Series(原 Ponte Vecchio)
* Intel Arc B-Series Graphics 和 Intel Arc Pro B-Series Graphics(原 Battlemage)
* 基于 Xe3p-XPC 架构的未来独立显卡(代号 Crescent Island)
* Intel 集成显卡:
* 第 11-14 代 Intel Core 处理器
* Intel Core Ultra Series 1 处理器的 Intel Graphics(原 Meteor Lake)
* Intel Core Ultra Series 2 处理器的 Intel Graphics(原 Arrow Lake 和 Lunar Lake)
* Intel Core Ultra Series 3 处理器的 Intel Graphics(原 Panther Lake)
* Intel Core Series 3 处理器的 Intel Graphics(原 Wildcat Lake)
* 未来 Intel Core Ultra 处理器的 Intel Graphics(代号 Nova Lake)
### 从源码构建的要求
oneDNN 支持满足以下要求的系统:
* 支持 Intel 64/AMD64、AArch 64、PPC64 或 s390x 架构的操作系统
* 支持 C++11 标准的 C++ 编译器
* [CMake] 3.13 或更高版本
构建 oneDNN 文档需要以下工具:
* [Doxygen] 1.8.5 或更高版本
* [Doxyrest] 2.1.2 或更高版本
* [Sphinx] 6.2.1 或更高版本
* [sphinx-book-theme] 1.1.4 或更高版本
* [sphinx-copybutton] 0.5.2 或更高版本
* [graphviz] 2.40.1
CPU 和 GPU 引擎的配置可能会引入额外的构建时依赖。
#### CPU 引擎
oneDNN CPU 引擎用于在基于 Intel 64/AMD64 的处理器、64 位 Arm 架构 (AArch64) 处理器、64 位 Power ISA (PPC64) 处理器、IBMz (s390x) 及兼容设备上执行原语。
CPU 引擎在默认情况下会构建,但可以在构建时通过将 `ONEDNN_CPU_RUNTIME` 设置为 `NONE` 来禁用。在这种情况下,必须启用 GPU 引擎。
CPU 引擎可以配置为使用 OpenMP、TBB 或 SYCL 运行时。以下附加要求适用:
* OpenMP 运行时需要支持 OpenMP 2.0 或更高版本标准的 C++ 编译器
* TBB 运行时需要 [Threading Building Blocks (TBB)] 2017 或更高版本。
* SYCL 运行时需要
* [Intel oneAPI DPC++/C++ Compiler]
* [Threading Building Blocks (TBB)]
某些实现依赖于 OpenMP 4.0 SIMD 扩展。为了在 Intel 架构处理器上获得最佳性能,我们推荐使用 Intel C++ 编译器。
在基于 Arm AArch64 架构的 CPU 上,oneDNN CPU 引擎可以通过 [Arm Compute Library (ACL)] 集成来构建。ACL 是一个用于机器学习应用的开源库,提供核心函数的 AArch64 优化实现。此功能目前要求单独下载并构建 ACL。有关详细信息,请参阅开发者指南中的 [Build from Source] 章节。ACL 支持的最低版本为 52.7.0。
#### GPU 引擎
oneDNN GPU 引擎用于在各种加速器(包括 Intel 集成和独立显卡、NVIDIA GPU、AMD GPU 以及其他支持 SYCL 编程语言的设备)上执行原语。GPU 引擎在默认构建配置中处于禁用状态,可以通过将 `ONEDNN_GPU_RUNTIME` 构建选项设置为 `NONE` 以外的值来启用。必须在构建时使用 `ONEDNN_GPU_VENDOR` 构建选项选择目标加速器供应商。
对于 Intel 集成和独立显卡,适用以下附加要求:
* 使用 OpenCL(TM) 运行时:
* OpenCL SDK(支持 OpenCL 1.2)
* 支持 OpenCL C 2.0、Intel 子组支持和 USM 扩展支持的 Intel 显卡驱动程序
* 使用 SYCL 运行时:
* [Intel oneAPI DPC++/C++ Compiler]
* OpenCL SDK(支持 OpenCL 3.0)
* [oneAPI Level Zero]
* 支持 OpenCL C 2.0、Intel 子组支持和 USM 扩展支持的 Intel 显卡驱动程序
对于 NVIDIA GPU,适用以下附加要求:
* [oneAPI DPC++ Compiler with support for CUDA] 或 [oneAPI for NVIDIA GPUs]
* NVIDIA CUDA\* 驱动程序
* cuBLAS 10.1 或更高版本
* cuDNN 7.6 或更高版本
对于 AMD GPU,适用以下附加要求:
* [oneAPI DPC++ Compiler with support for HIP AMD] 或 [oneAPI for AMD GPUs]
* [AMD ROCm] 5.3 或更高版本
* [MIOpen] 2.18 或更高版本(如果 AMD ROCm 包含所需版本的 MIOpen,则为可选)
* [rocBLAS] 2.45.0 或更高版本(如果 AMD ROCm 包含所需版本的 rocBLAS,则为可选)
其他支持 SYCL 编程模型的设备需要支持目标 GPU 的 oneAPI DPC++/C++ 编译器。有关更多详细信息,请参阅 [generic GPU vendor] 文档。
[generic GPU vendor](src/gpu/generic/sycl/README.md)
### 运行时依赖
当 oneDNN 从源代码构建时,库的运行时依赖项和特定版本由构建环境定义。
#### Linux
常见依赖项:
* GNU C 库 (`libc.so`)
* GNU Standard C++ Library v3 (`libstdc++.so`)
* 动态链接库 (`libdl.so`)
* C 数学库 (`libm.so`)
* POSIX 线程库 (`libpthread.so`)
特定运行时依赖项:
| 运行时配置 | 编译器 | 依赖项
| :------------------------- | :---------------------------- | :---------
| `ONEDNN_CPU_RUNTIME=OMP` | GCC | GNU OpenMP 运行时 (`libgomp.so`)
| `ONEDNN_CPU_RUNTIME=OMP` | Intel C/C++ Compiler | Intel OpenMP 运行时 (`libiomp5.so`)
| `ONEDNN_CPU_RUNTIME=OMP` | Clang | Intel OpenMP 运行时 (`libiomp5.so`)
| `ONEDNN_CPU_RUNTIME=TBB` | any | TBB (`libtbb.so`)
| `ONEDNN_CPU_RUNTIME=SYCL` | Intel oneAPI DPC++ Compiler | Intel oneAPI DPC++ Compiler 运行时 (`libsycl.so`), TBB (`libtbb.so`), OpenCL 加载器 (`libOpenCL.so`)
| `ONEDNN_GPU_RUNTIME=OCL` | any | OpenCL 加载器 (`libOpenCL.so`)
| `ONEDNN_GPU_RUNTIME=SYCL` | Intel oneAPI DPC++ Compiler | Intel oneAPI DPC++ Compiler 运行时 (`libsycl.so`), OpenCL 加载器 (`libOpenCL.so`), oneAPI Level Zero 加载器 (`libze_loader.so`)
| `ONEDNN_GPU_RUNTIME=ZE` | any | oneAPI Level Zero 加载器 (`libze_loader.so`)
#### Windows
常见依赖项:
* Microsoft Visual C++ Redistributable (`msvcrt.dll`)
特定运行时依赖项:
| 运行时配置 | 编译器 | 依赖项
| :------------------------- | :---------------------------- | :---------
| `ONEDNN_CPU_RUNTIME=OMP` | Microsoft Visual C++ Compiler | 无额外要求
| `ONEDNN_CPU_RUNTIME=OMP` | Intel C/C++ Compiler | Intel OpenMP 运行时 (`iomp5.dll`)
| `ONEDNN_CPU_RUNTIME=TBB` | any | TBB (`tbb.dll`)
| `ONEDNN_CPU_RUNTIME=SYCL` | Intel oneAPI DPC++ Compiler | Intel oneAPI DPC++ Compiler 运行时 (`sycl.dll`), TBB (`tbb.dll`), OpenCL 加载器 (`OpenCL.dll`)
| `ONEDNN_GPU_RUNTIME=OCL` | | OpenCL 加载器 (`OpenCL.dll`)
| `ONEDNN_GPU_RUNTIME=SYCL` | Intel oneAPI DPC++ Compiler | Intel oneAPI DPC++ Compiler 运行时 (`sycl.dll`), OpenCL 加载器 (`OpenCL.dll`), oneAPI Level Zero 加载器 (`ze_loader.dll`)
| `ONEDNN_GPU_RUNTIME=ZE` | any | oneAPI Level Zero 加载器 (`ze_loader.dll`)
#### macOS
常见依赖项:
* 系统 C/C++ 运行时 (`libc++.dylib`, `libSystem.dylib`)
特定运行时依赖项:
| 运行时配置 | 编译器 | 依赖项
| :----------------------- | :---------------------------- | :---------
| `ONEDNN_CPU_RUNTIME=OMP` | Intel C/C++ Compiler | Intel OpenMP 运行时 (`libiomp5.dylib`)
| `ONEDNN_CPU_RUNTIME=TBB` | any | TBB (`libtbb.dylib`)
## 安装
您可以使用以下选项之一下载并安装 oneDNN 库:
- 二进制分发版:您可以从以下来源下载预构建的二进制包:
- [conda-forge]:如果您需要的配置在 conda-forge 频道上不可用,您可以使用源码分发版构建该库。
- Intel oneAPI:
- [Intel® oneAPI Base Toolkit](https://www.intel.com/content/www/us/en/developer/tools/oneapi/base-toolkit-download.htm)
- [Intel® oneDNN standalone package](https://www.intel.com/content/www/us/en/developer/tools/oneapi/onednn-download.html)
- 源码分发版:您可以按照 [Build from Source] 页面上的说明从源代码构建该库。
## 已验证配置
x86-64 CPU 引擎在 RedHat\* Enterprise Linux 8 上使用以下工具进行了验证:
* GNU Compiler Collection 8.5、9.5、11.1、11.3
* Clang\* 11.0、14.0.6
* [Intel oneAPI DPC++/C++ Compiler] 2025.1
在 Windows Server\* 2019 上使用以下工具进行了验证:
* Microsoft Visual Studio 2022 和 MSVC 19.43
* [Intel oneAPI DPC++/C++ Compiler] 2025.1
在 macOS 14 (Sonoma) 上使用以下工具进行了验证:
* Apple LLVM 15.0 版本
AArch64 CPU 引擎在 Ubuntu 22.04 上使用以下工具进行了验证:
* GNU Compiler Collection 10.0、13.0
* Clang\* 17.0
* [Arm Compiler for Linux] 24.04
* 为 armv8-a 架构构建的 [Arm Compute Library (ACL)],发布时可用的最新稳定版本
在 macOS 14 (Sonoma) 上使用以下工具进行了验证:
* Apple LLVM 15.0 版本
GPU 引擎在 Ubuntu\* 22.04 上使用以下工具进行了验证:
* GNU Compiler Collection 8.5 和 9.5
* Clang\* 11.0
* [Intel oneAPI DPC++/C++ Compiler] 2025.1
* 发布时可用的最新稳定版 [Intel Software for General Purpose GPU capabilities]
在 Windows Server\* 2019 上使用以下工具进行了验证:
* Microsoft Visual Studio 2022 和 MSVC 19.43
* [Intel oneAPI DPC++/C++ Compiler] 2025.1
* 发布时可用的最新稳定版 [Intel Arc & Iris Xe Graphics Driver]
## 支持
请在 [GitHub issues] 页面提交问题、功能请求和错误报告。
您也可以通过 [UXL Foundation Slack] 使用 [#onednn] 频道联系 oneDNN 开发者。
## 治理
oneDNN 项目由 [UXL Foundation] 治理,您可以通过多种方式参与此项目。您可以加入 [AI Special Interest Group (SIG)] 会议,各小组会在会上讨论并展示使用该项目的工作。成员还可以加入开源和规范工作组会议。
您也可以加入 [mailing lists for the UXL Foundation],以获取会议举行的通知并接收最新信息和讨论。
## 贡献
我们欢迎社区对 oneDNN 的贡献。您可以在 Github 的 [Milestones] 部分找到 oneDNN 的发布计划和正在为未来里程碑进行的工作。如果您正在寻找特定任务来开始,可以考虑从标记有 [help wanted] 标签的问题中进行选择。
请参阅[贡献指南](CONTRIBUTING.md)以开始向 oneDNN 贡献。您也可以通过 [UXL Foundation Slack] 使用 [#onednn] 频道联系 oneDNN 的开发者和维护者。
本项目旨在成为一个安全、欢迎的合作空间,贡献者应遵守 [Contributor Covenant](CODE_OF_CONDUCT.md) 行为准则。
## 许可证
oneDNN 在 [Apache License Version 2.0](LICENSE) 下获得许可。有关完整的许可文本和版权声明,请参阅“[LICENSE](LICENSE)”文件。
本分发版包含受单独许可条款管辖的第三方软件。
3 条款 BSD 许可证:
* [Xbyak](https://github.com/herumi/xbyak)
* [gtest](https://github.com/google/googletest)
* [Instrumentation and Tracing Technology API (ITT API)](https://github.com/intel/ittapi)
* [CMake](https://github.com/Kitware/CMake)
2 条款 BSD 许可证:
* [Sphinx](https://www.sphinx-doc.org/)
Apache License Version 2.0:
* [Xbyak_aarch64](https://github.com/fujitsu/xbyak_aarch64)
* [OpenCLTM API Headers](https://github.com/KhronosGroup/OpenCL-Headers)
Boost Software License, Version 1.0:
* [Boost C++ Libraries](https://www.boost.org/)
MIT License:
* [Intel Graphics Compute Runtime for oneAPI Level Zero and OpenCL Driver](https://github.com/intel/compute-runtime)
* [Intel Graphics Compiler](https://github.com/intel/intel-graphics-compiler)
* [oneAPI Level Zero](https://github.com/oneapi-src/level-zero)
* [Doxyrest](https://github.com/vovkos/doxyrest)
* [Intel Metrics Discovery Application Programming Interface](https://github.com/intel/metrics-discovery)
* [spdlog](https://github.com/gabime/spdlog)
* [sphinx-copybutton](https://github.com/executablebooks/sphinx-copybutton)
此第三方软件,即使随其他软件一起分发,也可能受单独的许可条款管辖,包括但不限于第三方许可条款、其他软件许可条款和开源软件许可条款。这些单独的许可条款管辖您对第三方程序的使用,如“[THIRD-PARTY-PROGRAMS](THIRD-PARTY-PROGRAMS)”文件中所列。
## 安全
[安全策略](SECURITY.md) 概述了我们的指南和程序,旨在为使用 oneDNN 的用户确保最高级别的安全性和信任。
[法律信息](doc/legal_information.md)
标签:AI加速, AMD, Apex, Bash脚本, C++, CPU优化, Intel, oneAPI, oneDNN, ONNX, PyTorch, RISC-V, TensorFlow, Veh, 大模型推理, 并发计算, 底层优化, 底层架构, 开源库, 搜索引擎爬虫, 数据擦除, 机器学习, 深度学习, 神经网络, 算子库, 英特尔, 计算机视觉, 高性能计算