Publishing 2019 R1 content
[platform/upstream/dldt.git] / inference-engine / thirdparty / mkl-dnn / src / cpu / ref_roi_pooling.hpp
1 /*******************************************************************************
2 * Copyright 2016 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_REF_ROI_POOLING_FWD_HPP
18 #define CPU_REF_ROI_POOLING_FWD_HPP
19
20 #include <assert.h>
21
22 #include "c_types_map.hpp"
23 #include "cpu_roi_pooling_pd.hpp"
24 #include "cpu_engine.hpp"
25 #include "type_helpers.hpp"
26 #include "utils.hpp"
27
28 namespace mkldnn {
29 namespace impl {
30 namespace cpu {
31
32 template <impl::data_type_t data_type>
33 struct ref_roi_pooling_fwd_t: public cpu_primitive_t {
34     struct pd_t: public cpu_roi_pooling_fwd_pd_t {
35         pd_t(engine_t *engine, const roi_pooling_desc_t *adesc,
36                 const primitive_attr_t *attr,
37                 const roi_pooling_fwd_pd_t *hint_fwd_pd)
38         : cpu_roi_pooling_fwd_pd_t(engine, adesc, attr, hint_fwd_pd) {}
39
40         DECLARE_COMMON_PD_T("ref:any", ref_roi_pooling_fwd_t);
41
42         virtual status_t init() override {
43             using namespace prop_kind;
44             assert(engine()->kind() == engine_kind::cpu);
45             bool ok = true
46             && utils::one_of(desc()->prop_kind, forward_inference)
47             && utils::everyone_is(data_type, src_pd()->desc()->data_type,
48                                   dst_pd()->desc()->data_type);
49             if (!ok) return status::unimplemented;
50
51             return status::success;
52         }
53     };
54
55     ref_roi_pooling_fwd_t(const pd_t *apd, const input_vector &inputs,
56             const output_vector &outputs)
57         : cpu_primitive_t(apd, inputs, outputs) { }
58
59     typedef typename prec_traits<data_type>::type data_t;
60
61     ~ref_roi_pooling_fwd_t() { }
62
63     virtual void execute(event_t *e) const {
64         execute_forward_generic();
65         e->set_state(event_t::ready);
66     }
67     
68 private:
69     void execute_forward_generic() const;
70     const pd_t *pd() const { return (const pd_t *)primitive_t::pd(); }
71 };
72
73 }
74 }
75 }
76
77 #endif
78
79 // vim: et ts=4 sw=4 cindent cino^=l0,\:0,N-s