Publishing R5 content (#72)
[platform/upstream/dldt.git] / inference-engine / thirdparty / mkl-dnn / src / cpu / gemm_convolution_utils.hpp
1 /*******************************************************************************
2 * Copyright 2016-2018 Intel Corporation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *     http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *******************************************************************************/
16
17 #ifndef CPU_JIT_GEMM_CONVOLUTION_UTILS_HPP
18 #define CPU_JIT_GEMM_CONVOLUTION_UTILS_HPP
19
20 #include "c_types_map.hpp"
21 #include "cpu_convolution_pd.hpp"
22 #include "cpu_engine.hpp"
23 #include "jit_primitive_conf.hpp"
24 #include "mkldnn_thread.hpp"
25 #include "scratchpad.hpp"
26
27 namespace mkldnn {
28 namespace impl {
29 namespace cpu {
30
31 namespace jit_gemm_convolution_utils {
32
33     void im2col_3d(jit_gemm_conv_conf_t &jcp, const float *im, float *col,
34         int od);
35     void im2col(jit_gemm_conv_conf_t &jcp, const float *im, float *col);
36     template <typename T>
37     void im2col_u8(jit_gemm_conv_conf_t &jcp, const T *im, uint8_t *col);
38
39     void col2im_s32(jit_gemm_conv_conf_t &jcp, const int32_t *col, int32_t *im);
40     void col2im_3d(jit_gemm_conv_conf_t &jcp, const float *col, float *im,
41         int od);
42     void col2im(jit_gemm_conv_conf_t &jcp, const float *col, float *im);
43
44     void init_conf(jit_gemm_conv_conf_t &jcp,
45         const convolution_desc_t &cd, const memory_desc_wrapper &src_d,
46         const memory_desc_wrapper &weights_d, const memory_desc_wrapper &dst_d,
47         int max_threads, bool with_relu = false, float relu_negative_slope = -1.0);
48
49     status_t prepare_scratchpad(jit_gemm_conv_conf_t &jcp,
50                 scratchpad_t **col_scratchpad_, size_t size, const int nthr);
51
52     void bwd_weights_balance(int ithr, int nthr,
53         int ngroups, int mb, int &ithr_g, int &nthr_g, int &ithr_mb,
54             int &nthr_mb);
55     void bwd_weights_reduction_par(int ithr, int nthr,
56         const jit_gemm_conv_conf_t &jcp, const float *weights_reduce_ws,
57             float *weights);
58 };
59
60 }
61 }
62 }
63
64 #endif