lightzhan-intellif commented on code in PR #13630:
URL: https://github.com/apache/tvm/pull/13630#discussion_r1050552367
##########
python/tvm/script/parser/core/parser.py:
##########
@@ -150,7 +150,7 @@ def add(self, var: str, value: Any, allow_shadowing: bool =
False):
The options of whether variable shadowing allwed for this variable.
"""
# Skip if the key and value are equal to those in the var_table
- if self.name2value[var] and self.name2value[var][-1] == value:
+ if self.name2value[var] and self.name2value[var][-1] is value:
return
Review Comment:
Thanks for your suggestion. I have done some trials in the python terminal
according to your concern. Let's have a look:
```shell
# python3
Python 3.8.13 (default, Apr 19 2022, 00:53:22)
[GCC 7.5.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 1 is 1
<stdin>:1: SyntaxWarning: "is" with a literal. Did you mean "=="?
True
>>> a = 1
>>> a is 1
<stdin>:1: SyntaxWarning: "is" with a literal. Did you mean "=="?
True
>>> a = 1
>>> b = 1
>>> a is b
True
>>> a = [1, 2, 3]
>>> b = 1
>>> a[0] is b
True
>>> b = [1, 2, 3]
>>> a [0] is b[1]
False
```
According to the above output, we can find that there will be a warning if
we use literal directly, but here it is a variable/list/dict which in your
concern contains a literal. It looks like that python differentiates literal
from variables with `literal` value. In our case, it belongs to the latter. So
maybe no problem here with "is".
There might be some other scenarios I didn't cover, feel free to point out.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]