Canonicalization: Remove unused primal arguments for region op#2640
Canonicalization: Remove unused primal arguments for region op#2640vimarsh6739 merged 1 commit intomainfrom
Conversation
wsmoses
left a comment
There was a problem hiding this comment.
It's safe to remove any unused arg, not just const
|
There is one caveat, we assume that the only use of primals in the region are the block arguments of the entry basic block(and not the passed arguments to the op). Should we add a verifier for this? Currently, this is a manual check which is repeated for both outlining and #2562 |
No that's a limitation that should be fixed by the requisite users, as that is legal IR that ought be supported [tho perhaps not as well optimized] |
f7dfb69 to
4021d22
Compare
|
@wsmoses thinking a bit more about it, the trigger conditions for args with activity which aren't If we remove ( This also holds for the reverse mode case(in the below example, The other option is to leave it as a convention and make a note somewhere to users that this would const out computations. |
776948e to
a8dd70f
Compare
I don't understand this case, x2 is always const here. in fact the entire region is constant? %xx is literally unused in the region so it is always safe to remove, definitionally. |
a8dd70f to
7e2544a
Compare
7e2544a to
d88a7e7
Compare
It is safe to remove unused primal arguments for AutoDiffRegionOp when the primal has no uses within the function.
d88a7e7 to
2208124
Compare
This reverts commit 15a3d98.
It is safe to remove unused primal arguments for AutoDiffRegionOp when the primal has no uses within the function and is enzyme_const