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

Enhance backward process #18700

Merged
merged 6 commits into from
Jul 24, 2019
Merged

Conversation

chengduoZH
Copy link
Contributor

@chengduoZH chengduoZH commented Jul 19, 2019

Prune the unnecessary op in backward.
Related PR #15955

Fix #15283

feature = fluid.layers.fc(input=x, size=10, act=None)
label = fluid.layers.cast(label, dtype="float32")
label = fluid.layers.cast(label, dtype='int64')
loss = fluid.layers.cross_entropy(input=feature, label=label)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note that the label is not persistable in fluid.layers.cross_entropy.

Copy link
Contributor

Choose a reason for hiding this comment

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

这个解释https://github.com/PaddlePaddle/Paddle/pull/18700/files#r305269149 可以加入单测代码中么?
这个单测的意思是,如果有并不需要的label,也能保持正确么?

test=develop
feature = fluid.layers.fc(input=x, size=10, act=None)
label = fluid.layers.cast(label, dtype="float32")
label = fluid.layers.cast(label, dtype='int64')
loss = fluid.layers.cross_entropy(input=feature, label=label)
Copy link
Contributor

Choose a reason for hiding this comment

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

这个解释https://github.com/PaddlePaddle/Paddle/pull/18700/files#r305269149 可以加入单测代码中么?
这个单测的意思是,如果有并不需要的label,也能保持正确么?

@@ -247,6 +247,104 @@ def _op_can_be_removed_(op_desc, no_grad_set):
return op_descs


def __find_not_need_ops(grad_op_descs, ops, input_grad_names_set):
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. 可以多加一些注释,说一下整体剪枝的逻辑么,比如是先转成图再剪?
  2. 会有性能上的影响么?

Copy link
Contributor

@Xreki Xreki Jul 22, 2019

Choose a reason for hiding this comment

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

同@luotao02
虽然issue里面有详情,也建议在PR里面描述一下。

Copy link
Contributor Author

Choose a reason for hiding this comment

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

可以多加一些注释,说一下整体剪枝的逻辑么,比如是先转成图再剪?

Done

会有性能上的影响么?

时间复杂度是O(N),与之前构建backward过程的时间复杂度是一样的。

test=develop
@chengduoZH chengduoZH closed this Jul 23, 2019
@chengduoZH chengduoZH reopened this Jul 23, 2019
test=develop
@chengduoZH chengduoZH closed this Jul 23, 2019
@chengduoZH chengduoZH reopened this Jul 23, 2019
Pruning Program with Structural Analysis Method of Computational Graph.
The nodes of the computational graph composed of backward OPS should be
interconnected. If there are unconnected sub-graphs in the computational graph,
these sub-graphs should be cut off.
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe better to add comments for grad_op_descs, ops, input_grad_names_set

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

test=develop
Copy link
Contributor

@luotao1 luotao1 left a comment

Choose a reason for hiding this comment

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

LGTM for update backward.py

@chengduoZH chengduoZH merged commit 8259f14 into PaddlePaddle:develop Jul 24, 2019
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.

用户使用momentum optimizer时出现cast op输入不存在错误
4 participants