Skip to content

Commit

Permalink
fix: fix for __array__ removal from array-api-strict
Browse files Browse the repository at this point in the history
  • Loading branch information
njzjz committed Nov 7, 2024
1 parent 3236db5 commit cde3039
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions deepmd/dpmodel/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ def to_numpy_array(x: Any) -> Optional[np.ndarray]:
"""
if x is None:
return None
if x.device == "cpu":
# dlpack needs the device to be the same
return np.from_dlpack(x)
# asarray is not within Array API standard, so may fail
return np.asarray(x)


Expand Down

0 comments on commit cde3039

Please sign in to comment.