FLOPs Calculator
Calculate the floating point operations required for a model's forward pass.
About FLOPs Calculator
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
Worked example
With the default values below, FLOPs Calculator returns Total FLOPs of 262,144. Change any input above and every figure here is recalculated in your browser.
Inputs used
- Layer Typeone of Dense (Fully Connected), Conv2D
- Dense (Fully Connected)
- Input Dimension / Channelsaccepts 1–1,000,000
- 512
- Output Dimension / Channelsaccepts 1–1,000,000
- 256
- Kernel Sizeaccepts 1–64
- 3
- Output Feature Map Size (H×W)accepts 1–100,000
- 224
Results
- Total FLOPs
- 262,144
- GFLOPs
- 0.0003 GFLOPs
Step by step
- 1Dense: 2 × input_dim × output_dim= 262,144
- 2In GFLOPs: total FLOPs ÷ 1e9= 0.0003 GFLOPs
Assumptions and limits
- The result is derived only from the 5 inputs listed above. Anything not among them is not part of the calculation.
- In particular, this calculator does not take inflation, tax, fees or charges or compounding frequency into account.
- Figures are rounded for display to 4 decimal places, so totals built from several rounded parts can differ slightly from the unrounded arithmetic.
How these calculators are built and tested is described on the Methodology page. If a figure looks wrong, please report it.
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.
