From 2e2ba681304cb8588115953ac88a8213e9ad18bd Mon Sep 17 00:00:00 2001 From: Matteo Visconti di Oleggio Castello Date: Wed, 15 Feb 2023 19:14:44 -0800 Subject: [PATCH] FIX asarray --- himalaya/backend/torch.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/himalaya/backend/torch.py b/himalaya/backend/torch.py index d49b276..d2a3b55 100644 --- a/himalaya/backend/torch.py +++ b/himalaya/backend/torch.py @@ -176,7 +176,7 @@ def asarray(x, dtype=None, device="cpu"): tensor = torch.as_tensor(x, dtype=dtype, device=device) except Exception: import numpy as np - if x.device != "cpu": + if torch.is_tensor(x) and x.device != "cpu": x = x.cpu() array = np.asarray(x, dtype=_dtype_to_str(dtype)) tensor = torch.as_tensor(array, dtype=dtype, device=device)