Added more version comparison operations (#63848)
authorNived P A <62166124+nivedwho@users.noreply.github.com>
Thu, 9 Sep 2021 17:29:10 +0000 (10:29 -0700)
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
Thu, 9 Sep 2021 17:30:20 +0000 (10:30 -0700)
commit8deaa476ac33daea6af4cf079eb13757ca86c2ad
tree348bfee9577bdd967ae2fbac3037c623815bf7b6
parentcfa6162e5e5bafcb1e89bd14b64ae336f57fcdbe
Added more version comparison operations (#63848)

Summary:
Currently the [TorchVersion](https://github.com/pytorch/pytorch/blob/1022443168b5fad55bbd03d087abf574c9d2e9df/torch/torch_version.py#L13) only only supports 'greater than', and 'equal to' operations for comparing torch versions and something like `TorchVersion('1.5.0') < (1,5,1)` or `TorchVersion('1.5.0') >= (1,5)` will throw an error.

I have added 'less than' (`__lt__()`), 'greater than or equal to' (`__ge__()`) and 'less than or equal to' (`__le__()`) operations, so that the TorchVersion object can be useful for wider range of version comparisons.

cc seemethere zsol

Pull Request resolved: https://github.com/pytorch/pytorch/pull/63848

Reviewed By: fmassa, heitorschueroff

Differential Revision: D30526996

Pulled By: seemethere

fbshipit-source-id: 1db6bee555043e0719fd541cec27810852590940
torch/torch_version.py