8

I know that Caffe uses GEneral Matrix to Matrix Multiplication (GEMM) which is part of Basic Linear Algebra Subprograms (BLAS) library for performing convolution operations. Where a convolution is converted to matrix multiplication operation. I have referred below article. https://petewarden.com/2015/04/20/why-gemm-is-at-the-heart-of-deep-learning/

I want to understand how other deep learning frameworks like Theano, Tensorflow, Pytorch perform convolution operations. Do they use similar libraries in the backend. There might be some articles present on this topic. If someone can point me to those or can explain with an answer.

PS: I posted the same question on datascience.stackexchange.com. As I didn't get a reply there, I am posting it here as well. If there is a better forum to post this question please let me know.

1 Answer 1

8

tensorflow has multiple alternatives for the operations.

for GPU, cuda support is used. Most of the operations are implemented with cuDNN, some use cuBLAS, and others use cuda.

You can also use openCL instead of cuda, but you should compile tensorflow by yourself.

for CPU, intel mkl is used as the blas library.

I'm not familiar with pytorch and theano, but some commonly used blas libraries are listed below:

  • cuDNN, cuBLAS, and cuda: nvidia GPU support, most popular library
  • openCL: common GPU support, I don't know about it at all.
  • MKL: CPU blas library provided by intel
  • openBLAS: CPU library
8
  • 2
    To add for PyTorch: The documentation mentions some specific BLAS/LAPACK operations, e.g. addbmm, and additionally, it is helpful to mention that some operations fall back t NumPy, which can have a configurable BLAS backend (e.g., the version shipped with Anaconda Python has natively Intel MKL enabled)
    – dennlinger
    Aug 13, 2018 at 6:35
  • @dennlinger: unless Kaihong Zhang updates his answer to integrate your comment, I'd say it is worth its own answer... :) Aug 13, 2018 at 9:11
  • I'm not so familiar with PyTorch, could you please add a new answer to explain it? @dennlinger Aug 13, 2018 at 10:32
  • 1
    I was going through this blog (goldsborough.me/cuda/ml/cudnn/c++/2017/10/01/…) on the implementation of convolution using cuDNN. It seems all the high-level deep learning libraries use cuDNN convolution function, which has three ways to implement convolution: CUDNN_CONVOLUTION_FWD_ALGO_GEMM (models convolution as an explicit matrix multiplication), CUDNN_CONVOLUTION_FWD_ALGO_FFT (uses a Fast Fourier Transform for the convolution) and CUDNN_CONVOLUTION_FWD_ALGO_WINOGRAD (employs the Winograd algorithm to perform the convolution). Aug 14, 2018 at 5:09
  • 2
    stackoverflow.com/questions/41518379/… says tensorflow uses 'Eigen' instead of blas. (Blas can be accelerated by cublas. and some frameworks can use cudnn, a higher level accelleration using cuda)
    – Chan Kim
    May 18, 2020 at 5:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.