torchsummaryX icon indicating copy to clipboard operation
torchsummaryX copied to clipboard

negative MAdds appear, shall update datatype of np.int32 to int64

Open canornot opened this issue 3 years ago • 0 comments

For large networks, negative MAdds appear. It's because the caculated macs exceed the data range at line 53:

param.nelement() returns python int64 but np.prod(info["out"][2:])) returns numpy np.int32

multiplication of these two gives np.int32, with maximum value limitation of 2,147,483,647

Shall update line 53 into info["macs"] += param.nelement() * int(np.prod(info["out"][2:]))

so that maximum limitation of both mulitpliers, as well as results are 9,223,372,036,854,775,807

canornot avatar May 10 '22 07:05 canornot