TOPI unit test coverage for ResNet18

We are interested to use TVM at the TOPI/TVM C++ interface level. I have built and ran the tests under TVM repo tests/cpp/. These tests cover some aspects of the library, but I didn’t see tests that computes actual results using TOPI operators. Do you have unit tests or example that shows this usage (from defining TOPI operator, building/compile, passing actual input data then validate)? It would be very useful to see for example how a convolution operator can created and ran without the Python front end. Specifically we are interested in the operators used in ResNet18.

Thanks,
Louis

Hi Louis, feel free to dig under tvm/topi/tests/python for some unit tests. Here is one instance of Conv2D in NCHW format: https://github.com/dmlc/tvm/blob/master/topi/tests/python/test_topi_conv2d_nchw.py#L41

Hopefully this addresses your question.

Hi Thierry, thanks for pointing to the conv2d example. Because I’m fairly new to TVM, I’m more looking for a C++ example to do these computations. Is there an example that shows how to actually run the built module with its packed function with some input data? The closest I found were


I’m still missing the piece on how to bind the TVM Vars and actual data values to pass into the built packed function.

Thanks,
Louis

Good question. I believe that the packed_func_test.cc test is a good starting point, it should give you examples on how to prepare arguments, and call packed functions that TVM generates in C++.

The getting started tutorial shows how to save/load a TVM module: https://docs.tvm.ai/tutorials/get_started.html#load-compiled-module

I hope this answers your question.

Hi Thierry, I’m specifically looking at the C++ API and can’t use Python. The packed_func_test.cc examples are showing how to use concrete data to do some compute, while the build_module_test.cc shows how to construct a compute graph using the TVM Var and Tensor objects. It’s not clear from these tests how to bind actual data to the TVM Var and Tensor objects to execute the PackedFunc. Maybe I’m missing something very simple. Could you please provide an example of that in C++?

Thanks,
Louis

I see what you need. I haven’t tried invoking a packed function from C++ but perhaps @tqchen can point you to an specific example.

if you are looking for executing things, take a look at https://docs.tvm.ai/deploy/ The short answer is that you can pass in DLTensor object into the PackedFunc as argument.

@tqchen thanks, I’m able to run the example and my separate test is also working.