Skip to content

Commit 69cd5f2

Browse files
committed
Add unit test
1 parent 66bb90b commit 69cd5f2

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

python/test/unit/language/test_core.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2803,6 +2803,23 @@ def histogram_kernel(x_ptr, z_ptr, M: tl.constexpr, N: tl.constexpr):
28032803
assert (z_torch == z).all()
28042804

28052805

2806+
@pytest.mark.interpreter
2807+
def test_histogram_silent_data_corruption(device):
2808+
2809+
@triton.jit
2810+
def histogram_kernel(x_ptr, z_ptr):
2811+
offset = tl.arange(0, 1)
2812+
x = tl.load(x_ptr + offset)
2813+
z = tl.histogram(x, 1)
2814+
tl.store(z_ptr + offset, z)
2815+
2816+
x = torch.ones(1, device=device, dtype=torch.int32)
2817+
z = torch.ones(2, device=device, dtype=torch.int32)
2818+
2819+
histogram_kernel[(1,)](x, z)
2820+
assert z[1] == 1, f"Second element shouldn't be affected, expected_buffer=[1, 1], actual_buffer={z}"
2821+
2822+
28062823
# ------------------------
28072824
# test histogram with mask
28082825
# ------------------------

0 commit comments

Comments
 (0)