IntelLabs / SkimCaffe

Caffe for Sparse Convolutional Neural Network
Other
238 stars 64 forks source link

winograd convolution (portable and fast in inference) #11

Open TaoHuUMD opened 7 years ago

TaoHuUMD commented 7 years ago

Dear developers, thanks for your contribution to this excellent program, here are parts of my work about winograd convolution for cpu inference.

Three files are added for cpu inference based on winograd convolution, winograd_inference.hpp, winograd_layer_inference. hpp, and winograd_layer_inference.cpp.

  1. Three winograd algrithms are supported, and WT8X8 with F(6x6, 3x3) are added to support cpu inference.
  2. Also, winograd2D_initialize() is provided, which supports precomputed and stored before runtime inference.
  3. Float calculations are supported for fast inference.

The new wiongrad interface is more portable for usage, and usages can be found in winograd_layer_inference.cpp.

Hope for a contribution. Thanks.

jspark1105 commented 7 years ago

Thanks for your contribution. I think your contribution on dense Winograd convolution can be more appreciated in the main caffe branch because SkimCaffe focuses on taking advantage of sparsity. Also, you may want to compare the performance/portability with Winograd implementation in libxsmm, which is already used in TensorFlow.

hfp commented 7 years ago

Regarding Joongso's comment on Winograd in LIBXSMM, I recommend to build the library and the sample code under samples/dnn and then execute for example:

WINOGRAD=1 ./run_googlenetv1.sh

This will run all GoogleNetv1 convolutions forcing the Winograd algorithm (even when not beneficial). The default as used by the DNN sample codes relies on direct convolutions. However, a real use case would be to rely on LIBXSMM_DNN_CONV_ALGO_AUTO rather then LIBXSMM_DNN_CONV_ALGO_DIRECT or LIBXSMM_DNN_CONV_ALGO_WINOGRAD. The environment variable WINOGRAD is simply to reuse the sample code programs for testing purpose.

All sample codes print performance measures, which can be used to compare with your implementation. Please note that you may want to use at least an AVX2-capable system since otherwise only fallback code paths are taken. Further, since we merged some code which partially broke our Winograd implementation (whoever ;-) you may want to take LIBXSMM/20d993e:

git clone https://github.com/hfp/libxsmm.git
git checkout 20d993e
imniksha commented 6 years ago

Hello,

Have you tried substituting a Winograd Layer in for the Convolution Layer in a CNN using SkimCaffe yet?

I am doing a comparative study between the two types of convolution and want to insert a Winograd Conv Layer instead of the conv layer in Lenet. I have tried with unsuccessful results.

Is this possible to do using SkimCaffe's winograd Layer? Could you please guide me to an example usage of the Winograd layer? I appreciate the help!

Thank you :)