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

If I use a VSSM block in a model, how can I quickly calculate the FLOPs? #312

Open
batman47steam opened this issue Oct 5, 2024 · 3 comments

Comments

@batman47steam
Copy link

batman47steam commented Oct 5, 2024

I modified the code in flops.py and commented out the patch_embed in backbone_vssm in vmamba.py to calculate the FLOPs for a single VSSM block.
image
Will this give an accurate result for the FLOPs of a single VSSM block?

the output
image

@batman47steam batman47steam changed the title If I use a VSSM block in my new model, how can I quickly calculate the FLOPs? If I use a VSSM block in a model, how can I quickly calculate the FLOPs? Oct 5, 2024
@MzeroMiko
Copy link
Owner

I think its better using the functions FLOPs.fvcore_flop_count to count the whole new model you build,with unsupported operations printed.

FLOPs.fvcore_flop_count can be seen as an extended version of fvcore.flops_count which supports s6 operations in ss2d blocks.

@batman47steam
Copy link
Author

batman47steam commented Oct 9, 2024

Thank you for your reply; that was very helpful. I'd like to ask further about the impact of those unsupported operations on the final results. Can they be ignored?

@MzeroMiko
Copy link
Owner

For vmamba specific,the selective_scan operation is supported by our own implemented flops_count (so it should not appear in the unsupported list), the crossscantritonF is just a copy operation, so it has no effect on flops. For other operations,you can refer to networks without ss2d.

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

2 participants