Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
5f968557
Unverified
Commit
5f968557
authored
Feb 08, 2024
by
Huazhong Ji
Committed by
GitHub
Feb 07, 2024
Browse files
Add npu device for pipeline (#28885)
add npu device for pipeline Co-authored-by:
unit_test
<
test@unit.com
>
parent
308d2b90
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
0 deletions
+3
-0
src/transformers/pipelines/base.py
src/transformers/pipelines/base.py
+3
-0
No files found.
src/transformers/pipelines/base.py
View file @
5f968557
...
...
@@ -41,6 +41,7 @@ from ..utils import (
is_tf_available
,
is_torch_available
,
is_torch_cuda_available
,
is_torch_npu_available
,
is_torch_xpu_available
,
logging
,
)
...
...
@@ -852,6 +853,8 @@ class Pipeline(_ScikitCompat):
self
.
device
=
torch
.
device
(
"cpu"
)
elif
is_torch_cuda_available
():
self
.
device
=
torch
.
device
(
f
"cuda:
{
device
}
"
)
elif
is_torch_npu_available
():
self
.
device
=
torch
.
device
(
f
"npu:
{
device
}
"
)
elif
is_torch_xpu_available
(
check_device
=
True
):
self
.
device
=
torch
.
device
(
f
"xpu:
{
device
}
"
)
else
:
...
...
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