Skip to content

【Infer Symbolic Shape No.124】【BUAA】Add bmm, changed 3 files - #67431

Closed
Whsjrczr wants to merge 6 commits into
PaddlePaddle:developfrom
Whsjrczr:api5
Closed

Whsjrczr wants to merge 6 commits into
PaddlePaddle:developfrom
Whsjrczr:api5

Conversation

@Whsjrczr

@Whsjrczr Whsjrczr commented Aug 14, 2024 •

Copy link
Copy Markdown
Contributor

PR Category

CINN

PR Types

Others

Description

加入bmm, broadcast_tensors:
paddle/fluid/pir/dialect/operator/interface/infer_symbolic_shape/binary_infer_sym.cc
paddle/fluid/pir/dialect/operator/interface/infer_symbolic_shape/binary_infer_sym.h
paddle/phi/ops/yaml/ops.yaml
本地测试pir=True且通过
截屏2024-08-15 16 17 53

@paddle-bot

paddle-bot Bot commented Aug 14, 2024

Copy link
Copy Markdown

你的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 14, 2024
Comment on lines +235 to +245
auto cal_shape_fn = [](const symbol::DimExpr &x,
const symbol::DimExpr &y,
const std::string &error_str) -> symbol::DimExpr {
if (x == -1) {
return y;
} else if (y == -1) {
return x;
}
PADDLE_ENFORCE_EQ(x, y, common::errors::InvalidArgument(error_str, x, y));
return x;
};

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

DimExpr不可能为-1,这段逻辑是想给两个DimExpr加约束

"in BmmOp, but received Y's shape: [%d].",
y_ndims));

auto cal_shape_fn = [](const symbol::DimExpr &x,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

删掉这个lambda表达式,调用cal_shape_fn的地方都使用 addequalcstr

return x;
};

cal_shape_fn(x_dims[2],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

修改为 equal constrain

y_dims[1],
"Input(X)'s width must be equal with Input(Y)'s height in "
"BmmOp, but receive X's width: [%d], Y's height: [%d].");
symbol::DimExpr batch_size = cal_shape_fn(

@gongshaotian gongshaotian Aug 19, 2024 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

同上,batch_size 直接取其中一个Dim就行

const auto &y_shape_or_data =
infer_context->GetShapeOrDataForValue(op->operand_source(1));

const std::vector<symbol::DimExpr> &x_dims = x_shape_or_data.shape();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

命名不规范,x_shape

infer_context->GetShapeOrDataForValue(op->operand_source(1));

const std::vector<symbol::DimExpr> &x_dims = x_shape_or_data.shape();
const std::vector<symbol::DimExpr> &y_dims = y_shape_or_data.shape();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

同上

Hongqing-work
Hongqing-work previously approved these changes Aug 23, 2024
@luotao1

luotao1 commented Aug 26, 2024

Copy link
Copy Markdown
Collaborator

冲突了

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.

4 participants