mbaret opened a new pull request #5100: [DRAFT][BYOC] Add support for multiple outputs to the graph partitioning flow URL: https://github.com/apache/incubator-tvm/pull/5100 This PR makes changes to the GraphPartition pass to support producing functions with multiple outputs as well as introducing a new pass, MergeSupported, to handle the merging of supported operators into legal partitions. It is only a draft to demonstrate the progress we are making in this area. Our goal is to implement the design described in the RFC here: (). We will contribute these components as separate PRs once the design has been agreed upon. To illustrate what happens, here is a graph before and after the partitioning flow ('add' is supported by the 'test' target, whereas 'subtract' is not): ``` def @main(%in_1: Tensor[(10, 10), float32], %in_2: Tensor[(10, 10), float32], %in_3: Tensor[(10, 10), float32], %in_4: Tensor[(10, 10), float32], %in_5: Tensor[(10, 10), float32], %in_6: Tensor[(10, 10), float32], %in_7: Tensor[(10, 10), float32], %in_8: Tensor[(10, 10), float32], %in_9: Tensor[(10, 10), float32], %in_10: Tensor[(10, 10), float32]) -> Tensor[(10, 10), float32] { %0 = add(%in_1, %in_2) /* ty=Tensor[(10, 10), float32] */; %1 = add(%in_3, %in_4) /* ty=Tensor[(10, 10), float32] */; %2 = add(%0, %1) /* ty=Tensor[(10, 10), float32] */; %3 = subtract(%in_5, %in_6) /* ty=Tensor[(10, 10), float32] */; %4 = subtract(%in_7, %3) /* ty=Tensor[(10, 10), float32] */; %5 = add(%2, %4) /* ty=Tensor[(10, 10), float32] */; %6 = subtract(%in_8, %5) /* ty=Tensor[(10, 10), float32] */; %7 = add(%in_9, %5) /* ty=Tensor[(10, 10), float32] */; %8 = add(%6, %7) /* ty=Tensor[(10, 10), float32] */; add(%in_10, %8) /* ty=Tensor[(10, 10), float32] */ } ``` ``` def @test_4(%test_4_i5: Tensor[(10, 10), float32], %test_4_i0: Tensor[(10, 10), float32], %test_4_i1: Tensor[(10, 10), float32], %test_4_i2: Tensor[(10, 10), float32], %test_4_i3: Tensor[(10, 10), float32], %test_4_i4: Tensor[(10, 10), float32], Inline=1, Compiler="test", ExternalSymbol="test_4", Primitive=1) -> (Tensor[(10, 10), float32], Tensor[(10, 10), float32]) { %0 = add(%test_4_i0, %test_4_i1) /* ty=Tensor[(10, 10), float32] */; %1 = add(%test_4_i2, %test_4_i3) /* ty=Tensor[(10, 10), float32] */; %2 = add(%0, %1) /* ty=Tensor[(10, 10), float32] */; %3 = add(%2, %test_4_i4) /* ty=Tensor[(10, 10), float32] */; %4 = add(%test_4_i5, %3) /* ty=Tensor[(10, 10), float32] */; (%4, %3) } def @default_1(%default_1_i0: Tensor[(10, 10), float32], %default_1_i1: Tensor[(10, 10), float32], Inline=1, Compiler="default", ExternalSymbol="default_1", Primitive=1) -> Tensor[(10, 10), float32] { subtract(%default_1_i0, %default_1_i1) /* ty=Tensor[(10, 10), float32] */ } def @test_0(%test_0_i0: Tensor[(10, 10), float32], %test_0_i1: Tensor[(10, 10), float32], %test_0_i2: Tensor[(10, 10), float32], Inline=1, Compiler="test", ExternalSymbol="test_0", Primitive=1) -> Tensor[(10, 10), float32] { %5 = add(%test_0_i1, %test_0_i2) /* ty=Tensor[(10, 10), float32] */; add(%test_0_i0, %5) /* ty=Tensor[(10, 10), float32] */ } def @default_3(%default_3_i0: Tensor[(10, 10), float32], %default_3_i1: Tensor[(10, 10), float32], %default_3_i2: Tensor[(10, 10), float32], Inline=1, Compiler="default", ExternalSymbol="default_3", Primitive=1) -> Tensor[(10, 10), float32] { %6 = subtract(%default_3_i1, %default_3_i2) /* ty=Tensor[(10, 10), float32] */; subtract(%default_3_i0, %6) /* ty=Tensor[(10, 10), float32] */ } def @main(%in_1: Tensor[(10, 10), float32], %in_2: Tensor[(10, 10), float32], %in_3: Tensor[(10, 10), float32], %in_4: Tensor[(10, 10), float32], %in_5: Tensor[(10, 10), float32], %in_6: Tensor[(10, 10), float32], %in_7: Tensor[(10, 10), float32], %in_8: Tensor[(10, 10), float32], %in_9: Tensor[(10, 10), float32], %in_10: Tensor[(10, 10), float32]) -> Tensor[(10, 10), float32] { %7 = @default_3(%in_7, %in_5, %in_6) /* ty=Tensor[(10, 10), float32] */; %8 = @test_4(%in_9, %in_1, %in_2, %in_3, %in_4, %7) /* ty=(Tensor[(10, 10), float32], Tensor[(10, 10), float32]) */; %9 = %8.1; %10 = @default_1(%in_8, %9) /* ty=Tensor[(10, 10), float32] */; %11 = %8.0; @test_0(%in_10, %10, %11) /* ty=Tensor[(10, 10), float32] */ } ``` This is the same example as demonstrated here [https://discuss.tvm.ai/t/relay-improved-graph-partitioning-algorithm/5830 ](https://discuss.tvm.ai/t/relay-improved-graph-partitioning-algorithm/5830).
---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
