MCPcopy Create free account
hub / github.com/ByteDance-Seed/Triton-distributed / _to_expr

Method _to_expr

python/little_kernel/core/expr.py:44–56  ·  view source on GitHub ↗

Convert Python native values (int/float/bool) to Literal nodes

(self, value)

Source from the content-addressed store, hash-verified

42 # Utility: Convert Python values to Literal
43 # ------------------------------
44 def _to_expr(self, value) -> "Expr":
45 """Convert Python native values (int/float/bool) to Literal nodes"""
46 if isinstance(value, Expr):
47 return value
48 if isinstance(value, int):
49 return Literal(value, int32) # Simplification: default int to int32
50 if isinstance(value, float):
51 return Literal(value, float32) # Simplification: default float to float32
52 if isinstance(value, bool):
53 return Literal(value, bool_)
54 if isinstance(value, str):
55 return Literal(value, str_)
56 raise TypeError(f"Unsupported operand type: {type(value)}")
57
58 # ------------------------------
59 # Binary operator overloading (arithmetic)

Callers 15

__add__Method · 0.95
__sub__Method · 0.95
__mul__Method · 0.95
__truediv__Method · 0.95
__mod__Method · 0.95
__and__Method · 0.95
__or__Method · 0.95
__xor__Method · 0.95
__lshift__Method · 0.95
__rshift__Method · 0.95
__eq__Method · 0.95
__ne__Method · 0.95

Calls 1

LiteralClass · 0.85

Tested by

no test coverage detected