-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Description
Sorry to change my mind again and again, and I will never use the term "finally". Making ideas is endless.
An IR Dumper #2288 , is more heavy-weighted than I supposed before.
I now decide to break this issue into 2 steps:
We already have Halide's IRPrinter to do a statical sanity check, and also the lowered IRs are too low-level to give good readability. Overall, what I want becomes something which is both runnable and gives full control to the IR body.
- The current Halide
IRPrinterhas bad support to the double-name thing.
This is because currently, TVM uses "unique pointer" to differentiate objects.
For example, these 2 tensors below share the same name, but they are essentially two different tensors.
However, if users use these 2 tensors to build a module, and see the lowered body, it will be extremely confusing.IRPrinterjust dumps these tensors without checking double-name.
a = tvm.placeholder(shape)
b = tvm.placeholder(shape)
Also, he current IRDump dumps results of each pass to files whose suffixes are .cc. I guess the point of doing this is to borrow the syntax highlight of .cc. However, the contents dumped have nothing to do with C, so I believe migrating the text format to Python, and using Python suffix will be better.
Thus,What's more, dumping IR as Python snippet will not suffice. Dumping a complete hybrid script function will be highly desirable.
Something which is both runnable and contains its source code is exactly whatmoduleis in TVM.
Finally, I decided to extend a hybrid module looks like this:
#sch is a schedule of abitary op node
with tvm.target.create('hybrid'): #this with stmt is required by special lower passes
module = tvm.build(sch, tvm_args) #a hybrid module is returned
hybrid_op = module(*tvm_args) #hybrid compilation
np_res = module(*np_args) #software emulation