Skip to content
Calcrivo

FLOPs Calculator

Calculate the floating point operations required for a dense or convolutional layer's forward pass.

Inputs

Only used for Conv2D (assumes a square kernel).

Only used for Conv2D. Assumes a square output feature map of this side length.

Total FLOPs

262,144

GFLOPs

0.0003GFLOPs

Step by step

  1. Dense: 2 × input_dim × output_dim

    2 × 512 × 256

    = 262,144

  2. In GFLOPs: total FLOPs ÷ 1e9

    262,144 ÷ 1e9

    = 0.0003 GFLOPs

How it works

FLOPs (floating point operations) measure the raw compute cost of a layer's forward pass. Each multiply-accumulate is typically counted as 2 FLOPs (one multiply, one add). For a dense layer, FLOPs = 2 × input_dim × output_dim. For a Conv2D layer, the same multiply-add is repeated at every output spatial location, giving FLOPs = 2 × kernel_h × kernel_w × in_channels × out_channels × output_h × output_w. Summing FLOPs across all layers estimates the total compute needed for one forward pass, which is useful for comparing model efficiency and estimating inference latency.

Formulas

Dense layer FLOPs

FLOPs = 2 * input_dim * output_dim

input_dim
Input dimension
output_dim
Output dimension

Conv2D layer FLOPs

FLOPs = 2 * kernel_h * kernel_w * in_channels * out_channels * output_h * output_w

kernel_h
Kernel height
kernel_w
Kernel width
in_channels
Input channels
out_channels
Output channels
output_h
Output feature map height
output_w
Output feature map width

Frequently Asked Questions

Why multiply by 2 in these formulas?

Each multiply-accumulate operation (multiply the inputs, then add to a running sum) is conventionally counted as 2 FLOPs — one for the multiplication and one for the addition.

How is this different from the Parameter Count Calculator?

Parameter count measures the number of learnable weights/biases (memory footprint), while FLOPs measure the number of arithmetic operations to compute one forward pass (compute cost). A layer can have few parameters but many FLOPs if it's applied repeatedly, as with convolutions.

Does this include the backward pass?

No, this calculates forward-pass FLOPs only. Training FLOPs are commonly approximated as about 3x forward FLOPs (1x forward + 2x backward) — see the Training Time Calculator, which uses a factor of 6x total including both passes.

How do I compute FLOPs for a full model?

Sum the FLOPs of every layer in the network's forward pass, using each layer's actual input/output dimensions in sequence.

You might also need