Skip to content

Commit

Permalink
Add npu device for pipeline (huggingface#28885)
Browse files Browse the repository at this point in the history
add npu device for pipeline

Co-authored-by: unit_test <test@unit.com>
  • Loading branch information
2 people authored and jon-tow committed Feb 12, 2024
1 parent edfa7ae commit 9fab561
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/transformers/pipelines/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
is_tf_available,
is_torch_available,
is_torch_cuda_available,
is_torch_npu_available,
is_torch_xpu_available,
logging,
)
Expand Down Expand Up @@ -852,6 +853,8 @@ def __init__(
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:
Expand Down

0 comments on commit 9fab561

Please sign in to comment.