Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
c00ed19d
P
Paddle
项目概览
PaddlePaddle
/
Paddle
11 个月 前同步成功
通知
2292
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
c00ed19d
编写于
2月 14, 2019
作者:
Y
Yan Chunwei
提交者:
GitHub
2月 14, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add more comment (#15603)
上级
c794ecf6
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
47 addition
and
15 deletion
+47
-15
paddle/fluid/inference/api/paddle_api.h
paddle/fluid/inference/api/paddle_api.h
+47
-15
未找到文件。
paddle/fluid/inference/api/paddle_api.h
浏览文件 @
c00ed19d
...
@@ -16,6 +16,12 @@
...
@@ -16,6 +16,12 @@
/*! \file paddle_api.h
/*! \file paddle_api.h
*/
*/
/*! \mainpage Paddle Inference APIs
* \section intro_sec Introduction
* The Paddle inference library aims to offer an high performance inference SDK
* for Paddle users.
*/
#include <cassert>
#include <cassert>
#include <memory>
#include <memory>
#include <string>
#include <string>
...
@@ -34,26 +40,49 @@ enum PaddleDType {
...
@@ -34,26 +40,49 @@ enum PaddleDType {
};
};
/**
/**
*
\brief Memory menager for PaddleTensor
.
*
\brief Memory manager for `PaddleTensor`
.
*
*
*The PaddleBuf holds a buffer for data input or output. The memory can be
*
The PaddleBuf holds a buffer for data input or output. The memory can be
*allocated by user or by PaddleBuf itself, but in any case, the PaddleBuf
*
allocated by user or by PaddleBuf itself, but in any case, the PaddleBuf
*should be reused for better performance.
*
should be reused for better performance.
*
*
*For user allocated memory, the following API can be used:
* For user allocated memory, the following API can be used:
*- PaddleBuf(void* data, size_t length) to set an external memory by
* - PaddleBuf(void* data, size_t length) to set an external memory by
*specifying
* specifying the memory address and length.
* the memory address and length.
* - Reset(void* data, size_t length) to reset the PaddleBuf with an external
*- Reset(void* data, size_t length) to reset the PaddleBuf with an external
*memory.
*memory.
*ATTENTION, for user allocated memory, deallocation should be done by users
*
ATTENTION, for user allocated memory, deallocation should be done by users
*externally after the program finished. The PaddleBuf won't do any allocation
*externally after the program finished. The PaddleBuf won't do any allocation
*or deallocation.
*or deallocation.
*
*
*To have the PaddleBuf allocate and manage the memory:
*
To have the PaddleBuf allocate and manage the memory:
*- PaddleBuf(size_t length) will allocate a memory of size `length`.
*
- PaddleBuf(size_t length) will allocate a memory of size `length`.
*- Resize(size_t length) resize the memory to no less than `length`, ATTENTION
*
- Resize(size_t length) resize the memory to no less than `length`, ATTENTION
* if the allocated memory is larger than `length`, nothing will done.
* if the allocated memory is larger than `length`, nothing will done.
*
* Usage:
*
* Let PaddleBuf manage the memory internally.
* \code{cpp}
* const int num_elements = 128;
* PaddleBuf buf(num_elements * sizeof(float));
* \endcode
*
* Or
* \code{cpp}
* PaddleBuf buf;
* buf.Resize(num_elements * sizeof(float));
* \endcode
* Works the exactly the same.
*
* One can also make the `PaddleBuf` use the external memory.
* \code{cpp}
* PaddleBuf buf;
* void* external_memory = new float[num_elements];
* buf.Reset(external_memory, num_elements*sizeof(float));
* ...
* delete[] external_memory; // manage the memory lifetime outside.
* \endcode
*/
*/
class
PaddleBuf
{
class
PaddleBuf
{
public:
public:
...
@@ -78,7 +107,7 @@ class PaddleBuf {
...
@@ -78,7 +107,7 @@ class PaddleBuf {
/** Tell whether the buffer is empty.
/** Tell whether the buffer is empty.
*/
*/
bool
empty
()
const
{
return
length_
==
0
;
}
bool
empty
()
const
{
return
length_
==
0
;
}
/** Get the memory address.
/** Get the
data's
memory address.
*/
*/
void
*
data
()
const
{
return
data_
;
}
void
*
data
()
const
{
return
data_
;
}
/** Get the memory length.
/** Get the memory length.
...
@@ -110,7 +139,8 @@ struct PaddleTensor {
...
@@ -110,7 +139,8 @@ struct PaddleTensor {
};
};
enum
class
PaddlePlace
{
kUNK
=
-
1
,
kCPU
,
kGPU
};
enum
class
PaddlePlace
{
kUNK
=
-
1
,
kCPU
,
kGPU
};
/** Tensor without copy, currently only supports AnalysisPredictor.
/** Tensor without copy, currently only supports `AnalysisPredictor`.
*/
*/
class
ZeroCopyTensor
{
class
ZeroCopyTensor
{
public:
public:
...
@@ -269,9 +299,11 @@ struct NativeConfig : public PaddlePredictor::Config {
...
@@ -269,9 +299,11 @@ struct NativeConfig : public PaddlePredictor::Config {
*
*
* Usage:
* Usage:
*
*
* \code{.cpp}
* NativeConfig config;
* NativeConfig config;
* ... // change the configs.
* ... // change the configs.
* auto native_predictor = CreatePaddlePredictor(config);
* auto native_predictor = CreatePaddlePredictor(config);
* \endcode
*
*
* FOR EXTENSION DEVELOPER:
* FOR EXTENSION DEVELOPER:
* Different predictors are designated by config type. Similar configs can be
* Different predictors are designated by config type. Similar configs can be
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录