Add a section of how to link IE with CMake project (#99)
[platform/upstream/dldt.git] / inference-engine / thirdparty / mkl-dnn / src / cpu / jit_sse42_i8i8_pooling.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 CPU_JIT_uni_I8I8_POOLING_HPP
18 #define CPU_JIT_uni_I8I8_POOLING_HPP
19
20 #include "c_types_map.hpp"
21 #include "cpu_pooling_pd.hpp"
22 #include "cpu_engine.hpp"
23 #include "jit_generator.hpp"
24 #include "jit_primitive_conf.hpp"
25
26 namespace mkldnn {
27 namespace impl {
28 namespace cpu {
29
30 struct jit_sse42_i8i8_pool_fwd_ker_t;
31
32 struct jit_sse42_i8i8_pooling_fwd_t : public cpu_primitive_t {
33     struct pd_t : public cpu_pooling_fwd_pd_t {
34         pd_t(engine_t *engine, const pooling_desc_t  *adesc,
35                 const primitive_attr_t *attr,
36                 const pooling_fwd_pd_t  *hint_fwd_pd)
37         : cpu_pooling_fwd_pd_t(engine, adesc, attr, hint_fwd_pd) {}
38
39         DECLARE_COMMON_PD_T(
40                 JIT_IMPL_NAME_HELPER("jit:", sse42, ""),
41                 jit_sse42_i8i8_pooling_fwd_t);
42
43         virtual status_t init() override {
44             assert(this->engine()->kind() == engine_kind::cpu);
45             bool ok = true
46                 && desc()->src_desc.ndims == 4
47                 && set_default_params() == status::success
48                 && desc()->prop_kind == prop_kind::forward_inference
49                 && utils::one_of(desc()->alg_kind, alg_kind::pooling_max,
50                         alg_kind::pooling_avg_include_padding,
51                         alg_kind::pooling_avg_exclude_padding)
52                 && utils::one_of(src_pd()->desc()->data_type, data_type::s32,
53                         data_type::s8, data_type::u8)
54                 && src_pd()->desc()->data_type == dst_pd()->desc()->data_type
55                 && utils::everyone_is(memory_format::nhwc,
56                         src_pd()->desc()->format, dst_pd()->desc()->format)
57                 && attr()->has_default_values();
58             if (!ok) return status::unimplemented;
59
60             return jit_conf();
61         }
62
63         jit_pool_conf_t jpp_;
64
65     protected:
66         status_t jit_conf();
67
68         virtual status_t set_default_params() override {
69             using namespace memory_format;
70             if (dst_pd_.desc()->format == any)
71                 CHECK(dst_pd_.set_format(nhwc));
72             return status::success;
73         }
74     };
75
76     jit_sse42_i8i8_pooling_fwd_t(const pd_t *pd,
77             const input_vector &inputs, const output_vector &outputs);
78     ~jit_sse42_i8i8_pooling_fwd_t();
79
80     virtual void execute(event_t *e) const {
81         execute_forward();
82         e->set_state(event_t::ready);
83     }
84
85 private:
86     void execute_forward() const;
87     const pd_t *pd() const { return (const pd_t *)primitive_t::pd(); }
88
89     jit_sse42_i8i8_pool_fwd_ker_t *ker_;
90 };
91
92 }
93 }
94 }
95
96 #endif