-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Fix set value grad #59034
Fix set value grad #59034
Conversation
0bc76a7
to
8a5f39f
Compare
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.
这个修改还需要麻烦永康Review一下。这么改了以后paddle/fluid/ir_adaptor/translator/op_translator.cc里的SetValueGradOpTranscriber需要做调整吗?
switch (rank) { | ||
case 1: | ||
SetValueGradImpl<T, Context, 1>(dev_ctx, |
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.
这里是不是直接调SetValueGradKernel就可以了,value_grad传入nullptr。
op->SetType("set_value_grad"); | ||
op->SetInput(framework::GradVarName("Out"), this->OutputGrad("Out")); |
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.
这里应该讨论,如果有ValueTensor调用set_value_grad,没有ValueTensor调用set_value_with_scalar_grad
op->SetType("assign"); | ||
op->SetInput("X", this->OutputGrad("Out")); | ||
op->SetOutput("Out", this->InputGrad("Input")); | ||
op->SetType("set_value_with_scalar_grad"); |
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.
这行看起来依然没有被覆盖到,是不是需要注册一个新Op set_value_with_scalar_grad?
Sorry to inform you that 6cc1f71's CIs have passed for more than 7 days. To prevent PR conflicts, you need to re-run all CIs manually. |
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
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
* first fix the UT * fix set value grad * polish code * add static mode backward test * always has input valuetensor * add dygraph test
* first fix the UT * fix set value grad * polish code * add static mode backward test * always has input valuetensor * add dygraph test
* Fix set value grad (#59034) * first fix the UT * fix set value grad * polish code * add static mode backward test * always has input valuetensor * add dygraph test * Fix shape error in combined-indexing setitem (#60447) * add ut * fix shape error in combine-indexing * fix ut * Set value with scalar (#60452) * set_value with scalar * fix ut * remove test_pir * remove one test since 2.6 not support uint8-add
PR types
Bug fixes
PR changes
OPs
Description
Pcard-66985
在此前,为了适配分布式动半模式,
set_value
算子及其反向算子迁移到phi下。在此之前,set_value算子可同时处理value 为scalar或tensor两种场景,由inputValueTensor
是否存在来决定。相应的,其反向set_value_grad
也是如此。由于phi的要求,需要显式区分
set_value
(对应value 为scalar) 和set_value_with_tensor
(对应value 为tensor)两个算子。因此,反向也需要对应区分。在phi之前的算子历史定义fluid/operator
中,将前者的反向行为错误地设置为assign
,这使得在迁移phi时 #58893 的行为参考有误。导致目前value 为scalar时,赋值的反向结果与预期不符,需要修复。本PR 中新增kernel
set_value_with_scalar_grad
,用于该场景的计算,替代此前错误的assign
行为,其底层仍然复用SetValueGradImpl
。