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

benchmark.Compare raises: TypeError: object of type 'NoneType' has no len() #63971

Open
ezyang opened this issue Aug 25, 2021 · 4 comments
Open
Labels
module: benchmark related to torch.utils.benchmark e.g. Timer module: error checking Bugs related to incorrect/lacking error checking triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module

Comments

@ezyang
Copy link
Contributor

ezyang commented Aug 25, 2021

Traceback (most recent call last):
  File "test.py", line 12, in <module>
    compare.print()
  File "/Users/ezyang/miniconda3/lib/python3.7/site-packages/torch/utils/benchmark/utils/compare.py", line 298, in print
    print(str(self))
  File "/Users/ezyang/miniconda3/lib/python3.7/site-packages/torch/utils/benchmark/utils/compare.py", line 278, in __str__
    return "\n".join(self._render())
  File "/Users/ezyang/miniconda3/lib/python3.7/site-packages/torch/utils/benchmark/utils/compare.py", line 305, in _render
    output.append(self._layout(group))
  File "/Users/ezyang/miniconda3/lib/python3.7/site-packages/torch/utils/benchmark/utils/compare.py", line 321, in _layout
    return table.render()
  File "/Users/ezyang/miniconda3/lib/python3.7/site-packages/torch/utils/benchmark/utils/compare.py", line 252, in render
    col_widths = [max(len(j) for j in i) for i in zip(*string_rows)]
  File "/Users/ezyang/miniconda3/lib/python3.7/site-packages/torch/utils/benchmark/utils/compare.py", line 252, in <listcomp>
    col_widths = [max(len(j) for j in i) for i in zip(*string_rows)]
  File "/Users/ezyang/miniconda3/lib/python3.7/site-packages/torch/utils/benchmark/utils/compare.py", line 252, in <genexpr>
    col_widths = [max(len(j) for j in i) for i in zip(*string_rows)]
TypeError: object of type 'NoneType' has no len()
(base) ezyang-mbp:~ ezyang$ cat test.py
import torch
import torch.utils.benchmark as benchmark

results = []
results.append(benchmark.Timer(
    stmt='2',
    label='foo',
    sub_label='bar',
).blocked_autorange(min_run_time=1))

compare = benchmark.Compare(results)
compare.print()

I know how to fix it (add description) but it shouldn't raise an uninterpretable error like this.

@ezyang
Copy link
Contributor Author

ezyang commented Aug 25, 2021

cc @robieta

@robieta
Copy link

robieta commented Aug 25, 2021

Yeah, the internals of Compare are kind of horrible. I should dust off #54010.

@ezyang ezyang added module: benchmark related to torch.utils.benchmark e.g. Timer triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module module: error checking Bugs related to incorrect/lacking error checking labels Aug 30, 2021
@matham
Copy link
Contributor

matham commented Apr 27, 2024

Did you figure out what the actual problem is/workaround?

@akihironitta
Copy link
Contributor

I remember I needed to provide a string to description as stated in the issue description.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module: benchmark related to torch.utils.benchmark e.g. Timer module: error checking Bugs related to incorrect/lacking error checking triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module
Projects
None yet
Development

No branches or pull requests

4 participants