Do not use negative values in GCD computation. (#49379)
Summary:
GCD should always return positive integers. When negative values are used, we hit a corner case that results in an infinite recursion during simplification.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/49379
Reviewed By: ezyang
Differential Revision: D25597115
Pulled By: navahgar
fbshipit-source-id: b0e8ac07ee50a5eb775c032628d4840df7424927