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

【BUAA】【Infer Symbolic Shape No.90 92 2.8】Add CINN #66892

Merged
merged 23 commits into from
Aug 13, 2024

Conversation

uanu2002
Copy link
Contributor

@uanu2002 uanu2002 commented Aug 1, 2024

PR Category

CINN

PR Types

Others

Description

添加 randperm, segment_pool, set_value 算子符号推导接口实现。

Copy link

paddle-bot bot commented Aug 1, 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.

@luotao1 luotao1 added contributor External developers HappyOpenSource Pro 进阶版快乐开源活动,更具挑战性的任务 labels Aug 1, 2024
@uanu2002 uanu2002 changed the title 【Infer Symbolic Shape BUAA No.90 92 2.8】Add CINN 【BUAA】【Infer Symbolic Shape No.90 92 2.8】Add CINN Aug 5, 2024
@@ -124,7 +124,7 @@ def setUp(self):
self.convert_bf16()

def test_check_output(self):
self.check_output(check_pir=True)
Copy link
Contributor

Choose a reason for hiding this comment

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

不要改pir的flag

infer_context->GetShapeOrDataForValue(op->operand_source(0)).shape();
std::vector<symbol::DimExpr> out_shape;
symbol::DimExpr out_unknown =
infer_context->GetNextSymName(); // unknown until runtime
Copy link
Contributor

Choose a reason for hiding this comment

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

恭喜触发第一个需要添加新符号的任务🎉

Copy link
Contributor

Choose a reason for hiding this comment

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

秉持最少的引入新符号的原则

op->attribute<pir::StrAttribute>("pooltype").AsString();
if (pool_type == "MEAN") {
std::vector<symbol::DimExpr> summed_shape;
summed_shape.push_back(out_unknown);
Copy link
Contributor

Choose a reason for hiding this comment

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

写个注释,这两个维度是相同的

bool SegmentPoolOpInferSymbolicShape(
pir::Operation *op, pir::InferSymbolicShapeContext *infer_context) {
const auto &input_shape =
infer_context->GetShapeOrDataForValue(op->operand_source(0)).shape();
Copy link
Contributor

Choose a reason for hiding this comment

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

判断一下data区有没有数据,有数据的话需要通过计算得到,不能再上新符号

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thx,已修改~

@uanu2002
Copy link
Contributor Author

randperm, segment_pool, set_value有对应optest单测。

op->attribute<pir::StrAttribute>("pooltype").AsString();

int ndims_ids = ids_shape.size();
int last_dim = static_cast<int>(ids_shape[ndims_ids - 1].Get<std::int64_t>());
Copy link
Contributor

Choose a reason for hiding this comment

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

这里应该是 ids_shape.size() - 1 吧

if (ids_shape_or_data.data().has_value()) {
const auto &ids_data = ids_shape_or_data.data();
int out_known =
static_cast<int>(ids_data.value()[last_dim - 1].Get<std::int64_t>());
Copy link
Contributor

@gongshaotian gongshaotian Aug 12, 2024

Choose a reason for hiding this comment

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

这个维度变换感觉写的有问题,应该是 out_shape.push_back(ids_data.value()[ids_shape.size() -1] + DimExpr{1})

Copy link
Contributor

Choose a reason for hiding this comment

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

这里可以不再cast成int类型了

Copy link
Contributor Author

Choose a reason for hiding this comment

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

已修改

Copy link
Contributor

@gongshaotian gongshaotian left a comment

Choose a reason for hiding this comment

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

LGTM

@luotao1
Copy link
Contributor

luotao1 commented Aug 13, 2024

image 看看编译没过

@gongshaotian
Copy link
Contributor

image 看看编译没过
这个op的实现在unary 里面已经有了,是不是在别的pr里已经合入了

@luotao1 luotao1 merged commit 92dc713 into PaddlePaddle:develop Aug 13, 2024
27 of 28 checks passed
@uanu2002 uanu2002 deleted the cinn_new branch August 15, 2024 02:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor External developers HappyOpenSource Pro 进阶版快乐开源活动,更具挑战性的任务
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants