Skip to content
DeepForgeby svx
All problems
EasyComputer Visioncv-265

Operator Fusion Pairs

Problem

Count the adjacent operator pairs that a graph optimizer can fuse.

A pair can be fused when it is (conv, bn), (bn, relu) or (conv, relu). Return the number of such adjacent pairs in the op list.

Test cases

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

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