trevor-m opened a new pull request #5320: [BYOC] Prevent duplicate outputs in subgraph Tuple URL: https://github.com/apache/incubator-tvm/pull/5320 This PR fixes an issue with the AnnotateTarget -> MergeCompilerRegions -> PartitionGraph flow. When the output of a subgraph is accessed multiple times by other nodes in the relay program, that output is duplicated in the subgraph function output tuple. Added test case `test_duplicate_outputs` as well. Test case before this fix: ``` def @test_duplicate_outputs_0(%test_duplicate_outputs_0_i0: Tensor[(10, 10), float32], Inline=1, Compiler="test_duplicate_outputs", global_symbol="test_duplicate_outputs_0", Primitive=1) -> (Tensor[(10, 10), float32], Tensor[(10, 10), float32], Tensor[(10, 10), float32]) { %0 = abs(%test_duplicate_outputs_0_i0) /* ty=Tensor[(10, 10), float32] */; (%0, %0, %0) } def @main(%data: Tensor[(10, 10), float32]) -> (Tensor[(10, 10), float32], Tensor[(10, 10), float32], Tensor[(10, 10), float32]) { %1 = @test_duplicate_outputs_0(%data) /* ty=(Tensor[(10, 10), float32], Tensor[(10, 10), float32], Tensor[(10, 10), float32]) */; %2 = %1.0; %3 = nn.relu(%2) /* ty=Tensor[(10, 10), float32] */; %4 = %1.1; %5 = tanh(%4) /* ty=Tensor[(10, 10), float32] */; %6 = %1.2; %7 = log(%6) /* ty=Tensor[(10, 10), float32] */; (%3, %5, %7) } ``` With this fix: ``` def @test_duplicate_outputs_0(%test_duplicate_outputs_0_i0: Tensor[(10, 10), float32], Inline=1, Compiler="test_duplicate_outputs", global_symbol="test_duplicate_outputs_0", Primitive=1) -> Tensor[(10, 10), float32] { abs(%test_duplicate_outputs_0_i0) /* ty=Tensor[(10, 10), float32] */ } def @main(%data: Tensor[(10, 10), float32]) -> (Tensor[(10, 10), float32], Tensor[(10, 10), float32], Tensor[(10, 10), float32]) { %0 = @test_duplicate_outputs_0(%data) /* ty=Tensor[(10, 10), float32] */; %1 = nn.relu(%0) /* ty=Tensor[(10, 10), float32] */; %2 = tanh(%0) /* ty=Tensor[(10, 10), float32] */; %3 = log(%0) /* ty=Tensor[(10, 10), float32] */; (%1, %2, %3) } ``` This is a separate issue from https://github.com/apache/incubator-tvm/pull/5310 which prevents a similar bug in which the input args to a subgraph are duplicated.
---------------------------------------------------------------- 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
