Caffe2 - C++ API
A deep learning, cross platform ML framework
sgemm_pack.h
1 #ifndef CAFFE2_UTILS_MKL_SGEMM_PACK_H_
2 #define CAFFE2_UTILS_MKL_SGEMM_PACK_H_
3 
4 #include "caffe2/core/logging.h"
5 
6 namespace caffe2 {
7 namespace mkl {
9  CBLAS_IDENTIFIER identifier_;
10  CBLAS_TRANSPOSE trans_;
11  int m_;
12  int n_;
13  int k_;
14  float alpha_;
15  int ld_;
16  float* data_ = nullptr;
17 
19  const CBLAS_IDENTIFIER identifier,
20  const CBLAS_TRANSPOSE trans,
21  const int m,
22  const int n,
23  const int k,
24  const float alpha,
25  const float* src,
26  const int ld)
27  : identifier_(identifier),
28  trans_(trans),
29  m_(m),
30  n_(n),
31  k_(k),
32  alpha_(alpha),
33  ld_(ld) {
34  data_ = cblas_sgemm_alloc(identifier, m, n, k);
35  CAFFE_ENFORCE(data_, "MKL runtime error: cannot allocate sgemm memory.");
36  cblas_sgemm_pack(
37  CblasRowMajor, identifier, trans, m, n, k, alpha, src, ld, data_);
38  }
39 
40  ~MKLPackedMatrix() {
41  if (data_) {
42  cblas_sgemm_free(data_);
43  }
44  }
45 };
46 
47 } // namespace mkl
48 } // namespace caffe2
49 
50 #endif // CAFFE2_UTILS_MKL_SGEMM_PACK_H_
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...