Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BugFix][TVMScript]fix var capturing order error #13640

Merged
merged 2 commits into from
Dec 19, 2022

Conversation

lightzhan-intellif
Copy link
Contributor

This PR try to fix the following bug:

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.

@tvm-bot
Copy link
Collaborator

tvm-bot commented Dec 18, 2022

Thanks for contributing to TVM! Please refer to the contributing guidelines https://tvm.apache.org/docs/contribute/ for useful information and tips. Please request code reviews from Reviewers by @-ing them in a comment.

  • No users to tag found in teams: bugfix, tvmscript See #10317 for details

Generated by tvm-bot

@Hzfengsy
Copy link
Member

cc @junrushao

Copy link
Member

@junrushao junrushao left a comment

Choose a reason for hiding this comment

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

nice catch!

@lightzhan-intellif lightzhan-intellif changed the title [BugFix][TVMScript]fix var capturing order error. [BugFix][TVMScript]fix var capturing order error Dec 19, 2022
@lightzhan-intellif
Copy link
Contributor Author

@tvm-bot rerun

@junrushao junrushao merged commit 6161a8d into apache:main Dec 19, 2022
fzi-peccia pushed a commit to fzi-peccia/tvm that referenced this pull request Mar 27, 2023
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 <zhan.liang@intellif.com>
mikeseven pushed a commit to mikeseven/tvm that referenced this pull request Sep 27, 2023
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 <zhan.liang@intellif.com>
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.

5 participants