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

There was a bug with computing FLOPs in OpenPCdet #114

Open
M0NSTERCOCO opened this issue Jul 5, 2023 · 1 comment
Open

There was a bug with computing FLOPs in OpenPCdet #114

M0NSTERCOCO opened this issue Jul 5, 2023 · 1 comment
Labels
question Further information is requested

Comments

@M0NSTERCOCO
Copy link

When I use this function to compute FLOPs in OpenPCdet framework, it didn't work well.

Can I use this function this way?

    macs, params = get_model_complexity_info(model, (1,), as_strings=True,
                                           print_per_layer_stat=False, verbose=True)
    print('{:<30}  {:<8}'.format('Computational complexity: ', macs))
    print('{:<30}  {:<8}'.format('Number of parameters: ', params))
Traceback (most recent call last):
  File "test.py", line 219, in <module>
    main()
  File "test.py", line 209, in main
    stat(model,(3,224,224))
  File "/opt/conda/lib/python3.7/site-packages/torchstat/statistics.py", line 71, in stat
    ms.show_report()
  File "/opt/conda/lib/python3.7/site-packages/torchstat/statistics.py", line 64, in show_report
    collected_nodes = self._analyze_model()
  File "/opt/conda/lib/python3.7/site-packages/torchstat/statistics.py", line 57, in _analyze_model
    model_hook = ModelHook(self._model, self._input_size)
  File "/opt/conda/lib/python3.7/site-packages/torchstat/model_hook.py", line 24, in __init__
    self._model(x)
  File "/opt/conda/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
    return forward_call(*input, **kwargs)
  File "../pcdet/models/detectors/IASSD.py", line 13, in forward
    batch_dict = cur_module(batch_dict)
  File "/opt/conda/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
    return forward_call(*input, **kwargs)
  File "../pcdet/models/backbones_3d/IASSD_backbone.py", line 143, in forward
    batch_size = batch_dict['batch_size']
IndexError: too many indices for tensor of dimension 4
@sovrasov sovrasov added the question Further information is requested label Jul 13, 2023
@sovrasov
Copy link
Owner

Hi. ptflops is designed to support 2d images as test input, so input shape (1,) seems to be not quite correct. Which input shape is consumed by your model? Whatever it is, you could use input_constructor parameter to create an input tensor of any shape: #14. You can ignore the resolution parameter and hardcode the required shape in prepare_input()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants