Publishing 2019 R1 content
[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 "memory_tracking.hpp"
22 #include "mkldnn_thread.hpp"
23
24 #include "cpu_convolution_pd.hpp"
25 #include "cpu_engine.hpp"
26 #include "jit_primitive_conf.hpp"
27
28 namespace mkldnn {
29 namespace impl {
30 namespace cpu {
31
32 namespace jit_gemm_convolution_utils {
33
34 void im2col_3d(const jit_gemm_conv_conf_t &jcp, const float *im, float *col,
35         int od);
36 void im2col(const jit_gemm_conv_conf_t &jcp, const float *__restrict im,
37        float *__restrict col, int hs, int hb, int ws, int wb);
38 template <typename T>
39 void im2col_u8(const jit_gemm_conv_conf_t &jcp, const T *__restrict im,
40         uint8_t *__restrict col);
41
42 void col2im_s32(const jit_gemm_conv_conf_t &jcp, const int32_t *__restrict col,
43         int32_t *__restrict im);
44 void col2im_3d(const jit_gemm_conv_conf_t &jcp, const float *col, float *im,
45         int od);
46 void col2im(const jit_gemm_conv_conf_t &jcp, const float *col, float *im);
47
48 status_t init_conf(jit_gemm_conv_conf_t &jcp,
49         memory_tracking::registrar_t &scratchpad, const convolution_desc_t &cd,
50         const memory_desc_wrapper &src_d, const memory_desc_wrapper &weights_d,
51         const memory_desc_wrapper &dst_d, int max_threads);
52
53 void bwd_weights_balance(int ithr, int nthr, int ngroups, int mb,
54         int &ithr_g, int &nthr_g, int &ithr_mb, 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
65 #endif