Producing a .so file when there are no lowered funcs

Using the new external codegen pathway, it’s possible to offload to an external compiler. If that external compiler produces some binary data as its output, then it must be serialized to disk. As far as I can tell, this happens in two ways:

If only part of the graph is offloaded and there are still some TVM functions to lower, the binary blob from the external compiler is turned into a .o file (devc.o) and linked with the TVM module .o to give a final .so file with all the modules inside.

If ALL of the graph is offloaded, there’s no TVM module to merge the binary blob into, and so the ‘export_library’ function doesn’t work. Instead you have to call ‘save’ on the particular module to serialize it to disk.

This behaviour isn’t ideal because it requires two different API mechanisms in order to accomplish the same thing. It would be much better if a .so could be produced in both cases so that we can have a standard way of handling serialization. I’m uncertain at the moment exactly how to go about this and would appreciate comments from anyone who understands this area. My only thoughts currently are to forcibly include a TVM ‘no op’ in the graph that does nothing but still triggers the production of TVM module.

I think it’s possible to modify export_library so that it can handle both cases. Will take a look and come up with some thoughts later on.