mbaret commented on issue #5409:
URL: https://github.com/apache/incubator-tvm/pull/5409#issuecomment-618290965


   The motivation for this is that when you have a supported operator, such as 
qnn.concatenate, which takes some constant inputs, those constant nodes are 
annotated as 'default'. So the operator itself goes into a target partition 
whereas the constants remain in the default partition and are then passed to 
the target partition as arguments.
   
   To see this, I can continue to run the test case through partition graph 
both with and without this change. Without the change:
   ```
   def @const_test_0(%const_test_0_i0: (Tensor[(10, 10), uint8], Tensor[(10, 
10), uint8]), %const_test_0_i1: (float32, float32), %const_test_0_i2: (int32, 
int32), Inline=1, Compiler="const_test", global_symbol="const_test_0", 
Primitive=1) -> Tensor[(10, 20), uint8] {
     qnn.concatenate(%const_test_0_i0, %const_test_0_i1, %const_test_0_i2, 0f 
/* ty=float32 */, 1 /* ty=int32 */, axis=1) /* ty=Tensor[(10, 20), uint8] */
   }
   
   def @main(%a: Tensor[(10, 10), uint8], %b: Tensor[(10, 10), uint8]) -> 
Tensor[(10, 20), uint8] {
     %0 = abs(%a) /* ty=Tensor[(10, 10), uint8] */;
     %1 = (%0, %b);
     %2 = (0f /* ty=float32 */, 0f /* ty=float32 */);
     %3 = (1 /* ty=int32 */, 1 /* ty=int32 */);
     @const_test_0(%1, %2, %3) /* ty=Tensor[(10, 20), uint8] */
   }
   ```
   
   With the change:
   ```
   def @const_test_0(%const_test_0_i0: (Tensor[(10, 10), uint8], Tensor[(10, 
10), uint8]), Inline=1, Compiler="const_test", global_symbol="const_test_0", 
Primitive=1) -> Tensor[(10, 20), uint8] {
     %0 = (0f /* ty=float32 */, 0f /* ty=float32 */);
     %1 = (1 /* ty=int32 */, 1 /* ty=int32 */);
     qnn.concatenate(%const_test_0_i0, %0, %1, 0f /* ty=float32 */, 1 /* 
ty=int32 */, axis=1) /* ty=Tensor[(10, 20), uint8] */
   }
   
   def @main(%a: Tensor[(10, 10), uint8], %b: Tensor[(10, 10), uint8]) -> 
Tensor[(10, 20), uint8] {
     %2 = abs(%a) /* ty=Tensor[(10, 10), uint8] */;
     %3 = (%2, %b);
     @const_test_0(%3) /* ty=Tensor[(10, 20), uint8] */
   }
   ```
   I'll add this as an explicit test case in the graph partition tests.
   
   The reason I've chosen to just omit the annotations for constants altogether 
is that the requirement for MergeCompilerRegions is that all dataflow paths are 
annotated. As constants are just data with no flow, they can be considered as 
part of the operator which consumes them for the purposes of the analysis done 
in that pass.


----------------------------------------------------------------
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]


Reply via email to