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