I’ve been studying TVM for quite a few weeks, still not crystal-clear about the relationship between these items: relay, tir, topi, te. I’ll try to summarize my understanding and please correct me in my description below. Thanks in advance.
- Relay
Relay is the replacement for NNVM, which is a graph optimization toolset. It works on tensor expressions (te, question: is relay te same as tir te?).
Input te is either extracted from imported trained neural network or manually constructed using relay.<op>, those are so-called Relay IR, a high-level IR.
There are certain attr are defined or extracted for each relay operator. These attributes are used to later match or find best implementations in topi using so-called FTVMStrategy.
- tir
Tir is low-level IR before “translating” to target-specific backends. E.g. if x86 is target, then tir is first mapped to llvm IR, then x86 codegen is called to generate target binary.
- topi
A bridge between Relay IR and tir. A repository of operator implementations, describing what to compute and how to compute (schedule). The FTVMSTrategy mechanism allows relay operator to be mapped to highest scored implementation.