I have an input tensor of shape $\mathbf{(3, 32, 32)}$ consisting of 3 channels, 16 rows, and 16 columns. I want to convolve the input tensor using $\mathbf{(3 \times 3)}$ kernel/filter. How can I calculate the required FLOPs?
Asked
Active
Viewed 464 times
1
-
FLOPs required to compute it – Mhasan502 Aug 11 '21 at 08:53
-
First, do you know what a FLOP is? – user253751 Aug 11 '21 at 08:54
-
Floating point operations – Mhasan502 Aug 11 '21 at 09:11
-
And do you know how to calculate the output? If you know how to calculate the output, you should be able to count the FLOPs in the calculation. – user253751 Aug 11 '21 at 09:13
-
I don't know how to. That's why I asked the question – Mhasan502 Aug 11 '21 at 09:14
-
How many output channels? – user253751 Aug 11 '21 at 09:16
-
It will be the same as the input. Three – Mhasan502 Aug 11 '21 at 09:31
1 Answers
1
Each output pixel channel is a 3x3x3 filter, so 27 inputs which get multiplied by 27 weights and then added together. This is 27 FMA (fused-multiply-add) operations, or 27 multiply operations and 26 additions. I believe all modern devices implement FMA.
The number of output pixel channels is 30x30x3 = 2700 (as a 3x3 kernel shaves off one pixel on each edge) and each one takes 27 operations to calculate. So that's 72900 operations in total.

user253751
- 922
- 3
- 11