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

[PIR][DynamicShape] Add InferSymbolicShape for gather_nd, squeeze, and unsqueeze #61224

Merged
merged 3 commits into from
Jan 30, 2024

Conversation

lanxianghit
Copy link
Contributor

PR types

Others

PR changes

Others

Description

Pcard-67164
Add InferSymbolicShape for gather_nd, squeeze, and unsqueeze, which used in RoPE

@@ -607,8 +656,91 @@ bool ScaleSr_OpInferSymbolicShape(

bool SqueezeOpInferSymbolicShape(
pir::Operation *op, pir::ShapeConstraintIRAnalysis *shape_analysis) {
PADDLE_THROW(phi::errors::Unimplemented(
op->name() + " DOES NOT have InferSymbolicShapeInterface!"));
IR_ENFORCE(op->num_operands() == 2,
Copy link
Contributor

Choose a reason for hiding this comment

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

这部分是不是会在 verify 或者 infermeta 函数中检查过了? 所以 此处不需要再重复检查了

Copy link
Contributor Author

Choose a reason for hiding this comment

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

我看pd_op里还有其他build的定义,不确定是否还有其他形式的,所以先做个检查,以免直接越界了

Copy link
Contributor

@zhangbopd zhangbopd left a comment

Choose a reason for hiding this comment

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

LGTM

// Mark dimensions need to be squeezed.
if (num_squeeze_dims == 0) {
for (size_t i = 0; i < in_dims_sym.size(); ++i) {
// TODO(lanxianghit): if symbol here, maybe we need the result of dim expr
Copy link
Contributor

Choose a reason for hiding this comment

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

这个头文件的函数可以对 dim_expr 实现化简 已经从 cinn 移动到 shape dialect 下了
#include "paddle/pir/dialect/shape/utils/dim_expr_simplify.h"

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再优化一下

@lanxianghit lanxianghit merged commit e8722ad into PaddlePaddle:develop Jan 30, 2024
29 of 30 checks passed
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.

2 participants