Great, thank you for this! For posterity, I actually ended up using gperftools
, Google’s CPU profiling toolkit. It worked pretty well. To use it, I compiled TVM and linked in their libprofiler
:
@@ -297,6 +297,11 @@ target_link_libraries(tvm_topi tvm ${TVM_LINKER_LIBS} ${TVM_RUNTIME_LINKER_LIBS}
target_link_libraries(tvm_runtime ${TVM_RUNTIME_LINKER_LIBS})
target_link_libraries(nnvm_compiler tvm)
+target_link_libraries(tvm /usr/local/Cellar/gperftools/2.7/lib/libprofiler.dylib)
+target_link_libraries(tvm_topi /usr/local/Cellar/gperftools/2.7/lib/libprofiler.dylib)
+target_link_libraries(tvm_runtime /usr/local/Cellar/gperftools/2.7/lib/libprofiler.dylib)
+target_link_libraries(nnvm_compiler /usr/local/Cellar/gperftools/2.7/lib/libprofiler.dylib)
+
if (HIDE_PRIVATE_SYMBOLS AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(HIDE_SYMBOLS_LINKER_FLAGS "-Wl,--exclude-libs,ALL")
# Note: 'target_link_options' with 'PRIVATE' keyword would be cleaner
Then I ran the script, setting the variable CPUPROFILE
:
CPUPROFILE=script.out `pyenv which python3` script.py
Finally, open the outputted file with pprof
, their provided tool for parsing the results:
pprof `pyenv which python3` script.out
Using the web
command I was able to see a call graph. This was a very coarse way to profile, as it included profiling information on the compilation process in addition to information on the program that TVM generated and ran. However, it got me the information I needed!
Thanks all!