Caffe2 - C++ API
A deep learning, cross platform ML framework
sgemm_pack.h
1 
17 #ifndef CAFFE2_UTILS_MKL_SGEMM_PACK_H_
18 #define CAFFE2_UTILS_MKL_SGEMM_PACK_H_
19 
20 #include "caffe2/core/logging.h"
21 
22 namespace caffe2 {
23 namespace mkl {
25  CBLAS_IDENTIFIER identifier_;
26  CBLAS_TRANSPOSE trans_;
27  int m_;
28  int n_;
29  int k_;
30  float alpha_;
31  int ld_;
32  float* data_ = nullptr;
33 
35  const CBLAS_IDENTIFIER identifier,
36  const CBLAS_TRANSPOSE trans,
37  const int m,
38  const int n,
39  const int k,
40  const float alpha,
41  const float* src,
42  const int ld)
43  : identifier_(identifier),
44  trans_(trans),
45  m_(m),
46  n_(n),
47  k_(k),
48  alpha_(alpha),
49  ld_(ld) {
50  data_ = cblas_sgemm_alloc(identifier, m, n, k);
51  CAFFE_ENFORCE(data_, "MKL runtime error: cannot allocate sgemm memory.");
52  cblas_sgemm_pack(
53  CblasRowMajor, identifier, trans, m, n, k, alpha, src, ld, data_);
54  }
55 
56  ~MKLPackedMatrix() {
57  if (data_) {
58  cblas_sgemm_free(data_);
59  }
60  }
61 };
62 
63 } // namespace mkl
64 } // namespace caffe2
65 
66 #endif // CAFFE2_UTILS_MKL_SGEMM_PACK_H_
Copyright (c) 2016-present, Facebook, Inc.