Get entire graph in C/LLVM output (not only lib)


#1

Hi,

I am using TVM to obtain either C or LLVM code. In any case, the suggested way (here and in the tutorials) is something like

graph, lib, params = relay.build_module.build(
        mod, target, params=params)

out_file.write(lib.get_source())

This however produces source code for single functions. As I understand, graph contains the information about how they are connected to each other. Is there any way of merging the two types of information, i.e. the implementation of functions from lib and the way they are used from graph?


#2

I used a hack in the tvm code to find the lower ‘c’ or ‘llvm’ code :

In this example code : https://docs.tvm.ai/tutorials/optimize/opt_gemm.html#sphx-glr-tutorials-optimize-opt-gemm-py

Make the following changes :

with tvm.target.cuda():
sg = topi.generic.schedule_reduce(g) print(tvm.lower(sg, [a, b], simple_mode=True))


#3

Hi,
thank you for your answer. Can you expand a bit what the different parameters are?
I am not working on CUDA (but changing the target should not be too difficult), g should be graph in my example? And what about [a,b]?