-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Conversation
@@ -115,12 +115,32 @@ class SequencePoolGradOp : public framework::OperatorWithKernel { | |||
} | |||
}; | |||
|
|||
class SequencePoolGradOpMaker : public framework::SingleGradOpDescMaker { | |||
public: | |||
using framework::SingleGradOpDescMaker::SingleGradOpDescMaker; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- 只有MinusOp和AssignOp有类似的GradMaker,但这两个Op都没有单独的GradOp。同时这两个GradMaker继承的父类不一样,SequencePoolGradOpMaker继承
SingleGradOpDescMaker
,是因为MinusOp是组合Op么?
class MinusGradMaker : public framework::GradOpDescMakerBase
class AssignGradMaker : public framework::SingleGradOpDescMaker
- GradOpMaker和GradMaker需要统一下名字么,这样方便grep的时候,能查到?
- 能否下一个PR在new_op_cn.md和new_op_en.md中写一下,什么情况下需要单独创建GradMaker么?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- 确实是因为MinusOp的反向是组合op。SingleGradOpDescMaker继承自GradOpDescMakerBase,专门用于产生单独的反向op。
- 我觉得需要统一一下。
- 假设正向op的输入为I,输出为O。那么在默认情况下,框架会自动将其反向op的输入设置为I、O和OG(正向输出的梯度),输出设置为IG(正向输入的梯度)。但在一些特殊情况下,直接这样设置并不合适。例如在本例子中,只有在设置为“MAX”的情况下反向op才会需要MaxIndex这个正向的输入,因此我们需要自己写GradOpMaker,来订制反向op中输入输出和attribute的生成机制。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
好的,我提个issue吧
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Resolves #7346