Caffe2 - C++ API
A deep learning, cross platform ML framework
mkl_utils.h
1 
17 #ifndef CAFFE2_UTILS_MKL_UTILS_H_
18 #define CAFFE2_UTILS_MKL_UTILS_H_
19 
20 #include "caffe2/core/macros.h" // For caffe2 macros.
21 
22 #ifdef CAFFE2_USE_MKL
23 
24 #include "caffe2/mkl/utils/mkl_version_check.h"
25 
26 // MKLDNN_CHECK should be used in places where exceptions should not be thrown,
27 // such as in destructors.
28 #define MKLDNN_CHECK(condition) \
29  do { \
30  dnnError_t error = condition; \
31  CAFFE_ENFORCE_EQ( \
32  error, \
33  E_SUCCESS, \
34  "Error at : ", \
35  __FILE__, \
36  ":", \
37  __LINE__, \
38  ", error number: ", \
39  error); \
40  } while (0)
41 
42 #define MKLDNN_SAFE_CALL(condition) \
43  do { \
44  dnnError_t error = condition; \
45  CAFFE_ENFORCE_EQ( \
46  error, \
47  E_SUCCESS, \
48  "Error at : ", \
49  __FILE__, \
50  ":", \
51  __LINE__, \
52  ", error number: ", \
53  error); \
54  } while (0)
55 
56 #define CHECK_INPUT_FILTER_DIMS(X, filter, condition) \
57  do { \
58  if (cached_input_dims_ != X.dims() || \
59  cached_filter_dims_ != filter.dims()) { \
60  cached_input_dims_ = X.dims(); \
61  cached_filter_dims_ = filter.dims(); \
62  condition = true; \
63  } else { \
64  condition = false; \
65  } \
66  } while (0)
67 
68 #define CHECK_INPUT_DIMS(X, condition) \
69  do { \
70  if (cached_input_dims_ != X.dims()) { \
71  cached_input_dims_ = X.dims(); \
72  condition = true; \
73  } else { \
74  condition = false; \
75  } \
76  } while (0)
77 
78 // All caffe2 mkl related headers
79 
80 #ifdef CAFFE2_HAS_MKL_DNN
81 #include "caffe2/mkl/utils/mkl_context.h"
82 #include "caffe2/mkl/utils/mkl_dnn_cppwrapper.h"
83 #include "caffe2/mkl/utils/mkl_memory.h"
84 #include "caffe2/mkl/utils/mkl_operator.h"
85 #endif // CAFFE2_HAS_MKL_DNN
86 
87 #ifdef CAFFE2_HAS_MKL_SGEMM_PACK
88 #include "caffe2/mkl/utils/sgemm_pack.h"
89 #endif // CAFFE2_HAS_MKL_SGEMM_PACK
90 
91 #endif // CAFFE2_USE_MKL
92 #endif // CAFFE2_UTILS_MKL_UTILS_H_