updated readme file due to moving CMake scripts to the root folder
[platform/upstream/dldt.git] / inference-engine / thirdparty / mkl-dnn / src / cpu / gemm_inner_product_utils.hpp
1 /*******************************************************************************
2 * Copyright 2019 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_GEMM_INNER_PRODUCT_UTILS_HPP
18 #define CPU_GEMM_INNER_PRODUCT_UTILS_HPP
19
20 #include "c_types_map.hpp"
21 #include "cpu_inner_product_pd.hpp"
22 #include "cpu_engine.hpp"
23 #include "type_helpers.hpp"
24 #include "utils.hpp"
25 #include "jit_generator.hpp"
26 #include "jit_uni_eltwise.hpp"
27 #include "ref_eltwise.hpp"
28
29 namespace mkldnn {
30 namespace impl {
31 namespace cpu {
32
33 namespace inner_product_utils {
34
35 template <impl::data_type_t acc_type, impl::data_type_t dst_type>
36 class pp_kernel_t : jit_generator
37 {
38 public:
39     DECLARE_CPU_JIT_AUX_FUNCTIONS(gemm_x8s8s32x_inner_product_fwd_t::pp_kernel);
40     pp_kernel_t(const cpu_inner_product_fwd_pd_t *pd);
41     ~pp_kernel_t() {
42         if (do_eltwise_) {
43             delete eltwise_injector_;
44             delete ref_eltwise_;
45         }
46     }
47
48     typedef typename prec_traits<acc_type>::type acc_data_t;
49     typedef typename prec_traits<dst_type>::type dst_data_t;
50
51     void operator()(dst_data_t *dst, const acc_data_t *acc, const char *bias,
52             const float *scales, size_t start, size_t end);
53
54 private:
55     void generate();
56
57     struct ker_args {
58         dst_data_t *dst;
59         const acc_data_t *acc;
60         const char *bias;
61         const float *scales;
62         float nslope;
63         size_t len;
64         size_t oc_offset;
65     };
66     void (*ker_)(const ker_args *args);
67     jit_uni_eltwise_injector_f32<avx512_common> *eltwise_injector_;
68     ref_eltwise_scalar_fwd_t *ref_eltwise_;
69
70     size_t OC_;
71     data_type_t bias_data_type_;
72     size_t bias_data_type_size_;
73     size_t scale_idx_mult_;
74     round_mode_t rmode_;
75     bool do_bias_;
76     bool do_eltwise_;
77     post_ops_t::entry_t::eltwise_t eltwise_;
78 };
79
80 }
81
82 }
83 }
84 }
85
86 #endif