Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix for __array__ removal from array-api-strict #4325

Merged
merged 11 commits into from
Nov 9, 2024
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
Loading