pytorch
092eeedc - [profier] Fix double printing of FLOPs (#56974)

Commit
3 years ago
[profier] Fix double printing of FLOPs (#56974) Summary: Call table() shouldn't modify the events Pull Request resolved: https://github.com/pytorch/pytorch/pull/56974 Test Plan: ``` import torch from torch import nn from torch.profiler import profile, record_function model = nn.Conv2d(8, 64, 3, padding=1) input = torch.randn(1, 8, 272, 272) with profile(record_shapes=True, with_flops=True) as prof: with record_function("model_inference"): model(input) events = prof.key_averages(group_by_input_shape=True) print(events.table()) print(events.table()) ``` ``` ---------------------------- ------------ ------------ ------------ ------------ ------------ ------------ --------------------------------------------- ------------ Name Self CPU % Self CPU CPU total % CPU total CPU time avg # of Calls Input Shapes GFLOPS/s ---------------------------- ------------ ------------ ------------ ------------ ------------ ------------ --------------------------------------------- ------------ aten::zeros 0.78% 68.000us 1.16% 101.000us 101.000us 1 [[], [], [], [], []] -- aten::empty 0.49% 43.000us 0.49% 43.000us 14.333us 3 [[], [], [], [], [], []] -- aten::zero_ 0.23% 20.000us 0.23% 20.000us 20.000us 1 [[1]] -- model_inference 13.67% 1.195ms 98.84% 8.639ms 8.639ms 1 [] -- aten::conv2d 0.42% 37.000us 85.13% 7.440ms 7.440ms 1 [[1, 8, 272, 272], [64, 8, 3, 3], [64], [], [ 91.645 aten::convolution 0.15% 13.000us 84.70% 7.403ms 7.403ms 1 [[1, 8, 272, 272], [64, 8, 3, 3], [64], [], [ -- aten::_convolution 0.48% 42.000us 84.55% 7.390ms 7.390ms 1 [[1, 8, 272, 272], [64, 8, 3, 3], [64], [], [ -- aten::mkldnn_convolution 83.47% 7.295ms 84.07% 7.348ms 7.348ms 1 [[1, 8, 272, 272], [64, 8, 3, 3], [64], [], [ -- aten::as_strided_ 0.31% 27.000us 0.31% 27.000us 27.000us 1 [[1, 64, 272, 272], [], [], []] -- ---------------------------- ------------ ------------ ------------ ------------ ------------ ------------ --------------------------------------------- ------------ Self CPU time total: 8.740ms ---------------------------- ------------ ------------ ------------ ------------ ------------ ------------ --------------------------------------------- ------------ Name Self CPU % Self CPU CPU total % CPU total CPU time avg # of Calls Input Shapes GFLOPS/s ---------------------------- ------------ ------------ ------------ ------------ ------------ ------------ --------------------------------------------- ------------ aten::zeros 0.78% 68.000us 1.16% 101.000us 101.000us 1 [[], [], [], [], []] -- aten::empty 0.49% 43.000us 0.49% 43.000us 14.333us 3 [[], [], [], [], [], []] -- aten::zero_ 0.23% 20.000us 0.23% 20.000us 20.000us 1 [[1]] -- model_inference 13.67% 1.195ms 98.84% 8.639ms 8.639ms 1 [] -- aten::conv2d 0.42% 37.000us 85.13% 7.440ms 7.440ms 1 [[1, 8, 272, 272], [64, 8, 3, 3], [64], [], [ 91.645 aten::convolution 0.15% 13.000us 84.70% 7.403ms 7.403ms 1 [[1, 8, 272, 272], [64, 8, 3, 3], [64], [], [ -- aten::_convolution 0.48% 42.000us 84.55% 7.390ms 7.390ms 1 [[1, 8, 272, 272], [64, 8, 3, 3], [64], [], [ -- aten::mkldnn_convolution 83.47% 7.295ms 84.07% 7.348ms 7.348ms 1 [[1, 8, 272, 272], [64, 8, 3, 3], [64], [], [ -- aten::as_strided_ 0.31% 27.000us 0.31% 27.000us 27.000us 1 [[1, 64, 272, 272], [], [], []] -- ---------------------------- ------------ ------------ ------------ ------------ ------------ ------------ --------------------------------------------- ------------ Self CPU time total: 8.740ms ``` Fixes https://github.com/pytorch/pytorch/issues/55606 Reviewed By: xuzhao9 Differential Revision: D28019925 Pulled By: ilia-cher fbshipit-source-id: 7e7d7ed496059caf917a3dd8dea2daaceb5db920
Author
Ilia Cherniavskii
Parents
Loading