MCPcopy
hub / github.com/huggingface/transformers / is_torch_less_or_equal

Function is_torch_less_or_equal

src/transformers/utils/import_utils.py:182–194  ·  view source on GitHub ↗

Accepts a library version and returns True if the current version of the library is less than or equal to the given version. If `accept_dev` is True, it will also accept development versions (e.g. 2.7.0.dev20250320 matches 2.7.0).

(library_version: str, accept_dev: bool = False)

Source from the content-addressed store, hash-verified

180
181@lru_cache
182def is_torch_less_or_equal(library_version: str, accept_dev: bool = False) -> bool:
183 """
184 Accepts a library version and returns True if the current version of the library is less than or equal to the
185 given version. If `accept_dev` is True, it will also accept development versions (e.g. 2.7.0.dev20250320 matches
186 2.7.0).
187 """
188 if not is_torch_available():
189 return False
190
191 if accept_dev:
192 return version.parse(version.parse(get_torch_version()).base_version) <= version.parse(library_version)
193 else:
194 return version.parse(get_torch_version()) <= version.parse(library_version)
195
196
197@lru_cache

Callers 3

_can_use_grouped_mmFunction · 0.85
__init__Method · 0.85

Calls 3

is_torch_availableFunction · 0.85
get_torch_versionFunction · 0.85
parseMethod · 0.45

Tested by

no test coverage detected