Skip to content

【CINN】Add IterMark/IterSplit/IterSum structures and conversion methods #68011

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

Merged
merged 5 commits into from
Sep 10, 2024

Conversation

liuruyan
Copy link
Contributor

@liuruyan liuruyan commented Sep 4, 2024

PR Category

CINN

PR Types

New features

Description

  1. Add IterExpr: IterMark/IterSplit/IterSum basic structures, IterMark is a mark for entirely iter.
IterSplit = source / lower_factor % extent * scale
IterSum = Sum(args) + base
  1. Add conversion method for Expr and IterExpr.
  2. Add Visit func for simplify: Add, Sub, Mul.
  3. Extract the const_fold function into a separate file.

Pcard-67164

@@ -0,0 +1,75 @@
// Copyright (c) 2023 CINN Authors. All Rights Reserved.
Copy link
Contributor

Choose a reason for hiding this comment

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

2023 -> 2024

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

}
return std::nullopt;
}

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 Author

Choose a reason for hiding this comment

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

会在下一个pr中引入除法,因为当前pr没有visit(Div)

@@ -0,0 +1,275 @@
// Copyright (c) 2023 CINN Authors. All Rights Reserved.
Copy link
Contributor

Choose a reason for hiding this comment

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

2023 -> 2024

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

namespace cinn {
namespace common {

bool isIterExpr(const Expr& a, const Expr& b) {
Copy link
Contributor

Choose a reason for hiding this comment

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

image

首字母大写

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

b.As<ir::IterSplit>() || b.As<ir::IterSum>();
}

bool isOne(const Expr& expr) {
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 Author

Choose a reason for hiding this comment

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

Done

Comment on lines +1049 to +1053
Type type() const { return source.type(); }
Expr source;
Expr lower_factor;
Expr extent;
Expr scale;
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 Author

Choose a reason for hiding this comment

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

Done

Comment on lines +1062 to +1063
std::vector<Expr> args;
Expr base;
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 Author

Choose a reason for hiding this comment

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

Done

Copy link
Contributor

Choose a reason for hiding this comment

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

测试文件加到test目录下

@@ -0,0 +1,219 @@
// Copyright (c) 2023 CINN Authors. All Rights Reserved.
Copy link
Contributor

Choose a reason for hiding this comment

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

2023 -> 2024

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

@@ -0,0 +1,78 @@
// Copyright (c) 2023 CINN Authors. All Rights Reserved.
Copy link
Contributor

Choose a reason for hiding this comment

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

2023 -> 2024

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

Copy link
Contributor

@Aurelius84 Aurelius84 left a comment

Choose a reason for hiding this comment

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

LGTM for const_cast


class IterMapToExprNormalizer : public ir::IRMutator<> {
public:
explicit IterMapToExprNormalizer(SymbolicExprAnalyzer analyzer)
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
explicit IterMapToExprNormalizer(SymbolicExprAnalyzer analyzer)
explicit IterMapToExprNormalizer(const SymbolicExprAnalyzer& analyzer)

这里是值copy传入,然后引用这个copy?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

是的

@zyfncg zyfncg merged commit b94916c into PaddlePaddle:develop Sep 10, 2024
28 of 29 checks passed
@liuruyan liuruyan changed the title Add IterMark/IterSplit/IterSum structures and conversion methods 【CINN】Add IterMark/IterSplit/IterSum structures and conversion methods Oct 16, 2024
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.

3 participants