We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent d3b01da commit 3452a2aCopy full SHA for 3452a2a
1 file changed
deepmd/dpmodel/common.py
@@ -121,10 +121,11 @@ def to_numpy_array(x: Optional["Array"]) -> np.ndarray | None:
121
try:
122
# asarray is not within Array API standard, so may fail
123
return np.asarray(x)
124
- except (ValueError, AttributeError):
+ except (ValueError, AttributeError, TypeError):
125
xp = array_api_compat.array_namespace(x)
126
# to fix BufferError: Cannot export readonly array since signalling readonly is unsupported by DLPack.
127
- x = xp.asarray(x, copy=True)
+ # Move to CPU device to ensure numpy compatibility
128
+ x = xp.asarray(x, device="cpu", copy=True)
129
return np.from_dlpack(x)
130
131
0 commit comments