diff --git a/.gitignore b/.gitignore
index 300dbef05b06f..f21889b9b421b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,3 +3,5 @@
*.DS_Store
._*
docs/_build/
+docs/api/
+docs/doxyoutput/
diff --git a/docs/conf.py b/docs/conf.py
index bb399a47f9138..b1ea576299a44 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -172,3 +172,46 @@
# A list of files that should not be packed into the epub file.
epub_exclude_files = ['search.html']
+
+extensions = [
+ # there may be others here already, e.g. 'sphinx.ext.mathjax'
+ 'breathe',
+ 'exhale'
+]
+
+# Setup the breathe extension
+breathe_projects = {
+ "My Project": "./doxyoutput/xml"
+}
+breathe_default_project = "My Project"
+
+# Setup the exhale extension
+exhale_args = {
+ # These arguments are required
+ "containmentFolder": "./api",
+ "rootFileName": "library_root.rst",
+ "rootFileTitle": "Library API",
+ "doxygenStripFromPath": "..",
+ # Suggested optional arguments
+ "createTreeView": True,
+ # TIP: if using the sphinx-bootstrap-theme, you need
+ # "treeViewIsBootstrap": True,
+ "exhaleExecutesDoxygen": True,
+ "exhaleDoxygenStdin": "INPUT = paddle_include_file"
+}
+
+# Tell sphinx what the primary language being documented is.
+primary_domain = 'cpp'
+
+# Tell sphinx what the pygments highlight language should be.
+highlight_language = 'cpp'
+
+import os
+
+on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
+
+if not on_rtd: # only import and set the theme if we're building docs locally
+ import sphinx_rtd_theme
+ html_theme = 'sphinx_rtd_theme'
+ #html_theme = "alabaster"
+ html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
diff --git a/docs/index.rst b/docs/index.rst
index c1b14a0d1e458..30af359119269 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -38,7 +38,6 @@ Welcome to Paddle-Inference's documentation!
tools/visual
tools/x2paddle
-
.. toctree::
:maxdepth: 1
@@ -48,10 +47,10 @@ Welcome to Paddle-Inference's documentation!
benchmark/benchmark
.. toctree::
- :maxdepth: 1
+ :maxdepth: 2
:caption: API文档
- api_reference/cxx_api_doc
+ api/library_root
.. toctree::
:maxdepth: 1
diff --git a/docs/introduction/quick_start.md b/docs/introduction/quick_start.md
deleted file mode 100644
index 2792cda710c29..0000000000000
--- a/docs/introduction/quick_start.md
+++ /dev/null
@@ -1,175 +0,0 @@
-# Quick Start
-
-
前提准备
-接下来我们会通过几段Python代码的方式对Paddle Inference使用进行介绍,
-为了能够成功运行代码,请您在环境中(Mac, Windows,Linux)安装不低于1.7版本的Paddle,
-安装Paddle 请参考[飞桨官网主页](https://www.paddlepaddle.org.cn/)。
-
-## 导出预测模型文件
-
-在模型训练期间,我们通常使用Python来构建模型结构,比如:
-
-```python
-import paddle.fluid as fluid
-res = fluid.layers.conv2d(input=data, num_filters=2, filter_size=3, act="relu", param_attr=param_attr)
-```
-
-在模型部署时,我们需要提前将这种Python表示的结构以及参数序列化到磁盘中。那是如何做到的呢?
-
-在模型训练过程中或者模型训练结束后,我们可以通过`save_inference_model` 接口来导出标准化的模型文件。
-
-我们用一个简单的代码例子来展示下导出模型文件的这一过程。
-
-
-```python
-import paddle
-import paddle.fluid as fluid
-# 建立一个简单的网络,网络的输入的shape为[batch, 3, 28, 28]
-image_shape = [3, 28, 28]
-
-img = fluid.layers.data(name='image', shape=image_shape, dtype='float32', append_batch_size=True)
-# 模型包含两个Conv层
-conv1 = fluid.layers.conv2d(
- input=img,
- num_filters=8,
- filter_size=3,
- stride=2,
- padding=1,
- groups=1,
- act=None,
- bias_attr=True)
-
-out = fluid.layers.conv2d(
- input=conv1,
- num_filters=8,
- filter_size=3,
- stride=2,
- padding=1,
- groups=1,
- act=None,
- bias_attr=True)
-
-place = fluid.CPUPlace()
-exe = fluid.Executor(place)
-# 创建网络中的参数变量,并初始化参数变量
-exe.run(fluid.default_startup_program())
-
-# 如果存在预训练模型
-# def if_exist(var):
-# return os.path.exists(os.path.join("./ShuffleNet", var.name))
-# fluid.io.load_vars(exe, "./pretrained_model", predicate=if_exist)
-# 保存模型到model目录中,只保存与输入image和输出与推理相关的部分网络
-fluid.io.save_inference_model(dirname='./sample_model', feeded_var_names=['image'], target_vars = [out], executor=exe, model_filename='model', params_filename='params')
-```
-
-该程序运行结束后,会在本目录中生成一个sample_model目录,目录中包含model, params 两个文件,model文件表示模型的结构文件,params表示所有参数的融合文件。
-
-
-飞桨提供了**两种标准**的模型文件,一种为Combined方式, 一种为No-Combined的方式。
-
-- Combined的方式
-
-```
-fluid.io.save_inference_model(dirname='./sample_model', feeded_var_names=['image'], target_vars = [out], executor=exe, model_filename='model', params_filename='params')
-```
-`model_filename`,`params_filename`表示要生成的模型结构文件、融合参数文件的名字。
-
-
-* No-Combined的方式
-
-```
-fluid.io.save_inference_model(dirname='./sample_model', feeded_var_names=['image'], target_vars = [out], executor=exe)
-```
-
-如果不指定`model_filename`,`params_filename`,会在sample_model目录下生成`__model__` 模型结构文件,以及一系列的参数文件。
-
-
-在模型部署期间,**我们更推荐使用Combined的方式**,因为涉及模型上线加密的场景时,这种方式会更友好一些。
-
-
-
-## 加载模型预测
-
-1)使用load_inference方式
-
-我们可以使用`load_inference_model` 接口加载训练好的模型(以`sample_model`模型举例),并复用训练框架的前向计算,直接完成推理。示例程序如下所示:
-
-```
-import paddle.fluid as fluid
-import numpy as np
-
-data = np.ones((1, 3, 28, 28)).astype(np.float32)
-exe = fluid.Executor(fluid.CPUPlace())
-
-# 加载Combined的模型需要指定model_filename, params_filename
-# 加载No-Combined的模型不需要指定model_filename, params_filename
-[inference_program, feed_target_names, fetch_targets] = \
- fluid.io.load_inference_model(dirname='sample_model', executor=exe, model_filename='model', params_filename='params')
-
-with fluid.program_guard(inference_program):
- results = exe.run(inference_program,
- feed={feed_target_names[0]: data},
- fetch_list=fetch_targets, return_numpy=False)
-
- print (np.array(results[0]).shape)
- # (1, 8, 7, 7)
-```
-
-在上述方式中,在模型加载后会按照执行顺序将所有的OP进行拓扑排序,在运行期间Op会按照排序一一运行,整个过程中运行的为训练中前向的OP,期间不会有任何的优化(OP融合,显存优化,预测Kernel针对优化)。 因此,`load_inference_model`的方式预测期间很可能不会有很好的性能表现,此方式比较适合用来做实验(测试模型的效果、正确性等)使用,并不适用于真正的部署上线。接下来我们会重点介绍Paddle Inference的使用。
-
-2)使用Paddle Inference Api 方式
-
-不同于 `load_inference_model` 方式,Paddle Inference 在模型加载后会进行一系列的优化,包括: Kernel优化,OP横向,纵向融合,显存/内存优化,以及MKLDNN,TensorRT的集成等,性能和吞吐会得到大幅度的提升。这些优化会在之后的文档中进行详细的介绍。
-
-那我们先用一个简单的代码例子来介绍Paddle Inference 的使用。
-
-```Python
-from paddle.fluid.core import AnalysisConfig
-from paddle.fluid.core import create_paddle_predictor
-
-import numpy as np
-
-# 配置运行信息
-# config = AnalysisConfig("./sample_model") # 加载non-combined 模型格式
-config = AnalysisConfig("./sample_model/model", "./sample_model/params") # 加载combine的模型格式
-
-config.switch_use_feed_fetch_ops(False)
-config.enable_memory_optim()
-config.enable_use_gpu(1000, 0)
-
-# 根据config创建predictor
-predictor = create_paddle_predictor(config)
-
-img = np.ones((1, 3, 28, 28)).astype(np.float32)
-
-# 准备输入
-input_names = predictor.get_input_names()
-input_tensor = predictor.get_input_tensor(input_names[0])
-input_tensor.reshape(img.shape)
-input_tensor.copy_from_cpu(img.copy())
-
-# 运行
-predictor.zero_copy_run()
-
-# 获取输出
-output_names = predictor.get_output_names()
-output_tensor = predictor.get_output_tensor(output_names[0])
-output_data = output_tensor.copy_to_cpu()
-
-print (output_data)
-```
-
-
-上述的代码例子,我们通过加载一个简答模型以及随机输入的方式,展示了如何使用Paddle Inference进行模型预测。可能对于刚接触Paddle Inferenece同学来说,代码中会有一些陌生名词出现,比如AnalysisConfig, Predictor 等。先不要着急,接下来的文章中会对这些概念进行详细的介绍。
-
-
-相关链接
-
-[Python API 使用介绍](../user_guides/inference_python_api)
-
-[C++ API使用介绍](../user_guides/cxx_api)
-
-[Python 使用样例](https://github.com/PaddlePaddle/Paddle-Inference-Demo/tree/master/python)
-
-[C++ 使用样例](https://github.com/PaddlePaddle/Paddle-Inference-Demo/tree/master/c%2B%2B)
-
diff --git a/docs/introduction/quick_start.rst b/docs/introduction/quick_start.rst
new file mode 100644
index 0000000000000..c00ba9cea6292
--- /dev/null
+++ b/docs/introduction/quick_start.rst
@@ -0,0 +1,176 @@
+Quick Start
+=================
+
+**前提准备**
+接下来我们会通过几段Python代码的方式对Paddle Inference使用进行介绍,
+为了能够成功运行代码,请您在环境中(Mac, Windows,Linux)安装不低于1.7版本的Paddle,
+安装Paddle 请参考 `飞桨官网主页 `_。
+
+导出预测模型文件
+----------------
+
+在模型训练期间,我们通常使用Python来构建模型结构,比如:
+
+.. code:: python
+
+ import paddle.fluid as fluid
+ res = fluid.layers.conv2d(input=data, num_filters=2, filter_size=3, act="relu", param_attr=param_attr)
+
+在模型部署时,我们需要提前将这种Python表示的结构以及参数序列化到磁盘中。那是如何做到的呢?
+
+在模型训练过程中或者模型训练结束后,我们可以通过save_inference_model接口来导出标准化的模型文件。
+
+我们用一个简单的代码例子来展示下导出模型文件的这一过程。
+
+
+.. code:: python
+
+ import paddle
+ import paddle.fluid as fluid
+ # 建立一个简单的网络,网络的输入的shape为[batch, 3, 28, 28]
+ image_shape = [3, 28, 28]
+
+ img = fluid.layers.data(name='image', shape=image_shape, dtype='float32', append_batch_size=True)
+ # 模型包含两个Conv层
+ conv1 = fluid.layers.conv2d(
+ input=img,
+ num_filters=8,
+ filter_size=3,
+ stride=2,
+ padding=1,
+ groups=1,
+ act=None,
+ bias_attr=True)
+
+ out = fluid.layers.conv2d(
+ input=conv1,
+ num_filters=8,
+ filter_size=3,
+ stride=2,
+ padding=1,
+ groups=1,
+ act=None,
+ bias_attr=True)
+
+ place = fluid.CPUPlace()
+ exe = fluid.Executor(place)
+ # 创建网络中的参数变量,并初始化参数变量
+ exe.run(fluid.default_startup_program())
+
+ # 如果存在预训练模型
+ # def if_exist(var):
+ # return os.path.exists(os.path.join("./ShuffleNet", var.name))
+ # fluid.io.load_vars(exe, "./pretrained_model", predicate=if_exist)
+ # 保存模型到model目录中,只保存与输入image和输出与推理相关的部分网络
+ fluid.io.save_inference_model(dirname='./sample_model', feeded_var_names=['image'], target_vars = [out], executor=exe, model_filename='model', params_filename='params')
+
+该程序运行结束后,会在本目录中生成一个sample_model目录,目录中包含model, params 两个文件,model文件表示模型的结构文件,params表示所有参数的融合文件。
+
+
+飞桨提供了 **两种标准** 的模型文件,一种为Combined方式, 一种为No-Combined的方式。
+
+- Combined的方式
+
+.. code:: python
+
+ fluid.io.save_inference_model(dirname='./sample_model', feeded_var_names=['image'], target_vars = [out], executor=exe, model_filename='model', params_filename='params')
+
+model_filename,params_filename表示要生成的模型结构文件、融合参数文件的名字。
+
+
+* No-Combined的方式
+
+.. code:: python
+
+ fluid.io.save_inference_model(dirname='./sample_model', feeded_var_names=['image'], target_vars = [out], executor=exe)
+
+如果不指定model_filename,params_filename,会在sample_model目录下生成__model__ 模型结构文件,以及一系列的参数文件。
+
+
+在模型部署期间,**我们更推荐使用Combined的方式**,因为涉及模型上线加密的场景时,这种方式会更友好一些。
+
+
+
+加载模型预测
+----------------
+
+1)使用load_inference方式
+
+我们可以使用load_inference_model接口加载训练好的模型(以sample_model模型举例),并复用训练框架的前向计算,直接完成推理。
+示例程序如下所示:
+
+.. code:: python
+
+ import paddle.fluid as fluid
+ import numpy as np
+
+ data = np.ones((1, 3, 28, 28)).astype(np.float32)
+ exe = fluid.Executor(fluid.CPUPlace())
+
+ # 加载Combined的模型需要指定model_filename, params_filename
+ # 加载No-Combined的模型不需要指定model_filename, params_filename
+ [inference_program, feed_target_names, fetch_targets] = \
+ fluid.io.load_inference_model(dirname='sample_model', executor=exe, model_filename='model', params_filename='params')
+
+ with fluid.program_guard(inference_program):
+ results = exe.run(inference_program,
+ feed={feed_target_names[0]: data},
+ fetch_list=fetch_targets, return_numpy=False)
+
+ print (np.array(results[0]).shape)
+ # (1, 8, 7, 7)
+
+在上述方式中,在模型加载后会按照执行顺序将所有的OP进行拓扑排序,在运行期间Op会按照排序一一运行,整个过程中运行的为训练中前向的OP,期间不会有任何的优化(OP融合,显存优化,预测Kernel针对优化)。 因此,load_inference_model的方式预测期间很可能不会有很好的性能表现,此方式比较适合用来做实验(测试模型的效果、正确性等)使用,并不适用于真正的部署上线。接下来我们会重点介绍Paddle Inference的使用。
+
+2)使用Paddle Inference API方式
+
+不同于 load_inference_model方式,Paddle Inference 在模型加载后会进行一系列的优化,包括: Kernel优化,OP横向,纵向融合,显存/内存优化,以及MKLDNN,TensorRT的集成等,性能和吞吐会得到大幅度的提升。这些优化会在之后的文档中进行详细的介绍。
+
+那我们先用一个简单的代码例子来介绍Paddle Inference 的使用。
+
+.. code::
+
+ from paddle.fluid.core import AnalysisConfig
+ from paddle.fluid.core import create_paddle_predictor
+
+ import numpy as np
+
+ # 配置运行信息
+ # config = AnalysisConfig("./sample_model") # 加载non-combined 模型格式
+ config = AnalysisConfig("./sample_model/model", "./sample_model/params") # 加载combine的模型格式
+
+ config.switch_use_feed_fetch_ops(False)
+ config.enable_memory_optim()
+ config.enable_use_gpu(1000, 0)
+
+ # 根据config创建predictor
+ predictor = create_paddle_predictor(config)
+
+ img = np.ones((1, 3, 28, 28)).astype(np.float32)
+
+ # 准备输入
+ input_names = predictor.get_input_names()
+ input_tensor = predictor.get_input_tensor(input_names[0])
+ input_tensor.reshape(img.shape)
+ input_tensor.copy_from_cpu(img.copy())
+
+ # 运行
+ predictor.zero_copy_run()
+
+ # 获取输出
+ output_names = predictor.get_output_names()
+ output_tensor = predictor.get_output_tensor(output_names[0])
+ output_data = output_tensor.copy_to_cpu()
+
+ print (output_data)
+
+上述的代码例子,我们通过加载一个简答模型以及随机输入的方式,展示了如何使用Paddle Inference进行模型预测。可能对于刚接触Paddle Inferenece同学来说,代码中会有一些陌生名词出现,比如AnalysisConfig, Predictor 等。先不要着急,接下来的文章中会对这些概念进行详细的介绍。
+
+
+**相关链接**
+
+`Python API 使用介绍 <../user_guides/inference_python_api.html>`_
+`C++ API使用介绍 <../user_guides/cxx_api.html>`_
+`Python 使用样例 `_
+`C++ 使用样例 `_
+
diff --git a/docs/introduction/summary.md b/docs/introduction/summary.md
index 5935151a26e01..16ead666d12c2 100644
--- a/docs/introduction/summary.md
+++ b/docs/introduction/summary.md
@@ -1,9 +1,11 @@
-
-# 概述
+概述
+========
Paddle Inference为飞桨核心框架推理引擎。Paddle Inference功能特性丰富,性能优异,针对不同平台不同的应用场景进行了深度的适配优化,做到高吞吐、低时延,保证了飞桨模型在服务器端即训即用,快速部署。
-### 特性
+特性
+-------
+
- 通用性。支持对Paddle训练出的所有模型进行预测。
- 内存/显存复用。在推理初始化阶段,对模型中的OP输出Tensor 进行依赖分析,将两两互不依赖的Tensor在内存/显存空间上进行复用,进而增大计算并行量,提升服务吞吐量。
@@ -15,26 +17,28 @@ Paddle Inference为飞桨核心框架推理引擎。Paddle Inference功能特性
- 高性能CPU/GPU Kernel。内置同Intel、Nvidia共同打造的高性能kernel,保证了模型推理高性能的执行。
-- 子图集成[TensorRT](https://developer.nvidia.com/tensorrt)。Paddle Inference采用子图的形式集成TensorRT,针对GPU推理场景,TensorRT可对一些子图进行优化,包括OP的横向和纵向融合,过滤冗余的OP,并为OP自动选择最优的kernel,加快推理速度。
+- 子图集成 `TensorRT `_。Paddle Inference采用子图的形式集成TensorRT,针对GPU推理场景,TensorRT可对一些子图进行优化,包括OP的横向和纵向融合,过滤冗余的OP,并为OP自动选择最优的kernel,加快推理速度。
- 集成MKLDNN
-- 支持加载PaddleSlim量化压缩后的模型。 [PaddleSlim](https://github.com/PaddlePaddle/PaddleSlim)是飞桨深度学习模型压缩工具,Paddle Inference可联动PaddleSlim,支持加载量化、裁剪和蒸馏后的模型并部署,由此减小模型存储空间、减少计算占用内存、加快模型推理速度。其中在模型量化方面,[Paddle Inference在X86 CPU上做了深度优化](https://github.com/PaddlePaddle/PaddleSlim/tree/80c9fab3f419880dd19ca6ea30e0f46a2fedf6b3/demo/mkldnn_quant/quant_aware),常见分类模型的单线程性能可提升近3倍,ERNIE模型的单线程性能可提升2.68倍。
+- 支持加载PaddleSlim量化压缩后的模型。 `PaddleSlim `_ 是飞桨深度学习模型压缩工具,Paddle Inference可联动PaddleSlim,支持加载量化、裁剪和蒸馏后的模型并部署,由此减小模型存储空间、减少计算占用内存、加快模型推理速度。其中在模型量化方面,`Paddle Inference在X86 CPU上做了深度优化 `_ ,常见分类模型的单线程性能可提升近3倍,ERNIE模型的单线程性能可提升2.68倍。
-### 支持系统及硬件
+支持系统及硬件
+------------
支持服务器端X86 CPU、NVIDIA GPU芯片,兼容Linux/macOS/Windows系统。
同时也支持NVIDIA Jetson嵌入式平台。
-### 语言支持
+语言支持
+------------
- 支持Pyhton语言
- 支持C++ 语言
- 支持Go语言
- 支持R语言
-下一步
+**下一步**
-- 如果您刚接触Paddle Inference, 请访问[Quick start](./quick_start)。
+- 如果您刚接触Paddle Inference, 请访问 `Quick start <./quick_start.html>`_。
diff --git a/docs/paddle_include_file/paddle_analysis_config.h b/docs/paddle_include_file/paddle_analysis_config.h
new file mode 100644
index 0000000000000..2002d1f76abfe
--- /dev/null
+++ b/docs/paddle_include_file/paddle_analysis_config.h
@@ -0,0 +1,579 @@
+// Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+///
+/// \file paddle_analysis_config.h
+///
+/// \brief Paddle Analysis Config API信息
+///
+/// \author paddle-infer@baidu.com
+/// \date 2020-03-20
+/// \since 1.7
+///
+
+#pragma once
+
+#include
+#include