Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
2a20fdc1
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看板
提交
2a20fdc1
编写于
1月 13, 2017
作者:
H
hedaoyuan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Change BufferArgPtr to BufferArg*
上级
bff19f57
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
37 addition
and
5 deletion
+37
-5
paddle/function/Function.cpp
paddle/function/Function.cpp
+6
-3
paddle/function/Function.h
paddle/function/Function.h
+31
-2
未找到文件。
paddle/function/Function.cpp
浏览文件 @
2a20fdc1
...
...
@@ -79,15 +79,18 @@ FuncConfig& FuncConfig::set<bool>(const std::string& key, bool v) {
void
BufferArgs
::
addArg
(
const
Matrix
&
arg
,
const
TensorShape
&
shape
,
ArgType
argType
)
{
args_
.
push_back
(
std
::
make_shared
<
BufferArg
>
(
arg
,
shape
,
argType
));
_args_
.
push_back
(
new
BufferArg
(
arg
,
shape
,
argType
));
addArg
(
*
_args_
.
back
());
}
void
BufferArgs
::
addArg
(
const
CpuSparseMatrix
&
arg
,
ArgType
argType
)
{
args_
.
push_back
(
std
::
make_shared
<
SparseMatrixArg
>
(
arg
,
argType
));
_args_
.
push_back
(
new
SparseMatrixArg
(
arg
,
argType
));
addArg
(
*
_args_
.
back
());
}
void
BufferArgs
::
addArg
(
const
GpuSparseMatrix
&
arg
,
ArgType
argType
)
{
args_
.
push_back
(
std
::
make_shared
<
SparseMatrixArg
>
(
arg
,
argType
));
_args_
.
push_back
(
new
SparseMatrixArg
(
arg
,
argType
));
addArg
(
*
_args_
.
back
());
}
ClassRegistrar
<
FunctionBase
>
FunctionBase
::
funcRegistrar_
;
...
...
paddle/function/Function.h
浏览文件 @
2a20fdc1
...
...
@@ -50,10 +50,25 @@ protected:
* Argument type for Function::calc().
* A BufferArgs contains a set of BufferArg,
* because Function can have multiple inputs and outputs.
*
* addArg() with Matix object used to adapt Layer Argument.
* Will create a BufferArg object in addArg(),
* and free in destructor of BufferArgs.
*
* addArg() with BufferArg object, just save BufferArg object address,
* and the caller needs to guarantee the validity of the BufferArg object
* in the BufferArgs life time.
*/
class
BufferArgs
{
public:
BufferArgs
()
{}
~
BufferArgs
()
{
for
(
auto
arg
:
_args_
)
{
delete
arg
;
}
}
size_t
size
()
const
{
return
args_
.
size
();
}
// add argument into BufferArgs
...
...
@@ -62,7 +77,8 @@ public:
// For outputs, the argType needs to be specified as ASSIGN_TO or ADD_TO.
template
<
typename
Tensor
>
void
addArg
(
const
Tensor
&
arg
,
ArgType
argType
=
UNSPECIFIED
)
{
args_
.
push_back
(
std
::
make_shared
<
BufferArg
>
(
arg
,
argType
));
_args_
.
push_back
(
new
BufferArg
(
arg
,
argType
));
addArg
(
*
_args_
.
back
());
}
// Add arg into BufferArgs and reshape the arg.
...
...
@@ -83,14 +99,27 @@ public:
return
*
args_
[
num
];
}
void
addArg
(
BufferArg
&
arg
)
{
args_
.
push_back
(
&
arg
);
}
void
addArg
(
SequenceIdArg
&
arg
)
{
args_
.
push_back
(
&
arg
);
}
void
addArg
(
SequenceArg
&
arg
)
{
args_
.
push_back
(
&
arg
);
}
void
addArg
(
SparseMatrixArg
&
arg
)
{
args_
.
push_back
(
&
arg
);
}
private:
std
::
vector
<
BufferArgPtr
>
args_
;
std
::
vector
<
BufferArg
*>
args_
;
// The BufferArg object is constructed and freed by BufferArgs.
std
::
vector
<
BufferArg
*>
_args_
;
};
/**
* \brief Base class for Function.
* The basic Function implementation requires override init and calc interfaces.
*
* The caller needs to ensure the validity of the arguments
* during Function execution.
*
* Function inputs are readonly, Function outputs have two modes: ASSIGN_TO
* and ADD_TO.
* If output.getArgType() == ASSIGN_TO, this is assign mode, and the calculation
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录