Skip to content
Open
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
5 changes: 5 additions & 0 deletions paddle/phi/common/place.cc
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,11 @@ TEST_API bool is_cpu_place(const Place &p) {
return p.GetType() == phi::AllocationType::CPU;
}

PADDLE_API bool is_pinned_place(const Place &p) {
return p.GetType() == phi::AllocationType::GPUPINNED ||
p.GetType() == phi::AllocationType::XPUPINNED;
}

bool is_cuda_pinned_place(const Place &p) {
return p.GetType() == phi::AllocationType::GPUPINNED;
}
Expand Down
1 change: 1 addition & 0 deletions paddle/phi/common/place.h
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ PADDLE_API bool is_gpu_place(const Place&);
PADDLE_API bool is_xpu_place(const Place&);
PADDLE_API bool is_ipu_place(const Place&);
PADDLE_API bool is_cpu_place(const Place&);
PADDLE_API bool is_pinned_place(const Place&);
PADDLE_API bool is_cuda_pinned_place(const Place&);
PADDLE_API bool is_xpu_pinned_place(const Place&);
PADDLE_API bool is_custom_place(const Place& p);
Expand Down
4 changes: 2 additions & 2 deletions paddle/phi/core/memory/allocation/stat_allocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class StatAllocator : public Allocator {
protected:
void FreeImpl(phi::Allocation* allocation) override {
if (phi::is_cpu_place(allocation->place()) ||
phi::is_cuda_pinned_place(allocation->place())) {
phi::is_pinned_place(allocation->place())) {
HOST_MEMORY_STAT_UPDATE(
Allocated, allocation->place().GetDeviceId(), -allocation->size());
} else {
Expand All @@ -51,7 +51,7 @@ class StatAllocator : public Allocator {
underlying_allocator_->Allocate(size);

const phi::Place& place = allocation->place();
if (phi::is_cpu_place(place) || phi::is_cuda_pinned_place(place)) {
if (phi::is_cpu_place(place) || phi::is_pinned_place(place)) {
HOST_MEMORY_STAT_UPDATE(
Allocated, place.GetDeviceId(), allocation->size());
} else {
Expand Down
Loading