masahi commented on issue #4570: [relay] Relay annotation and partitioning for external compilers URL: https://github.com/apache/incubator-tvm/pull/4570#issuecomment-569217109 For others who might be interested in this PR, here is a before/after of partitioning in test_multi_node_compiler(). Before ``` fn (%x: Tensor[(10, 10), float32], %w0: Tensor[(10, 10), float32], %w1: Tensor[(10, 10), float32], %w2: Tensor[(10, 10), float32], %w3: Tensor[(10, 10), float32], %w4: Tensor[(10, 10), float32], %w5: Tensor[(10, 10), float32], %w6: Tensor[(10, 10), float32], %w7: Tensor[(10, 10), float32]) -> Tensor[(30, 10), float32] { %0 = annotation.compiler_begin(%x, meta[relay.attrs.CompilerAttrs][0]) /* ty=Tensor[(10, 10), float32] */; %1 = annotation.compiler_begin(%w0, meta[relay.attrs.CompilerAttrs][1]) /* ty=Tensor[(10, 10), float32] */; %2 = add(%0, %1) /* ty=Tensor[(10, 10), float32] */; %3 = annotation.compiler_begin(%w1, meta[relay.attrs.CompilerAttrs][2]) /* ty=Tensor[(10, 10), float32] */; %4 = subtract(%2, %3) /* ty=Tensor[(10, 10), float32] */; %5 = annotation.compiler_begin(%w2, meta[relay.attrs.CompilerAttrs][3]) /* ty=Tensor[(10, 10), float32] */; %6 = multiply(%4, %5) /* ty=Tensor[(10, 10), float32] */; %7 = annotation.compiler_end(%6, meta[relay.attrs.CompilerAttrs][4]) /* ty=Tensor[(10, 10), float32] */; %8 = annotation.compiler_begin(%x, meta[relay.attrs.CompilerAttrs][5]) /* ty=Tensor[(10, 10), float32] */; %9 = annotation.compiler_begin(%w3, meta[relay.attrs.CompilerAttrs][6]) /* ty=Tensor[(10, 10), float32] */; %10 = add(%8, %9) /* ty=Tensor[(10, 10), float32] */; %11 = annotation.compiler_begin(%w4, meta[relay.attrs.CompilerAttrs][7]) /* ty=Tensor[(10, 10), float32] */; %12 = subtract(%10, %11) /* ty=Tensor[(10, 10), float32] */; %13 = annotation.compiler_begin(%w5, meta[relay.attrs.CompilerAttrs][8]) /* ty=Tensor[(10, 10), float32] */; %14 = multiply(%12, %13) /* ty=Tensor[(10, 10), float32] */; %15 = annotation.compiler_end(%14, meta[relay.attrs.CompilerAttrs][9]) /* ty=Tensor[(10, 10), float32] */; %16 = add(%x, %w6) /* ty=Tensor[(10, 10), float32] */; %17 = subtract(%16, %w7) /* ty=Tensor[(10, 10), float32] */; %18 = (%7, %15, %17); concatenate(%18) /* ty=Tensor[(30, 10), float32] */ } ``` After ``` def @main(%x: Tensor[(10, 10), float32], %w0: Tensor[(10, 10), float32], %w1: Tensor[(10, 10), float32], %w2: Tensor[(10, 10), float32], %w3: Tensor[(10, 10), float32], %w4: Tensor[(10, 10), float32], %w5: Tensor[(10, 10), float32], %w6: Tensor[(10, 10), float32], %w7: Tensor[(10, 10), float32]) -> Tensor[(30, 10), float32] { %2 = fn (%ccompiler_input0: Tensor[(10, 10), float32], %ccompiler_input1: Tensor[(10, 10), float32], %ccompiler_input2: Tensor[(10, 10), float32], %ccompiler_input3: Tensor[(10, 10), float32], Compiler="ccompiler", ExternalSymbol="ccompiler_0", Primitive=1) -> Tensor[(10, 10), float32] { %0 = add(%ccompiler_input0, %ccompiler_input1) /* ty=Tensor[(10, 10), float32] */; %1 = subtract(%0, %ccompiler_input2) /* ty=Tensor[(10, 10), float32] */; multiply(%1, %ccompiler_input3) /* ty=Tensor[(10, 10), float32] */ }; %3 = %2(%x, %w0, %w1, %w2) /* ty=Tensor[(10, 10), float32] */; %6 = fn (%ccompiler_input4: Tensor[(10, 10), float32], %ccompiler_input5: Tensor[(10, 10), float32], %ccompiler_input6: Tensor[(10, 10), float32], %ccompiler_input7: Tensor[(10, 10), float32], Compiler="ccompiler", ExternalSymbol="ccompiler_1", Primitive=1) -> Tensor[(10, 10), float32] { %4 = add(%ccompiler_input4, %ccompiler_input5) /* ty=Tensor[(10, 10), float32] */; %5 = subtract(%4, %ccompiler_input6) /* ty=Tensor[(10, 10), float32] */; multiply(%5, %ccompiler_input7) /* ty=Tensor[(10, 10), float32] */ }; %7 = %6(%x, %w3, %w4, %w5) /* ty=Tensor[(10, 10), float32] */; %8 = add(%x, %w6) /* ty=Tensor[(10, 10), float32] */; %9 = subtract(%8, %w7) /* ty=Tensor[(10, 10), float32] */; %10 = (%3, %7, %9); concatenate(%10) /* ty=Tensor[(30, 10), float32] */ } ```
---------------------------------------------------------------- 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
