All problems
Mobile Block FLOPs
Problem
Count the multiply-accumulate FLOPs of a MobileNetV2-style block at a given spatial size.
Add 2*h*w*cin*expand for the pointwise expansion, 2*h*w*expand*k*k for the depthwise kernel and 2*h*w*expand*cout for the projection. Return the integer total.
Test cases
case 1
in: [4,4,3,6,2,3]
expected: 2688
case 2
in: [1,1,1,1,1,1]
expected: 6
case 3
in: [7,7,8,2,8,3]
expected: 4900
Starter codePython
def mobile_block_flops(h, w, cin, expand, cout, k):
# Your code here
pass3 test cases · run your code against them in the editor