Skip to content

Commit 438289b

Browse files
committed
backport unwrap_if_constexpr
1 parent b5bf3fb commit 438289b

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

src/flag_gems/ops/sort.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,26 @@
1111
logger = logging.getLogger(__name__)
1212

1313

14+
def unwrap_if_constexpr(o):
15+
return o.value if isinstance(o, tl.constexpr) else o
16+
17+
1418
@tl.constexpr
15-
def get_int_t(num_bits, signed) -> tl.dtype:
19+
def get_int_t(num_bits: tl.constexpr, signed: tl.constexpr) -> tl.dtype:
20+
num_bits = unwrap_if_constexpr(num_bits)
21+
signed = unwrap_if_constexpr(signed)
1622
return tl.core.get_int_dtype(num_bits, signed)
1723

1824

1925
@tl.constexpr
20-
def one_zeros(num_bits) -> int:
26+
def one_zeros(num_bits: tl.constexpr) -> int:
27+
num_bits = unwrap_if_constexpr(num_bits)
2128
return 1 << (num_bits - 1)
2229

2330

2431
@tl.constexpr
25-
def zero_ones(num_bits) -> int:
32+
def zero_ones(num_bits: tl.constexpr) -> int:
33+
num_bits = unwrap_if_constexpr(num_bits)
2634
return (1 << (num_bits - 1)) - 1
2735

2836

0 commit comments

Comments
 (0)