updated readme file due to moving CMake scripts to the root folder
[platform/upstream/dldt.git] / inference-engine / thirdparty / mkl-dnn / src / cpu / ref_binarization.hpp
1 /*******************************************************************************
2 * Copyright 2019 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_BINARIZATION_HPP
18 #define CPU_REF_BINARIZATION_HPP
19
20 #include <assert.h>
21
22 #include "cpu_binarization_pd.hpp"
23 #include "cpu_engine.hpp"
24 #include "type_helpers.hpp"
25 #include "utils.hpp"
26 #include "c_types_map.hpp"
27
28 namespace mkldnn {
29 namespace impl {
30 namespace cpu {
31
32 template <impl::data_type_t src_type>
33 struct ref_binarization_fwd_t: public cpu_primitive_t {
34     struct pd_t: public cpu_binarization_fwd_pd_t {
35         pd_t(engine_t *engine, const binarization_desc_t *adesc,
36                 const primitive_attr_t *attr,
37                 const binarization_fwd_pd_t *hint_fwd_pd)
38             : cpu_binarization_fwd_pd_t(engine, adesc, attr, hint_fwd_pd) {}
39
40         DECLARE_COMMON_PD_T("ref:any", ref_binarization_fwd_t);
41
42         virtual status_t init() override {
43             using namespace prop_kind;
44             assert(engine()->kind() == engine_kind::cpu);
45
46             bool ok = true
47                 && utils::one_of(desc()->prop_kind, forward_training, forward_inference)
48                 && utils::everyone_is(src_type, desc()->src_desc.data_type, desc()->weights_desc.data_type,
49                         desc()->output_mask_desc.data_type)
50                 && utils::everyone_is(data_type::bin, desc()->dst_desc.data_type)
51                 && utils::one_of(desc()->alg_kind, mkldnn_binarization_depthwise)
52                 && attr()->has_default_values();
53             if (!ok) return status::unimplemented;
54
55             return status::success;
56         }
57     };
58
59     ref_binarization_fwd_t(const pd_t *apd, const input_vector &inputs,
60             const output_vector &outputs)
61         : cpu_primitive_t(apd, inputs, outputs) {}
62
63     typedef typename prec_traits<src_type>::type src_data_t;
64
65     virtual void execute(event_t *e) const {
66         execute_forward();
67         e->set_state(event_t::ready);
68     }
69
70 private:
71     void execute_forward() const;
72     const pd_t *pd() const { return (const pd_t *)primitive_t::pd(); }
73 };
74
75 }
76 }
77 }
78
79 #endif