Information of C++ API and best way to learn TVM implementation

Recently I started to use TVM and recently gradually get to be used to using this project in python. On the other hand, in order to go to next step, I just want to understand the actual implementation of this framework such as how the executable libraries are generated, how to expand Halide IR inside and etc… In this way, I feel it would be better for me to use it from C++ because I can follow the code one by one, by using debugger, whereas it’s difficult to inspect the implementation from python due to the FFI. therefore, I’m looking for the C++ API now.

I found this post, and this is actually what I wanna know (sorry for it’s in japanese, but you can see the code)

however this sample codes might be already old, since it’s not compilable anymore. Now I have only an idea to get the information of what I desire is looking over the header files like tvm/tvm.h or tvm/build_module.h.

Is there any document about the C++ API usage??, and if you’d like, please tell me what is your best way to learn TVM’s actual implementation.

1 Like

This is a great point and it is true that we would need more tutorials for c++ API. contributions are more than welcomed

Thanks for your reply, and I understood that.
I’ll try to implement the C++ API by inspecting some header files.
Hopefully, I’m gonna commit the progress.

@tqchen
Now I’m writing some sample code in C++ to write small tutorial, however there is a problem.
I wrote the question in Lower function crash in C++ API
probably I don’t understand the C++ interface so well, so I’m stacking here.
could you tell me some intuition about this if you’d like?

There are some great starter code in cpp unit tests. It has coverage for some of the important modules(build, codegen, etc). I’m not sure how your build your code, you can simply run the following code to build all the cpp unittests:

# the only dependency is google test, but I find the build system broken for Mac so I installed google test myself just to work around
make cpptest -j

# or build a specific unit test
make build_module_test

As for your crash, if you look at the build_module_test.cc, what you need to do is:

  auto config = build_config();
  auto target = target::llvm();

I do feel like the cpp documentation is lacking as well and am willing to help improve. We don’t seem to even have instructions about how to build cpp tests. I figured it out by checking out travis build script.

1 Like

I tried to use above line in build_module_test.cc and it worked!
Many Thanks.
In fact I’ve started the same approach to see the codes in tests/cpp and run them with debuger.