RN there is already a few analysis in relay.
For example, quantize analyze for the best range, an WIP bitpack analyze for 
the correct layout, Partial Eval do a trivial analysis for functions id, ANF do 
analysis for scope...
One can even say that type inference is an analysis.
And annotations like stop_fusion is analysis as well.

RN there is two way to deal with analysis:
returning a data structure
special annotate node.

they both have their cons:
returning a data structure mean you have to keep track of the data structure 
throughout different part of compilation pipeline, and sometimes it is 
impossible (for example, DeDup, subst, ANF, does not maintain any additional 
datastructure whatsoever).
special annotation is very cumbersome to use, explode the program size in the 
amount of annotation added, and additionally, is immutable so is not suitable 
for iteration style passes.

This two also make it difficult to combine passes. For example, it is hard to 
combine pointer analysis with a control flow analysis to get better precision 
right now. the cons of datastructure approach/annotation approach will be 
exacerbated.
For example, now there is two (or more) data structure to maintain and pass to 
all the place, or annotation node number will also double... So an complex 
analysis pass will spend all time juggling all of the result around, instead of 
spending time on the core need (getting the result).

an example is the partial evaluator, 
https://github.com/dmlc/tvm/blob/master/src/relay/pass/partial_eval.cc#L1196, 
which has to track and thread withfuncid across the whole pass, accounting for 
the most complex component in that file, causing tons of segfault that I have 
to fix.

I propose we add a mutable HashMap from String -> Node to solve this problem. 
This also make analysis-preserving transformation easier (as now there is a 
standard format to save the analysis).
e.g. DeDup can look at the analyisis and simply copy them.

@jroesch 

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/dmlc/tvm/issues/3895

Reply via email to