In the context of the command-line driver PR, it was possible to notice some issues in the way different ModuleNode subclasses - such as ONNXSourceModuleNode, StackVMModuleNode, LLVMModuleNode, etc. - behave, with regards to SaveToFile.
Example: LLVMModuleNode will fail in case you ask for an unsupported format, and give an error. Other classes like StackVMModuleNode will simply ignore the format you ask and give you a create a file (path from file_name) with binary serialization of the module.
This RFC intends to get a common understanding on what we should expect (or improve) from void SaveToFile(file_name, format).
Problem
Based on the context above, it was possible to identify two related problems:
- P1: Different classes will behave differently for the requested formats
- P2: It is impossible to know beforehand, which formats are supported by each class
Proposed Solutions
To solve P2, we can (1) implement a new attribute for the ModuleNode class, that reports what are the expected formats that ModuleNode supports, as a list of strings, and (2) provide a Python API for the supported formats to be retrieved, as a list.
Addressing P1 then consists of improving ModuleNode.SaveToFile then should only accept format that are on that supported list, and fail with error in case there is a legitimate issue generating the file or in case the format is not supported.
Some rework will be needed on existing classes to make this uniform among different ModuleNode implementations.
Final Remarks
I think this is fairly small topic, but wanted to open this discussion as this will affect existing Module implementations.
cc @comaniac, @tqchen, @ramana-arm
