Skip to content

Commit

Permalink
use default_dtype only when dtype is None
Browse files Browse the repository at this point in the history
  • Loading branch information
HydrogenSulfate committed Jan 9, 2025
1 parent 7b8555e commit 603c852
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions array_api_compat/paddle/_aliases.py
Original file line number Diff line number Diff line change
Expand Up @@ -1118,13 +1118,13 @@ def asarray(
)
elif copy is True:
obj = np.array(obj, copy=True)
if np.issubdtype(obj.dtype, np.floating):
if np.issubdtype(obj.dtype, np.floating) and dtype is None:
obj = obj.astype(paddle.get_default_dtype())
return paddle.to_tensor(obj, dtype=dtype, place=device)
else:
if not paddle.is_tensor(obj) or (dtype is not None and obj.dtype != dtype):
obj = np.array(obj, copy=False)
if np.issubdtype(obj.dtype, np.floating):
if np.issubdtype(obj.dtype, np.floating) and dtype is None:
obj = obj.astype(paddle.get_default_dtype())
if dtype != paddle.bool and dtype != "bool":
obj = paddle.from_dlpack(obj.__dlpack__(), **kwargs).to(dtype)
Expand Down

0 comments on commit 603c852

Please sign in to comment.