Publishing 2019 R1 content
[platform/upstream/dldt.git] / inference-engine / thirdparty / mkl-dnn / src / cpu / jit_avx512_common_lrn.hpp
1 /*******************************************************************************
2 * Copyright 2017-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_AVX512_COMMON_LRN_HPP
18 #define CPU_JIT_AVX512_COMMON_LRN_HPP
19
20 #include "c_types_map.hpp"
21 #include "cpu_lrn_pd.hpp"
22 #include "cpu_engine.hpp"
23 #include "jit_generator.hpp"
24
25 namespace mkldnn {
26 namespace impl {
27 namespace cpu {
28
29 struct jit_avx512_common_lrn_fwd_t: public cpu_primitive_t {
30     struct pd_t: public cpu_lrn_fwd_pd_t {
31         pd_t(engine_t *engine, const lrn_desc_t *adesc,
32                 const primitive_attr_t *attr, const lrn_fwd_pd_t *hint_fwd_pd)
33             : cpu_lrn_fwd_pd_t(engine, adesc, attr, hint_fwd_pd) {}
34
35         DECLARE_COMMON_PD_T(
36                 JIT_IMPL_NAME_HELPER("jit:", avx512_common, ""),
37                 jit_avx512_common_lrn_fwd_t);
38
39         virtual status_t init() override;
40     };
41
42     jit_avx512_common_lrn_fwd_t(const pd_t *apd, const input_vector &inputs,
43             const output_vector &outputs);
44     ~jit_avx512_common_lrn_fwd_t();
45
46     typedef typename prec_traits<data_type::f32>::type data_t;
47
48     virtual void execute(event_t *e) const {
49         execute_forward();
50         e->set_state(event_t::ready);
51     }
52
53 private:
54     void execute_forward() const;
55     const pd_t *pd() const { return (const pd_t *)primitive_t::pd(); }
56
57     int use_h_parallelism;
58     struct jit_avx512_common_lrn_kernel_f32;
59     jit_avx512_common_lrn_kernel_f32 *ker_, *ker_first_, *ker_last_;
60
61 };
62
63 struct jit_avx512_common_lrn_bwd_t: public cpu_primitive_t {
64     struct pd_t: public cpu_lrn_bwd_pd_t {
65         pd_t(engine_t *engine, const lrn_desc_t *adesc,
66                 const primitive_attr_t *attr, const lrn_fwd_pd_t *hint_fwd_pd)
67             : cpu_lrn_bwd_pd_t(engine, adesc, attr, hint_fwd_pd) {}
68
69         DECLARE_COMMON_PD_T(
70                 JIT_IMPL_NAME_HELPER("jit:", avx512_common, ""),
71                 jit_avx512_common_lrn_bwd_t);
72
73         virtual status_t init() override;
74     };
75
76     jit_avx512_common_lrn_bwd_t(const pd_t *apd, const input_vector &inputs,
77             const output_vector &outputs);
78     ~jit_avx512_common_lrn_bwd_t();
79
80     typedef typename prec_traits<data_type::f32>::type data_t;
81
82     virtual void execute(event_t *e) const {
83         execute_backward();
84         e->set_state(event_t::ready);
85     }
86
87 private:
88     void execute_backward() const;
89     const pd_t *pd() const { return (const pd_t *)primitive_t::pd(); }
90
91     int use_h_parallelism;
92     struct jit_avx512_common_lrn_kernel_f32;
93     jit_avx512_common_lrn_kernel_f32 *ker_, *ker_first_, *ker_last_;
94
95 };
96
97 }
98 }
99 }
100
101 #endif
102
103 // vim: et ts=4 sw=4 cindent cino^=l0,\:0,N-s