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

[PIR] pir onednn support mul #61662

Merged
merged 12 commits into from
Feb 26, 2024

Conversation

wanghuancoder
Copy link
Contributor

@wanghuancoder wanghuancoder commented Feb 6, 2024

PR types

New features

PR changes

Others

Description

Pcard-67164

pir onednn 支持mul。PIR中还没有mul的yaml信息,新增yaml配置。
由于PIR非OneDNN的的mul,在op_translator中,翻译为matmul来实现。但经试验,OneDNN无法使用OneDNN的matmul替代mul。因此,修改op_translator,在OneDNN且use_mkldnn=True情况下,将Program的mul翻译为onednn_op.mul。
OneDNN matmul替代OneDNN mul的原因有:

  1. mul根据首个输入确定kernel dtype,mul存在mul(int8, float32)的使用场景。matmul无法适配。
  2. mul在OneDNN中额外需要scale_x、scale_y、scale_out、force_fp32_output参数,matmul无法支持。

过程中发现PIR机制错误获取fluid_op_name的bug,在本PR中修复。

Copy link

paddle-bot bot commented Feb 6, 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.

zhangbo9674
zhangbo9674 previously approved these changes Feb 23, 2024
Comment on lines 1457 to 1461
#ifdef PADDLE_WITH_DNNL
if (op_desc.GetAttrIfExists<bool>("use_mkldnn")) {
return OpTranscriber::LookUpOpInfo(ctx, op_desc);
}
#endif
Copy link
Contributor

Choose a reason for hiding this comment

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

推荐重载下 operator() 方法,像这样分发试试,不需要修改其他函数

pir::Operation* OpTranscriber::operator()(pir::IrContext* ctx,
                                          TranslationContext* param_map,
                                          const OpDesc& op_desc,
                                          pir::Block* block) {
  if (op_desc.GetAttrIfExists<bool>("use_mkldnn")) {
     return static_cast<OpTranscriber>(*this).operator()(ctx, param_map, op_desc, block);
  }
  return OpTranscriber::operator()(ctx, param_map, op_desc, block);
}

@phlrain phlrain self-requested a review February 26, 2024 05:15
@wanghuancoder wanghuancoder merged commit cc63252 into PaddlePaddle:develop Feb 26, 2024
30 checks passed
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.

4 participants