Caffe2 - C++ API
A deep learning, cross platform ML framework
op_utils_cudnn.h
1 #ifndef CAFFE2_OPERATORS_CUDNN_OP_UTILS_H_
2 #define CAFFE2_OPERATORS_CUDNN_OP_UTILS_H_
3 
4 #include "caffe2/core/cudnn_wrappers.h"
5 
6 namespace caffe2 {
7 
8 // Earlier in the days Caffe sets the default cudnn workspace to 8MB. We bump
9 // it up to 64MB in Caffe2, as this enables the use of Winograd in many cases,
10 // something very beneficial to more recent CNN models.
11 static constexpr size_t kCONV_CUDNN_WORKSPACE_LIMIT_BYTES = 64 * 1024 * 1024;
12 
13 // Manually specified number of algorithms implemented in CuDNN.
14 // This does not have any performance implications, as we will always find the
15 // fastest algorithm; setting them to the right number of algorithms will enable
16 // us to best report the statistics when doing an exhaustive search, though.
17 #if CUDNN_VERSION_MIN(7, 0, 0)
18 // Note: Double each of these due to potential
19 // tensorcore + non-tensorcore versions
20 // which are treated as separate returned algos
21 static constexpr size_t kNUM_CUDNN_FWD_ALGS =
22  2 * CUDNN_CONVOLUTION_FWD_ALGO_COUNT;
23 static constexpr size_t kNUM_CUDNN_BWD_FILTER_ALGS =
24  2 * CUDNN_CONVOLUTION_BWD_FILTER_ALGO_COUNT;
25 static constexpr size_t kNUM_CUDNN_BWD_DATA_ALGS =
26  2 * CUDNN_CONVOLUTION_BWD_DATA_ALGO_COUNT;
27 #else
28 static constexpr size_t kNUM_CUDNN_FWD_ALGS = 7;
29 static constexpr size_t kNUM_CUDNN_BWD_FILTER_ALGS = 4;
30 static constexpr size_t kNUM_CUDNN_BWD_DATA_ALGS = 5;
31 #endif
32 
33 namespace {
34 template <typename ArrayOfcudnnConvolutionAlgoPerf_t>
35 inline void LogCuDNNPerfStats(
36  const ArrayOfcudnnConvolutionAlgoPerf_t& perf_stat,
37  int returned_algo_count) {
38  VLOG(1) << "Perf result: (algo: stat, time, memory)";
39  for (int i = 0; i < returned_algo_count; ++i) {
40  const auto& stat = perf_stat[i];
41  VLOG(1) << stat.algo << ": " << stat.status << " " << stat.time << " "
42  << stat.memory;
43  }
44 }
45 } // namespace
46 
47 // Easier indexing into force_algo_ vector,
48 // shared by CudnnConvTransposeOpBase and CudnnConvOpBase to force
49 // usage of a particular algortihm instead of searching
50 enum { ALGO_FWD = 0, ALGO_WGRAD = 1, ALGO_DGRAD = 2 };
51 
52 } // namespace caffe2
53 
54 #endif // CAFFE2_OPERATORS_CUDNN_OP_UTILS_H_
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...
Definition: blob.h:13