Skip to content
DeepForgeby svx
All problems
EasyDeep Learningdl-287

ONNX Runtime Partition Count

Problem

Count the contiguous accelerator partitions when executing an ONNX graph: a new partition starts at a supported node that does not immediately follow the previously supported node. Sort the supported list first.

The signature is onnx_partition_count(num_nodes, supported). Return an integer.

Hint

Unsupported nodes force a fallback to CPU, splitting the accelerated graph.

Test cases

case 1
in: [5,[0,1,2]]
expected: 1
case 2
in: [5,[1,3]]
expected: 2
case 3
in: [4,[]]
expected: 0
case 4
in: [4,[0,1,2,3]]
expected: 1
case 5
in: [6,[3,4,0,5]]
expected: 2
Starter codePython
def onnx_partition_count(num_nodes, supported):
    # Your code here
    pass

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