Lyken17 / pytorch-OpCounter

Count the MACs / FLOPs of your PyTorch model.
MIT License
4.8k stars 522 forks source link

[WARN] Cannot find rule for <class 'torch.nn.modules.container.Sequential'>. Treat it as zero Macs and zero Params. #107

Open hitachinsk opened 3 years ago

hitachinsk commented 3 years ago

Hello, I'm not familiar with this excellent tool, I wanna implement a CNN model using pytorch, and this model may contain some Sequential objects, which include some submodels because I want to make my codes more readable.

However, when I test the FLOPS and parameters of my model, I encounter such warning [WARN] Cannot find rule for <class 'torch.nn.modules.container.Sequential'>. Treat it as zero Macs and zero Params. does it make some difference to the final result? I'm looking forward to your reply, thank you very much.

chenxlin222 commented 3 years ago

hello,have you resolved the problem?

hitachinsk commented 3 years ago

@chenxlin222 Sounds interesting, I will take a shot, thank you.

Wblossom commented 3 years ago

@hitachinsk Hi, have you resolved the problem? I met the same problem.

Jackyinuo commented 3 years ago

@hitachinsk I have met the same problem. have you resolved the problem?

sunruina2 commented 3 years ago

maybe same problem? flops, params = profile(xtr_net, inputs=(dense, fly_emb_lst),custom_ops={}) print(flops / 1000, ' / ', params / 1000)

[WARN] Cannot find rule for <class 'main.mio_dense_layer'>. Treat it as zero Macs and zero Params. [WARN] Cannot find rule for <class 'torch.nn.modules.container.Sequential'>. Treat it as zero Macs and zero Params. [WARN] Cannot find rule for <class 'main.simple_dense_network'>. Treat it as zero Macs and zero Params. [WARN] Cannot find rule for <class 'main.XtrModule'>. Treat it as zero Macs and zero Params. [WARN] Cannot find rule for <class 'torch.nn.modules.container.ModuleList'>. Treat it as zero Macs and zero Params. [WARN] Cannot find rule for <class 'torch.nn.modules.activation.Sigmoid'>. Treat it as zero Macs and zero Params. [WARN] Cannot find rule for <class 'main.simple_lhuc_network'>. Treat it as zero Macs and zero Params. [WARN] Cannot find rule for <class 'torch.nn.modules.activation.Softmax'>. Treat it as zero Macs and zero Params. [WARN] Cannot find rule for <class 'main.transformer_component'>. Treat it as zero Macs and zero Params. [WARN] Cannot find rule for <class 'main.mmoe_layer'>. Treat it as zero Macs and zero Params. [WARN] Cannot find rule for <class 'main.PositionalEmbedding'>. Treat it as zero Macs and zero Params. [WARN] Cannot find rule for <class 'main.SnackModuleInner'>. Treat it as zero Macs and zero Params. 0.0 / 0.0

yuyijie1995 commented 3 years ago

Have you solved it?

JiahaoHuang99 commented 3 years ago

I met the same prob. Have you solved it?

zhangqizky commented 3 years ago

same here, beg for solution.

Cassieyy commented 3 years ago

Beg for solution...

paleomoon commented 3 years ago

Same question, found an explanation at another tool, seems it's ok to a container.

ClarissaDHL commented 3 years ago

Hi, I met the same question. Have u sovled the problem?

Leojc commented 3 years ago

I think this warning doesn't affect the result. The submodules in the nn.Sequential are calculated. The warning info is a little misleading though.

Jasonx001 commented 3 years ago

If the rule does not generate computation, or it is not a part of your source architecture, just treat it as zero Macs and zero Params.

ironman1996 commented 2 years ago

I think this warning doesn't affect the result. The submodules in the nn.Sequential are calculated. The warning info is a little misleading though.

Actually it affects. With the warning, my network's macs and paras equal 0.

zyxjtu commented 2 years ago

Same question, found an explanation at another tool, seems it's ok to a container.

Excuse me, the calculate result of another tool is right? And you verify it's result? I'm looking forward to your reply, thank you very much.

zhangqizky commented 2 years ago

您的邮件已收到,我会尽快回复,谢谢。张琦

Cassieyy commented 2 years ago

您的邮件已收到哦我会及时处理哒~

paleomoon commented 2 years ago

@zyxjtu I didn't use the another, I just state the similar issues. Use this tool, and ignore the warning, it's ok.

Lyken17 commented 2 years ago

Hi there,

Could you try upgrade to the latest version and see the warning still continues?

bigdaronlee163 commented 2 years ago

I meet the same problem previously,for the FLOPs counter,I use [https://github.com/1adrianb/pytorch-estimate-flops](flops tool) and get the correct answer.

sunsq1024 commented 2 years ago

Hi there,

Could you try upgrade to the latest version and see the warning still continues? 到现在仍然有警告

zhangqizky commented 2 years ago

您的邮件已收到,我会尽快回复,谢谢。张琦

SebastianWang9 commented 2 years ago

I have same problems.Beg for solution...

zhangqizky commented 2 years ago

您的邮件已收到,我会尽快回复,谢谢。张琦

SebastianWang9 commented 2 years ago

您好,我已收到您的邮件,谢谢!

Cassieyy commented 2 years ago

您的邮件已收到哦我会及时处理哒~