[ONNX] Modifications in remove inplace ops passes to better handle binary inplace ops (#51318) (#51572)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/51572
Modifications in remove_inplace_ops_for_onnx pass and remove_inplace_ops pass to better handle binary inplace ops
* Handles special case of binary inplace ops, where the first input node has a lower type precedence than the second input node.
* When the inplace node is converted to a regular op, this information is lost and the resulting type is based on type precedence, just like regular ops. To avoid this loss of information, we add a cast node before the input node with the higher data type precedence, so that both the input types are the same.
Test Plan: Imported from OSS
Reviewed By: pbelevich
Differential Revision: D26203117
Pulled By: SplitInfinity
fbshipit-source-id: f018b503701b9067dba053c2764c3b92ef1abc38