File tree Expand file tree Collapse file tree 3 files changed +8
-2
lines changed
Expand file tree Collapse file tree 3 files changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -191,6 +191,11 @@ TEST_API bool is_cpu_place(const Place &p) {
191191 return p.GetType () == phi::AllocationType::CPU;
192192}
193193
194+ bool is_pinned_place (const Place &p) {
195+ return p.GetType () == phi::AllocationType::GPUPINNED ||
196+ p.GetType () == phi::AllocationType::XPUPINNED;
197+ }
198+
194199bool is_cuda_pinned_place (const Place &p) {
195200 return p.GetType () == phi::AllocationType::GPUPINNED;
196201}
Original file line number Diff line number Diff line change @@ -225,6 +225,7 @@ PADDLE_API bool is_gpu_place(const Place&);
225225PADDLE_API bool is_xpu_place (const Place&);
226226PADDLE_API bool is_ipu_place (const Place&);
227227PADDLE_API bool is_cpu_place (const Place&);
228+ PADDLE_API bool is_pinned_place (const Place&);
228229PADDLE_API bool is_cuda_pinned_place (const Place&);
229230PADDLE_API bool is_xpu_pinned_place (const Place&);
230231PADDLE_API bool is_custom_place (const Place& p);
Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ class StatAllocator : public Allocator {
3232 protected:
3333 void FreeImpl (phi::Allocation* allocation) override {
3434 if (phi::is_cpu_place (allocation->place ()) ||
35- phi::is_cuda_pinned_place (allocation->place ())) {
35+ phi::is_pinned_place (allocation->place ())) {
3636 HOST_MEMORY_STAT_UPDATE (
3737 Allocated, allocation->place ().GetDeviceId (), -allocation->size ());
3838 } else {
@@ -51,7 +51,7 @@ class StatAllocator : public Allocator {
5151 underlying_allocator_->Allocate (size);
5252
5353 const phi::Place& place = allocation->place ();
54- if (phi::is_cpu_place (place) || phi::is_cuda_pinned_place (place)) {
54+ if (phi::is_cpu_place (place) || phi::is_pinned_place (place)) {
5555 HOST_MEMORY_STAT_UPDATE (
5656 Allocated, place.GetDeviceId (), allocation->size ());
5757 } else {
You can’t perform that action at this time.
0 commit comments