@@ -63,9 +63,6 @@ void Free(const Place &place, void *p, size_t size);
6363template <typename Place>
6464uint64_t Release (const Place &place);
6565
66- template <typename Place>
67- void *BasePtr (const Place &place, void *p);
68-
6966template <typename Place>
7067size_t Used (const Place &place);
7168
@@ -117,11 +114,6 @@ uint64_t Release<platform::CPUPlace>(const platform::CPUPlace &place) {
117114 return GetCPUBuddyAllocator ()->Release ();
118115}
119116
120- template <>
121- void *BasePtr<platform::CPUPlace>(const platform::CPUPlace &place, void *p) {
122- return GetCPUBuddyAllocator ()->BasePtr (p);
123- }
124-
125117template <>
126118size_t Used<platform::CPUPlace>(const platform::CPUPlace &place) {
127119 return GetCPUBuddyAllocator ()->Used ();
@@ -140,24 +132,16 @@ void *Alloc<platform::IPUPlace>(const platform::IPUPlace &place, size_t size) {
140132 VLOG (10 ) << " pointer=" << p;
141133 return p;
142134}
143-
144135template <>
145136void Free<platform::IPUPlace>(const platform::IPUPlace &place, void *p,
146137 size_t size) {
147138 VLOG (10 ) << " Free pointer=" << p << " on " << platform::Place (place);
148139 GetCPUBuddyAllocator ()->Free (p);
149140}
150-
151141template <>
152142uint64_t Release<platform::IPUPlace>(const platform::IPUPlace &place) {
153143 return GetCPUBuddyAllocator ()->Release ();
154144}
155-
156- template <>
157- void *BasePtr<platform::IPUPlace>(const platform::IPUPlace &place, void *p) {
158- return GetCPUBuddyAllocator ()->BasePtr (p);
159- }
160-
161145template <>
162146size_t Used<platform::IPUPlace>(const platform::IPUPlace &place) {
163147 return GetCPUBuddyAllocator ()->Used ();
@@ -262,11 +246,6 @@ uint64_t Release<platform::XPUPlace>(const platform::XPUPlace &place) {
262246 return -1 ;
263247}
264248
265- template <>
266- void *BasePtr<platform::XPUPlace>(const platform::XPUPlace &place, void *p) {
267- return p;
268- }
269-
270249template <>
271250size_t Used<platform::XPUPlace>(const platform::XPUPlace &place) {
272251#ifdef PADDLE_WITH_XPU
@@ -423,16 +402,6 @@ uint64_t Release<platform::NPUPlace>(const platform::NPUPlace &place) {
423402#endif
424403}
425404
426- template <>
427- void *BasePtr<platform::NPUPlace>(const platform::NPUPlace &place, void *p) {
428- #ifdef PADDLE_WITH_ASCEND_CL
429- return GetNPUBuddyAllocator (place.device )->BasePtr (p);
430- #else
431- PADDLE_THROW (platform::errors::PermissionDenied (
432- " 'NPUPlace' is not supported in CPU only device." ));
433- #endif
434- }
435-
436405template <>
437406size_t Used<platform::NPUPinnedPlace>(const platform::NPUPinnedPlace &place) {
438407#ifdef PADDLE_WITH_ASCEND_CL
@@ -485,17 +454,6 @@ uint64_t Release<platform::NPUPinnedPlace>(
485454#endif
486455}
487456
488- template <>
489- void *BasePtr<platform::NPUPinnedPlace>(const platform::NPUPinnedPlace &place,
490- void *p) {
491- #ifdef PADDLE_WITH_ASCEND_CL
492- return GetNPUPinnedBuddyAllocator ()->BasePtr (p);
493- #else
494- PADDLE_THROW (platform::errors::PermissionDenied (
495- " 'NPUPPinnedPlace' is not supported in CPU only device." ));
496- #endif
497- }
498-
499457// For CUDA
500458#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP)
501459class GPUBuddyAllocatorList {
@@ -627,16 +585,6 @@ uint64_t Release<platform::CUDAPlace>(const platform::CUDAPlace &place) {
627585#endif
628586}
629587
630- template <>
631- void *BasePtr<platform::CUDAPlace>(const platform::CUDAPlace &place, void *p) {
632- #if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP)
633- return GetGPUBuddyAllocator (place.device )->BasePtr (p);
634- #else
635- PADDLE_THROW (platform::errors::PermissionDenied (
636- " 'CUDAPlace' is not supported in CPU only device." ));
637- #endif
638- }
639-
640588#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP)
641589BuddyAllocator *GetCUDAPinnedBuddyAllocator () {
642590 static std::once_flag init_flag;
@@ -867,18 +815,6 @@ struct ReleaseVisitor : public boost::static_visitor<uint64_t> {
867815 }
868816};
869817
870- struct BasePtrVisitor : public boost ::static_visitor<void *> {
871- inline explicit BasePtrVisitor (void *ptr) : ptr_(ptr) {}
872-
873- template <typename Place>
874- inline void *operator ()(const Place &place) const {
875- return BasePtr<Place>(place, ptr_);
876- }
877-
878- private:
879- void *ptr_;
880- };
881-
882818size_t Usage::operator ()(const platform::CPUPlace &cpu) const {
883819 return Used (cpu);
884820}
@@ -906,8 +842,7 @@ namespace allocation {
906842
907843Allocation *NaiveBestFitAllocator::AllocateImpl (size_t size) {
908844 void *ptr = boost::apply_visitor (legacy::AllocVisitor (size), place_);
909- void *base_ptr = boost::apply_visitor (legacy::BasePtrVisitor (ptr), place_);
910- auto *tmp_alloc = new Allocation (ptr, base_ptr, size, place_);
845+ auto *tmp_alloc = new Allocation (ptr, size, place_);
911846 platform::MemEvenRecorder::Instance ().PushMemRecord (
912847 static_cast <void *>(tmp_alloc), place_, size);
913848 return tmp_alloc;
0 commit comments