Publishing R3
[platform/upstream/dldt.git] / inference-engine / thirdparty / mkl-dnn / src / cpu / cpu_roi_pooling_pd.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_ROI_POOLING_FWD_PD_HPP
18 #define CPU_ROI_POOLING_FWD_PD_HPP
19
20 #include <assert.h>
21
22 #include "c_types_map.hpp"
23 #include "roi_pooling_pd.hpp"
24 #include "cpu_engine.hpp"
25 #include "cpu_memory.hpp"
26 #include "cpu_primitive.hpp"
27 #include "type_helpers.hpp"
28 #include "utils.hpp"
29
30 namespace mkldnn {
31 namespace impl {
32 namespace cpu {
33
34 struct cpu_roi_pooling_fwd_pd_t: public roi_pooling_fwd_pd_t {
35     using cpu_memory_pd_t = cpu_memory_t::pd_t;
36
37     cpu_roi_pooling_fwd_pd_t(engine_t *engine, const roi_pooling_desc_t *adesc,
38             const primitive_attr_t *attr,
39             const roi_pooling_fwd_pd_t *hint_fwd_pd)
40         : roi_pooling_fwd_pd_t(engine, adesc, attr, hint_fwd_pd)
41         , num_src_(desc_.num_src)
42         , dst_pd_(engine_, &desc_.dst_desc)
43     {
44         for (int i = 0; i < num_src_; ++i) {
45             src_pds_.push_back(cpu_memory_pd_t(engine_, &desc_.src_desc[i]));
46         }
47     }
48
49     virtual ~cpu_roi_pooling_fwd_pd_t() {}
50
51     virtual const cpu_memory_pd_t *src_pd(int index = 0) const override {
52         return &src_pds_[index];
53     }
54
55     virtual const cpu_memory_pd_t *dst_pd(int index = 0) const override
56     { return index == 0 ? &dst_pd_ : nullptr; }
57
58     int num_src() {
59         return num_src_;
60     }
61
62 protected:
63     nstl::vector<cpu_memory_pd_t> src_pds_;
64     int num_src_;
65
66     cpu_memory_pd_t dst_pd_;
67
68     virtual status_t init() = 0;
69 };
70
71 }
72 }
73 }
74
75 #endif
76
77 // vim: et ts=4 sw=4 cindent cino^=l0,\:0,N-s