Description
PyTorch and Caffe2 use the following libraries as preferred for BLAS/LAPACK capabilities:
-
MKL - first preference in unified build system
-
Eigen - 2nd preference in unified build system, but first preference if ATen is not being compiled
-
PyTorch finds OpenBLAS, Accelerate, cblas if MKL is not found -- finding OpenBLAS is useful for PPC64
-
I have to explore what Caffe2 does if Eigen is not found
There are however additional subtelities.
MKL and Eigen are not used JUST for BLAS/LAPACK, but also for additional functionality:
- MKL for FFT, VML in pytorch
- Eigen for implementing caffe2 operators
Additionally, we also use fortran-blas interface in pytorch, cblas interface in Caffe2 (if not Eigen), and eigen::MatrixMap interface if Eigen is found and CAFFE2_USE_EIGEN_FOR_BLAS
is set.
Cleanup plan:
- separate what it means to detect MKL / Eigen from what it means to detect BLAS capabilities
- Find MKL at a single entry point across PyTorch, Caffe2, and if it's found, set a USE_BLAS="mkl" with BLAS_INCLUDE and BLAS_LIBRARIES variables set to MKL paths. This is in addition to setting MKL_FOUND
- [Should we] Find Eigen by default (unless USE_EIGEN=OFF (which we can set via setup.py) and use it for everything (building caffe2 operators etc.) except BLAS (i.e. only not set CAFFE2_USE_EIGEN_FOR_BLAS). If MKL was not found, use Eigen for BLAS as well cc: @Yangqing for guidance.
- On PPC64 and OSX, should we prefer OpenBLAS and Accelerate respectively (instead of Eigen) for the BLAS capabilities? cc: @Yangqing
cc @malfet @seemethere @walterddr @jianyuh @nikitaved @pearu @mruberry @heitorschueroff