未验证 提交 4537ba23 编写于 作者: W Weilong Wu 提交者: GitHub

[eager] use CPUAllocator directly (#47125)

* [eager] use CPUAllocator directly

* modify pstring sizeof 48 default

* rm CPU test for NaiveBestFitAllocator

* fix Mac ci compile errors

* use UNUSED to state unused_obj

* mv UNUSED statement to allocator_facade.cc

* fix roi_align

* fix yolov3 test case

* recover original code

* recover original code

* fix trt roi_align test
Co-authored-by: Njerrywgz <jerrywgz@126.com>
上级 502f5e88
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include "paddle/fluid/memory/allocation/stat_allocator.h" #include "paddle/fluid/memory/allocation/stat_allocator.h"
#include "paddle/fluid/platform/enforce.h" #include "paddle/fluid/platform/enforce.h"
#include "paddle/fluid/platform/place.h" #include "paddle/fluid/platform/place.h"
#include "paddle/phi/core/macros.h"
#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP) #if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP)
#include <shared_mutex> #include <shared_mutex>
...@@ -493,8 +494,8 @@ class AllocatorFacadePrivate { ...@@ -493,8 +494,8 @@ class AllocatorFacadePrivate {
const AllocatorMap& GetAllocatorMap() { return allocators_; } const AllocatorMap& GetAllocatorMap() { return allocators_; }
void InitNaiveBestFitCPUAllocator() { void InitNaiveBestFitCPUAllocator() {
allocators_[platform::CPUPlace()] = // It is more efficient to use CPUAllocator directly.
std::make_shared<NaiveBestFitAllocator>(platform::CPUPlace()); allocators_[platform::CPUPlace()] = std::make_shared<CPUAllocator>();
} }
#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP) #if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP)
...@@ -1197,6 +1198,10 @@ void AllocatorFacade::RemoveMemoryPoolOfCUDAGraph(int64_t id) { ...@@ -1197,6 +1198,10 @@ void AllocatorFacade::RemoveMemoryPoolOfCUDAGraph(int64_t id) {
} }
#endif #endif
#endif #endif
UNUSED static std::shared_ptr<NaiveBestFitAllocator> unused_obj =
std::make_shared<NaiveBestFitAllocator>(platform::CPUPlace());
} // namespace allocation } // namespace allocation
} // namespace memory } // namespace memory
} // namespace paddle } // namespace paddle
...@@ -98,7 +98,7 @@ inline size_t SizeOf(DataType data_type) { ...@@ -98,7 +98,7 @@ inline size_t SizeOf(DataType data_type) {
case DataType::COMPLEX128: case DataType::COMPLEX128:
return 16; return 16;
case DataType::PSTRING: case DataType::PSTRING:
return 24; return 48;
case DataType::UNDEFINED: case DataType::UNDEFINED:
return 0; return 0;
case DataType::NUM_DATA_TYPES: case DataType::NUM_DATA_TYPES:
......
...@@ -56,8 +56,8 @@ class FakeDataReader: ...@@ -56,8 +56,8 @@ class FakeDataReader:
img = np.random.normal( img = np.random.normal(
0.485, 0.229, [3, cfg.input_size, cfg.input_size] 0.485, 0.229, [3, cfg.input_size, cfg.input_size]
) )
point1 = cfg.input_size / 4 point1 = 1 / 4
point2 = cfg.input_size / 2 point2 = 1 / 2
gt_boxes = np.array([[point1, point1, point2, point2]]) gt_boxes = np.array([[point1, point1, point2, point2]])
gt_labels = np.random.randint( gt_labels = np.random.randint(
low=0, high=cfg.class_num, size=[1] low=0, high=cfg.class_num, size=[1]
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册