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


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 =
        mod, target, params=params)


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?

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

In this example code :

Make the following changes :

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

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]?

Yes changing target to llvm should do it.

Also, sg is the output operation to be scheduled
example :

and the [A,B] parameters are the inputs required for that op to be carried out.
example :

k = tvm.reduce_axis((0, K), ‘k’)
A = tvm.placeholder((M, K), name=‘A’)
B = tvm.placeholder((K, N), name=‘B’)
C = tvm.compute( (M, N), lambda x, y: tvm.sum(A[x, k] * B[k, y], axis=k), name=‘C’)

s = tvm.create_schedule(C.op)

print(tvm.lower(s, [A, B, C], simple_mode=True))