Created
June 8, 2020 11:11
-
-
Save BloodAxe/f9765d29bf7897e8f24b0e23ad988e6c 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
def test_loss_profiling(): | |
loss = nn.BCEWithLogitsLoss() | |
with torch.autograd.profiler.profile(use_cuda=True) as prof: | |
input = torch.randn((8, 1, 128, 128)).cuda() | |
input.requires_grad = True | |
target = torch.randint(1, (8, 1, 128, 128)).cuda().float() | |
for i in range(10): | |
l = loss(input, target) | |
l.backward() | |
print(prof.key_averages().table(sort_by="self_cpu_time_total")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment