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

[Custom Device]如何使用融合算子conv_fusion_op #60476

Closed
engineer1109 opened this issue Dec 29, 2023 · 5 comments
Closed

[Custom Device]如何使用融合算子conv_fusion_op #60476

engineer1109 opened this issue Dec 29, 2023 · 5 comments
Assignees
Labels
PFCC Paddle Framework Contributor Club,https://github.com/PaddlePaddle/community/tree/master/pfcc status/close 已关闭 type/question 用户提问

Comments

@engineer1109
Copy link
Contributor

请提出你的问题 Please ask your question

我在CUDA和Custom Device都同时启用的时候,可以使用OP conv_fusion_op 以及自定义kernel conv2d_fusion(OpenCL)
在Paddle Inference添加Pass的时候 conv_elementwise_add_act_fuse_pass 也是有效的。

但是如果把编译CUDA关闭了,只开启Custom Device。就会出现OP找不到的问题。

terminate called after throwing an instance of 'phi::enforce::EnforceNotMet'
  what():  (NotFound) Operator (conv2d_fusion) is not registered.
  [Hint: op_info_ptr should not be null.] (at /media/wjl/D2/github/fork/10/Paddle/paddle/fluid/framework/op_info.h:149)

那么我该如何让Custom Device找到OP conv_fusion_op?

@engineer1109
Copy link
Contributor Author

目前想到一个修改源码的方法:
paddle/fluid/operators/fused/CMakeLists.txt
修改如下:

op_library(conv_fusion_op)
if(WITH_GPU OR WITH_ROCM)
  # fused_bn_activation_op needs cudnn 7.4.1 above
  # HIP not support bn act fuse in MIOPEN
  if((NOT WITH_ROCM) AND (NOT ${CUDNN_VERSION} VERSION_LESS 7401))
    op_library(fused_bn_activation_op)
  endif()
  # conv_fusion_op needs cudnn 7 above
  if(NOT ${CUDNN_VERSION} VERSION_LESS 7100)
    #op_library(conv_fusion_op)
  endif()

把原本只有CUDA能用的conv_fusion_op 放到公共可用的位置
就可以给Custom Device使用了。

@engineer1109
Copy link
Contributor Author

好像近期OP 代码又大改了,得要年后再试了

@paddle-bot paddle-bot bot added the PFCC Paddle Framework Contributor Club,https://github.com/PaddlePaddle/community/tree/master/pfcc label Dec 29, 2023
@yuanlehome
Copy link
Contributor

好像近期OP 代码又大改了,得要年后再试了

是的,前段时间对conv2d_fusion op做了如下改动:

  1. 迁移到phi中,统一使用yaml自动生成op定义,所以op定义不论在什么后端都会有定义;
  2. conv2d_fusion op更名为fused_conv2d_add_act;
    可以使用最新版paddle再试一下还有没有issue所提问题~

@yuanlehome yuanlehome self-assigned this Jan 2, 2024
@engineer1109
Copy link
Contributor Author

新的融合算子名称更改为fused_conv2d_add_act
已经不再是CUDA专属,可以被CUSTOM_DEVICE使用。

@engineer1109
Copy link
Contributor Author

@yuanlehome 还有一个古老问题 #60541 的修复

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PFCC Paddle Framework Contributor Club,https://github.com/PaddlePaddle/community/tree/master/pfcc status/close 已关闭 type/question 用户提问
Projects
None yet
Development

No branches or pull requests

2 participants