Can you test your c++ code under c++ env without binding? (use libtorch)
The python apis and c++ apis actually hit the same underlying c++ code, the slowness is probably due to python binding for cpp extension.