How to build TVM with cblas (openblas)?

Hi. I found this other post related to Mac, which seems inapplicable to my case.

In order to build, I had to change the CMakeLists.txt:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 818e8b50ad..c939e5147a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -131,8 +131,9 @@ include_directories(SYSTEM ${COMPILER_RT_PATH})
 include_directories(SYSTEM ${PICOJSON_PATH})
 
 # initial variables
-set(TVM_LINKER_LIBS "")
-set(TVM_RUNTIME_LINKER_LIBS "")
+include(FindBLAS)
+set(TVM_LINKER_LIBS "-lcblas")
+set(TVM_RUNTIME_LINKER_LIBS "-lcblas")
 
 
 # Check if this is being run on its own or as a subdirectory for another project
@@ -628,7 +629,12 @@ if(USE_THREADS AND NOT BUILD_FOR_HEXAGON)
 endif()
 
 target_link_libraries(tvm PRIVATE ${TVM_LINKER_LIBS} ${TVM_RUNTIME_LINKER_LIBS})
-target_link_libraries(tvm_runtime PRIVATE ${TVM_RUNTIME_LINKER_LIBS})
+# Does this actually do anything?
+# https://stackoverflow.com/a/59848812
+target_link_libraries(tvm_runtime PRIVATE ${TVM_RUNTIME_LINKER_LIBS} ${BLAS_LIBRARIES})
+target_compile_options(tvm_runtime_objs PRIVATE ${BLAS_LINKER_FLAGS})
+target_link_libraries(tvm_runtime_objs ${BLAS_LIBRARIES})
+
 
 if(BUILD_FOR_HEXAGON AND DEFINED USE_HEXAGON_GTEST AND EXISTS ${USE_HEXAGON_GTEST})
   include(FetchContent)

(note that the Git commit is included in the header of the diff)

Currently, my system has:

clang 15.0.7-2
cmake 3.25.3-1
cnpy-git r53.4e8810b-2
gcc 12.2.1-2 (base-devel)
gcc-fortran 12.2.1-2
gcc-libs 12.2.1-2
glu 9.0.2-3
gtest 1.13.0-1
hdf5-openmpi 1.12.2-3
libbacktrace-git r75.cdb64b6-1
libgccjit 12.2.1-2
libopenmpt 0.6.9-1
llvm 15.0.7-2
llvm-libs 15.0.7-2
llvm11-libs 11.1.0-6
llvm14 14.0.6-3
llvm14-libs 14.0.6-3
mesa 22.3.6-1
mesa-utils 8.5.0-2
netcdf-openmpi 4.9.0-3
ocl-icd 2.3.1-1
openblas 0.3.21-4
opencl-headers 2:2022.09.30-1
opencl-mesa 23.0.1-2
openmp 15.0.7-1
openmpi 4.1.5-1
python-attrs 22.2.0-1
python-cloudpickle 2.2.0-5
python-decorator 5.1.1-2
python-llvmlite 0.39.1-1
python-numpy 1.24.2-1
python-psutil 5.9.4-1
python-scipy 1.10.1-1
python-scipy-docs 1.9.2-1
python-tornado 6.2.0-2
python-typing_extensions 4.5.0-1
python38 3.8.16-3
rkcommon 1.10.0-1
scotch 7.0.1-1
scotch 7.0.1-1
spirv-llvm-translator 15.0.0.r10+g78ad93b9-1
vulkan-intel 22.3.6-1

I hope that this helps. If somebody knows of a better way to do this, please, let me know. Thanks!

would be more than welcome if you’d modularize it a bit and send a PR :slight_smile:

Sorry, my CMake-foo is rather limited (thus welcoming alternatives). I also don’t have a Micro$oft GitHub account.