[BYOC] Codegen, JSON, non-composite

Hi,

I am in the process of building a codegeneration for my own (currently abstract) accelerator. And finally got the graph annotation working correctly. My goal was to directly generate the instructions from its ISA during the codegeneration phase in TVMs BYOC flow, and adapt the runtime accordingly.

Is this a sensible approach, or should I just use a JSON representation between code generation and runtime, and create the instructions in the runtime? Compiling at runtime seems to do a lot of redo work, that does not has to be done multiple times, because the output is always the same.

EDIT: I looked into the JSON codegen, and the comments say, that it only supports composites? Can I extend it to also support my (non-composite) annotated nodes?

The decision of using JSON (or any customized) runtime or C source module is based on whether the generated code is GCC compilable. If you are going to generate assembly code in your ISA, and the assembly code needs to be compiled by your own compiler, then based on JSON runtime would be a better idea.

Although it’s based on JSON runtime, it doesn’t mean you have to generate JSON graphs. JSON is just a graph representation. In your case, you should use assembly code in your ISA to replace JSON format. You can refer to ARM Ethos-N support in this PR.

1 Like