8000 profile for torch.add(x, x) where x is a zero-sized tensor looks bogus · Issue #151829 · pytorch/pytorch · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
profile for torch.add(x, x) where x is a zero-sized tensor looks bogus #151829
Closed
@zou3519

Description

@zou3519
from torch.profiler import profile, record_function, ProfilerActivity

import torch

x = torch.randn(0)

with profile(activities=[ProfilerActivity.CPU], record_shapes=True) as prof:
    with record_function("model_inference"):
        x + x


print(prof.key_averages().table(sort_by="cpu_time_total", row_limit=10))

Gives:

In [7]: print(prof.key_averages().table(sort_by="cpu_time_total", row_limit=10))
-----------------------------  ------------  ------------  ------------  ------------  ------------  ------------
                         Name    Self CPU %      Self CPU   CPU total %     CPU total  CPU time avg    # of Calls
-----------------------------  ------------  ------------  ------------  ------------  ------------  ------------
                 aten::matmul         0.46%       8.994us        62.32%       1.213ms     606.382us             2
                    aten::dot        61.72%       1.201ms        61.86%       1.204ms     601.884us             2
              model_inference         6.61%     128.555us         8.13%     158.251us     158.251us             1
                     aten::to         1.04%      20.242us         5.30%     103.077us       3.221us            32
               aten::_to_copy         2.19%      42.586us         4.26%      82.835us       2.589us            32
                   aten::ones         2.08%      40.453us         2.87%      55.895us      13.974us             4
                    aten::add         2.32%      45.200us         2.59%      50.328us      12.582us             4
                    aten::abs         1.27%      24.757us         2.20%      42.744us      21.372us             2
             aten::__lshift__         0.67%      12.990us         1.76%      34.283us      34.283us             1
                    aten::pow         1.40%      27.282us         1.58%      30.817us      10.272us             3
-----------------------------  ------------  ------------  ------------  ------------  ------------  ------------

which seems really bizarre

cc @robieta @chaekit @guotuofeng @guyang3532 @dzhulgakov @davidberard98 @briancoutinho @sraikund16 @sanrise

Metadata

Metadata

Assignees

Labels

oncall: profilerprofiler-related issues (cpu, gpu, kineto)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0