remove vars when remove ops#9384
remove vars when remove ops#9384luotao1 merged 2 commits intoPaddlePaddle:developfrom luotao1:removeVar
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. |
when removing an op, the vars of this op should be removed at the same time:
add a simple unit test to check
RemoveOpmethod.