Skip to content
DeepForgeby svx
All problems
EasyDeep Learningdl-286

Operator Fusion Count

Problem

Count fused kernel groups in a graph. Each group starts with any operator and absorbs every following operator that is fusable (bn, relu, add, mul); a non-fusable operator always starts a fresh group.

The signature is operator_fusion_count(ops). Return the number of groups.

Hint

Fewer groups means fewer kernel launches and less memory traffic.

Test cases

case 1
in: [["conv"]]
expected: 1
case 2
in: [["conv","relu","relu"]]
expected: 1
case 3
in: [["conv","pool","relu"]]
expected: 2
case 4
in: [["relu","bn"]]
expected: 1
case 5
in: [["conv","bn","relu","pool","relu"]]
expected: 2
Starter codePython
def operator_fusion_count(ops):
    # Your code here
    pass

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