diff --git a/README.md b/README.md index 70c53a5775148c6608008d0a86a6966aca29c644..d995bcc327705228098c1b26753213928ad4a79d 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,6 @@ Paddle Lite提供了C++、Java、Python三种API,并且提供了相应API的 - [iOS示例](https://paddle-lite.readthedocs.io/zh/latest/demo_guides/ios_app_demo.html) - [ARMLinux示例](https://paddle-lite.readthedocs.io/zh/latest/demo_guides/linux_arm_demo.html) - [X86示例](https://paddle-lite.readthedocs.io/zh/latest/demo_guides/x86.html) -- [CUDA示例](https://paddle-lite.readthedocs.io/zh/latest/demo_guides/cuda.html) - [OpenCL示例](https://paddle-lite.readthedocs.io/zh/latest/demo_guides/opencl.html) - [FPGA示例](https://paddle-lite.readthedocs.io/zh/latest/demo_guides/fpga.html) - [华为NPU示例](https://paddle-lite.readthedocs.io/zh/latest/demo_guides/huawei_kirin_npu.html) @@ -77,7 +76,6 @@ Paddle Lite提供了C++、Java、Python三种API,并且提供了相应API的 | CPU(32bit) |  |  |  |  | | CPU(64bit) |  |  |  |  | | OpenCL | - | - |  | - | -| CUDA |  |  | - | - | | FPGA | - |  | - | - | | 华为NPU | - | - |  | - | | 百度 XPU |  |  | - | - | diff --git a/docs/index.rst b/docs/index.rst index 88170c3f6ee177b55631b008c888cb88eda866d3..adc52db898ce48818db3352cdecc8bc1ae6ed6bb 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -46,6 +46,7 @@ Welcome to Paddle-Lite's documentation! user_guides/post_quant_with_data user_guides/post_quant_no_data user_guides/model_quantization + user_guides/model_visualization user_guides/debug .. toctree:: diff --git a/docs/introduction/support_model_list.md b/docs/introduction/support_model_list.md index 016190290e90328b1a4be08ef0176360e67c6e24..11f39134b5457703cc00b2dde93d5ab286e48636 100644 --- a/docs/introduction/support_model_list.md +++ b/docs/introduction/support_model_list.md @@ -4,33 +4,35 @@ | 类别 | 类别细分 | 模型 | 支持平台 | |-|-|:-|:-| -| CV | 分类 | mobilenetv1 | ARM,X86,NPU,RKNPU,APU | -| CV | 分类 | mobilenetv2 | ARM,X86,NPU | -| CV | 分类 | resnet18 | ARM,NPU | -| CV | 分类 | resnet50 | ARM,X86,NPU,XPU | -| CV | 分类 | mnasnet | ARM,NPU | -| CV | 分类 | efficientnet | ARM | -| CV | 分类 | squeezenetv1.1 | ARM,NPU | -| CV | 分类 | ShufflenetV2 | ARM | -| CV | 分类 | shufflenet | ARM | -| CV | 分类 | inceptionv4 | ARM,X86,NPU | -| CV | 分类 | vgg16 | ARM | -| CV | 分类 | vgg19 | XPU| -| CV | 分类 | googlenet | ARM,X86,XPU | -| CV | 检测 | mobilenet_ssd | ARM,NPU* | -| CV | 检测 | mobilenet_yolov3 | ARM,NPU* | -| CV | 检测 | Faster RCNN | ARM | -| CV | 检测 | Mask RCNN | ARM | -| CV | 分割 | Deeplabv3 | ARM | -| CV | 分割 | unet | ARM | -| CV | 人脸 | facedetection | ARM | -| CV | 人脸 | facebox | ARM | -| CV | 人脸 | blazeface | ARM | -| CV | 人脸 | mtcnn | ARM | -| CV | OCR | ocr_attention | ARM | -| CV | GAN | CycleGAN | NPU | -| NLP | 机器翻译 | transformer | ARM,NPU* | -| NLP | 机器翻译 | BERT | XPU | -| NLP | 语义表示 | ERNIE | XPU | +| CV | 分类 | [MobileNetV1](https://paddlelite-demo.bj.bcebos.com/models/mobilenet_v1_fp32_224_fluid.tar.gz) | ARM,X86,NPU,RKNPU,APU | +| CV | 分类 | [MobileNetV2](https://paddlelite-demo.bj.bcebos.com/models/mobilenet_v2_fp32_224_fluid.tar.gz) | ARM,X86,NPU | +| CV | 分类 | [ResNet18](https://paddlelite-demo.bj.bcebos.com/models/resnet18_fp32_224_fluid.tar.gz) | ARM,NPU | +| CV | 分类 | [ResNet50](https://paddlelite-demo.bj.bcebos.com/models/resnet50_fp32_224_fluid.tar.gz) | ARM,X86,NPU,XPU | +| CV | 分类 | [MnasNet](https://paddlelite-demo.bj.bcebos.com/models/mnasnet_fp32_224_fluid.tar.gz) | ARM,NPU | +| CV | 分类 | [EfficientNet*](https://github.com/PaddlePaddle/PaddleClas) | ARM | +| CV | 分类 | [SqueezeNet](https://paddlelite-demo.bj.bcebos.com/models/squeezenet_fp32_224_fluid.tar.gz) | ARM,NPU | +| CV | 分类 | [ShufflenetV2*](https://github.com/PaddlePaddle/PaddleClas) | ARM | +| CV | 分类 | [ShuffleNet](https://paddlepaddle-inference-banchmark.bj.bcebos.com/shufflenet_inference.tar.gz) | ARM | +| CV | 分类 | [InceptionV4](https://paddle-inference-dist.bj.bcebos.com/inception_v4_simple.tar.gz) | ARM,X86,NPU | +| CV | 分类 | [VGG16](https://paddlepaddle-inference-banchmark.bj.bcebos.com/VGG16_inference.tar) | ARM | +| CV | 分类 | [VGG19](https://paddlepaddle-inference-banchmark.bj.bcebos.com/VGG19_inference.tar) | XPU| +| CV | 分类 | [GoogleNet](https://paddlepaddle-inference-banchmark.bj.bcebos.com/GoogleNet_inference.tar) | ARM,X86,XPU | +| CV | 检测 | [MobileNet-SSD](https://paddlelite-demo.bj.bcebos.com/models/ssd_mobilenet_v1_pascalvoc_fp32_300_fluid.tar.gz) | ARM,NPU* | +| CV | 检测 | [YOLOv3-MobileNetV3](https://paddlelite-demo.bj.bcebos.com/models/yolov3_mobilenet_v3_prune86_FPGM_320_fp32_fluid.tar.gz) | ARM,NPU* | +| CV | 检测 | [Faster RCNN](https://paddlepaddle-inference-banchmark.bj.bcebos.com/faster_rcnn.tar) | ARM | +| CV | 检测 | [Mask RCNN*](https://github.com/PaddlePaddle/PaddleDetection/blob/release/0.4/docs/MODEL_ZOO_cn.md) | ARM | +| CV | 分割 | [Deeplabv3](https://paddlelite-demo.bj.bcebos.com/models/deeplab_mobilenet_fp32_fluid.tar.gz) | ARM | +| CV | 分割 | [UNet](https://paddlelite-demo.bj.bcebos.com/models/Unet.zip) | ARM | +| CV | 人脸 | [FaceDetection](https://paddlelite-demo.bj.bcebos.com/models/facedetection_fp32_240_430_fluid.tar.gz) | ARM | +| CV | 人脸 | [FaceBoxes*](https://github.com/PaddlePaddle/PaddleDetection/blob/release/0.4/docs/featured_model/FACE_DETECTION.md#FaceBoxes) | ARM | +| CV | 人脸 | [BlazeFace*](https://github.com/PaddlePaddle/PaddleDetection/blob/release/0.4/docs/featured_model/FACE_DETECTION.md#BlazeFace) | ARM | +| CV | 人脸 | [MTCNN](https://paddlelite-demo.bj.bcebos.com/models/mtcnn.zip) | ARM | +| CV | OCR | [OCR-Attention](https://paddle-inference-dist.bj.bcebos.com/ocr_attention.tar.gz) | ARM | +| CV | GAN | [CycleGAN*](https://github.com/PaddlePaddle/models/tree/release/1.7/PaddleCV/gan/cycle_gan) | NPU | +| NLP | 机器翻译 | [Transformer*](https://github.com/PaddlePaddle/models/tree/release/1.8/PaddleNLP/machine_translation/transformer) | ARM,NPU* | +| NLP | 机器翻译 | [BERT](https://paddle-inference-dist.bj.bcebos.com/PaddleLite/models_and_data_for_unittests/bert.tar.gz) | XPU | +| NLP | 语义表示 | [ERNIE](https://paddle-inference-dist.bj.bcebos.com/PaddleLite/models_and_data_for_unittests/ernie.tar.gz) | XPU | -**注意:** NPU* 代表ARM+NPU异构计算 +**注意:** +1. 模型列表中 * 代表该模型链接来自[PaddlePaddle/models](https://github.com/PaddlePaddle/models),否则为推理模型的下载链接 +2. 支持平台列表中 NPU* 代表ARM+NPU异构计算,否则为NPU计算 diff --git a/docs/quick_start/release_lib.md b/docs/quick_start/release_lib.md index c2c441bbfa7dea0ae2ebd54f5545ae61590604ec..9c722df1537d49a2c7b8a009b5273b93ff68ffbe 100644 --- a/docs/quick_start/release_lib.md +++ b/docs/quick_start/release_lib.md @@ -76,7 +76,6 @@ pip install paddlelite - [ArmLinux源码编译](../source_compile/compile_linux) - [x86源码编译](../demo_guides/x86) - [opencl源码编译](../demo_guides/opencl) -- [CUDA源码编译](../demo_guides/cuda) - [FPGA源码编译](../demo_guides/fpga) - [华为NPU源码编译](../demo_guides/huawei_kirin_npu) - [百度XPU源码编译](../demo_guides/baidu_xpu) diff --git a/docs/quick_start/tutorial.md b/docs/quick_start/tutorial.md index 5affbf6de0c8550db60ebbb8f3fd559ed32c7ba2..6bf8706eed40e5be9e083b46bc615312f9088e76 100644 --- a/docs/quick_start/tutorial.md +++ b/docs/quick_start/tutorial.md @@ -44,7 +44,6 @@ Paddle Lite提供了C++、Java、Python三种API的完整使用示例和开发 - [iOS示例](../demo_guides/ios_app_demo.html) - [ARMLinux示例](../demo_guides/linux_arm_demo.html) - [X86示例](../demo_guides/x86.html) -- [CUDA示例](../demo_guides/cuda.html) - [OpenCL示例](../demo_guides/opencl.html) - [FPGA示例](../demo_guides/fpga.html) - [华为NPU示例](../demo_guides/huawei_kirin_npu.html) diff --git a/docs/source_compile/compile_env.md b/docs/source_compile/compile_env.md index 5322558afbf2c3ad09f04e0596ddc18f967ffabb..7c32311cda212091796a2cff7d60bbefbb751e7c 100644 --- a/docs/source_compile/compile_env.md +++ b/docs/source_compile/compile_env.md @@ -19,7 +19,6 @@ Paddle Lite提供了Android/iOS/X86平台的官方Release预测库下载,如 - [ArmLinux源码编译](../source_compile/compile_linux) - [X86源码编译](../demo_guides/x86) - [OpenCL源码编译](../demo_guides/opencl) -- [CUDA源码编译](../demo_guides/cuda) - [FPGA源码编译](../demo_guides/fpga) - [华为NPU源码编译](../demo_guides/huawei_kirin_npu) - [百度XPU源码编译](../demo_guides/baidu_xpu) diff --git a/docs/user_guides/model_visualization.md b/docs/user_guides/model_visualization.md new file mode 100644 index 0000000000000000000000000000000000000000..0d7d9fe1c0f509b66f1e8856b59bec987e9898c8 --- /dev/null +++ b/docs/user_guides/model_visualization.md @@ -0,0 +1,214 @@ +# 模型可视化方法 + +Paddle Lite框架中主要使用到的模型结构有2种:(1) 为[PaddlePaddle](https://github.com/PaddlePaddle/Paddle)深度学习框架产出的模型格式; (2) 使用[Lite模型优化工具opt](model_optimize_tool)优化后的模型格式。因此本章节包含内容如下: + +1. [Paddle推理模型可视化](model_visualization.html#paddle) +2. [Lite优化模型可视化](model_visualization.html#lite) +3. [Lite子图方式下模型可视化](model_visualization.html#id2) + +## Paddle推理模式可视化 + +Paddle用于推理的模型是通过[save_inference_model](https://www.paddlepaddle.org.cn/documentation/docs/zh/api_cn/io_cn/save_inference_model_cn.html#save-inference-model)这个API保存下来的,存储格式有两种,由save_inference_model接口中的 `model_filename` 和 `params_filename` 变量控制: + +- **non-combined形式**:参数保存到独立的文件,如设置 `model_filename` 为 `None` , `params_filename` 为 `None` + + ```bash + $ ls -l recognize_digits_model_non-combined/ + total 192K + -rw-r--r-- 1 root root 28K Sep 24 09:39 __model__ # 模型文件 + -rw-r--r-- 1 root root 104 Sep 24 09:39 conv2d_0.b_0 # 独立权重文件 + -rw-r--r-- 1 root root 2.0K Sep 24 09:39 conv2d_0.w_0 # 独立权重文件 + -rw-r--r-- 1 root root 224 Sep 24 09:39 conv2d_1.b_0 # ... + -rw-r--r-- 1 root root 98K Sep 24 09:39 conv2d_1.w_0 + -rw-r--r-- 1 root root 64 Sep 24 09:39 fc_0.b_0 + -rw-r--r-- 1 root root 32K Sep 24 09:39 fc_0.w_0 + ``` + +- **combined形式**:参数保存到同一个文件,如设置 `model_filename` 为 `model` , `params_filename` 为 `params` + + ```bash + $ ls -l recognize_digits_model_combined/ + total 160K + -rw-r--r-- 1 root root 28K Sep 24 09:42 model # 模型文件 + -rw-r--r-- 1 root root 132K Sep 24 09:42 params # 权重文件 + ``` + +通过以上方式保存下来的模型文件都可以通过[Netron](https://lutzroeder.github.io/netron/)工具来打开查看模型的网络结构。 + +**注意:**[Netron](https://github.com/lutzroeder/netron)当前要求PaddlePaddle的保存模型文件名必须为`__model__`,否则无法识别。如果是通过第二种方式保存下来的combined形式的模型文件,需要将文件重命名为`__model__`。 + + + +## Lite优化模型可视化 + +Paddle Lite在执行模型推理之前需要使用[模型优化工具opt](model_optimize_tool)来对模型进行优化,优化后的模型结构同样可以使用[Netron](https://lutzroeder.github.io/netron/)工具进行查看,但是必须保存为`protobuf`格式,而不是`naive_buffer`格式。 + +**注意**: 为了减少第三方库的依赖、提高Lite预测框架的通用性,在移动端使用Lite API您需要准备Naive Buffer存储格式的模型(该模型格式是以`.nb`为后缀的单个文件)。但是Naive Buffer格式的模型为序列化模型,不支持可视化。 + +这里以[paddle_lite_opt](opt/opt_python)工具为例: + +- 当模型输入为`non-combined`格式的Paddle模型时,需要通过`--model_dir`来指定模型文件夹 + + ```bash + $ paddle_lite_opt \ + --model_dir=./recognize_digits_model_non-combined/ \ + --valid_targets=arm \ + --optimize_out_type=protobuf \ # 注意:这里必须输出为protobuf格式 + --optimize_out=model_opt_dir_non-combined + ``` + + 优化后的模型文件会存储在由`--optimize_out`指定的输出文件夹下,格式如下 + + ```bash + $ ls -l model_opt_dir_non-combined/ + total 152K + -rw-r--r-- 1 root root 17K Sep 24 09:51 model # 优化后的模型文件 + -rw-r--r-- 1 root root 132K Sep 24 09:51 params # 优化后的权重文件 + ``` + +- 当模式输入为`combined`格式的Paddle模型时,需要同时输入`--model_file`和`--param_file`来分别指定Paddle模型的模型文件和权重文件 + + ```bash + $ paddle_lite_opt \ + --model_file=./recognize_digits_model_combined/model \ + --param_file=./recognize_digits_model_combined/params \ + --valid_targets=arm \ + --optimize_out_type=protobuf \ # 注意:这里必须输出为protobuf格式 + --optimize_out=model_opt_dir_combined + ``` + 优化后的模型文件同样存储在由`--optimize_out`指定的输出文件夹下,格式相同 + + ```bash + ls -l model_opt_dir_combined/ + total 152K + -rw-r--r-- 1 root root 17K Sep 24 09:56 model # 优化后的模型文件 + -rw-r--r-- 1 root root 132K Sep 24 09:56 params # 优化后的权重文件 + ``` + + +将通过以上步骤输出的优化后的模型文件`model`重命名为`__model__`,然后用[Netron](https://lutzroeder.github.io/netron/)工具打开即可查看优化后的模型结构。将优化前后的模型进行对比,即可发现优化后的模型比优化前的模型更轻量级,在推理任务中耗费资源更少且执行速度也更快。 + +