Skip to content

Commit

Permalink
#0: correct fallback to not throw when tensor is not on device
Browse files Browse the repository at this point in the history
  • Loading branch information
ayerofieiev-tt committed May 17, 2024
1 parent 9831fa9 commit c1afeeb
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion ttnn/ttnn/operations/fallback.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
import sys
import ttnn
import torch
import tt_lib

THIS_MODULE = sys.modules[__name__]


def reshape(tensor: ttnn.Tensor, shape) -> ttnn.Tensor:
device = tensor.device() if tensor.storage_type() == tt_lib.tensor.StorageType.DEVICE else None
torch_tensor = ttnn.to_torch(tensor)
torch_tensor = torch.reshape(torch_tensor, tuple(shape))
tensor = ttnn.from_torch(torch_tensor, layout=tensor.layout, dtype=tensor.dtype, device=tensor.device())
tensor = ttnn.from_torch(torch_tensor, layout=tensor.layout, dtype=tensor.dtype, device=device)
return tensor

0 comments on commit c1afeeb

Please sign in to comment.