Publishing 2019 R1 content
[platform/upstream/dldt.git] / inference-engine / thirdparty / mkl-dnn / src / cpu / cpu_reorder_pd.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_REORDER_PD_HPP
18 #define CPU_REORDER_PD_HPP
19
20 #include <assert.h>
21
22 #include "c_types_map.hpp"
23 #include "reorder_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_reorder_pd_t: public reorder_pd_t {
35     using cpu_memory_pd_t = cpu_memory_t::pd_t;
36
37     cpu_reorder_pd_t(const cpu_memory_pd_t *input_pd,
38             const cpu_memory_pd_t *output_pd, const primitive_attr_t *attr)
39         : reorder_pd_t(input_pd->engine(), attr)
40         , input_pd_(*input_pd), output_pd_(*output_pd) {}
41     virtual ~cpu_reorder_pd_t() {}
42
43     virtual status_t init() {
44         const auto &post_ops = attr()->post_ops_;
45         bool args_ok = true
46             && IMPLICATION(post_ops.len_ != 0,
47                     post_ops.len_ == 1
48                     && post_ops.entry_[0].kind == primitive_kind::sum);
49         return args_ok ? success : unimplemented;
50     }
51
52     virtual const cpu_memory_pd_t *input_pd(int index = 0) const override
53     { return index == 0 ? &input_pd_ : nullptr; }
54     virtual const cpu_memory_pd_t *output_pd(int index = 0) const override
55     { return index == 0 ? &output_pd_ : nullptr; }
56
57 protected:
58     cpu_memory_pd_t input_pd_, output_pd_;
59 };
60
61 }
62 }
63 }
64
65 #endif
66
67 // vim: et ts=4 sw=4 cindent cino^=l0,\:0,N-s