Skip to content

Commit 603c852

Browse files
use default_dtype only when dtype is None
1 parent 7b8555e commit 603c852

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Diff for: array_api_compat/paddle/_aliases.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1118,13 +1118,13 @@ def asarray(
11181118
)
11191119
elif copy is True:
11201120
obj = np.array(obj, copy=True)
1121-
if np.issubdtype(obj.dtype, np.floating):
1121+
if np.issubdtype(obj.dtype, np.floating) and dtype is None:
11221122
obj = obj.astype(paddle.get_default_dtype())
11231123
return paddle.to_tensor(obj, dtype=dtype, place=device)
11241124
else:
11251125
if not paddle.is_tensor(obj) or (dtype is not None and obj.dtype != dtype):
11261126
obj = np.array(obj, copy=False)
1127-
if np.issubdtype(obj.dtype, np.floating):
1127+
if np.issubdtype(obj.dtype, np.floating) and dtype is None:
11281128
obj = obj.astype(paddle.get_default_dtype())
11291129
if dtype != paddle.bool and dtype != "bool":
11301130
obj = paddle.from_dlpack(obj.__dlpack__(), **kwargs).to(dtype)

0 commit comments

Comments
 (0)