-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[PHI Decoupling]Remove memory header (Part3) #51288
[PHI Decoupling]Remove memory header (Part3) #51288
Conversation
你的PR提交成功,感谢你对开源项目的贡献! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM except for one small problem.
@@ -51,7 +51,7 @@ inline std::unique_ptr<DeviceContext> CreateDeviceContext( | |||
using PtrType = std::unique_ptr<DeviceContext>; | |||
|
|||
DevCtx* dev_ctx = ConstructDevCtx<DevCtx>(p, stream_priority); | |||
|
|||
auto& instance = *(MemoryUtils::Instance().GetAllocatorFacade()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why move this line outside the macro #if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP)
? (see line 63)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
为了能复用instance这个变量
@@ -289,6 +307,44 @@ void Copy(const Place& dst_place, | |||
const void* src, | |||
size_t num); | |||
int64_t DeviceMemoryStatCurrentValue(const std::string& stat_type, int dev_id); | |||
|
|||
class Buffer { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Buffer看上去用的地方不多,这是不是一个可以去掉的数据结构?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个数据结构确实能通过memory下的方法组合出来,不过我觉得buffer这个设计初衷应该是为了方便使用memory的方法,我倾向于保留该结构
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
void EmplaceDeviceContexts( | ||
std::map<Place, std::shared_future<std::unique_ptr<DeviceContext>>>* | ||
place_to_device_context, | ||
const std::vector<phi::Place>& places, | ||
bool disable_setting_default_stream_for_allocator, | ||
int stream_priority) { | ||
CheckMemoryMethod(); | ||
PADDLE_ENFORCE_NE( | ||
memory_method_->emplace_device_contexts, | ||
nullptr, | ||
phi::errors::Unavailable( | ||
"emplace_device_contexts method in memory_method_ is not " | ||
"initiazed yet. You need init it first.")); | ||
memory_method_->emplace_device_contexts( | ||
place_to_device_context, | ||
places, | ||
disable_setting_default_stream_for_allocator, | ||
stream_priority); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个函数功能与memory相关性已经不大了,后面看怎么调整下命名或者位置
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
好的
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
PR types
Others
PR changes
Others
Describe
Pcard-67890
memory头文件解耦第二个PR,移除:paddle/fluid/memory/allocation/allocator_facade.h 和 paddle/fluid/memory/buffer.h