Skip to content
DeepForgeby svx
All problems
MediumComputer Visioncv-357

3D Conv FLOPs

Problem

Count the multiply-accumulate floating point operations of a 3D convolution.

Each output element combines cin * kt * kh * kw inputs, and the factor 2 accounts for one multiply and one add. Return 2 * cin * cout * kt * kh * kw * t_out * h_out * w_out with bias excluded.

Hint

The kernel volume is kt * kh * kw; multiply by both channel counts and the output volume.

Test cases

case 1
in: [3,16,3,3,3,8,28,28]
expected: 16257024
case 2
in: [1,1,1,3,3,4,10,10]
expected: 7200
case 3
in: [64,64,3,3,3,2,14,14]
expected: 86704128
case 4
in: [2,4,2,2,2,3,5,5]
expected: 9600
Starter codePython
def conv3d_flops(cin, cout, kt, kh, kw, t_out, h_out, w_out):
    # Your code here
    pass

4 test cases · run your code against them in the editor