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
MLC is a Python-first toolkit that makes it more ergonomic to build AI compilers, runtimes, and compound AI systems with Pythonic dataclass, rich tooling infra and zero-copy interoperability with C++ plugins.
18
+
MLC is a Python-first toolkit that streamlines the development of AI compilers, runtimes, and compound AI systems with its Pythonic dataclasses, structure-aware tooling, and Python-based text formats.
19
+
20
+
Beyond pure Python, MLC natively supports zero-copy interoperation with C++ plugins, and enables a smooth engineering practice transitioning from Python to hybrid or Python-free development.
19
21
20
22
## :inbox_tray: Installation
21
23
@@ -41,7 +43,7 @@ class MyClass(mlcd.PyClass):
41
43
instance = MyClass(12, "test", c=None)
42
44
```
43
45
44
-
**Type safety**. MLC dataclass checks type strictly in Cython and C++.
46
+
**Type safety**. MLC dataclass enforces strict type checking using Cython and C++.
An extra `structure` field are used to specify a dataclass's structure, indicating def site and scoping in an IR.
70
72
73
+
<details><summary> Define a toy IRwith`structure`. </summary>
74
+
71
75
```python
72
76
import mlc.dataclasses as mlcd
73
77
@@ -92,18 +96,15 @@ class Let(Expr):
92
96
body: Expr
93
97
```
94
98
99
+
</details>
100
+
95
101
**Structural equality**. Member method `eq_s` compares the structural equality (alpha equivalence) of two IRs represented by MLC's structured dataclass.
96
102
97
103
```python
98
-
"""
99
-
L1: let z = x + y; z
100
-
L2: let x = y + z; x
101
-
L3: let z = x + x; z
102
-
"""
103
104
>>> x, y, z = Var("x"), Var("y"), Var("z")
104
-
>>> L1 = Let(rhs=x + y, lhs=z, body=z)
105
-
>>> L2 = Let(rhs=y + z, lhs=x, body=x)
106
-
>>> L3 = Let(rhs=x + x, lhs=z, body=z)
105
+
>>> L1 = Let(rhs=x + y, lhs=z, body=z)# let z = x + y; z
106
+
>>> L2 = Let(rhs=y + z, lhs=x, body=x)# let x = y + z; x
107
+
>>> L3 = Let(rhs=x + x, lhs=z, body=z)# let z = x + x; z
**IR Printer.** By defining an `__ir_print__` method, which converts an IR node to MLC's Python-style AST, MLC's `IRPrinter` handles variable scoping, renaming and syntax highlighting automatically for a text format based on Python syntax.
125
+
126
+
<details><summary>Defining Python-based text format on a toy IR using `__ir_print__`.</summary>
0 commit comments