Skip to content
DeepForgeby svx
All problems
EasyDeep Learningdl-414

Forward FLOPs Per Token

Problem

Estimate forward-pass FLOPs per token with the 2N rule: each of the num_params parameters participates in one multiply-add (2 FLOPs) per token.

The signature is forward_flops_per_token(num_params). Return an integer number of FLOPs.

Hint

One multiply and one add per parameter equals two floating point operations.

Test cases

case 1
in: [7000000000]
expected: 14000000000
case 2
in: [0]
expected: 0
case 3
in: [125000000]
expected: 250000000
case 4
in: [1]
expected: 2
Starter codePython
def forward_flops_per_token(num_params):
    # Your code here
    pass

4 test cases · run your code against them in the editor