Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
3a49ebe0
Unverified
Commit
3a49ebe0
authored
Jun 24, 2024
by
amyeroberts
Committed by
GitHub
Jun 24, 2024
Browse files
Fix is_torch_xpu_available for torch < 2.3 (#31573)
parent
2fc9d8e9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
2 deletions
+5
-2
src/transformers/utils/import_utils.py
src/transformers/utils/import_utils.py
+5
-2
No files found.
src/transformers/utils/import_utils.py
View file @
3a49ebe0
...
@@ -754,10 +754,13 @@ def is_torch_xpu_available(check_device=False):
...
@@ -754,10 +754,13 @@ def is_torch_xpu_available(check_device=False):
if
not
is_torch_available
():
if
not
is_torch_available
():
return
False
return
False
import
torch
torch_version
=
version
.
parse
(
_torch_version
)
if
is_ipex_available
():
if
is_ipex_available
():
import
intel_extension_for_pytorch
# noqa: F401
import
intel_extension_for_pytorch
# noqa: F401
elif
torch_version
.
major
<
2
or
(
torch_version
.
major
==
2
and
torch_version
.
minor
<
4
):
return
False
import
torch
if
check_device
:
if
check_device
:
try
:
try
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment