模型 flops 估算

🔮 Model FLOPs Estimator

Estimate forward-pass FLOPs from fully-connected and convolutional layer dimensions, to compare model architectures before training.

📐 计算公式 / 原理
卷积 FLOPs ≈ 2·H·W·C_in·C_out·K²;全连接 FLOPs ≈ 2·in·out;MACs ≈ FLOPs / 2
按输出特征图每个元素所需的乘加次数累计:卷积为 K²·C_in 次乘加、输出 HWC_out 个元素,乘 2 得 FLOPs。1 MAC = 1 次乘加 = 2 FLOPs,硬件标称算力多用 MACs,对比时要注意单位换算。

📐 计算公式与说明

卷积 FLOPs ≈ 2 × H × W × C_in × C_out × K²
全连接 FLOPs ≈ 2 × in × out

FLOPs 衡量模型计算量。

📚 深度解析:模型 flops 估算

💡 常见使用场景

卷积层算力
3×3 卷积, C_in=64,C_out=128, 特征图 56×56:FLOPs≈2×9×64×128×56×56≈4.66×10⁹ 次/样本。可见大特征图与多通道下卷积算力增长极快。

❓ 常见问题(FAQ)

FLOPs 越大模型越慢?
通常如此,但还受显存带宽与并行度影响;某些高 FLOPs 算子若访存密集会被带宽卡住,实际延迟需结合硬件实测。
训练 FLOPs 怎么算?
约为前向的 2~3 倍(反向含梯度计算),再乘训练 token 数;大模型的训练算力常用 Kaplan 缩放律直接由参数量与数据量估算。

Formula & Standard References

Item Formula / Note Source / Standard
Matmul counting an m-by-k times k-by-n matrix product costs about 2mnk floating point operations BLAS / cuBLAS convention
Parameter estimate inference FLOPs approximate twice the parameter count times the token count Kaplan et al. 2020 scaling laws
Unit FLOPs counts operations while FLOPS counts operations per second MLPerf benchmark rules

如何使用模型 flops 估算

  1. 按页面提示逐项填写或选择所需参数。
  2. 点击「计算」或「生成」按钮运行。
  3. 在结果区查看输出,可复制结果或导出使用。

参数说明

适用场景

全连接层 FLOPs≈2·in·out·batch·seq(乘加各算一次)。

常见问题

FLOPs 越大模型越慢?
通常如此,但还受显存带宽与并行度影响;某些高 FLOPs 算子若访存密集会被带宽卡住,实际延迟需结合硬件实测。
训练 FLOPs 怎么算?
约为前向的 2~3 倍(反向含梯度计算),再乘训练 token 数;大模型的训练算力常用 Kaplan 缩放律直接由参数量与数据量估算。