-
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
[Dy2stat] Add Support for paddle.grad #33110
Conversation
Thanks for your contribution! |
Sorry to inform you that 8b48d9b's CIs have passed for more than 7 days. To prevent PR conflicts, you need to re-run all CIs manually. |
def forward(self, inputs): | ||
in_vars, out_vars, tmp_scope_vec = self._prepare(inputs) | ||
|
||
double_grads = self._get_double_grads(self._origin_main_program) |
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.
这里的main_program是固定的,所以 double_grads 是否只需要 core.VarBase 创建一次就可以了,每个batch 直接复用就好了?
因为这个 get_double_grads
放在forward里,调用频率会很高,grads_var的name解析等都是可以只做一次的。
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.
好的,移动到构造函数里
python/paddle/fluid/dygraph/io.py
Outdated
for b_idx in six.moves.range(program_desc.num_blocks()): | ||
cur_block = program_desc.block(b_idx) | ||
for var_idx, var in enumerate(cur_block.all_vars()): | ||
name_old = var.name() | ||
is_double_grad_var = "GRAD" in name_old |
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.
这里是否应该是 @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.
你说得对,我的错,新commit已更正
value=[1], | ||
name='Fake_var', | ||
place=framework._current_expected_place()) | ||
] |
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.
ddout在 Maker 里标记的是 AsDispensable
,如果为空,这里是不是不用 fake 了?
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.
LGTM with my knowledge
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
PR types
New features
PR changes
APIs
Describe
This PR made these changes to support double grad:
paddle.grad
topaddle.static.gradients
to support double grad for dy2stat.DOut
to support double grad variables inrun_program_op
jit.save/load