Skip to content

[TIR][NarrowDataType] Bufferload's index should not inherit bits constraint of value#17411

Merged
tqchen merged 1 commit into
apache:mainfrom
wrongtest-intellif:fix_narrow_bufferload_index_dtype
Sep 25, 2024
Merged

[TIR][NarrowDataType] Bufferload's index should not inherit bits constraint of value#17411
tqchen merged 1 commit into
apache:mainfrom
wrongtest-intellif:fix_narrow_bufferload_index_dtype

Conversation

@wrongtest-intellif

Copy link
Copy Markdown
Contributor

Fix an issue in NarrowDataType pass. When we perform narrowing on buffer indices, the integer bits constraint is irrelevant to buffer load value's integer bits. Thus it looks like we should reset the context bit info when traverse into the indices field.

Another small change is in cast node rewrite, skip node construction when dtype actually matches.

@tqchen

tqchen commented Sep 24, 2024

Copy link
Copy Markdown
Member

do u mind leave a quick comment about what will happen without this PR

@wrongtest-intellif

Copy link
Copy Markdown
Contributor Author

do u mind leave a quick comment about what will happen without this PR

In the main branch, this case's indices would not change after narrowing with i32.

@T.prim_func
def before(A: T.Buffer((16,), "int64")):
    for i in range(T.int64(15)):
          A[i + T.int64(1)] = A[i] + T.int64(1)

The deduction chain is like below:

  1. A[i] + T.int64(1) -> 64b
  2. A[i] -> 64b
  3. indices of load A -> 64b (here is the issue)
  4. i -> requires 64b

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