CARVIEW |
Navigation Menu
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
[PIR] pir onednn support mixed instruction #60754
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 mixed instruction #60754
Conversation
你的PR提交成功,感谢你对开源项目的贡献! |
… pir_onednn_mixedinstr
… pir_onednn_mixedinstr
… pir_onednn_mixedinstr
@@ -833,6 +833,25 @@ bool AnalysisPredictor::PrepareExecutor() { | |||
gpu_pm.EnableIRPrinting(); | |||
} | |||
gpu_pm.Run(pir_program_.get()); | |||
} else { | |||
::pir::PassManager cpu_pm(::pir::IrContext::Instance(), 2); | |||
cpu_pm.AddPass(::pir::CreateReplaceFetchWithShadowOutputPass()); |
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.
这行重复了吧?可以删掉这个
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.
好的好的感谢!
@@ -15,19 +15,17 @@ | |||
extra_args : bool is_test=false | |||
data_format_tensors : x, out, mid_out, out_grad | |||
|
|||
- op : pad3d | |||
extra_args : |
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.
没有extra_args仍需要指定这个key吗?
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.
这个底层能力上是可以不指定的。但是我写这里的时候,想了一下,还是想放个空的。大多数op都有extra_args,写一个空的extra_args更能让看代码的人一眼就知道他的extra_args是空的。
test/ir/inference/auto_scan_test.py
Outdated
@@ -341,6 +341,118 @@ def inference_config_str(self, config) -> str: | |||
dic["use_gpu"] = enable_gpu | |||
return str(dic) | |||
|
|||
def pir_run_test_config( |
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.
给MkldnnAutoScanTest派生出PirMkldnnAutoScanTest是不是更好点?而不是给MkldnnAutoScanTest增加新成员函数。之后的单测可继承PirMkldnnAutoScanTest
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.
能复用的代码,还是建议抽出来尽量复用下,减少后期维护成本
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.
好的好的
#ifdef PADDLE_WITH_DNNL | ||
auto new_in_type = new_in.type(); | ||
if (new_in_type.isa<AllocatedDenseTensorType>()) { | ||
if (new_in_type.dyn_cast<AllocatedDenseTensorType>().data_layout() == | ||
phi::DataLayout::ONEDNN) { | ||
new_in = AddOneDNN2PaddleLayoutTransferOp( | ||
new_in, phi::DataLayout::ANY, block); | ||
} | ||
} | ||
#endif |
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.
这个不太合理吧,大家编译的时候带上WITH_MKLDNN,但是不跑mkldnn模式,这里会影响其他模式逻辑?
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.
看错了,有这个判断不会的if (new_in_type.dyn_cast().data_layout() == phi::DataLayout::ONEDNN)
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.
在不跑mkldnn模式的时候,new_in_type.dyn_cast().data_layout() == phi::DataLayout::ONEDNN 为 false。所以不会影响其它模式。但位置在当前pd_op_to_kernel_pass.cc的代码框架下,只能放在这里。
#ifdef PADDLE_WITH_DNNL | ||
for (auto& ins : vec_instruction_base_) { | ||
if (static_cast<OneDNNPhiKernelInstruction*>(ins.get()) != nullptr || | ||
static_cast<OneDNNLegacyKernelInstruction*>(ins.get()) != nullptr || |
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.
C++11 有 std::is_base_of<A, B>::Value
,另外只需要判断是否是OnDNN的基类是否就可以了?
… pir_onednn_mixedinstr
PR types
New features
PR changes
Others
Description
Pcard-67164
PIR适配OneDNN 支持OneDNNMixedPhiKernelInstruction,并支持pad3d。
此外还做了如下处理: