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] Add pir::ConstantTensorOp and improve constant_folding_pass #59244

Merged
merged 4 commits into from
Nov 25, 2023

Conversation

zhangyuqin1998
Copy link
Contributor

@zhangyuqin1998 zhangyuqin1998 commented Nov 22, 2023

PR types

New features

PR changes

Others

Description

Add pir::ConstantTensorOp and improve constant_folding_pass

@zhangyuqin1998 zhangyuqin1998 changed the title Pr1122 temp [pir]Adding constant_tensor_op, rewrite constant folding pass Nov 22, 2023
@paddle-bot paddle-bot bot added the contributor External developers label Nov 22, 2023
for (uint32_t i = 0; i < op->num_results(); i++) {
auto use_ops = pir::GetUseOpsForOutput(op, i);
for (auto* use_op : use_ops) {
if (use_op->isa<pir::CombineOp>()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

CombineOp是不是可以再根据CombineOp的user来判断?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

CombineOp是不是可以再根据CombineOp的user来判断?

好滴

"Type of value must be strattribute");
}

ConstantTensorOp ConstantTensorOp::dyn_cast(Operation *op) {
Copy link
Contributor

Choose a reason for hiding this comment

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

ConstantTensorOp 的 isa 和 dyn_cast 有点问题,需要判断一下 value 是不是一个 TensorNameAttribute

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ConstantTensorOp 的 isa 和 dyn_cast 有点问题,需要判断一下 value 是不是一个 TensorNameAttribute

已增加

@@ -495,6 +495,22 @@ void ConstantOp::VerifySig() const {

Attribute ConstantOp::value() const { return attributes().at("value"); }

void ConstantTensorOp::VerifySig() const {
Copy link
Contributor

Choose a reason for hiding this comment

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

缺少一个 TensorNameAttibute 用于代表一个 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.

缺少一个 TensorNameAttibute 用于代表一个 Tensor名字的属性

已增加


bool operator<(const TensorNameAttribute& right) const;

std::string AsString() const;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
std::string AsString() const;
std::string data() const;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done~


size_t size() const;

static TensorNameAttribute get(IrContext* ctx, const std::string& value);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
static TensorNameAttribute get(IrContext* ctx, const std::string& value);
static TensorNameAttribute get(IrContext* ctx, const std::string& tensor_name);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done~

zhangbo9674
zhangbo9674 previously approved these changes Nov 23, 2023
zhangyuqin1998 and others added 2 commits November 24, 2023 10:32
Copy link
Contributor

@yuanlehome yuanlehome left a comment

Choose a reason for hiding this comment

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

LGTM

@yuanlehome yuanlehome changed the title [pir]Adding constant_tensor_op, rewrite constant folding pass [PIR] Add pir::ConstantTensorOp and improve constant_folding_pass Nov 25, 2023
@yuanlehome yuanlehome merged commit 28fb4bc into PaddlePaddle:develop Nov 25, 2023
SecretXV pushed a commit to SecretXV/Paddle that referenced this pull request Nov 28, 2023
…ddlePaddle#59244)

* [pir]Adding constant_tensor_op, rewrite constant folding pass

* fix

* fix

* Update analysis_predictor.cc
@zhangyuqin1998 zhangyuqin1998 deleted the pr1122_temp branch May 7, 2024 16:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor External developers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants