Can tvm convert a python function to c++ code?

TVM is not designed to be a source to source translator. I would suggest looking at a tool like py2many.

If you wish to compile python to binary, there are other options, look at this question.