Skip to content

[CINN]support backend compiler to link multiple modules #65916

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

Merged
merged 2 commits into from
Jul 11, 2024

Conversation

Hongqing-work
Copy link
Contributor

PR Category

CINN

PR Types

New features

Description

Pcard-67164
This PR adds support for codegen of switch, which is the second step for lowering broadcast tree.
To learn more about the theoretical explanation of lowering broadcast tree in host wrapper function and the step-by-step arrangement for the Pull Request (PR), please refer to the draft PR65604 for details.

Copy link

paddle-bot bot commented Jul 10, 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.

Comment on lines +240 to +243
if (end) {
RegisterDeviceModuleSymbol();
engine_->AddSelfModule();
}
Copy link
Contributor

Choose a reason for hiding this comment

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

end是什么含义?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

这里沿袭了之前扩展x86时候的参数,语义是已经链接完所有的子Module,可以整合起来。
之后PR中会考虑商量修改一下这里的参数命名

@@ -106,7 +106,7 @@ class Compiler final {
void Build(const ir::Module& module,
const std::string& code = "",
const bool end = true);
void AppendCX86(const ir::Module& module);
void AppendCX86(const ir::Module& module, const bool end = true);
Copy link
Contributor

Choose a reason for hiding this comment

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

最好不要使用bool值做参数,语义太弱,扩展性太差。
我看这个函数也不大,直接写成两个函数多好啊。就算调用处的就代码已经拿bool值做参数了,也不是新代码继续这么做的理由

Comment on lines +308 to +314
auto PatternMatch =
adt::match{[&](common::UnknownArch) { CINN_NOT_IMPLEMENTED; },
[&](common::X86Arch) { return; },
[&](common::ARMArch) { return; },
[&](common::NVGPUArch) { RegisterCudaModuleSymbol(); },
[&](common::HygonDCUArchHIP) { CINN_NOT_IMPLEMENTED; }};
return std::visit(PatternMatch, target_.arch.variant());
Copy link
Contributor

Choose a reason for hiding this comment

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

改一下代码,让它好看点:

return target_.arch.Match(
                 [&](common::UnknownArch) { CINN_NOT_IMPLEMENTED; },
                 [&](common::X86Arch) { return; },
                 [&](common::ARMArch) { return; },
                 [&](common::NVGPUArch) { RegisterCudaModuleSymbol(); },
                 [&](common::HygonDCUArchHIP) { CINN_NOT_IMPLEMENTED; });

Copy link
Contributor Author

Choose a reason for hiding this comment

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

收到,将在下一个step的PR修改这里的写法

return std::visit(PatternMatch, target_.arch.variant());
[&](common::NVGPUArch) { CompileCudaModule(module, code); },
[&](common::HygonDCUArchHIP) { CompileHipModule(module, code); }};
std::visit(PatternMatch, target_.arch.variant());
Copy link
Contributor

Choose a reason for hiding this comment

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

顺手把这里的代码改成target_.arch.Match(...)的形式。

@Hongqing-work Hongqing-work merged commit ef162f5 into PaddlePaddle:develop Jul 11, 2024
30 of 32 checks passed
lixcli pushed a commit to lixcli/Paddle that referenced this pull request Jul 22, 2024
…#65916)

* [CINN]support backend compiler to link multiple modules

* change comment
@Hongqing-work Hongqing-work deleted the broadcast-tree-s2 branch September 5, 2024 08:25
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