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

Disable patch_tensor_ops for modules with custom_modules_hooks #139

Closed
Rikorose opened this issue Jul 3, 2024 · 2 comments · Fixed by #140
Closed

Disable patch_tensor_ops for modules with custom_modules_hooks #139

Rikorose opened this issue Jul 3, 2024 · 2 comments · Fixed by #140
Labels
bug Something isn't working

Comments

@Rikorose
Copy link

Rikorose commented Jul 3, 2024

I have some custom layers where I implemented the flop counting manually in custom_modules_hooks. This enables nice outputs during print_per_layer_stats so I know the flops and params for the corresponding layers in a larger model.

However, some ops are counted also in patch_tensor_ops which results in the final output being twice as large as printed in the per layer stats:

1604a6vh

Ideally, patch_tensor_ops is not applied in modules with a custom hook.

@sovrasov sovrasov added the bug Something isn't working label Jul 3, 2024
@sovrasov
Copy link
Owner

sovrasov commented Jul 3, 2024

Thanks for reporting this. patch_tensor_ops was an attempt to add support of transformers. Now, ptflops has aten backend to handle transformer, so I'll consider disabling patch_tensor_ops

@sovrasov
Copy link
Owner

After #140 you can pass backend_specific_config={'count_functional': False} to disable counting functionals, which would workaround your problem. Also, to use torch backend passing backend=FLOPS_BACKEND.PYTORCH is required, since the defauls backend now is aten.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants