Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

【BUAA】【Infer Symbolic Shape】添加 weight_only_linear op的符号推导接口 #67875

Merged
merged 6 commits into from
Sep 6, 2024

Conversation

Jeff114514
Copy link
Contributor

@Jeff114514 Jeff114514 commented Aug 30, 2024

PR Category

CINN

PR Types

Others

Description

增加了新的符号推导
测试位于test_weight_only_linear.py 缺失optest
约束信息暂未修改,沿用了infermeta的PADDLE_ENFORCE

Copy link

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

@paddle-bot paddle-bot bot added the contributor External developers label Aug 30, 2024
@luotao1 luotao1 added the HappyOpenSource Pro 进阶版快乐开源活动,更具挑战性的任务 label Sep 2, 2024
@gongshaotian
Copy link
Contributor

标题修改一下,添加 weight_only_linear op的符号推导接口

auto weight_scale_shape = weight_scale_shape_or_data.shape();
auto x_shape = x_shape_or_data.shape();
auto weight_shape = weight_shape_or_data.shape();
auto n = group_size == -1 ? weight_scale_shape[0] : weight_scale_shape[1];
Copy link
Contributor

Choose a reason for hiding this comment

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

直接写明类型,尽量不使用auto

// 0,
// common::errors::InvalidArgument(
// "The second dimension of input must be divisible by 16, but
// got[%d]", weight_shape[1]));
Copy link
Contributor

Choose a reason for hiding this comment

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

把这两个Enforce的注释删了,修改成TODO项

"Input(X) dim[-1] and Input(Weight) dim[1] should be equal."
"But received Input(X) dim[-1](%s) != Input(Weight) dim[1](%s)",
x_shape[x_shape.size() - 1],
weight_shape[1]));
Copy link
Contributor

Choose a reason for hiding this comment

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

应该使用equalcstr

x_shape[x_shape.size() - 1],
weight_shape[1]));
if (!bias_shape_or_data.isa<symbol::NullShapeOrDataDimExpr>()) {
auto bias_shape = bias_shape_or_data.shape();
Copy link
Contributor

Choose a reason for hiding this comment

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

auto同上

"The input(weight_scale) must be a 2D Tensor"
" in groupwise mode."));
PADDLE_ENFORCE_EQ(weight_scale_shape[0],
(weight_shape[1] + (group_size - 1)) / group_size,
Copy link
Contributor

Choose a reason for hiding this comment

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

同上DIm的约束应该使用equalcstr

@Jeff114514 Jeff114514 changed the title 【BUAA】【Infer Symbolic Shape】Add Weight only linear for CINN 【BUAA】【Infer Symbolic Shape】添加 weight_only_linear op的符号推导接口 Sep 4, 2024
Copy link
Contributor Author

@Jeff114514 Jeff114514 left a comment

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.

approved,const &的问题可以放后面的PR修改


ExprVec weight_scale_shape = weight_scale_shape_or_data.shape();
ExprVec x_shape = x_shape_or_data.shape();
ExprVec weight_shape = weight_shape_or_data.shape();
Copy link
Contributor

Choose a reason for hiding this comment

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

能用 const & 尽量用,避免copy

@luotao1 luotao1 merged commit 5b0c895 into PaddlePaddle:develop Sep 6, 2024
29 checks passed
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
contributor External developers HappyOpenSource Pro 进阶版快乐开源活动,更具挑战性的任务
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants