1 /*******************************************************************************
2 * Copyright 2016-2018 Intel Corporation
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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 *******************************************************************************/
17 #ifndef CPU_JIT_GEMM_CONVOLUTION_UTILS_HPP
18 #define CPU_JIT_GEMM_CONVOLUTION_UTILS_HPP
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"
31 namespace jit_gemm_convolution_utils {
33 void im2col_3d(jit_gemm_conv_conf_t &jcp, const float *im, float *col,
35 void im2col(jit_gemm_conv_conf_t &jcp, const float *im, float *col);
37 void im2col_u8(jit_gemm_conv_conf_t &jcp, const T *im, uint8_t *col);
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,
42 void col2im(jit_gemm_conv_conf_t &jcp, const float *col, float *im);
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);
49 status_t prepare_scratchpad(jit_gemm_conv_conf_t &jcp,
50 scratchpad_t **col_scratchpad_, size_t size, const int nthr);
52 void bwd_weights_balance(int ithr, int nthr,
53 int ngroups, int mb, int &ithr_g, int &nthr_g, int &ithr_mb,
55 void bwd_weights_reduction_par(int ithr, int nthr,
56 const jit_gemm_conv_conf_t &jcp, const float *weights_reduce_ws,