Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow triton.code_gen.Binary to print asm. #89

Merged
merged 4 commits into from
Apr 23, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Rename ir to ttir in Binary::asm()
  • Loading branch information
daadaada committed Apr 23, 2021
commit 38ee6a3ef1882536b7b18d7eab81f6088209a0a5
2 changes: 1 addition & 1 deletion python/triton/code_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ def __init__(self, module, kernel, num_warps, shared_mem, ir_asm):
self.num_warps = num_warps

def asm(self, mode):
if mode == 'ir':
if mode == 'ttir':
return self.ir_asm
if mode == 'ptx':
return self.module.ptx()
Expand Down
11 changes: 3 additions & 8 deletions python/tutorials/01-vector-add.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ def add(x, y):
# - torch.tensor objects are implicitly converted to pointers to their first element.
# - `triton.jit`'ed functions can be subscripted with a launch grid to obtain a callable GPU kernel
# - don't forget to pass meta-parameters as keywords arguments
kernel = _add[grid](x, y, z, N, BLOCK=1024)
_add[grid](x, y, z, N, BLOCK=1024)
# We return a handle to z but, since `torch.cuda.synchronize()` hasn't been called, the kernel is still
# running asynchronously.
return z, kernel
return z


# %%
Expand All @@ -68,16 +68,11 @@ def add(x, y):
x = torch.rand(size, device='cuda')
y = torch.rand(size, device='cuda')
za = x + y
zb, kernel = add(x, y)
zb = add(x, y)
print(za)
print(zb)
print(f'The maximum difference between torch and triton is ' f'{torch.max(torch.abs(za - zb))}')

# print asm
# print(kernel.asm('ir'))
# print(kernel.asm('ptx'))
# print(kernel.asm('llir'))

# %%
# Seems like we're good to go!

Expand Down