C++ TVM Example

Hello, I have just started learning about TVM. I am finding a hard time trying to write a simple C++ example of running a TVM flow. What I want to do is the following:

  1. Load an IR from Text
  2. Run some optimizations
  3. Generate C code

Bonus: Run the auto scheduler and tuner (if possible).

I am struggling to do number 3, this is my code so Far:

This is my example Relay IR that I am testing: #[version = “0.0.5”] def @main(%x: Tensor[(1, 3, 224, 224), float32]) { let %a1 = multiply(%x, 2.0f); let %b1 = add(%a1, 0.0f); let %c1 = multiply(%b1, 1.0f); let %d1 = add(%c1, %c1); nn.relu(%d1) }

This is my current code:

 std::string inputPath = TEST_DATA_DIR + std::string{"add.ir"};
std::ifstream t(inputPath);
std::stringstream buffer;
buffer << t.rdbuf();

auto mod = tvm::IRModule::FromText(buffer.str(), inputPath);

// Apply optimization pass
auto optMod = tvm::relay::transform::Sequential({
  tvm::relay::transform::EliminateCommonSubexpr(),
  tvm::relay::transform::FoldConstant(),
  tvm::relay::transform::DeadCodeElimination(),
  tvm::relay::transform::SimplifyInference(),
  tvm::relay::transform::SimplifyExpr(),
})(mod);

std::cout << optMod << std::endl;

I cant figure out now how to generate C code from this. I assume I need to lower it to TIR so that I can then specify a target and generate code for it?

Does anyone have any recommendations on where to find more documentation and examples in C++?

One other flow would be to instead of manually running these optimizations to also run the auto scheduler.

Thanks!