Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
FluidDoc
提交
20c0c3ee
F
FluidDoc
项目概览
PaddlePaddle
/
FluidDoc
通知
10
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
23
列表
看板
标记
里程碑
合并请求
111
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
F
FluidDoc
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
23
Issue
23
列表
看板
标记
里程碑
合并请求
111
合并请求
111
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
20c0c3ee
编写于
6月 27, 2019
作者:
Z
Zhaolong Xing
提交者:
xsrobin
6月 27, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix inferene naive_infer.md doc typo (#949)
* refine inference api test=develop * fix typo * fix typo * fix comments * fix typo
上级
7757dc36
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
7 addition
and
4 deletion
+7
-4
doc/fluid/advanced_usage/deploy/inference/native_infer.md
doc/fluid/advanced_usage/deploy/inference/native_infer.md
+7
-4
未找到文件。
doc/fluid/advanced_usage/deploy/inference/native_infer.md
浏览文件 @
20c0c3ee
...
...
@@ -53,7 +53,7 @@ void CreateConfig(NativeConfig *config, const std::string& model_dirname) {
void
RunNative
(
int
batch_size
,
const
std
::
string
&
model_dirname
)
{
// 1. 创建NativeConfig
NativeConfig
config
;
CreateConfig
(
&
config
);
CreateConfig
(
&
config
,
model_dirname
);
// 2. 根据config 创建predictor
auto
predictor
=
CreatePaddlePredictor
(
config
);
...
...
@@ -61,7 +61,7 @@ void RunNative(int batch_size, const std::string& model_dirname) {
int
channels
=
3
;
int
height
=
224
;
int
width
=
224
;
float
data
[
batch_size
*
channels
*
height
*
width
]
=
{
0
}
;
float
*
data
=
new
float
[
batch_size
*
channels
*
height
*
width
]
;
// 3. 创建输入 tensor
PaddleTensor
tensor
;
...
...
@@ -78,7 +78,7 @@ void RunNative(int batch_size, const std::string& model_dirname) {
predictor
->
Run
(
paddle_tensor_feeds
,
&
outputs
,
batch_size
);
const
size_t
num_elements
=
outputs
.
front
().
data
.
length
()
/
sizeof
(
float
);
auto
*
data
=
static_cast
<
float
*>
(
outputs
.
front
().
data
.
data
());
auto
*
data
_out
=
static_cast
<
float
*>
(
outputs
.
front
().
data
.
data
());
}
}
// namespace paddle
...
...
@@ -95,6 +95,9 @@ AnalysisConfig 创建了一个高性能预测引擎。该引擎通过对计算
#### AnalysisPredictor 使用样例
```
c++
#include "paddle_inference_api.h"
namespace
paddle
{
void
CreateConfig
(
AnalysisConfig
*
config
,
const
std
::
string
&
model_dirname
)
{
// 模型从磁盘进行加载
config
->
SetModel
(
model_dirname
+
"/model"
,
...
...
@@ -122,7 +125,7 @@ void CreateConfig(AnalysisConfig* config, const std::string& model_dirname) {
void
RunAnalysis
(
int
batch_size
,
std
::
string
model_dirname
)
{
// 1. 创建AnalysisConfig
AnalysisConfig
config
;
CreateConfig
(
&
config
);
CreateConfig
(
&
config
,
model_dirname
);
// 2. 根据config 创建predictor
auto
predictor
=
CreatePaddlePredictor
(
config
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录