What a depthwise factorisation saves
complexity▲▲△Exact integers and fractions where possible; six decimals otherwise.
STATEMENT
Compare a standard convolution with a depthwise-plus-pointwise replacement.
GIVEN
One example has 32 input channels, 64 output channels and a by output grid. The standard kernel is by . The replacement uses one depthwise by filter per input channel followed by a by pointwise layer to 64 channels. Ignore biases and nonlinearities in both cases.
FIND
Weights and multiply-accumulates for both designs, the cost ratio, and a reason why equal shapes do not make their function classes equal.
STRATEGY
Count the depthwise and pointwise weights separately, then multiply by the number of output positions.
SOLUTION
The standard layer has weights. The factorised version has depthwise weights and pointwise weights, for a total of .
Since , the main-product counts are
The ratio is
That is about times fewer main-product operations in this counting model, not a measured latency speedup.
Without an intervening nonlinearity, the effective kernel has the form . For each input channel, all output channels use scalar multiples of its same spatial filter. A general convolution does not impose this restriction.
Answer
Standard: 18,432 weights and 14,450,688 MACs. Factorised: 2,336 weights and 1,831,424 MACs. The smaller operation is a constrained model, not an exact replacement for every standard kernel.
Check — sanity
Both weight counts and MAC counts have the same ratio because the two designs use the same spatial grid. Biases and intermediate activations were explicitly excluded.
Where this breaks
Real runtime also depends on memory traffic, kernel efficiency and hardware. Adding a nonlinearity between the layers changes the function again; it does not remove the need to evaluate accuracy after replacement.
Variation
For spatial width and output width , the corresponding ratio is . At the extra depthwise layer does not create the same saving.