Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add grad_op_maker for sequence_pool #7363

Merged
merged 2 commits into from
Jan 10, 2018
Merged

Conversation

pkuyym
Copy link
Contributor

@pkuyym pkuyym commented Jan 9, 2018

Resolves #7346

@@ -115,12 +115,32 @@ class SequencePoolGradOp : public framework::OperatorWithKernel {
}
};

class SequencePoolGradOpMaker : public framework::SingleGradOpDescMaker {
public:
using framework::SingleGradOpDescMaker::SingleGradOpDescMaker;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. 只有MinusOp和AssignOp有类似的GradMaker,但这两个Op都没有单独的GradOp。同时这两个GradMaker继承的父类不一样,SequencePoolGradOpMaker继承SingleGradOpDescMaker,是因为MinusOp是组合Op么?
  • class MinusGradMaker : public framework::GradOpDescMakerBase
  • class AssignGradMaker : public framework::SingleGradOpDescMaker
  1. GradOpMaker和GradMaker需要统一下名字么,这样方便grep的时候,能查到?
  2. 能否下一个PR在new_op_cn.mdnew_op_en.md中写一下,什么情况下需要单独创建GradMaker么?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@luotao1

  1. 确实是因为MinusOp的反向是组合op。SingleGradOpDescMaker继承自GradOpDescMakerBase,专门用于产生单独的反向op。
  2. 我觉得需要统一一下。
  3. 假设正向op的输入为I,输出为O。那么在默认情况下,框架会自动将其反向op的输入设置为I、O和OG(正向输出的梯度),输出设置为IG(正向输入的梯度)。但在一些特殊情况下,直接这样设置并不合适。例如在本例子中,只有在设置为“MAX”的情况下反向op才会需要MaxIndex这个正向的输入,因此我们需要自己写GradOpMaker,来订制反向op中输入输出和attribute的生成机制。

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JiayiFeng @pkuyym

我觉得需要统一一下

都统一成XXXGradOpMaker?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

好的,我提个issue吧

Copy link
Collaborator

@JiayiFeng JiayiFeng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@pkuyym pkuyym merged commit a158a3b into PaddlePaddle:develop Jan 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants