-
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] decouple dependency to device_context in phi (Part 1) #50865
[phi decoupling] decouple dependency to device_context in phi (Part 1) #50865
Conversation
… move_device_context
… move_device_context
… move_device_context
… move_device_context
… move_device_context
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
… move_device_context
…ddle into move_device_context
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 for CI-OP-Benchmark
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-66980
背景:飞桨算子体系重构 - PHI算子库独立编译
本 PR 解耦大部分 phi 算子库对
paddle/fluid/platform/device_context.h
头文件的依赖上图为解耦前 phi 对 fluid device_context 的依赖关系示意图,fluid 下的 device_context 定义了关于不同设备的 DeviceContext 以及实现根据 place 获取 DeviceContext 功能的 DeviceContextPool,其中 IPU、MLU、NPU 没有在 phi 下被用到,同时依赖较多,因此不迁移至 phi 下,而其余 DeviceContext 在 phi 下已有实现。
而 DeviceContextPool 在 phi 下的用法较多,且没有替代方案,因此需要迁移至 phi 下,但是 DeviceContextPool 的实现需要用到所有的 DeviceContext,所以问题在于如何在不迁移所有 DeviceContext 的情况下将 DeviceContextPool 迁移至 phi 下,经讨论,决定将实现向 DeviceContextPool 中插入 EmplaceDeviceContexts 的函数拆分成两个函数:
解耦后的调用关系如下图所示:
在 fluid 下定义的 EmplaceExternalContext 则通过函数指针传递给 EmplaceDeviceContexts,从而不影响 DeviceContextPool 在 fluid 下的使用(因为 EmplaceDeviceContexts 只在进行 DeviceContextPool::Init() 时调用,如果在 fluid 下调用需传递 EmplaceExternalContext 函数指针,而在 phi 下调用则传递一个空指针即可)