Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
6d371e45
P
Paddle
项目概览
机器未来
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
6d371e45
编写于
5月 10, 2018
作者:
Y
Yan Chunwei
提交者:
GitHub
5月 10, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
init Inference top APIs (#10549)
上级
13457ef3
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
96 addition
and
0 deletion
+96
-0
contrib/inference/README.md
contrib/inference/README.md
+27
-0
contrib/inference/paddle_inference_api.h
contrib/inference/paddle_inference_api.h
+69
-0
未找到文件。
contrib/inference/README.md
0 → 100644
浏览文件 @
6d371e45
# Embed Paddle Inference in Your Application
Paddle inference offers the APIs in
`C`
and
`C++`
languages.
One can easily deploy a model trained by Paddle following the steps as below:
1.
Optimize the native model;
2.
Write some codes for deployment.
Let's explain the steps in detail.
## Optimize the native Fluid Model
The native model that get from the training phase needs to be optimized for that.
-
Clean the noise such as the cost operators that do not need inference;
-
Prune unnecessary computation fork that has nothing to do with the output;
-
Remove extraneous variables;
-
Memory reuse for native Fluid executor;
-
Translate the model storage format to some third-party engine's, so that the inference API can utilize the engine for acceleration;
We have an official tool to do the optimization, call
`paddle_inference_optimize --help`
for more information.
## Write some codes
Read
`paddle_inference_api.h`
for more information.
contrib/inference/paddle_inference_api.h
0 → 100644
浏览文件 @
6d371e45
/* 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. */
#pragma once
#include <string>
#include <vector>
namespace
paddle
{
class
Predictor
{
public:
struct
Attr
;
Predictor
()
=
default
;
// Build the network before inference.
bool
Init
(
const
Attr
&
attr
);
// Predict an record.
// Arguments:
// inputs: the name of the input variables.
// outputs: the name of the output varaibles.
// input_shapes: the shape of the input variables.
// output_shapes: the shape of the output variables.
// input_data: the data of the input variables.
// output_data: the data of the output variables.
bool
Run
(
const
std
::
vector
<
std
::
string
>&
inputs
,
const
std
::
vector
<
std
::
string
>&
outputs
,
const
std
::
vector
<
std
::
vector
<
int
>>&
input_shapes
,
const
std
::
vector
<
std
::
vector
<
int
>>&
output_shapes
,
const
std
::
vector
<
std
::
vector
<
float
>>&
input_data
,
std
::
vector
<
std
::
vector
<
float
>>*
output_data
);
// Clone a predictor that share the model weights.
Predictor
*
Clone
();
// Destroy the Predictor.
~
Predictor
();
struct
Attr
{
enum
class
EngineKind
;
std
::
string
model_dir
;
// path to the model directory.
bool
enable_engine
{
false
};
// Enable to execute (part of) the model on
// third-party engines.
EngineKind
engine_kind
{
Attr
::
EngineKind
::
kNone
};
enum
class
EngineKind
{
kNone
=
-
1
,
// Use the native Fluid facility.
kAnakin
,
// Use Anakin for inference.
kTensorRT
,
// Use TensorRT for inference.
kAutoMixedAnakin
,
// Automatically mix Fluid with Anakin.
kAutoMixedTensorRT
,
// Automatically mix Fluid with TensorRT.
};
};
};
}
// namespace paddle
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录