apache / apache/tvm

[Bug] [TOPI]te_create_prime cannot generate valid tir for the topk with ret_type='both'

Open
#17,956 1 comment 0 reactions 0 assignees View on GitHub
needs-triage type: bug
Dominant language
Python
Stars
13.7k
Forks
4k
Avg merge
2d 19h
Merged PRs (30d)
111

Description

### Actual behavior

```
# from tvm.script import ir as I
# from tvm.script import tir as T

@I.ir_module
class Module:
@T.prim_func
def main(data: T.Buffer((128, 64), "float32")):
T.func_attr({"tir.noalias": T.bool(True)})
T.evaluate(0)
```

### Environment

tvm-0.21.dev0

### Steps to reproduce

```
import tvm
from tvm import te, topi, tir

data = te.placeholder((128, 64), dtype='float32', name='data')
op_output = topi.topk(data, k=10, axis=1, ret_type='both')
print(op_output)
sch = tir.Schedule(te.create_prim_func([data, op_output]))
print(sch.mod)
```

### Triage

* needs-triage
* te

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce the issue with topi.topk(..., ret_type='both'), then inspect te.create_prim_func and the resulting tir.Schedule module. Trace why this combination produces invalid TIR; done means the same reproduction generates valid TIR for the topk outputs.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.