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

[CINN Zero-Dim] CINN supports 0D-Tensor with trick temporarily #53382

Merged
merged 2 commits into from
Apr 27, 2023

Conversation

jiahy0825
Copy link
Contributor

@jiahy0825 jiahy0825 commented Apr 26, 2023

PR types

New features

PR changes

Others

Description

Pcard-66989

Paddle 0D-Tensor 机制需要合入 2.5 分支,目前该机制依赖于 CINN 提供 0D-Tensor 支持。由于开发时间较紧张,本 PR 提供了一种低成本快速适配 CINN 0D-Tensor 的机制,在 build_cinn_pass 前新增 cinn_zero_tensor_trick_pass,将 CINN 的所有 0D-Tensor 输入转换为 1D-Tensor。

本 PR 只是一种临时方案,待 CINN 全面原生支持 0D-Tensor 后,会将本 PR 中的 pass 移除,本 pass 的移除也标志着 CINN 全面支持 0D-Tensor 子项的完结。

Paddle's 0D-Tensor mechanism must be merged in the release/2.5 branch, but this mechanism requires CINN to provide corresponding support. This PR adds cinn_zero_tensor_trick_pass before build_cinn_pass to convert all CINN's 0D-Tensor inputs into 1D-Tensor, which can support Paddle's 0D-Tensor with low costs.

Note that this PR only provides a temporary trick, the cinn_zero_tensor_trick_pass in this PR will be removed after CINN fully supports 0D-Tensor.

@paddle-bot
Copy link

paddle-bot bot commented Apr 26, 2023

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


void CinnZeroTensorTrickPass::ApplyImpl(ir::Graph* graph) const {
// fix shape attr of these ops
const std::unordered_set<std::string> op_cases_fix_attr{"fill_constant",
Copy link
Contributor

Choose a reason for hiding this comment

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

目前是只有这些算子可能会引入0D-tensor么?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

这个算子集合可能不是完备的,本 PR 只是暂时提供了绕过的机制,拉取受影响 PR 经本地测试是可以全部绕过的:

后续如果有 op 引入 0D-Tensor,可以往这个集合里面添加。

@@ -0,0 +1,56 @@
/* Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
Copy link
Contributor

Choose a reason for hiding this comment

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

2020 -> 2023

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks~ 下个 PR 改

Copy link
Contributor

@thisjiang thisjiang left a comment

Choose a reason for hiding this comment

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

LGTM

@jiahy0825 jiahy0825 merged commit 9ab1486 into PaddlePaddle:develop Apr 27, 2023
@zhwesky2010 zhwesky2010 changed the title [CINN Support 0D-Tensor] CINN supports 0D-Tensor with trick temporarily [CINN 0D] CINN supports 0D-Tensor with trick temporarily Apr 28, 2023
@zhwesky2010 zhwesky2010 changed the title [CINN 0D] CINN supports 0D-Tensor with trick temporarily [CINN Zero-Dim] CINN supports 0D-Tensor with trick temporarily May 8, 2023
zhwesky2010 pushed a commit to zhwesky2010/Paddle that referenced this pull request May 8, 2023
…ly (PaddlePaddle#53382)

* [CINN Support 0D-Tensor] CINN supports 0D-Tensor with trick temporarily

* Add unittest
XiaoguangHu01 pushed a commit that referenced this pull request May 9, 2023
#53601)

* [Zero-Dim] fix functool.reduce more safe with intial value, to support empty list (#53182)

* [Zero-Dim] support 0d tensor for shape and squeeze onednn kernel (#52832)

* support 0d tensor for shape and squeeze onednn kernel

* set python api for shape op ut

* [Zero-Dim] distributed scatter/all_to_all support input 0D tensor (#53186)

* [Zero-Dim] Support paddle.sum/mean/loss api output 0D,test=allcase (#52739)

* [CINN Support 0D-Tensor] CINN supports 0D-Tensor with trick temporarily (#53382)

* [CINN Support 0D-Tensor] CINN supports 0D-Tensor with trick temporarily

* Add unittest

* [CINN Support 0D-Tensor] CINN hack squeeze2 with trick temporarily (#53454)

* fix test_autograd_dynamic (#53473)

Co-authored-by: zhwesky2010 <zhouwei25@baidu.com>

---------

Co-authored-by: YangQun <qun.yang@intel.com>
Co-authored-by: HongyuJia <jiahongyu@baidu.com>
Co-authored-by: HydrogenSulfate <490868991@qq.com>
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