Skip to content

Commit

Permalink
Support torch convert_to_numpy for all devices (keras-team#20042)
Browse files Browse the repository at this point in the history
* Support torch convert_to_numpy for all devices

* reformat
  • Loading branch information
aboubezari committed Jul 25, 2024
1 parent c9bd4a8 commit 08e7394
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion keras/src/backend/torch/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ def transform(x):
if x.requires_grad:
x = x.detach()
# Tensor has to be moved to CPU before converting to numpy.
if x.is_cuda or x.is_mps:
if x.device != torch.device("cpu"):
x = x.cpu()
if x.dtype == torch.bfloat16:
# Attempting to call .numpy() on a bfloat16 torch tensor leads
Expand Down

0 comments on commit 08e7394

Please sign in to comment.