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

[CustomDevice] Support stride[Part 2] #62697

Merged
merged 7 commits into from
Mar 21, 2024

Conversation

Tongkaio
Copy link
Member

@Tongkaio Tongkaio commented Mar 13, 2024

PR types

Others

PR changes

Others

Description

#62532

  1. 给 CustomDevice支持剩余的 stride kernel;
  2. 添加单测 test_as_strided,test_index_select_strided,test_tensor_unfold;
  3. 算子注册名更正:index_select_grad_strided -> index_select_strided_grad;
  4. 反向代码中使用如下方式替换原有的 kernel 调用方式,即去除模板参数Context,通过输入tensor的 place().GetType() 判断后端类型来设置Context,cpu、gpu、xpu 仍然直接调用 kernel 函数,CustomDevice 则从 kernel factory 中查找算子并调用,来避免编译 Paddle 时出现 CustomContext 的 kernel 未定义的错误:
before after
StridedCopyKernel<T, Context> StridedTensorCopy<T>
FillKernel<T, Context> StridedTensorFill<T>
ContiguousKernel<T, Context> StridedTensorContiguous<T>
  1. 修改后,前向反向代码可直接使用 PD_REGISTER_KERNEL_FOR_ALL_BACKEND_DTYPE 给所有后端注册;

Copy link

paddle-bot bot commented Mar 13, 2024

你的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.

wanghuancoder
wanghuancoder previously approved these changes Mar 14, 2024
Copy link
Contributor

@wanghuancoder wanghuancoder left a comment

Choose a reason for hiding this comment

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

LGTM

wanghuancoder
wanghuancoder previously approved these changes Mar 20, 2024
Copy link
Contributor

@wanghuancoder wanghuancoder left a comment

Choose a reason for hiding this comment

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

LGTM

risemeup1
risemeup1 previously approved these changes Mar 20, 2024
Copy link
Contributor

@qili93 qili93 left a comment

Choose a reason for hiding this comment

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

需要有更好的抽象来解决这个算子对custom device的注册

@Tongkaio Tongkaio dismissed stale reviews from risemeup1 and wanghuancoder via c26d23b March 20, 2024 08:34
Copy link
Contributor

@qili93 qili93 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Collaborator

@raindrops2sea raindrops2sea left a comment

Choose a reason for hiding this comment

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

LGTM

@YanhuiDua YanhuiDua merged commit 316af17 into PaddlePaddle:develop Mar 21, 2024
29 of 30 checks passed
@Tongkaio Tongkaio deleted the custom_stride branch April 3, 2024 10:32
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.

7 participants