Compares the current PyTorch version to a given reference with an operation. Args: operation (`str`): A string representation of an operator, such as `">"` or `"<="` version (`str`): A string version of PyTorch
(operation: str, version: str)
| 688 | |
| 689 | # This function was copied from: https://github.com/huggingface/accelerate/blob/874c4967d94badd24f893064cc3bef45f57cadf7/src/accelerate/utils/versions.py#L338 |
| 690 | def is_torch_version(operation: str, version: str): |
| 691 | """ |
| 692 | Compares the current PyTorch version to a given reference with an operation. |
| 693 | |
| 694 | Args: |
| 695 | operation (`str`): |
| 696 | A string representation of an operator, such as `">"` or `"<="` |
| 697 | version (`str`): |
| 698 | A string version of PyTorch |
| 699 | """ |
| 700 | return compare_versions(parse(_torch_version), operation, version) |
| 701 | |
| 702 | |
| 703 | def is_transformers_version(operation: str, version: str): |