Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Crayon鑫
Paddle
提交
49a59421
P
Paddle
项目概览
Crayon鑫
/
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看板
提交
49a59421
编写于
11月 16, 2017
作者:
W
wanghaox
浏览文件
操作
浏览文件
下载
差异文件
fix some typos
上级
352c5a96
4579bd44
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
23 addition
and
20 deletion
+23
-20
paddle/operators/sequence_slice_op.cc
paddle/operators/sequence_slice_op.cc
+3
-3
paddle/operators/sequence_slice_op.h
paddle/operators/sequence_slice_op.h
+20
-17
未找到文件。
paddle/operators/sequence_slice_op.cc
浏览文件 @
49a59421
...
...
@@ -90,11 +90,11 @@ class SequenceSliceOpMaker : public framework::OpProtoAndCheckerMaker {
"a vector<int> to describe the length of every input sequence for "
"sub sequence item."
);
AddOutput
(
"Out"
,
"(LoDTensor),
T
he output of SequenceSliceOp."
);
"(LoDTensor),
t
he output of SequenceSliceOp."
);
AddComment
(
R"DOC(
Sequence slice operator
The operator crop a subsequence from given sequence with given start offset and subsequence length.
The operator crop
s
a subsequence from given sequence with given start offset and subsequence length.
It only supports sequence (LoD Tensor with level number is 1).
- Case:
X = [[a1, a2;
...
...
@@ -109,7 +109,7 @@ It only supports sequence (LoD Tensor with level number is 1).
b1, b2]
[e1, e2]]
LoD(Out) = {{0, 2, 3}}; Dims(Out) = (3, 2)
NOTE: The
length of the input, offset and length should be the same
. The offset start from 0.
NOTE: The
first dimension size of input, the size of offset and Length, should be equal
. The offset start from 0.
)DOC"
);
}
};
...
...
paddle/operators/sequence_slice_op.h
浏览文件 @
49a59421
...
...
@@ -83,7 +83,8 @@ class SequenceSliceOpKernel : public framework::OpKernel<T> {
PADDLE_ENFORCE_LT
(
lod
[
0
][
i
]
+
offset_data
[
i
]
+
length_data
[
i
],
lod
[
0
][
i
+
1
],
"The target tensor's length overflow"
)}
"The target tensor's length overflow"
)
}
out
->
mutable_data
<
T
>
(
ctx
.
GetPlace
());
auto
out_lod
=
SequenceSliceLoD
(
*
in
,
offset_data
,
length_data
);
...
...
@@ -140,6 +141,7 @@ class SequenceSliceGradOpKernel : public framework::OpKernel<T> {
auto
lod
=
in
->
lod
();
auto
out_lod
=
out_grad
->
lod
();
if
(
x_grad
)
{
x_grad
->
mutable_data
<
T
>
(
ctx
.
GetPlace
());
math
::
SetConstant
<
Place
,
T
>
set_zero
;
set_zero
(
ctx
.
device_context
(),
x_grad
,
static_cast
<
T
>
(
0
));
...
...
@@ -163,6 +165,7 @@ class SequenceSliceGradOpKernel : public framework::OpKernel<T> {
x_grad_t
.
data
<
T
>
());
}
}
}
};
}
// namespace operators
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录