I am trying to understand the internals of relay.build_module.build() function, and it looks like a complicated puzzle (sorry for my lack of experience) to me.
By my debugging I was able to solve some of this puzzle, and I know that “relay.build_module.build()” calls ScheduleGetter(target).Create(source_func) function inside the compile_enginee.cc. However, I am lost little bit lost in my debugging. My goal is to add my own custom (probably optimized) operator or template implementations in relay/tvm build. For that, I’d like to understand the whole flow in detail.
Could someone explain me what are the sequence of function calls from relay.build_module.build() all the way to code generation?
Could someone explain me how to dump IR of certain operators?
For my little experence, relay.build_module.build() is implement in function BuildRelay() of relay/backend/build_module.cc. BuildRelay() calls Optimize -> Lookup -> … GetLoweredFunc() . Then use tvm.build to get the final Module.
You can debug the process using tests/cpp/relay_build_module_test.cc.
I dont know if this will be helpfull to you , i am learning too.
I have able to trace from relay.build_module.build() to BuildRelay(). As you mentioned, I am (now) able to see that the BuildRelay() has two functionalities:
It does bunch of Optimization (calls Optimize() function)
It generates a code with “codegen”.
My question is when does the LLVM is called to generate the code lib(runtime lib)?
I assume LLVM is being called at some point after doing optimization in the TVM/Relay level, and at some point when it is ready to generate the code, the LLVM is called to generate the code. This is my understanding, and please correct me if I am wrong. So, I am wondering how the LLVM is being called and where it is being called at what stage (or point me some source code).