未验证 提交 3eebd5b3 编写于 作者: Z Zeng Jinle 提交者: GitHub

refine sequence_softmax grad maker, test=develop (#20127)

上级 eb05db71
...@@ -146,11 +146,14 @@ class SequenceSoftmaxGradOp : public framework::OperatorWithKernel { ...@@ -146,11 +146,14 @@ class SequenceSoftmaxGradOp : public framework::OperatorWithKernel {
} }
std::string data_format = ctx.Attr<std::string>("data_format"); std::string data_format = ctx.Attr<std::string>("data_format");
return framework::OpKernelType( return framework::OpKernelType(
ctx.Input<Tensor>("X")->type(), ctx.GetPlace(), ctx.Input<Tensor>("Out")->type(), ctx.GetPlace(),
framework::StringToDataLayout(data_format), library_); framework::StringToDataLayout(data_format), library_);
} }
}; };
DECLARE_NO_NEED_BUFFER_VARS_INFERENCE(
SequenceSoftmaxGradOpNoNeedBufferVarsInferer, "X");
} // namespace operators } // namespace operators
} // namespace paddle } // namespace paddle
...@@ -158,7 +161,8 @@ namespace ops = paddle::operators; ...@@ -158,7 +161,8 @@ namespace ops = paddle::operators;
REGISTER_OPERATOR(sequence_softmax, ops::SequenceSoftmaxOp, REGISTER_OPERATOR(sequence_softmax, ops::SequenceSoftmaxOp,
ops::SequenceSoftmaxOpMaker, ops::SequenceSoftmaxOpMaker,
paddle::framework::DefaultGradOpDescMaker<true>); paddle::framework::DefaultGradOpDescMaker<true>);
REGISTER_OPERATOR(sequence_softmax_grad, ops::SequenceSoftmaxGradOp); REGISTER_OPERATOR(sequence_softmax_grad, ops::SequenceSoftmaxGradOp,
ops::SequenceSoftmaxGradOpNoNeedBufferVarsInferer);
REGISTER_OP_CPU_KERNEL( REGISTER_OP_CPU_KERNEL(
sequence_softmax, sequence_softmax,
ops::SequenceSoftmaxKernel<paddle::platform::CPUDeviceContext, float>, ops::SequenceSoftmaxKernel<paddle::platform::CPUDeviceContext, float>,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册