Skip to content

[Arith] Simplify floordiv(x*8+7, 16) to floordiv(x, 2) - #10232

Merged
kparzysz-quic merged 1 commit into
apache:mainfrom
wrongtest-intellif:add_a_floordiv_simplify_rule
Feb 14, 2022
Merged

kparzysz-quic merged 1 commit into
apache:mainfrom
wrongtest-intellif:add_a_floordiv_simplify_rule

Conversation

@wrongtest-intellif

Copy link
Copy Markdown
Contributor

Hi, the PR add a simplify rule to allow patterns like floordiv(x*8+7, 16) => floordiv(x, 2).

We find the issue when using compute_at to repeat op:

T_add = T.alloc_buffer([4], dtype="float32")
    for i0 in T.serial(4):
        with T.block("T_add"):
            ax0 = T.axis.spatial(4, i0)
            T_add[ax0] = x[ax0] + 1.0
    for i0_0, i0_1 in T.grid(8, 8):
        with T.block("T_repeat"):
            ax0 = T.axis.spatial(64, i0_0 * 8 + i0_1)
            T_repeat[ax0] = T_add[ax0 // 16]

compute_at(T_add , i0_0) currently will result to a "dynamic" extent floordiv(x*8 + 7, 16) - floordiv(x, 2) + 1.

Also fix a typo of previous compute at testcase.

@kparzysz-quic kparzysz-quic left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The math checks out. The rest looks ok as well.

@kparzysz-quic
kparzysz-quic merged commit ce45f26 into apache:main Feb 14, 2022
pfk-beta pushed a commit to pfk-beta/tvm that referenced this pull request Apr 11, 2022
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