Skip to content
DeepForgeby svx
All problems
MediumDeep Learningdl-304

Structured Sparsity Speedup Bound

Problem

Compute the theoretical speedup from removing zeros: dense work divided by reduced work = total / nonzeros.

The signature is structured_sparsity_speedup(nonzeros, total). Return a float.

Hint

2:4 sparsity caps the theoretical speedup at 2x because half the weights remain.

Test cases

case 1
in: [2,4]
expected: 2
case 2
in: [1,2]
expected: 2
case 3
in: [3,4]
expected: 1.3333333333
case 4
in: [64,128]
expected: 2
Starter codePython
def structured_sparsity_speedup(nonzeros, total):
    # Your code here
    pass

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