MCPcopy Create free account
hub / github.com/OpenGVLab/HumanBench / count_conv2d

Function count_conv2d

PATH/helper/flops_helper.py:110–126  ·  view source on GitHub ↗
(m, x, y)

Source from the content-addressed store, hash-verified

108
109
110def count_conv2d(m, x, y):
111 cin = m.in_channels
112 cout = m.out_channels
113 kh, kw = m.kernel_size
114 out_h = y.size(2)
115 out_w = y.size(3)
116 batch_size = x[0].size(0)
117
118 kernel_ops = multiply_adds * kh * kw
119 bias_ops = 1 if m.bias is not None else 0
120
121 output_elements = batch_size * out_w * out_h * cout
122 total_ops = output_elements * kernel_ops * cin // m.groups + bias_ops * output_elements
123 m.total_ops = torch.Tensor([int(total_ops)])
124
125 total_params = kh * kw * cin * cout // m.groups + bias_ops * cout
126 m.total_params = torch.Tensor([int(total_params)])
127
128
129def count_bn(m, x, y):

Callers

nothing calls this directly

Calls 1

sizeMethod · 0.80

Tested by

no test coverage detected