Skip to content

Commit e87fdd9

Browse files
authored
[Gluon] Add support for assume (#8394)
1 parent 08c9807 commit e87fdd9

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

python/test/gluon/test_frontend.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,32 @@ def test_convert_layout(target):
7676
""")
7777

7878

79+
@gluon.jit
80+
def assume_kernel(arg: tl.int32):
81+
ttgl.assume(arg > 1)
82+
83+
84+
@pytest.mark.parametrize("target", ALL_TARGETS)
85+
def test_assume(target):
86+
arg = 100
87+
mod = run_parser(
88+
assume_kernel,
89+
*make_args(arg),
90+
target=target,
91+
)
92+
expecttest.assert_expected_inline(
93+
anonymize_ir(mod.str_nodebug()), """\
94+
module attributes {"ttg.num-ctas" = 1 : i32, "ttg.num-warps" = 4 : i32, ttg.target = "...", "ttg.threads-per-warp" = 32 : i32} {
95+
tt.func public @assume_kernel(%arg0: i32) attributes {noinline = false} {
96+
%c1_i32 = arith.constant 1 : i32
97+
%0 = arith.cmpi sgt, %arg0, %c1_i32 : i32
98+
llvm.intr.assume %0 : i1
99+
tt.return
100+
}
101+
}
102+
""")
103+
104+
79105
@filecheck_test
80106
@gluon.jit
81107
def test_histogram_frontend():

python/triton/experimental/gluon/language/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
allocate_shared_memory,
3535
arange,
3636
associative_scan,
37+
assume,
3738
atomic_add,
3839
atomic_and,
3940
atomic_cas,

python/triton/experimental/gluon/language/_core.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ def wrapper(*args, **kwargs):
100100

101101
# Explicitly import forwarded Triton language symbols so mypy sees them.
102102
associative_scan = builtin(tl_core.associative_scan)
103+
assume = builtin(tl_core.assume)
103104
atomic_add = builtin(tl_core.atomic_add)
104105
atomic_and = builtin(tl_core.atomic_and)
105106
atomic_cas = builtin(tl_core.atomic_cas)

0 commit comments

Comments
 (0)