"examples/vscode:/vscode.git/clone" did not exist on "5089a2d412cf5b3bb0cd029ea3266511ba28b39d"
Unverified Commit 1c381f36 authored by Cody Yu's avatar Cody Yu Committed by GitHub
Browse files

Cache results of is_torch_tpu_available() (#18777)

* Cache results of is_torch_tpu_available()

* Update src/transformers/utils/import_utils.py

* Update src/transformers/utils/import_utils.py
parent 954e18ab
......@@ -21,7 +21,7 @@ import os
import sys
import warnings
from collections import OrderedDict
from functools import wraps
from functools import lru_cache, wraps
from itertools import chain
from types import ModuleType
from typing import Any
......@@ -414,6 +414,7 @@ def is_ftfy_available():
return _ftfy_available
@lru_cache()
def is_torch_tpu_available(check_device=True):
"Checks if `torch_xla` is installed and potentially if a TPU is in the environment"
if not _torch_available:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment