Skip to content

Commit

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

Co-authored-by: unit_test <[email protected]>
  • Loading branch information
statelesshz and unit_test authored Feb 7, 2024
1 parent 308d2b9 commit 5f96855
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 5f96855

Please sign in to comment.