-
- Downloads
Add same_as to NodeBase (#550)
* Add same_as to NodeBase 1. Most class inherited from NodeBase(Schedule, Stage, etc) still have the convenience of using '==' for object identity. And this is the right behavior for non-Expr classes. 2. subclasses of ExprOp now create EQ expression when '==' is used. `__nonzero__` and `__bool__` in EQ and NE is a comprise that in some cases object identity semantics is still useful, like in unit test. For instance: ```` assert a == b ```` "a == b" will create EQ expression, assert then calls `__nonzero__` of the result expression. `Expr.__nonzero__` throws exception since it prohibits evaluating IR expression. More complex case like: ```` assert a in b # b is dict ```` it will call `__eq__` on a and all keys of b, then `__bool__` on the result expression. This could not easily be done by same_as. * Retain __hash__ from NodeBase in Python3
Showing
- python/tvm/_ffi/node.py 7 additions, 3 deletionspython/tvm/_ffi/node.py
- python/tvm/expr.py 14 additions, 4 deletionspython/tvm/expr.py
- python/tvm/ir_builder.py 1 addition, 1 deletionpython/tvm/ir_builder.py
- tests/python/unittest/test_ir_builder.py 1 addition, 1 deletiontests/python/unittest/test_ir_builder.py
Please register or sign in to comment