wrongtest-intellif opened a new pull request, #12572:
URL: https://github.com/apache/tvm/pull/12572

   Hi, there. The change aims to improve customization experience of TIR 
lowering using annotations.
   
   Currently, we have `LowerOpaqueBlock` pass to convert s-tir(schedulable tir 
with blocks) to non-stir. All annotations are dropped then except those used by 
legacy TE pragma attributes, they are converted to legacy AttrStmt. For example:
   ```python
   # before
   for i in range(10, annotations={"pragma_myattr0": 1, "my_attr0": 1}): ....
   
   # after
   with T.attr(i, "pragma_myattr0", 1):
       for i in range(10): ....
   ```
   
   This introduce difficulties when we want to leverage schedule phase 
annotations in lowering phase.
   1. `pragma_` annotations are converted to legacy AttrStmt, which only 
accepts `PrimExpr` typed value. But the loop/block annotations before are 
originally much flexible, one could use list/dict to encode more rich compile 
time hints.
   2. Using `AttrStmt` loses the roundtrip property of TIR, thus we fail to 
write testcases of lowering pass with friendly before/after script comparations.
   3. It is more cohesive to encode annotations just with related IR node (like 
`ForNode`). Or else the developers always have to write separate logics 
handling attr node and for node.
   
   The change just add a pass configuration `"tir.LowerOpaqueBlock": 
{"preserved_annotations": List[str]}}`. For each annotation key value of loop 
or block:
   1. if key starts with `pragma_`, keep the original behaviour.
   2. if key is registered in `preserved_annotations` list, the annotation is 
preserved.
   3. or else it is dropped.
   
   The alternative may be preserve all annotations without any extra 
configuration. But I think current way take the least impact on overall 
lowering stream. If we do not add customized pass config into pass context, all 
things should be same.
   


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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to