Open ohjunee opened 11 months ago
The same as yours: Conv2d MACs =K*K*Cin*Cout*img*img_w
except if bias exists, then Conv2d MACs+=Cout
In my case, if bias exists,
Conv2d MACs+=Ch*Layers*Imgsz*Imgsz
K: Kernel Size
Ch: Channel (In_channels = Out_channels)
Imgsz: Image Size (Width = Height)
Layers: Number of layers (modules)
The MAC calculation for the above equation is almost similar to the macs value calculated through onnx-tool, and an error occurs by adding only the output channel as in the equation below.
Conv2d MACs+=Cout
Is it correct that the Cout in the above equation means the output channel number of layers number of input pixels?
Thank you for your help.
Sorry, I've made a mistake. Conv2D MACs+=Cout
is not correct. It should be MACs+=Cout*img_h*img_w*batch
, as you can find the formula code here
I know the MAC calculation method of Conv2d as follows.
Conv2d MACs =K*K*Cin*Cout*img*img_w
Kernel_size : K In channel: Cin Out channel: Cout Output Image: img_h*img_wHowever, the result I calculated has some error with the value obtained from the formula. I think this error value is an error for the Bias calculation (Add).
Calculate the MAC of the onnx model using the following formula. What formula is used to calculate the value of onnx_tool.Model(modelpath).graph.macs provided by onnx-tool?