Skip to content
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

Merged
merged 28 commits into from
Mar 24, 2023

Conversation

YuanRisheng
Copy link
Contributor

@YuanRisheng YuanRisheng commented Mar 7, 2023

PR types

Others

PR changes

Others

Describe

Pcard-67890
memory头文件解耦第二个PR,移除:paddle/fluid/memory/allocation/allocator_facade.h 和 paddle/fluid/memory/buffer.h

@paddle-bot
Copy link

paddle-bot bot commented Mar 7, 2023

你的PR提交成功,感谢你对开源项目的贡献!
请关注后续CI自动化测试结果,详情请参考Paddle-CI手册
Your PR has been submitted. Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

jiahy0825
jiahy0825 previously approved these changes Mar 10, 2023
Copy link
Contributor

@jiahy0825 jiahy0825 left a 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());
Copy link
Contributor

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)

Copy link
Contributor Author

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 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Buffer看上去用的地方不多,这是不是一个可以去掉的数据结构?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个数据结构确实能通过memory下的方法组合出来,不过我觉得buffer这个设计初衷应该是为了方便使用memory的方法,我倾向于保留该结构

Copy link
Contributor

@jiahy0825 jiahy0825 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment on lines +296 to +315
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);
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个函数功能与memory相关性已经不大了,后面看怎么调整下命名或者位置

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

好的

Copy link
Contributor

@XiaoguangHu01 XiaoguangHu01 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@YuanRisheng YuanRisheng merged commit 3d78e75 into PaddlePaddle:develop Mar 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants