Hi All,
I am also new to TVM and trying to add support for some operators in TVM. Here is my understanding in addition to what is already documented by @alopez_13. I will try to keep it short for now:
For any operator that you want to support in TVM and corresponding Frontend DL framework, there are three layers where we have to make changes:
- Relay layer
- Topi layer
- Front-end layer(tensorflow, keras etc.)
Relay layer - Explained already but crux is that here you describe the semantics of operator, like its inputs, its attributes(remember number of inputs need not necessarily be the same as number of atrributes), relation between the input types etc.
Relay layer is organized in two parts: Python and C++. The python hooks call the C++ counterpart. Sometimes or for some operators(many old existing operators if i can say) the actual operation implementation is completely present in Relay. It might be done in Python itself sometimes, but mostly for performance reason you would most of the time find the implementation in C++.
Relay layer is also used to register the operator and describe it and associate different information about the operator. For eg. attributes relation, compute function declaration etc. Mostly from the associated compute function(in C++), we called the topi C++ layer.
Topi layer - Here you register the operator in TOPI, the TVM operator inventory. Topi layer is again organized both in Python and C++ layer. But the relay layer(C++) would always call corresponding topi layer implementation for the actual compute. The topi python layer also internally calls the topi C++ layer for actual operator implementation code.
Front-end layer - For every Front-end framework supported in TVM, you will find a corresponding file in tvm which is already brilliantly explained by @alopez_13. But still let me talk briefly about it. We write our binding/conversion (DL Frontend operator to tvm operator) in respective front-end file(eg. python/tvm/relay/frontend/tensorflow.py). Now we write corresponding test cases to compare our TVM operator performance/accuracy with DL Frontend operator in test_forward.py for that Frontend(eg. tests/python/frontend/tensorflow/test_forward.py).
Also topi and relay layers have their own testing related files similar to Front-end testing.
Hope this is little useful. Sorry I did not care much to format my documentation, but please feel free to ask any doubts/questions you may have.
Thank you.
Regards,
Deepak