You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 14 kB

8 years ago
8 years ago
7 years ago
7 years ago
8 years ago
8 years ago
7 years ago
7 years ago
7 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
7 years ago
8 years ago
7 years ago
8 years ago
7 years ago
8 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
6 years ago
7 years ago
7 years ago
7 years ago
6 years ago
7 years ago
7 years ago
8 years ago
8 years ago
8 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. ![](https://raw.githubusercontent.com/Tencent/ncnn/master/images/256-ncnn.png)
  2. # ncnn
  3. [![License](https://img.shields.io/badge/license-BSD--3--Clause-blue.svg)](https://raw.githubusercontent.com/Tencent/ncnn/master/LICENSE.txt)
  4. [![Build Status](https://travis-ci.org/Tencent/ncnn.svg?branch=master)](https://travis-ci.org/Tencent/ncnn)
  5. [![codecov](https://codecov.io/gh/Tencent/ncnn/branch/master/graph/badge.svg)](https://codecov.io/gh/Tencent/ncnn)
  6. ncnn is a high-performance neural network inference computing framework optimized for mobile platforms. ncnn is deeply considerate about deployment and uses on mobile phones from the beginning of design. ncnn does not have third party dependencies. it is cross-platform, and runs faster than all known open source frameworks on mobile phone cpu. Developers can easily deploy deep learning algorithm models to the mobile platform by using efficient ncnn implementation, create intelligent APPs, and bring the artificial intelligence to your fingertips. ncnn is currently being used in many Tencent applications, such as QQ, Qzone, WeChat, Pitu and so on.
  7. ncnn 是一个为手机端极致优化的高性能神经网络前向计算框架。ncnn 从设计之初深刻考虑手机端的部署和使用。无第三方依赖,跨平台,手机端 cpu 的速度快于目前所有已知的开源框架。基于 ncnn,开发者能够将深度学习算法轻松移植到手机端高效执行,开发出人工智能 APP,将 AI 带到你的指尖。ncnn 目前已在腾讯多款应用中使用,如 QQ,Qzone,微信,天天P图等。
  8. ---
  9. ### Current building status matrix
  10. | System | CPU (32bit) | CPU (64bit) | GPU (32bit) | GPU (64bit) |
  11. | :---: | :---: | :---: | :--: | :--: |
  12. | Linux (GCC) | — | [![Build Status](https://img.shields.io/github/workflow/status/Tencent/ncnn/linux-x64-cpu-gcc)](https://github.com/Tencent/ncnn/actions?query=workflow%3Alinux-x64-cpu-gcc) | — | [![Build Status](https://img.shields.io/github/workflow/status/Tencent/ncnn/linux-x64-gpu-gcc)](https://github.com/Tencent/ncnn/actions?query=workflow%3Alinux-x64-gpu-gcc) |
  13. | Linux (Clang) | — | [![Build Status](https://img.shields.io/github/workflow/status/Tencent/ncnn/linux-x64-cpu-clang)](https://github.com/Tencent/ncnn/actions?query=workflow%3Alinux-x64-cpu-clang) | — | [![Build Status](https://img.shields.io/github/workflow/status/Tencent/ncnn/linux-x64-gpu-clang)](https://github.com/Tencent/ncnn/actions?query=workflow%3Alinux-x64-gpu-clang) |
  14. | Linux (ARM) | [![Build Status](https://img.shields.io/github/workflow/status/Tencent/ncnn/linux-arm-cpu-gcc)](https://github.com/Tencent/ncnn/actions?query=workflow%3Alinux-arm-cpu-gcc) | [![Build Status](https://img.shields.io/github/workflow/status/Tencent/ncnn/linux-aarch64-cpu-gcc)](https://github.com/Tencent/ncnn/actions?query=workflow%3Alinux-aarch64-cpu-gcc) | — | — |
  15. | Linux (MIPS) | [![Build Status](https://img.shields.io/github/workflow/status/Tencent/ncnn/linux-mips-cpu-gcc)](https://github.com/Tencent/ncnn/actions?query=workflow%3Alinux-mips-cpu-gcc) | [![Build Status](https://img.shields.io/github/workflow/status/Tencent/ncnn/linux-mips64-cpu-gcc)](https://github.com/Tencent/ncnn/actions?query=workflow%3Alinux-mips64-cpu-gcc) | — | — |
  16. | Linux (RISC-V) | — | [![Build Status](https://img.shields.io/github/workflow/status/Tencent/ncnn/linux-riscv64-cpu-gcc)](https://github.com/Tencent/ncnn/actions?query=workflow%3Alinux-riscv64-cpu-gcc) | — | — |
  17. | Windows (VS2017) | — | [![Build Status](https://badges.herokuapp.com/travis/Tencent/ncnn?env=NAME=windows-vs2017&label=build)](https://travis-ci.org/Tencent/ncnn) | — | [![Build Status](https://badges.herokuapp.com/travis/Tencent/ncnn?env=NAME=windows-vs2017-gpu&label=build)](https://travis-ci.org/Tencent/ncnn) |
  18. | Windows (VS2019) | — | [![Build Status](https://img.shields.io/github/workflow/status/Tencent/ncnn/windows-x64-cpu-vs2019)](https://github.com/Tencent/ncnn/actions?query=workflow%3Awindows-x64-cpu-vs2019) | — | [![Build Status](https://img.shields.io/github/workflow/status/Tencent/ncnn/windows-x64-gpu-vs2019)](https://github.com/Tencent/ncnn/actions?query=workflow%3Awindows-x64-gpu-vs2019) |
  19. | MacOS | — | [![Build Status](https://img.shields.io/github/workflow/status/Tencent/ncnn/macos-x64-cpu)](https://github.com/Tencent/ncnn/actions?query=workflow%3Amacos-x64-cpu) | — | [![Build Status](https://img.shields.io/github/workflow/status/Tencent/ncnn/macos-x64-gpu)](https://github.com/Tencent/ncnn/actions?query=workflow%3Amacos-x64-gpu) |
  20. | Android | [![Build Status](https://img.shields.io/github/workflow/status/Tencent/ncnn/android-armv7-cpu)](https://github.com/Tencent/ncnn/actions?query=workflow%3Aandroid-armv7-cpu) | [![Build Status](https://img.shields.io/github/workflow/status/Tencent/ncnn/android-armv8-cpu)](https://github.com/Tencent/ncnn/actions?query=workflow%3Aandroid-armv8-cpu) | [![Build Status](https://img.shields.io/github/workflow/status/Tencent/ncnn/android-armv7-gpu)](https://github.com/Tencent/ncnn/actions?query=workflow%3Aandroid-armv7-gpu) | [![Build Status](https://img.shields.io/github/workflow/status/Tencent/ncnn/android-armv8-gpu)](https://github.com/Tencent/ncnn/actions?query=workflow%3Aandroid-armv8-gpu) |
  21. | Android-x86 | [![Build Status](https://img.shields.io/github/workflow/status/Tencent/ncnn/android-x86-cpu)](https://github.com/Tencent/ncnn/actions?query=workflow%3Aandroid-x86-cpu) | [![Build Status](https://img.shields.io/github/workflow/status/Tencent/ncnn/android-x64-cpu)](https://github.com/Tencent/ncnn/actions?query=workflow%3Aandroid-x64-cpu) | [![Build Status](https://img.shields.io/github/workflow/status/Tencent/ncnn/android-x86-gpu)](https://github.com/Tencent/ncnn/actions?query=workflow%3Aandroid-x86-gpu) | [![Build Status](https://img.shields.io/github/workflow/status/Tencent/ncnn/android-x64-gpu)](https://github.com/Tencent/ncnn/actions?query=workflow%3Aandroid-x64-gpu) |
  22. | iOS | [![Build Status](https://img.shields.io/github/workflow/status/Tencent/ncnn/ios-cpu)](https://github.com/Tencent/ncnn/actions?query=workflow%3Aios-cpu) | [![Build Status](https://img.shields.io/github/workflow/status/Tencent/ncnn/ios-cpu)](https://github.com/Tencent/ncnn/actions?query=workflow%3Aios-cpu) | — | [![Build Status](https://img.shields.io/github/workflow/status/Tencent/ncnn/ios-64bit-gpu)](https://github.com/Tencent/ncnn/actions?query=workflow%3Aios-64bit-gpu) |
  23. | iOS Simulator | [![Build Status](https://img.shields.io/github/workflow/status/Tencent/ncnn/ios-simulator)](https://github.com/Tencent/ncnn/actions?query=workflow%3Aios-simulator) | [![Build Status](https://img.shields.io/github/workflow/status/Tencent/ncnn/ios-simulator)](https://github.com/Tencent/ncnn/actions?query=workflow%3Aios-simulator) | — | — |
  24. | WebAssembly | — | [![Build Status](https://img.shields.io/github/workflow/status/Tencent/ncnn/web-assembly)](https://github.com/Tencent/ncnn/actions?query=workflow%3Aweb-assembly) | — | — |
  25. | RISC-V GCC/Newlib | [![Build Status](https://img.shields.io/github/workflow/status/Tencent/ncnn/elf-riscv32-cpu-gcc)](https://github.com/Tencent/ncnn/actions?query=workflow%3Aelf-riscv32-cpu-gcc) | [![Build Status](https://img.shields.io/github/workflow/status/Tencent/ncnn/elf-riscv64-cpu-gcc)](https://github.com/Tencent/ncnn/actions?query=workflow%3Aelf-riscv64-cpu-gcc) | — | — |
  26. ---
  27. ### Support most commonly used CNN network
  28. ### 支持大部分常用的 CNN 网络
  29. * Classical CNN: VGG AlexNet GoogleNet Inception ...
  30. * Practical CNN: ResNet DenseNet SENet FPN ...
  31. * Light-weight CNN: SqueezeNet MobileNetV1/V2/V3 ShuffleNetV1/V2 MNasNet ...
  32. * Face Detection: MTCNN RetinaFace ...
  33. * Detection: VGG-SSD MobileNet-SSD SqueezeNet-SSD MobileNetV2-SSDLite MobileNetV3-SSDLite ...
  34. * Detection: Faster-RCNN R-FCN ...
  35. * Detection: YOLOV2 YOLOV3 MobileNet-YOLOV3 YOLOV4 ...
  36. * Segmentation: FCN PSPNet UNet YOLACT ...
  37. * Pose Estimation: SimplePose ...
  38. ---
  39. ### HowTo
  40. **[how to build ncnn library](https://github.com/Tencent/ncnn/wiki/how-to-build) on Linux / Windows / Raspberry Pi3 / Android / NVIDIA Jetson / iOS**
  41. * [Build for NVIDIA Jetson](https://github.com/Tencent/ncnn/wiki/how-to-build#build-for-nvidia-jetson)
  42. * [Build for Linux x86](https://github.com/Tencent/ncnn/wiki/how-to-build#build-for-linux-x86)
  43. * [Build for Windows x64 using VS2017](https://github.com/Tencent/ncnn/wiki/how-to-build#build-for-windows-x64-using-visual-studio-community-2017)
  44. * [Build for MacOSX](https://github.com/Tencent/ncnn/wiki/how-to-build#build-for-macosx)
  45. * [Build for Raspberry Pi 3](https://github.com/Tencent/ncnn/wiki/how-to-build#build-for-raspberry-pi-3)
  46. * [Build for ARM Cortex-A family with cross-compiling](https://github.com/Tencent/ncnn/wiki/how-to-build#build-for-arm-cortex-a-family-with-cross-compiling)
  47. * [Build for Android](https://github.com/Tencent/ncnn/wiki/how-to-build#build-for-android)
  48. * [Build for iOS on MacOSX with xcode](https://github.com/Tencent/ncnn/wiki/how-to-build#build-for-ios-on-macosx-with-xcode)
  49. * [Build for iOS on Linux with cctools-port](https://github.com/Tencent/ncnn/wiki/how-to-build#build-for-ios-on-linux-with-cctools-port)
  50. * [Build for Hisilicon platform with cross-compiling](https://github.com/Tencent/ncnn/wiki/how-to-build#build-for-hisilicon-platform-with-cross-compiling)
  51. **[download prebuild binary package for android and ios](https://github.com/Tencent/ncnn/releases)**
  52. **[use ncnn with alexnet](https://github.com/Tencent/ncnn/wiki/use-ncnn-with-alexnet) with detailed steps, recommended for beginners :)**
  53. **[ncnn 组件使用指北 alexnet](https://github.com/Tencent/ncnn/wiki/use-ncnn-with-alexnet.zh) 附带详细步骤,新人强烈推荐 :)**
  54. **[use netron for ncnn model visualization](https://lutzroeder.github.io/netron/)**
  55. [ncnn low-level operation api](https://github.com/Tencent/ncnn/wiki/low-level-operation-api)
  56. [ncnn param and model file spec](https://github.com/Tencent/ncnn/wiki/param-and-model-file-structure)
  57. [ncnn operation param weight table](https://github.com/Tencent/ncnn/wiki/operation-param-weight-table)
  58. [how to implement custom layer step by step](https://github.com/Tencent/ncnn/wiki/how-to-implement-custom-layer-step-by-step)
  59. ---
  60. ### FAQ
  61. **[ncnn throw error](https://github.com/Tencent/ncnn/wiki/FAQ-ncnn-throw-error)**
  62. **[ncnn produce wrong result](https://github.com/Tencent/ncnn/wiki/FAQ-ncnn-produce-wrong-result)**
  63. **[ncnn vulkan](https://github.com/Tencent/ncnn/wiki/FAQ-ncnn-vulkan)**
  64. ---
  65. ### Features
  66. * Supports convolutional neural networks, supports multiple input and multi-branch structure, can calculate part of the branch
  67. * No third-party library dependencies, does not rely on BLAS / NNPACK or any other computing framework
  68. * Pure C ++ implementation, cross-platform, supports android, ios and so on
  69. * ARM NEON assembly level of careful optimization, calculation speed is extremely high
  70. * Sophisticated memory management and data structure design, very low memory footprint
  71. * Supports multi-core parallel computing acceleration, ARM big.LITTLE cpu scheduling optimization
  72. * Supports GPU acceleration via the next-generation low-overhead vulkan api
  73. * The overall library size is less than 700K, and can be easily reduced to less than 300K
  74. * Extensible model design, supports 8bit quantization and half-precision floating point storage, can import caffe/pytorch/mxnet/onnx/darknet models
  75. * Support direct memory zero copy reference load network model
  76. * Can be registered with custom layer implementation and extended
  77. * Well, it is strong, not afraid of being stuffed with 卷 QvQ
  78. ### 功能概述
  79. * 支持卷积神经网络,支持多输入和多分支结构,可计算部分分支
  80. * 无任何第三方库依赖,不依赖 BLAS/NNPACK 等计算框架
  81. * 纯 C++ 实现,跨平台,支持 android ios 等
  82. * ARM NEON 汇编级良心优化,计算速度极快
  83. * 精细的内存管理和数据结构设计,内存占用极低
  84. * 支持多核并行计算加速,ARM big.LITTLE cpu 调度优化
  85. * 支持基于全新低消耗的 vulkan api GPU 加速
  86. * 整体库体积小于 700K,并可轻松精简到小于 300K
  87. * 可扩展的模型设计,支持 8bit 量化和半精度浮点存储,可导入 caffe/pytorch/mxnet/onnx/darknet 模型
  88. * 支持直接内存零拷贝引用加载网络模型
  89. * 可注册自定义层实现并扩展
  90. * 恩,很强就是了,不怕被塞卷 QvQ
  91. ---
  92. ### supported platform matrix
  93. * ✅ = known work and runs fast with good optimization
  94. * ✔️ = known work, but speed may not be fast enough
  95. * ❔ = shall work, not confirmed
  96. * / = not applied
  97. | |Windows|Linux|Android|MacOS|iOS|
  98. |---|---|---|---|---|---|
  99. |intel-cpu|✔️|✔️|❔|✔️|/|
  100. |intel-gpu|✔️|✔️|❔|❔|/|
  101. |amd-cpu|✔️|✔️|❔|✔️|/|
  102. |amd-gpu|✔️|✔️|❔|❔|/|
  103. |nvidia-gpu|✔️|✔️|❔|❔|/|
  104. |qcom-cpu|❔|✔️|✅|/|/|
  105. |qcom-gpu|❔|✔️|✔️|/|/|
  106. |arm-cpu|❔|❔|✅|/|/|
  107. |arm-gpu|❔|❔|✔️|/|/|
  108. |apple-cpu|/|/|/|/|✅|
  109. |apple-gpu|/|/|/|/|✔️|
  110. ---
  111. ### Example project
  112. * https://github.com/nihui/ncnn-android-squeezenet
  113. * https://github.com/nihui/ncnn-android-styletransfer
  114. * https://github.com/nihui/ncnn-android-mobilenetssd
  115. * https://github.com/moli232777144/mtcnn_ncnn
  116. ![](https://github.com/nihui/ncnn-assets/raw/master/20181217/ncnn-2.jpg)
  117. ![](https://github.com/nihui/ncnn-assets/raw/master/20181217/4.jpg)
  118. ![](https://github.com/nihui/ncnn-assets/raw/master/20181217/ncnn-33.jpg)
  119. ![](https://github.com/nihui/ncnn-assets/raw/master/20181217/ncnn-m.png)
  120. ### 技术交流QQ群:637093648(超多大佬) 答案:卷卷卷卷卷
  121. ---
  122. ### License
  123. [BSD 3 Clause](LICENSE.txt)