Skip to content

Conversation

@liuruyan
Copy link
Contributor

@liuruyan liuruyan commented Jan 21, 2025

PR Category

CINN

PR Types

Improvements

Description

Enrich IndexExpr ability of Simplify dynamic shape.

case1.
(S5 * S6) * S4 / (S5 * S6)
=======>
S4

case2.
(S5 * S6) * S4 % (S5 * S6)
=======>
0

case 3. 
((((((f % ((S5 * S6) * 640)) % ((S5 * S6) * S4)) / (S5 * S6)) * S6) *
        S5) +
       (f % (S5 * S6))
=======>
((f % ((S5 * S6) * 640)) % ((S5 * S6) * S4))

case 4.
((f % ((S5 * S6) * 640)) % ((S5 * S6) * S4)) % (S5 * S6)
=======>
f % (S5 * S6)

case5.
      ((((((((((((((((S7 * 1024) + S8) + (S9 * 4096)) / S6) % S5) * S6) +
                ((((S7 * 1024) + S8) + (S9 * 4096)) % S6)) +
               (((((((((S7 * 1024) + S8) + (S9 * 4096)) / S6) / S5) % 640) %
                  S4) *
                 S6) *
                S5)) +
              (((((((((S7 * 1024) + S8) + (S9 * 4096)) / S6) / S5) / 640) *
                 S5) *
                S6) *
               S4)) /
             ((S5 * S6) * S4)) *
            S4) +
           (((((((((((S7 * 1024) + S8) + (S9 * 4096)) / S6) % S5) * S6) +
                ((((S7 * 1024) + S8) + (S9 * 4096)) % S6)) +
               (((((((((S7 * 1024) + S8) + (S9 * 4096)) / S6) / S5) % 640) %
                  S4) *
                 S6) *
                S5)) +
              (((((((((S7 * 1024) + S8) + (S9 * 4096)) / S6) / S5) / 640) *
                 S5) *
                S6) *
               S4)) /
             (S5 * S6)) %
            S4)) *
          S5) +
         (((((((((((S7 * 1024) + S8) + (S9 * 4096)) / S6) % S5) * S6) +
              ((((S7 * 1024) + S8) + (S9 * 4096)) % S6)) +
             (((((((((S7 * 1024) + S8) + (S9 * 4096)) / S6) / S5) % 640) % S4) *
               S6) *
              S5)) +
            (((((((((S7 * 1024) + S8) + (S9 * 4096)) / S6) / S5) / 640) * S5) *
              S6) *
             S4)) /
           S6) %
          S5)) *
        S6) +
       ((((((((((S7 * 1024) + S8) + (S9 * 4096)) / S6) % S5) * S6) +
           ((((S7 * 1024) + S8) + (S9 * 4096)) % S6)) +
          (((((((((S7 * 1024) + S8) + (S9 * 4096)) / S6) / S5) % 640) % S4) *
            S6) *
           S5)) +
         (((((((((S7 * 1024) + S8) + (S9 * 4096)) / S6) / S5) / 640) * S5) *
           S6) *
          S4)) %
        S6));
========>
((((((((S7 * 1024) + S8) + (S9 * 4096)) / ((S5 * S6) * 640)) * S5) * S6) *
        S4) +
       (((((S7 * 1024) + S8) + (S9 * 4096)) % ((S5 * S6) * 640)) %
        ((S5 * S6) * S4)))

Pcard-67164

std::optional<ir::IndexExpr> DivByPartMul(const ir::IndexExpr &lhs,
const ir::IndexExpr &rhs,
ir::IrNodeTy ty) {
std::vector<ir::IndexExpr> elems = common::GetFlattenExprs<ir::Mul>(rhs);
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 link
Contributor Author

Choose a reason for hiding this comment

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

好的,下一个 PR 中将进行添加

@zyfncg zyfncg merged commit a6c9bd4 into PaddlePaddle:develop Jan 23, 2025
34 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