FLOPs computation for layer_norm op. For layer_norm(input): equation: 1): WITHOUT epsilon flops = 7 * (numel)total number of elements in the input tensor. 2): WITH epsilon flops = 8 * (numel)total number of elements in the input tensor.
(input_shapes, attrs)
| 220 | |
| 221 | @register_flops("layer_norm") |
| 222 | def _layer_norm_flops(input_shapes, attrs): |
| 223 | """FLOPs computation for layer_norm op. |
| 224 | For layer_norm(input): |
| 225 | equation: |
| 226 | 1): WITHOUT epsilon flops = 7 * (numel)total number of elements in the input tensor. |
| 227 | 2): WITH epsilon flops = 8 * (numel)total number of elements in the input tensor. |
| 228 | """ |
| 229 | input = input_shapes.get('X')[0] |
| 230 | flops = prod(input) * 7 |
| 231 | if attrs.get('epsilon'): |
| 232 | flops += prod(input) |
| 233 | return flops |
| 234 | |
| 235 | |
| 236 | @register_flops("matmul") |