You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -114,10 +114,11 @@ By annotating IR definitions with `structure`, MLC supports structural equality
114
114
<details><summary> Define a toy IRwith`structure`. </summary>
115
115
116
116
```python
117
+
import mlc
117
118
import mlc.dataclasses as mlcd
118
119
119
120
@mlcd.py_class
120
-
class Expr(mlcd.PyClass):
121
+
class Expr:
121
122
def__add__(self, other):
122
123
return Add(a=self, b=other)
123
124
@@ -146,16 +147,16 @@ class Let(Expr):
146
147
>>> L1 = Let(rhs=x + y, lhs=z, body=z) # let z = x + y; z
147
148
>>> L2 = Let(rhs=y + z, lhs=x, body=x) # let x = y + z; x
148
149
>>> L3 = Let(rhs=x + x, lhs=z, body=z) # let z = x + x; z
149
-
>>>L1.eq_s(L2)
150
+
>>>mlc.eq_s(L1, L2)
150
151
True
151
-
>>>L1.eq_s(L3, assert_mode=True)
152
+
>>>mlc.eq_s(L1, L3, assert_mode=True)
152
153
ValueError: Structural equality check failed at {root}.rhs.b: Inconsistent binding. RHS has been bound to a different node whileLHSisnot bound
153
154
```
154
155
155
156
**Structural hashing**. The structure of MLC dataclasses can be hashed via `hash_s`, which guarantees if two dataclasses are alpha-equivalent, they will share the same structural hash:
0 commit comments