[XLA] Fix issue in conditional code motion regarding sharing of computations...
[XLA] Fix issue in conditional code motion regarding sharing of computations in conditionals and cleanup generated code. The branch computations inside a conditional may be shared among different Hlo instructions, e.g., different conditionals. When moving instructions across the boundaries of two computations, specifically the branch computations and the parent of a conditional, we must make sure the branch computations being modified are not shared --- if shared, they must be cloned first before being modified. The transformation code and the cost calculation for moving instructions inside branches are also modified to produce cleaner result and to refrain from modifying a conditional back and forth. The original implementation for moving instructions inside branches merely extends the old roots of the branches with new instructions. The improved transformation now folds the tuple/getTupleElement instructions in the branches to eliminate unnecessary tuple/getTupleElement pairs. PiperOrigin-RevId: 327764642 Change-Id: Ia7d7fda3f6e8d8d9af6e091f92a94946af096a7e
Showing
想要评论请 注册 或 登录