2022-08-18 01:42:48 +08:00
|
|
|
import torch
|
|
|
|
|
|
|
|
import triton
|
|
|
|
import triton.language as tl
|
|
|
|
|
|
|
|
# trigger the torch.device implicitly to ensure cuda context initialization
|
|
|
|
torch.zeros([10], device=torch.device('cuda'))
|
|
|
|
|
|
|
|
|
2022-08-20 01:46:01 +08:00
|
|
|
@triton.jit
|
|
|
|
def empty_kernel(X, stride_xm, BLOCK: tl.constexpr):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
2022-08-18 01:42:48 +08:00
|
|
|
def test_empty_kernel_cubin_compile():
|
|
|
|
|
|
|
|
device = torch.cuda.current_device()
|
2022-09-23 16:09:43 -07:00
|
|
|
kernel = triton.compile(empty_kernel,
|
2022-11-18 07:46:45 +01:00
|
|
|
signature="*fp32,i32,i32",
|
2022-09-23 16:09:43 -07:00
|
|
|
device=device,
|
|
|
|
constants={"BLOCK": 256})
|
2022-08-18 01:42:48 +08:00
|
|
|
|
2022-09-23 16:09:43 -07:00
|
|
|
assert len(kernel.asm["cubin"]) > 0
|
2022-08-20 01:46:01 +08:00
|
|
|
|
|
|
|
|
|
|
|
def test_empty_kernel_launch():
|
|
|
|
grid = lambda META: (
|
|
|
|
triton.cdiv(1024, META['BLOCK']) * triton.cdiv(1024, META['BLOCK']),
|
|
|
|
)
|
|
|
|
|
|
|
|
A = torch.zeros([1024], device="cuda")
|
2022-09-23 16:09:43 -07:00
|
|
|
empty_kernel[grid](X=A, stride_xm=256, BLOCK=256)
|