Commit 6161a8d
[BugFix][TVMScript]fix var capturing order error (#13640)
This PR try to fix the following bug:
```python
def test_var_capturing_order():
b = 2
@T.prim_func
def test_case():
k: T.int32 = b
if __name__ == "__main__":
b = 1
```
In the prim func `test_case`, the vaule of b should be 2, rather than 1. The parser wrongly uses global vars to shadow the value of nonlocal vars, which should be reversed.
Co-authored-by: lightzhan-intellif <[email protected]>1 parent ddb006e commit 6161a8d
File tree
2 files changed
+18
-1
lines changed- python/tvm/script/parser/core
- tests/python/unittest
2 files changed
+18
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
41 | 40 | | |
| 41 | + | |
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
61 | 76 | | |
62 | 77 | | |
63 | 78 | | |
64 | 79 | | |
| 80 | + | |
| 81 | + | |
0 commit comments