Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleDetection
提交
e579dc1c
P
PaddleDetection
项目概览
PaddlePaddle
/
PaddleDetection
大约 1 年 前同步成功
通知
694
Star
11112
Fork
2696
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
184
列表
看板
标记
里程碑
合并请求
40
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleDetection
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
184
Issue
184
列表
看板
标记
里程碑
合并请求
40
合并请求
40
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
e579dc1c
编写于
12月 18, 2017
作者:
W
whs
提交者:
GitHub
12月 18, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #6708 from wanghaoshuang/rename_seq
Rename seq to sequence in sequence_expand_op
上级
b28a1737
fbdaf7e0
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
27 addition
and
27 deletion
+27
-27
paddle/operators/sequence_expand_op.cc
paddle/operators/sequence_expand_op.cc
+15
-15
paddle/operators/sequence_expand_op.cu
paddle/operators/sequence_expand_op.cu
+5
-5
paddle/operators/sequence_expand_op.h
paddle/operators/sequence_expand_op.h
+2
-2
python/paddle/v2/fluid/tests/test_sequence_expand.py
python/paddle/v2/fluid/tests/test_sequence_expand.py
+5
-5
未找到文件。
paddle/operators/seq_expand_op.cc
→
paddle/operators/seq
uence
_expand_op.cc
浏览文件 @
e579dc1c
...
...
@@ -12,14 +12,14 @@
See the License for the specific language governing permissions and
limitations under the License. */
#include "paddle/operators/seq_expand_op.h"
#include "paddle/operators/seq
uence
_expand_op.h"
namespace
paddle
{
namespace
operators
{
using
framework
::
Tensor
;
class
SeqExpandOp
:
public
framework
::
OperatorWithKernel
{
class
Seq
uence
ExpandOp
:
public
framework
::
OperatorWithKernel
{
public:
using
framework
::
OperatorWithKernel
::
OperatorWithKernel
;
...
...
@@ -35,25 +35,25 @@ class SeqExpandOp : public framework::OperatorWithKernel {
}
};
class
SeqExpandOpMaker
:
public
framework
::
OpProtoAndCheckerMaker
{
class
Seq
uence
ExpandOpMaker
:
public
framework
::
OpProtoAndCheckerMaker
{
public:
SeqExpandOpMaker
(
framework
::
OpProto
*
proto
,
framework
::
OpAttrChecker
*
op_checker
)
Seq
uence
ExpandOpMaker
(
framework
::
OpProto
*
proto
,
framework
::
OpAttrChecker
*
op_checker
)
:
OpProtoAndCheckerMaker
(
proto
,
op_checker
)
{
AddInput
(
"X"
,
"(Tensor or LoDTensor) The input(X) of this operator can be a "
"LoDTensor or a base Tensor."
);
AddInput
(
"Y"
,
"(LoDTensor)The reference input(Y) of seq_expand op."
"(LoDTensor)The reference input(Y) of seq
uence
_expand op."
"It must be a LoDTensor with k-level(k>0)."
"The input(X) will be expanded according to LOD of input(Y)."
"The element numbers of last level in input(Y) "
"must be equal to dims[0] of input(X)."
);
AddOutput
(
"Out"
,
"(LodTensor)The output of seq_expand op."
"(LodTensor)The output of seq
uence
_expand op."
"The lod of output will be as same as input(Y)'s lod."
);
AddComment
(
R"DOC(
Seq Expand Operator.
Seq
uence
Expand Operator.
This operator expands input(X) according to LOD of input(Y).
Following are cases to better explain how this works:
...
...
@@ -124,7 +124,7 @@ then we get 2-level LoDTensor
}
};
class
SeqExpandOpGrad
:
public
framework
::
OperatorWithKernel
{
class
Seq
uence
ExpandOpGrad
:
public
framework
::
OperatorWithKernel
{
public:
using
framework
::
OperatorWithKernel
::
OperatorWithKernel
;
...
...
@@ -146,11 +146,11 @@ class SeqExpandOpGrad : public framework::OperatorWithKernel {
}
// namespace paddle
namespace
ops
=
paddle
::
operators
;
REGISTER_OP
(
seq
_expand
,
ops
::
SeqExpandOp
,
ops
::
Seq
ExpandOpMaker
,
seq
_expand_grad
,
ops
::
Seq
ExpandOpGrad
);
REGISTER_OP
(
seq
uence_expand
,
ops
::
SequenceExpandOp
,
ops
::
Sequence
ExpandOpMaker
,
seq
uence_expand_grad
,
ops
::
Sequence
ExpandOpGrad
);
REGISTER_OP_CPU_KERNEL
(
seq_expand
,
ops
::
SeqExpandKernel
<
paddle
::
platform
::
CPUDeviceContext
,
float
>
);
seq
uence
_expand
,
ops
::
Seq
uence
ExpandKernel
<
paddle
::
platform
::
CPUDeviceContext
,
float
>
);
REGISTER_OP_CPU_KERNEL
(
seq_expand_grad
,
ops
::
SeqExpandGradKernel
<
paddle
::
platform
::
CPUDeviceContext
,
float
>
);
seq
uence
_expand_grad
,
ops
::
Seq
uence
ExpandGradKernel
<
paddle
::
platform
::
CPUDeviceContext
,
float
>
);
paddle/operators/seq_expand_op.cu
→
paddle/operators/seq
uence
_expand_op.cu
浏览文件 @
e579dc1c
...
...
@@ -13,12 +13,12 @@
limitations under the License. */
#define EIGEN_USE_GPU
#include "paddle/operators/seq_expand_op.h"
#include "paddle/operators/seq
uence
_expand_op.h"
namespace
ops
=
paddle
::
operators
;
REGISTER_OP_CUDA_KERNEL
(
seq_expand
,
ops
::
SeqExpandKernel
<
paddle
::
platform
::
CUDADeviceContext
,
float
>
);
seq
uence
_expand
,
ops
::
Seq
uence
ExpandKernel
<
paddle
::
platform
::
CUDADeviceContext
,
float
>
);
REGISTER_OP_CUDA_KERNEL
(
seq_expand_grad
,
ops
::
SeqExpandGradKernel
<
paddle
::
platform
::
CUDADeviceContext
,
float
>
);
seq
uence
_expand_grad
,
ops
::
Seq
uence
ExpandGradKernel
<
paddle
::
platform
::
CUDADeviceContext
,
float
>
);
paddle/operators/seq_expand_op.h
→
paddle/operators/seq
uence
_expand_op.h
浏览文件 @
e579dc1c
...
...
@@ -24,7 +24,7 @@ namespace operators {
using
LoDTensor
=
framework
::
LoDTensor
;
template
<
typename
DeviceContext
,
typename
T
>
class
SeqExpandKernel
:
public
framework
::
OpKernel
<
T
>
{
class
Seq
uence
ExpandKernel
:
public
framework
::
OpKernel
<
T
>
{
public:
void
Compute
(
const
framework
::
ExecutionContext
&
context
)
const
override
{
auto
*
x
=
context
.
Input
<
LoDTensor
>
(
"X"
);
...
...
@@ -71,7 +71,7 @@ class SeqExpandKernel : public framework::OpKernel<T> {
*
* */
template
<
typename
DeviceContext
,
typename
T
>
class
SeqExpandGradKernel
:
public
framework
::
OpKernel
<
T
>
{
class
Seq
uence
ExpandGradKernel
:
public
framework
::
OpKernel
<
T
>
{
public:
void
Compute
(
const
framework
::
ExecutionContext
&
context
)
const
override
{
auto
*
d_out
=
context
.
Input
<
LoDTensor
>
(
framework
::
GradVarName
(
"Out"
));
...
...
python/paddle/v2/fluid/tests/test_seq_expand.py
→
python/paddle/v2/fluid/tests/test_seq
uence
_expand.py
浏览文件 @
e579dc1c
...
...
@@ -3,7 +3,7 @@ import numpy as np
from
op_test
import
OpTest
class
TestSeqExpand
(
OpTest
):
class
TestSeq
uence
Expand
(
OpTest
):
def
set_data
(
self
):
x_data
=
np
.
random
.
uniform
(
0.1
,
1
,
[
3
,
1
]).
astype
(
'float32'
)
y_data
=
np
.
random
.
uniform
(
0.1
,
1
,
[
8
,
1
]).
astype
(
'float32'
)
...
...
@@ -21,7 +21,7 @@ class TestSeqExpand(OpTest):
self
.
outputs
=
{
'Out'
:
out
}
def
setUp
(
self
):
self
.
op_type
=
'seq_expand'
self
.
op_type
=
'seq
uence
_expand'
self
.
set_data
()
self
.
compute
()
...
...
@@ -32,7 +32,7 @@ class TestSeqExpand(OpTest):
self
.
check_grad
([
"X"
],
"Out"
)
class
TestSeq
ExpandCase1
(
TestSeq
Expand
):
class
TestSeq
uenceExpandCase1
(
TestSequence
Expand
):
def
set_data
(
self
):
x_data
=
np
.
random
.
uniform
(
0.1
,
1
,
[
5
,
1
]).
astype
(
'float32'
)
x_lod
=
[[
0
,
2
,
5
]]
...
...
@@ -41,7 +41,7 @@ class TestSeqExpandCase1(TestSeqExpand):
self
.
inputs
=
{
'X'
:
(
x_data
,
x_lod
),
'Y'
:
(
y_data
,
y_lod
)}
class
TestSeq
ExpandCase2
(
TestSeq
Expand
):
class
TestSeq
uenceExpandCase2
(
TestSequence
Expand
):
def
set_data
(
self
):
x_data
=
np
.
random
.
uniform
(
0.1
,
1
,
[
1
,
2
,
2
]).
astype
(
'float32'
)
x_lod
=
[[
0
,
1
]]
...
...
@@ -50,7 +50,7 @@ class TestSeqExpandCase2(TestSeqExpand):
self
.
inputs
=
{
'X'
:
(
x_data
,
x_lod
),
'Y'
:
(
y_data
,
y_lod
)}
class
TestSeq
ExpandCase3
(
TestSeq
Expand
):
class
TestSeq
uenceExpandCase3
(
TestSequence
Expand
):
def
set_data
(
self
):
x_data
=
np
.
random
.
uniform
(
0.1
,
1
,
[
4
,
1
]).
astype
(
'float32'
)
x_lod
=
[[
0
,
1
,
2
,
3
,
4
]]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录