We propose to implement an API to TVM that allows users to export the TIR representation of the generated kernels as json.
**Motivation** Json is a standard file format and can easily be processed in python, for example. A json interface allows to analyze the generated kernels target agnostic. For example, this works for both llvm and c targets. The goal that we have is to be able to extract the full TIR representation of the host module and all device modules regardless of the specific executor, target or runtime. In the case of the AOT executor pipeline, this would also contain the tvmgen_default___main__ function. This allows to reconstruct the graph topology of the neural network. For Graph executors, the graph can still be accessed via module.graph_json. **Proposed Implementation** We have already conducted some experiments with a JsonScriptPrinter class similar to the TVMScriptPrinter class in src/printer/tvmscript_printer.cc based on the discussion here: https://discuss.tvm.apache.org/t/why-c-unpacked-api-not-work-anymore/11845/19?u=sebastianboblestetas We use it in driver_api.cc in the build function like this:  We make it accessible in python via json = module.lib.get_json() We do not know how to best export the TIR representation of the device modules. We would add a new boolean tir configuration option “tir.tir_export_to_json” to make this export functionality optional. We think we can provide a working prototype within a few weeks but would appreciate feedback already now. @Khoi @MJKlaiber @UlrikHjort @areusch --- [Visit Topic](https://discuss.tvm.apache.org/t/export-tir-to-json/12329/1) to respond. You are receiving this because you enabled mailing list mode. To unsubscribe from these emails, [click here](https://discuss.tvm.apache.org/email/unsubscribe/ad7414c9b68f7bcc27f4bec4ecd3a06bf9c541b3379701916706cd8c6ba59ff0).