Add a section of how to link IE with CMake project (#99)
[platform/upstream/dldt.git] / inference-engine / thirdparty / mkl-dnn / src / cpu / gemm / gemm_utils.hpp
1 /*******************************************************************************
2 * Copyright 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 GEMM_UTILS_HPP
18 #define GEMM_UTILS_HPP
19
20 namespace mkldnn {
21 namespace impl {
22 namespace cpu {
23
24 namespace gemm_utils {
25
26 template <typename T, bool isTransA, bool isTransB>
27 struct gemm_traits {};
28
29 template <bool isTransA, bool isTransB>
30 struct gemm_traits<double, isTransA, isTransB> {
31     static constexpr int m = 8;
32     static constexpr int n = 6;
33     static constexpr int BM = 4032;
34     static constexpr int BN = isTransA ? 96 : 192;
35     static constexpr int BK = isTransB ? 96 : 512;
36 };
37
38 template <bool isTransA, bool isTransB>
39 struct gemm_traits<float, isTransA, isTransB> {
40     static constexpr int m = 16;
41     static constexpr int n = 6;
42     static constexpr int BM = 4032;
43     static constexpr int BN = isTransA ? 96 : 48;
44     static constexpr int BK = isTransB ? 96 : 256;
45 };
46
47 template <typename T>
48 using unroll_factor = gemm_traits<T, false, false>;
49
50 template <typename data_type>
51 void sum_two_matrices(
52         int m, int n, data_type *p_src, int ld_src, data_type *p_dst, int ld_dst);
53
54 void calc_nthr_nocopy_avx512_common(int m,
55         int n, int k, int nthrs, int *nthrs_m, int *nthrs_n, int *nthrs_k,
56         int *BM, int *BN, int *BK);
57
58 void calc_nthr_nocopy_avx(int m, int n, int k,
59         int nthrs, int *nthrs_m, int *nthrs_n, int *nthrs_k, int *BM, int *BN,
60         int *BK);
61
62 void partition_unit_diff(
63         int ithr, int nthr, int n, int *t_offset, int *t_block);
64
65 inline double saturate(double value, double min, double max);
66 };
67
68 }
69 }
70 }
71 #endif