Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions python/paddle/base/dygraph/math_op_patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ def _new_full_(
dtype: DTypeLike | None = None,
device: PlaceLike | None = None,
requires_grad: bool = False,
pin_memory: bool = False,
) -> Tensor:
if dtype is None:
dtype = var.dtype
Expand All @@ -308,6 +309,7 @@ def _new_full_(
dtype=dtype,
device=device,
requires_grad=requires_grad,
pin_memory=pin_memory,
)

def _new_empty_(
Expand Down Expand Up @@ -339,6 +341,7 @@ def _new_ones_(
dtype: DTypeLike | None = None,
device: PlaceLike | None = None,
requires_grad: bool = False,
pin_memory: bool = False,
) -> Tensor:
if dtype is None:
dtype = var.dtype
Expand All @@ -351,6 +354,7 @@ def _new_ones_(
dtype,
device=device,
requires_grad=requires_grad,
pin_memory=pin_memory,
)

def _new_zeros_(
Expand All @@ -360,6 +364,7 @@ def _new_zeros_(
dtype: DTypeLike | None = None,
device: PlaceLike | None = None,
requires_grad: bool = False,
pin_memory: bool = False,
) -> Tensor:
if dtype is None:
dtype = var.dtype
Expand All @@ -372,6 +377,7 @@ def _new_zeros_(
dtype,
device=device,
requires_grad=requires_grad,
pin_memory=pin_memory,
)

@property
Expand Down
4 changes: 3 additions & 1 deletion python/paddle/base/framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -8280,10 +8280,12 @@ def _get_paddle_place(place):

if not isinstance(place, str):
raise ValueError(
"place only support string which is 'Place' and so on."
f"place only support string which is 'Place' and so on, but got {place}"
)

place = place.lower()
if place.startswith("cuda"):
place = place.replace("cuda", "gpu")
if place == "cpu":
return core.CPUPlace()

Expand Down
2 changes: 2 additions & 0 deletions python/paddle/device/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,8 @@ def _convert_to_place(device: PlaceLike) -> PlaceLike:
return device # return directly if not a string

lower_device = device.lower()
if lower_device.startswith("cuda"):
lower_device = lower_device.replace("cuda", "gpu")
if device in core.get_all_custom_device_type():
selected_devices = os.getenv(f"FLAGS_selected_{device}s", "0").split(
","
Expand Down
6 changes: 6 additions & 0 deletions python/paddle/pir/math_op_patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,7 @@ def _new_full_(
dtype: DTypeLike | None = None,
device: PlaceLike | None = None,
requires_grad: bool = False,
pin_memory: bool = False,
):
"""

Expand Down Expand Up @@ -682,6 +683,7 @@ def _new_full_(
dtype=dtype,
device=device,
requires_grad=requires_grad,
pin_memory=pin_memory,
)

def _new_empty_(
Expand Down Expand Up @@ -736,6 +738,7 @@ def _new_ones_(
dtype: DTypeLike | None = None,
device: PlaceLike | None = None,
requires_grad: bool = False,
pin_memory: bool = False,
):
"""

Expand Down Expand Up @@ -771,6 +774,7 @@ def _new_ones_(
dtype=dtype,
device=device,
requires_grad=requires_grad,
pin_memory=pin_memory,
)

def _new_zeros_(
Expand All @@ -780,6 +784,7 @@ def _new_zeros_(
dtype: DTypeLike | None = None,
device: PlaceLike | None = None,
requires_grad: bool = False,
pin_memory: bool = False,
):
"""

Expand Down Expand Up @@ -815,6 +820,7 @@ def _new_zeros_(
dtype=dtype,
device=device,
requires_grad=requires_grad,
pin_memory=pin_memory,
)

def _int_(self):
Expand Down
Loading