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] decouple dependency to device_context in phi (Part 1) #50865

Merged
merged 61 commits into from
Mar 6, 2023

Conversation

huangjiyi
Copy link
Member

@huangjiyi huangjiyi commented Feb 24, 2023

PR types

Others

PR changes

Others

Describe

Pcard-66980

image-20230228140125519

上图为解耦前 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 的函数拆分成两个函数:

  • EmplaceNativeContext:在 phi 下定义,实现向 DeviceContextPool 中插入 phi 下定义的 DeviceContext
  • EmplaceExternalContext:在 fluid 下定义,实现向 DeviceContextPool 中插入 fluid 下定义的 DeviceContext

解耦后的调用关系如下图所示:

image

在 fluid 下定义的 EmplaceExternalContext 则通过函数指针传递给 EmplaceDeviceContexts,从而不影响 DeviceContextPool 在 fluid 下的使用(因为 EmplaceDeviceContexts 只在进行 DeviceContextPool::Init() 时调用,如果在 fluid 下调用需传递 EmplaceExternalContext 函数指针,而在 phi 下调用则传递一个空指针即可)

@huangjiyi huangjiyi changed the title [phi decoupling] move DeviceContextPool from fluid to phi [phi decoupling] decouple dependency to device_context in phi Feb 24, 2023
@PaddlePaddle PaddlePaddle locked and limited conversation to collaborators Feb 27, 2023
@PaddlePaddle PaddlePaddle unlocked this conversation Feb 27, 2023
@huangjiyi huangjiyi marked this pull request as draft February 27, 2023 06:24
@huangjiyi huangjiyi marked this pull request as ready for review February 27, 2023 06:25
paddle/phi/kernels/gpu/affine_grid_grad_kernel.cu Outdated Show resolved Hide resolved
paddle/phi/kernels/gpu/depthwise_conv.h Outdated Show resolved Hide resolved
paddle/phi/kernels/gpudnn/affine_grid_kernel.cu Outdated Show resolved Hide resolved
YuanRisheng
YuanRisheng previously approved these changes Mar 3, 2023
jiahy0825
jiahy0825 previously approved these changes Mar 3, 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

@huangjiyi huangjiyi dismissed stale reviews from jiahy0825 and YuanRisheng via 7aa2630 March 3, 2023 05:11
Copy link
Contributor

@ZzSean ZzSean left a 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

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

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.

8 participants