MCPcopy Create free account
hub / github.com/apache/tvm / LetAnnotation

Class LetAnnotation

python/tvm/tirx/script/builder/ir.py:1477–1507  ·  view source on GitHub ↗

Marker for explicit LetStmt. Created by T.let or T.let[type]. Usage in TVMScript: x: T.let[T.int32] = expr # LetStmt with explicit type x: T.let = expr # LetStmt with auto-typed RHS

Source from the content-addressed store, hash-verified

1475
1476
1477class LetAnnotation:
1478 """Marker for explicit LetStmt. Created by T.let or T.let[type].
1479 Usage in TVMScript:
1480 x: T.let[T.int32] = expr # LetStmt with explicit type
1481 x: T.let = expr # LetStmt with auto-typed RHS
1482 """
1483
1484 def __init__(self, type_spec=None):
1485 self.type_spec = type_spec
1486
1487 def __class_getitem__(cls, item):
1488 return LetAnnotation(item)
1489
1490 def __getitem__(self, item):
1491 return LetAnnotation(item)
1492
1493 def as_var(self, rhs_dtype=None):
1494 """Resolve to a tir.Var."""
1495 if self.type_spec is not None:
1496 if isinstance(self.type_spec, Var):
1497 return self.type_spec # Already a Var (e.g. T.handle(...))
1498 elif callable(self.type_spec):
1499 return self.type_spec() # e.g. T.int32() -> Var
1500 elif isinstance(self.type_spec, Type):
1501 return Var("", self.type_spec)
1502 else:
1503 raise TypeError(f"Invalid type for T.let: {self.type_spec}")
1504 elif rhs_dtype is not None:
1505 return Var("", ir.PrimType(rhs_dtype))
1506 else:
1507 raise TypeError("T.let requires either a type or an RHS value")
1508
1509
1510let = LetAnnotation() # Singleton for T.let (no subscript)

Callers 3

__class_getitem__Method · 0.85
__getitem__Method · 0.85
ir.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…