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

Why are torch.mm and torch.bmm deleted in pytorch_ops.py #36

Open
wzk1015 opened this issue Aug 13, 2024 · 2 comments
Open

Why are torch.mm and torch.bmm deleted in pytorch_ops.py #36

wzk1015 opened this issue Aug 13, 2024 · 2 comments

Comments

@wzk1015
Copy link

wzk1015 commented Aug 13, 2024

When I use calculate_flops to calculate flops of a local model (e.g. openai/clip-vit-large-patch14-336 downloaded locally), the result is smaller than the FLOPs calculated manually (use the flops calculation from mmcv and add the self-attention flops).

I found that the modeling_clip.py in the huggingface transformers package use torch.bmm to calculate attention weights, but the torch.mm and torch.bmm are commented in _patch_tensor_methods in pytorch_ops.py. When I uncomment these lines, the result is consistent with my manual calculation.

Are there any reasons why they are deleted? From commit 4bcf54c it seems to fix the bug for calculate_flops_hf, but I suspect this introduces bugs to calculate_flops.

Maybe related to #26

@MrYxJ
Copy link
Owner

MrYxJ commented Aug 13, 2024 via email

@ChangeFWorld
Copy link

谢谢,MrYx已经收到您的邮件!

encounter the same bug. Any update?

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

No branches or pull requests

3 participants