Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
48029ab0
P
Paddle
项目概览
PaddlePaddle
/
Paddle
1 年多 前同步成功
通知
2302
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看板
未验证
提交
48029ab0
编写于
10月 10, 2019
作者:
Z
Zeng Jinle
提交者:
GitHub
10月 10, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove some DefaultGradOpDescMaker (#20185)
* remove fc_grad, test=develop * remove fsp op since no unittests, test=develop
上级
729f5846
变更
7
显示空白变更内容
内联
并排
Showing
7 changed file
with
67 addition
and
58 deletion
+67
-58
paddle/fluid/op_use_default_grad_op_maker.spec
paddle/fluid/op_use_default_grad_op_maker.spec
+0
-5
paddle/fluid/operators/conv_shift_op.cc
paddle/fluid/operators/conv_shift_op.cc
+21
-1
paddle/fluid/operators/fc_op.cc
paddle/fluid/operators/fc_op.cc
+1
-33
paddle/fluid/operators/fc_op.h
paddle/fluid/operators/fc_op.h
+0
-11
paddle/fluid/operators/fused/fused_embedding_seq_pool_op.cc
paddle/fluid/operators/fused/fused_embedding_seq_pool_op.cc
+20
-1
paddle/fluid/operators/modified_huber_loss_op.cc
paddle/fluid/operators/modified_huber_loss_op.cc
+24
-6
paddle/fluid/operators/rank_loss_op.cc
paddle/fluid/operators/rank_loss_op.cc
+1
-1
未找到文件。
paddle/fluid/op_use_default_grad_op_maker.spec
浏览文件 @
48029ab0
conv_shift
cos_sim
fc
flatten
fsp
fused_embedding_seq_pool
gru
lrn
lstm_unit
...
...
@@ -11,12 +8,10 @@ match_matrix_tensor
max_pool2d_with_index
max_pool3d_with_index
maxout
modified_huber_loss
nce
pool2d
pool3d
prelu
rank_loss
reduce_max
reduce_min
reduce_prod
...
...
paddle/fluid/operators/conv_shift_op.cc
浏览文件 @
48029ab0
...
...
@@ -13,6 +13,7 @@ See the License for the specific language governing permissions and
limitations under the License. */
#include "paddle/fluid/operators/conv_shift_op.h"
#include <memory>
#include "paddle/fluid/framework/eigen.h"
namespace
paddle
{
...
...
@@ -191,12 +192,31 @@ class ConvShiftGradKernel<platform::CPUPlace, T>
}
}
};
class
ConvShiftGradOpDescMaker
:
public
framework
::
SingleGradOpDescMaker
{
public:
using
framework
::
SingleGradOpDescMaker
::
SingleGradOpDescMaker
;
protected:
std
::
unique_ptr
<
framework
::
OpDesc
>
Apply
()
const
override
{
std
::
unique_ptr
<
framework
::
OpDesc
>
op
(
new
framework
::
OpDesc
());
op
->
SetType
(
"conv_shift_grad"
);
op
->
SetInput
(
"X"
,
Input
(
"X"
));
op
->
SetInput
(
"Y"
,
Input
(
"Y"
));
op
->
SetInput
(
framework
::
GradVarName
(
"Out"
),
OutputGrad
(
"Out"
));
op
->
SetOutput
(
framework
::
GradVarName
(
"X"
),
InputGrad
(
"X"
));
op
->
SetOutput
(
framework
::
GradVarName
(
"Y"
),
InputGrad
(
"Y"
));
op
->
SetAttrMap
(
Attrs
());
return
op
;
}
};
}
// namespace operators
}
// namespace paddle
namespace
ops
=
paddle
::
operators
;
REGISTER_OPERATOR
(
conv_shift
,
ops
::
ConvShiftOp
,
ops
::
ConvShiftOpMaker
,
paddle
::
framework
::
DefaultGradOpDescMaker
<
true
>
);
ops
::
ConvShiftGradOpDescMaker
);
REGISTER_OPERATOR
(
conv_shift_grad
,
ops
::
ConvShiftGradOp
);
REGISTER_OP_CPU_KERNEL
(
conv_shift
,
ops
::
ConvShiftKernel
<
paddle
::
platform
::
CPUPlace
,
float
>
);
...
...
paddle/fluid/operators/fc_op.cc
浏览文件 @
48029ab0
...
...
@@ -85,37 +85,6 @@ class FCOp : public framework::OperatorWithKernel {
}
};
void
FCOpGrad
::
InferShape
(
framework
::
InferShapeContext
*
ctx
)
const
{
auto
in_dims
=
ctx
->
GetInputDim
(
"Input"
);
auto
w_dims
=
ctx
->
GetInputDim
(
"W"
);
if
(
ctx
->
HasOutput
(
framework
::
GradVarName
(
"Input"
)))
{
ctx
->
SetOutputDim
(
framework
::
GradVarName
(
"Input"
),
in_dims
);
}
if
(
ctx
->
HasOutput
(
framework
::
GradVarName
(
"W"
)))
{
ctx
->
SetOutputDim
(
framework
::
GradVarName
(
"W"
),
w_dims
);
}
if
(
ctx
->
HasInput
(
"Bias"
))
{
PADDLE_ENFORCE_EQ
(
ctx
->
HasOutput
(
framework
::
GradVarName
(
"Bias"
)),
true
,
"Should have bias grad"
);
auto
bias_dims
=
ctx
->
GetInputDim
(
"Bias"
);
ctx
->
SetOutputDim
(
framework
::
GradVarName
(
"Bias"
),
bias_dims
);
}
}
framework
::
OpKernelType
FCOpGrad
::
GetExpectedKernelType
(
const
framework
::
ExecutionContext
&
ctx
)
const
{
framework
::
LibraryType
library
=
framework
::
LibraryType
::
kPlain
;
framework
::
DataLayout
layout
=
framework
::
DataLayout
::
kAnyLayout
;
if
(
ctx
.
Attr
<
bool
>
(
"use_mkldnn"
))
{
library
=
framework
::
LibraryType
::
kMKLDNN
;
layout
=
framework
::
DataLayout
::
kMKLDNN
;
}
return
framework
::
OpKernelType
(
ctx
.
Input
<
Tensor
>
(
"Input"
)
->
type
(),
ctx
.
GetPlace
(),
layout
,
library
);
}
class
FCOpMaker
:
public
framework
::
OpProtoAndCheckerMaker
{
public:
void
Make
()
override
{
...
...
@@ -154,8 +123,7 @@ The size of each dimension of the parameters checked in the infer-shape.
namespace
ops
=
paddle
::
operators
;
REGISTER_OPERATOR
(
fc
,
ops
::
FCOp
,
ops
::
FCOpMaker
,
paddle
::
framework
::
DefaultGradOpDescMaker
<
true
>
);
REGISTER_OPERATOR
(
fc_grad
,
ops
::
FCOpGrad
);
paddle
::
framework
::
EmptyGradOpMaker
);
REGISTER_OP_CPU_KERNEL
(
fc
,
ops
::
FCOpKernel
<
paddle
::
platform
::
CPUDeviceContext
,
float
>
,
ops
::
FCOpKernel
<
paddle
::
platform
::
CPUDeviceContext
,
double
>
);
paddle/fluid/operators/fc_op.h
浏览文件 @
48029ab0
...
...
@@ -24,17 +24,6 @@ namespace operators {
using
Tensor
=
framework
::
Tensor
;
class
FCOpGrad
:
public
framework
::
OperatorWithKernel
{
public:
using
framework
::
OperatorWithKernel
::
OperatorWithKernel
;
void
InferShape
(
framework
::
InferShapeContext
*
ctx
)
const
override
;
protected:
framework
::
OpKernelType
GetExpectedKernelType
(
const
framework
::
ExecutionContext
&
ctx
)
const
override
;
};
inline
void
FCOutputSize
(
const
framework
::
DDim
&
in_dims
,
const
framework
::
DDim
&
w_dims
,
std
::
vector
<
int64_t
>&
out_dims
,
// NOLINT
...
...
paddle/fluid/operators/fused/fused_embedding_seq_pool_op.cc
浏览文件 @
48029ab0
...
...
@@ -13,6 +13,7 @@ See the License for the specific language governing permissions and
limitations under the License. */
#include "paddle/fluid/operators/fused/fused_embedding_seq_pool_op.h"
#include <memory>
#include "paddle/fluid/framework/var_type_inference.h"
namespace
paddle
{
...
...
@@ -150,12 +151,30 @@ class FusedEmbeddingSeqPoolOpGradVarTypeInference
}
};
class
FusedEmbeddingSeqPoolGradOpDescMaker
:
public
framework
::
SingleGradOpDescMaker
{
public:
using
framework
::
SingleGradOpDescMaker
::
SingleGradOpDescMaker
;
protected:
std
::
unique_ptr
<
framework
::
OpDesc
>
Apply
()
const
override
{
std
::
unique_ptr
<
framework
::
OpDesc
>
op
(
new
framework
::
OpDesc
());
op
->
SetType
(
"fused_embedding_seq_pool_grad"
);
op
->
SetInput
(
"Ids"
,
Input
(
"Ids"
));
op
->
SetInput
(
"W"
,
Input
(
"W"
));
op
->
SetInput
(
framework
::
GradVarName
(
"Out"
),
OutputGrad
(
"Out"
));
op
->
SetOutput
(
framework
::
GradVarName
(
"W"
),
InputGrad
(
"W"
));
op
->
SetAttrMap
(
Attrs
());
return
op
;
}
};
}
// namespace operators
}
// namespace paddle
namespace
ops
=
paddle
::
operators
;
REGISTER_OPERATOR
(
fused_embedding_seq_pool
,
ops
::
FusedEmbeddingSeqPoolOp
,
paddle
::
framework
::
DefaultGradOpDescMaker
<
true
>
,
ops
::
FusedEmbeddingSeqPoolGradOpDescMaker
,
ops
::
FusedEmbeddingSeqPoolOpMaker
);
REGISTER_OPERATOR
(
fused_embedding_seq_pool_grad
,
ops
::
FusedEmbeddingSeqPoolOpGrad
,
...
...
paddle/fluid/operators/modified_huber_loss_op.cc
浏览文件 @
48029ab0
...
...
@@ -13,6 +13,7 @@ See the License for the specific language governing permissions and
limitations under the License. */
#include "paddle/fluid/operators/modified_huber_loss_op.h"
#include <memory>
namespace
paddle
{
namespace
operators
{
...
...
@@ -86,28 +87,45 @@ class ModifiedHuberLossGradOp : public framework::OperatorWithKernel {
using
framework
::
OperatorWithKernel
::
OperatorWithKernel
;
void
InferShape
(
framework
::
InferShapeContext
*
ctx
)
const
override
{
PADDLE_ENFORCE
(
ctx
->
HasInput
(
"X"
),
"X must be initialized."
);
PADDLE_ENFORCE
(
ctx
->
HasInput
(
"Y"
),
"Y must be initialized."
);
PADDLE_ENFORCE
(
ctx
->
HasInput
(
"IntermediateVal"
),
"Intermediate value must not be null."
);
PADDLE_ENFORCE
(
ctx
->
HasInput
(
framework
::
GradVarName
(
"Out"
)),
"Input(Out@Grad) must not be null."
);
auto
x_dims
=
ctx
->
GetInputDim
(
"X
"
);
auto
y_dims
=
ctx
->
GetInputDim
(
"Y
"
);
auto
intermediate_dims
=
ctx
->
GetInputDim
(
"IntermediateVal"
);
auto
out_grad_dims
=
ctx
->
GetInputDim
(
framework
::
GradVarName
(
"Out"
));
if
(
ctx
->
IsRuntime
())
{
PADDLE_ENFORCE_EQ
(
intermediate_dims
,
x
_dims
,
intermediate_dims
,
y
_dims
,
"The shape of X and intermediate value must be the same."
);
PADDLE_ENFORCE_EQ
(
out_grad_dims
,
x
_dims
,
PADDLE_ENFORCE_EQ
(
out_grad_dims
,
y
_dims
,
"The shape of Input(Out@Grad) and X must be the same."
);
}
if
(
ctx
->
HasOutput
(
framework
::
GradVarName
(
"X"
)))
{
ctx
->
SetOutputDim
(
framework
::
GradVarName
(
"X"
),
x_dims
);
ctx
->
SetOutputDim
(
framework
::
GradVarName
(
"X"
),
y_dims
);
}
}
};
class
ModifiedHuberLossGradOpDescMaker
:
public
framework
::
SingleGradOpDescMaker
{
public:
using
framework
::
SingleGradOpDescMaker
::
SingleGradOpDescMaker
;
protected:
std
::
unique_ptr
<
framework
::
OpDesc
>
Apply
()
const
override
{
std
::
unique_ptr
<
framework
::
OpDesc
>
op
(
new
framework
::
OpDesc
());
op
->
SetType
(
"modified_huber_loss_grad"
);
op
->
SetInput
(
"Y"
,
Input
(
"Y"
));
op
->
SetInput
(
"IntermediateVal"
,
Output
(
"IntermediateVal"
));
op
->
SetInput
(
framework
::
GradVarName
(
"Out"
),
OutputGrad
(
"Out"
));
op
->
SetOutput
(
framework
::
GradVarName
(
"X"
),
InputGrad
(
"X"
));
op
->
SetAttrMap
(
Attrs
());
return
op
;
}
};
...
...
@@ -117,7 +135,7 @@ class ModifiedHuberLossGradOp : public framework::OperatorWithKernel {
namespace
ops
=
paddle
::
operators
;
REGISTER_OPERATOR
(
modified_huber_loss
,
ops
::
ModifiedHuberLossOp
,
ops
::
ModifiedHuberLossOpMaker
,
paddle
::
framework
::
DefaultGradOpDescMaker
<
true
>
);
ops
::
ModifiedHuberLossGradOpDescMaker
);
REGISTER_OPERATOR
(
modified_huber_loss_grad
,
ops
::
ModifiedHuberLossGradOp
);
REGISTER_OP_CPU_KERNEL
(
...
...
paddle/fluid/operators/rank_loss_op.cc
浏览文件 @
48029ab0
...
...
@@ -180,7 +180,7 @@ class RankLossGradDescMaker : public framework::SingleGradOpDescMaker {
namespace
ops
=
paddle
::
operators
;
REGISTER_OPERATOR
(
rank_loss
,
ops
::
RankLossOp
,
ops
::
RankLossOpMaker
,
paddle
::
framework
::
DefaultGradOpDescMaker
<
true
>
);
ops
::
RankLossGradDescMaker
);
REGISTER_OPERATOR
(
rank_loss_grad
,
ops
::
RankLossGradOp
);
REGISTER_OP_CPU_KERNEL
(
rank_loss
,
ops
::
RankLossKernel
<
paddle
::
platform
::
CPUDeviceContext
,
float
>
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录