Properly handle NaN in binary max and min (#32541)
Summary:
The output depends asymmetrically on whether the first or the second
argument is NaN. See https://github.com/pytorch/pytorch/issues/25016 for detail of the issue.
This is part of a continuing effort that was dropped in https://github.com/pytorch/pytorch/issues/30851
The failure in https://github.com/pytorch/pytorch/issues/27185 is resolved by explicitly casting a half type number to float when applying `isnan`.
Close https://github.com/pytorch/pytorch/issues/25016
Pull Request resolved: https://github.com/pytorch/pytorch/pull/32541
Differential Revision: D19644643
Pulled By: VitalyFedyunin
fbshipit-source-id: 8d49e6ed5a9996a817df7a9419dc5eee601430bc