Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
01a96cbc
P
Paddle-Lite
项目概览
PaddlePaddle
/
Paddle-Lite
通知
338
Star
4
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
271
列表
看板
标记
里程碑
合并请求
78
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle-Lite
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
271
Issue
271
列表
看板
标记
里程碑
合并请求
78
合并请求
78
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
01a96cbc
编写于
11月 22, 2019
作者:
H
huzhiqiang
提交者:
GitHub
11月 22, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add declearation of C++ API in the doc (#2478)
* add declearation of C++ API in the doc
上级
68581661
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
500 addition
and
0 deletion
+500
-0
_all_pages/develop/cxx_api_doc.md
_all_pages/develop/cxx_api_doc.md
+250
-0
_all_pages/v2.0.0/cxx_api_doc.md
_all_pages/v2.0.0/cxx_api_doc.md
+250
-0
未找到文件。
_all_pages/develop/cxx_api_doc.md
浏览文件 @
01a96cbc
...
...
@@ -35,6 +35,203 @@ std::shared_ptr<PaddlePredictor> predictor = CreatePaddlePredictor<MobileConfig>
返回类型:
`std::shared_ptr<PaddlePredictor>`
# CxxConfig
```
c++
class
CxxConfig
;
```
`CxxConfig`
用来配置构建CxxPredictor的配置信息,如protobuf格式的模型地址、能耗模式、工作线程数、place信息等等。
示例:
```
c++
config
=
CxxConfig
()
# 设置模型目录,加载非combined模型时使用
config
.
set_model_dir
(
<
your_model_dir_path
>
)
# 设置工作线程数
config
.
set_threads
(
4
);
# 设置能耗模式
config
.
set_power_mode
(
PowerMode
.
LITE_POWER_NO_BIND
)
# 设置valid places
places
=
[
Place
(
TargetType
.
ARM
,
PrecisionType
.
FP32
)]
config
.
set_valid_places
(
places
)
# 根据CxxConfig创建CxxPredictor
predictor
=
create_paddle_predictor
(
config
)
```
## `set_model_dir(model_dir)`
设置模型文件夹路径,当需要从磁盘加载非combined模型时使用。
参数:
-
`model_dir(str)`
- 模型文件夹路径
返回:
`None`
返回类型:
`None`
## `model_dir()`
返回设置的模型文件夹路径。
参数:
-
`None`
返回:模型文件夹路径
返回类型:
`str`
## `set_model_file(model_file)`
设置模型文件路径,加载combined形式模型时使用。
参数:
-
`model_file(str)`
- 模型文件路径
返回类型:
`None`
## `model_file()`
获取设置模型文件路径,加载combined形式模型时使用。
参数:
-
`None`
返回:模型文件路径
返回类型:
`str`
## `set_param_file(param_file)`
设置模型参数文件路径,加载combined形式模型时使用。
参数:
-
`param_file(str)`
- 模型文件路径
返回类型:
`None`
## `param_file()`
获取设置模型参数文件路径,加载combined形式模型时使用。
参数:
-
`None`
返回:模型参数文件路径
返回类型:
`str`
## `set_valid_places(valid_places)`
设置可用的places列表。
参数:
-
`valid_places(list)`
- 可用place列表。
返回类型:
`None`
示例:
```
c++
config
=
CxxConfig
()
# 设置模型目录,加载非combined模型时使用
config
.
set_model_dir
(
<
your_model_dir_path
>
)
# 设置valid places
# 注意,valid_places列表中Place的排序表明了用户对Place的偏好程度,如用户想优先使用ARM上Int8精度的
# kernel,则应把Place(TargetType.ARM, PrecisionType.INT8)置于valid_places列表的首位。
places
=
[
Place
(
TargetType
.
ARM
,
PrecisionType
.
INT8
),
Place
(
TargetType
.
ARM
,
PrecisionType
.
FP32
)]
config
.
set_valid_places
(
places
)
# 根据CxxConfig创建CxxPredictor
predictor
=
create_paddle_predictor
(
config
)
```
## `set_power_mode(mode)`
设置CPU能耗模式。若不设置,则默认使用
`PowerMode.LITE_POWER_HIGH`
。
*注意:只在开启`OpenMP`时生效,否则系统自动调度。此函数只在使用`LITE_WITH_ARM`编译选项下生效。*
参数:
-
`mode(PowerMode)`
- CPU能耗模式
返回:
`None`
返回类型:
`None`
## `power_mode()`
获取设置的CPU能耗模式。
*注意:此函数只在使用`LITE_WITH_ARM`编译选项下生效。*
参数:
-
`None`
返回:设置的CPU能耗模式
返回类型:
`PowerMode`
## `set_threads(threads)`
设置工作线程数。若不设置,则默认使用单线程。
*注意:只在开启`OpenMP`的模式下生效,否则只使用单线程。此函数只在使用`LITE_WITH_ARM`编译选项下生效。*
参数:
-
`threads(int)`
- 工作线程数
返回:
`None`
返回类型:
`None`
## `threads()`
获取设置的工作线程数。
*注意:此函数只在使用`LITE_WITH_ARM`编译选项下生效。*
参数:
-
`None`
返回:工作线程数
返回类型:
`int`
# MobileConfig
```
c++
...
...
@@ -382,6 +579,59 @@ for (int i = 0; i < ShapeProduction(output_tensor->shape()); i += 100) {
返回类型:
`std::string`
# TargetType
```
c++
class
TargetType
;
```
`TargetType`
为目标设备硬件类型,用户可以根据应用场景选择硬件平台类型。
枚举型变量
`TargetType`
的所有可能取值包括:
`{X86, CUDA, ARM, OpenCL, FPGA, NPU}`
# PrecisionType
```
c++
class
PrecisionType
{
FP32
};
```
`PrecisionType`
为模型中Tensor的数据精度,默认值为FP32(float32)。
枚举型变量
`PrecisionType`
的所有可能取值包括:
`{FP32, INT8, INT32, INT64}`
# DataLayoutType
```
c++
class
DataLayoutType
{
NCHW
};
```
`DataLayoutType`
为Tensor的数据格式,默认值为NCHW(number, channel, height, weigth)。
枚举型变量
`DataLayoutType`
的所有可能取值包括:
` {NCHW, NHWC}`
# Place
```
c++
class
Place
{
TargetType
target
;
PrecisionType
precision
{
FP32
};
DataLayoutType
layout
{
NCHW
}
}
```
`Place`
是
`TargetType`
、
`PrecisionType`
和
`DataLayoutType`
的集合,说明运行时的设备类型、数据精度和数据格式。
示例:
```
C++
Place{TargetType(ARM), PrecisionType(FP32), DataLayoutType(NCHW)}
```
# PowerMode
```
c++
...
...
_all_pages/v2.0.0/cxx_api_doc.md
浏览文件 @
01a96cbc
...
...
@@ -35,6 +35,203 @@ std::shared_ptr<PaddlePredictor> predictor = CreatePaddlePredictor<MobileConfig>
返回类型:
`std::shared_ptr<PaddlePredictor>`
# CxxConfig
```
c++
class
CxxConfig
;
```
`CxxConfig`
用来配置构建CxxPredictor的配置信息,如protobuf格式的模型地址、能耗模式、工作线程数、place信息等等。
示例:
```
c++
config
=
CxxConfig
()
# 设置模型目录,加载非combined模型时使用
config
.
set_model_dir
(
<
your_model_dir_path
>
)
# 设置工作线程数
config
.
set_threads
(
4
);
# 设置能耗模式
config
.
set_power_mode
(
PowerMode
.
LITE_POWER_NO_BIND
)
# 设置valid places
places
=
[
Place
(
TargetType
.
ARM
,
PrecisionType
.
FP32
)]
config
.
set_valid_places
(
places
)
# 根据CxxConfig创建CxxPredictor
predictor
=
create_paddle_predictor
(
config
)
```
## `set_model_dir(model_dir)`
设置模型文件夹路径,当需要从磁盘加载非combined模型时使用。
参数:
-
`model_dir(str)`
- 模型文件夹路径
返回:
`None`
返回类型:
`None`
## `model_dir()`
返回设置的模型文件夹路径。
参数:
-
`None`
返回:模型文件夹路径
返回类型:
`str`
## `set_model_file(model_file)`
设置模型文件路径,加载combined形式模型时使用。
参数:
-
`model_file(str)`
- 模型文件路径
返回类型:
`None`
## `model_file()`
获取设置模型文件路径,加载combined形式模型时使用。
参数:
-
`None`
返回:模型文件路径
返回类型:
`str`
## `set_param_file(param_file)`
设置模型参数文件路径,加载combined形式模型时使用。
参数:
-
`param_file(str)`
- 模型文件路径
返回类型:
`None`
## `param_file()`
获取设置模型参数文件路径,加载combined形式模型时使用。
参数:
-
`None`
返回:模型参数文件路径
返回类型:
`str`
## `set_valid_places(valid_places)`
设置可用的places列表。
参数:
-
`valid_places(list)`
- 可用place列表。
返回类型:
`None`
示例:
```
c++
config
=
CxxConfig
()
# 设置模型目录,加载非combined模型时使用
config
.
set_model_dir
(
<
your_model_dir_path
>
)
# 设置valid places
# 注意,valid_places列表中Place的排序表明了用户对Place的偏好程度,如用户想优先使用ARM上Int8精度的
# kernel,则应把Place(TargetType.ARM, PrecisionType.INT8)置于valid_places列表的首位。
places
=
[
Place
(
TargetType
.
ARM
,
PrecisionType
.
INT8
),
Place
(
TargetType
.
ARM
,
PrecisionType
.
FP32
)]
config
.
set_valid_places
(
places
)
# 根据CxxConfig创建CxxPredictor
predictor
=
create_paddle_predictor
(
config
)
```
## `set_power_mode(mode)`
设置CPU能耗模式。若不设置,则默认使用
`PowerMode.LITE_POWER_HIGH`
。
*注意:只在开启`OpenMP`时生效,否则系统自动调度。此函数只在使用`LITE_WITH_ARM`编译选项下生效。*
参数:
-
`mode(PowerMode)`
- CPU能耗模式
返回:
`None`
返回类型:
`None`
## `power_mode()`
获取设置的CPU能耗模式。
*注意:此函数只在使用`LITE_WITH_ARM`编译选项下生效。*
参数:
-
`None`
返回:设置的CPU能耗模式
返回类型:
`PowerMode`
## `set_threads(threads)`
设置工作线程数。若不设置,则默认使用单线程。
*注意:只在开启`OpenMP`的模式下生效,否则只使用单线程。此函数只在使用`LITE_WITH_ARM`编译选项下生效。*
参数:
-
`threads(int)`
- 工作线程数
返回:
`None`
返回类型:
`None`
## `threads()`
获取设置的工作线程数。
*注意:此函数只在使用`LITE_WITH_ARM`编译选项下生效。*
参数:
-
`None`
返回:工作线程数
返回类型:
`int`
# MobileConfig
```
c++
...
...
@@ -382,6 +579,59 @@ for (int i = 0; i < ShapeProduction(output_tensor->shape()); i += 100) {
返回类型:
`std::string`
# TargetType
```
c++
class
TargetType
;
```
`TargetType`
为目标设备硬件类型,用户可以根据应用场景选择硬件平台类型。
枚举型变量
`TargetType`
的所有可能取值包括:
`{X86, CUDA, ARM, OpenCL, FPGA, NPU}`
# PrecisionType
```
c++
class
PrecisionType
{
FP32
};
```
`PrecisionType`
为模型中Tensor的数据精度,默认值为FP32(float32)。
枚举型变量
`PrecisionType`
的所有可能取值包括:
`{FP32, INT8, INT32, INT64}`
# DataLayoutType
```
c++
class
DataLayoutType
{
NCHW
};
```
`DataLayoutType`
为Tensor的数据格式,默认值为NCHW(number, channel, height, weigth)。
枚举型变量
`DataLayoutType`
的所有可能取值包括:
` {NCHW, NHWC}`
# Place
```
c++
class
Place
{
TargetType
target
;
PrecisionType
precision
{
FP32
};
DataLayoutType
layout
{
NCHW
}
}
```
`Place`
是
`TargetType`
、
`PrecisionType`
和
`DataLayoutType`
的集合,说明运行时的设备类型、数据精度和数据格式。
示例:
```
C++
Place{TargetType(ARM), PrecisionType(FP32), DataLayoutType(NCHW)}
```
# PowerMode
```
c++
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录