Created
December 21, 2020 22:30
-
-
Save sandeepkumar-skb/794600adc584c3aabc53475486c2ae96 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch | |
n = 1024 | |
x = torch.randn(n,n, device='cuda') | |
y = torch.randn(n,n, device='cuda') | |
num_iter = 100 | |
# Warmup | |
for _ in range(num_iter): | |
z = torch.matmul(x,y) | |
torch.cuda.synchronize() | |
start = torch.cuda.Event(enable_timing=True) | |
end = torch.cuda.Event(enable_timing=True) | |
start.record() | |
for _ in range(num_iter): | |
z = torch.matmul(x, y) | |
end.record() | |
end.synchronize() | |
duration = start.elapsed_time(end) | |
print("Duration: {:.4f} ms".format(duration)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment