-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
remove vars when remove ops #9384
Conversation
Is there a case that the output of the removed op is used by other op? |
If the output of removed op is the input of other ops, then other ops should adjust their inputs. If the output of removed op is the output of other ops, although this case has not been seen now, but these output vars should be remained, how do you think about it ? |
I think this case is in existence. Maybe two ways to remove var:
|
If we want to make this a general function, it's quite complex, see #9080 and https://en.wikipedia.org/wiki/Static_single_assignment_form. We must build a SSA graph before head so that two ops have same outputs ( write to var ) won't affect each other. For the simple implementation, I think just check if the output is used by other ops and do not remove them should work.
For generate inference programdesc, if remove_op can also remove unused vars, it's simpler to transpile a program for inference, I think. |
I agree with the simple implementation for generating inference program-desc at first. |
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++
when removing an op, the vars of this op should be removed at the same time:
add a simple unit test to check
RemoveOp
method.