Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
9189567a
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看板
提交
9189567a
编写于
12月 21, 2017
作者:
Y
Yang Yu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Follow comments
上级
8823a12e
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
26 addition
and
18 deletion
+26
-18
paddle/operators/reorder_lod_tensor_by_rank_op.cc
paddle/operators/reorder_lod_tensor_by_rank_op.cc
+15
-6
python/paddle/v2/fluid/layers/control_flow.py
python/paddle/v2/fluid/layers/control_flow.py
+2
-9
python/paddle/v2/fluid/registry.py
python/paddle/v2/fluid/registry.py
+9
-3
未找到文件。
paddle/operators/reorder_lod_tensor_by_rank_op.cc
浏览文件 @
9189567a
...
...
@@ -19,21 +19,28 @@
namespace
paddle
{
namespace
operators
{
class
ReorderLoDTensorProtoMaker
:
public
framework
::
OpProtoAndCheckerMaker
{
class
ReorderLoDTensorByRankTableOpProtoMaker
:
public
framework
::
OpProtoAndCheckerMaker
{
public:
ReorderLoDTensorProtoMaker
(
OpProto
*
proto
,
OpAttrChecker
*
op_checker
)
ReorderLoDTensorByRankTableOpProtoMaker
(
OpProto
*
proto
,
OpAttrChecker
*
op_checker
)
:
OpProtoAndCheckerMaker
(
proto
,
op_checker
)
{
AddInput
(
"X"
,
"(LoDTensor) the input lod tensor need to be reordered."
);
AddInput
(
"RankTable"
,
"(LoDRankTable) the rank table that input need follow"
);
AddOutput
(
"Out"
,
"(LoDTensor) reordered lod tensor"
);
AddComment
(
R"DOC(ReorderLoDTensor
LoD
RankTable
AddComment
(
R"DOC(ReorderLoDTensor
By
RankTable
Reorder the input X by the rank of `RankTable`. If `RankTable` is ordered by
index [3, 0, 2, 1]. Input X will reorder its sequence, the third sequence of
X will be the first sequence of Output.
NOTE: The RankTable does not need to be calculated by X.
For example:
The X = [Seq0, Seq1, Seq2, Seq3]. The indices of RankTable are [3, 0, 2, 1].
The Out = [Seq3, Seq0, Seq2, Seq1] with correct LoD information.
)DOC"
);
}
};
...
...
@@ -146,8 +153,9 @@ class ReorderLoDTensorByRankTableOp : public ReorderLoDTensorByRankTableBase {
size_t
out_offset
=
0
;
out
->
mutable_lod
()
->
clear
();
for
(
auto
&
item
:
rank_table
.
items
())
{
out_offset
=
this
->
CopyTensorAndLod
(
dev_ctx
,
absolute_table
[
item
.
index
],
x
,
out
,
out_offset
);
PADDLE_ENFORCE_LT
(
item
.
index
,
absolute_table
.
size
());
out_offset
=
CopyTensorAndLod
(
dev_ctx
,
absolute_table
[
item
.
index
],
x
,
out
,
out_offset
);
}
}
};
...
...
@@ -220,6 +228,7 @@ namespace ops = paddle::operators;
REGISTER_OPERATOR
(
reorder_lod_tensor_by_rank
,
ops
::
ReorderLoDTensorByRankTableOp
,
ops
::
ReorderLodTensorByRankGradOpMaker
,
ops
::
ReorderLoDTensorProtoMaker
,
ops
::
IdentityInferShape
);
ops
::
ReorderLoDTensorByRankTableOpProtoMaker
,
ops
::
IdentityInferShape
);
REGISTER_OPERATOR
(
reorder_lod_tensor_by_rank_grad
,
ops
::
ReorderLoDTensorByRankGradOp
,
ops
::
IdentityInferShape
);
python/paddle/v2/fluid/layers/control_flow.py
浏览文件 @
9189567a
...
...
@@ -3,6 +3,7 @@ from ..framework import Program, Variable, Operator
from
..
import
core
from
tensor
import
assign
,
fill_constant
import
contextlib
from
..registry
import
autodoc
__all__
=
[
'split_lod_tensor'
,
'merge_lod_tensor'
,
'BlockGuard'
,
'StaticRNNGuard'
,
...
...
@@ -983,16 +984,8 @@ class DynamicRNN(object):
method
))
@
autodoc
def
reorder_lod_tensor_by_rank
(
x
,
rank_table
):
"""
Args:
x(Variable):
rank_table(Variable):
Returns:
"""
helper
=
LayerHelper
(
'reorder_lod_tensor_by_rank'
,
**
locals
())
helper
.
is_instance
(
'x'
,
Variable
)
helper
.
is_instance
(
'rank_table'
,
Variable
)
...
...
python/paddle/v2/fluid/registry.py
浏览文件 @
9189567a
...
...
@@ -8,7 +8,7 @@ import proto.framework_pb2 as framework_pb2
from
framework
import
OpProtoHolder
,
Variable
,
Program
,
Operator
from
paddle.v2.fluid.layer_helper
import
LayerHelper
,
unique_name
__all__
=
[
'deprecated'
,
'register_layer'
]
__all__
=
[
'deprecated'
,
'register_layer'
,
'autodoc'
]
def
_convert_
(
name
):
...
...
@@ -175,12 +175,18 @@ def deprecated(func_or_class):
"""
Wrap func with deprecated warning
"""
warnings
.
simplefilter
(
'always'
,
DeprecationWarning
)
#turn off filter
warnings
.
simplefilter
(
'always'
,
DeprecationWarning
)
#
turn off filter
warnings
.
warn
(
"Call to deprecated function {}."
.
format
(
func
.
__name__
),
category
=
DeprecationWarning
,
stacklevel
=
2
)
warnings
.
simplefilter
(
'default'
,
DeprecationWarning
)
#reset filter
warnings
.
simplefilter
(
'default'
,
DeprecationWarning
)
#
reset filter
return
func
(
*
args
,
**
kwargs
)
return
func_wrapper
def
autodoc
(
func
):
func
.
__doc__
=
_generate_doc_string_
(
OpProtoHolder
.
instance
().
get_op_proto
(
func
.
__name__
))
return
func
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录