Publishing R3
[platform/upstream/dldt.git] / inference-engine / thirdparty / clDNN / src / include / reorder_inst.h
1 /*
2 // Copyright (c) 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 ///////////////////////////////////////////////////////////////////////////////////////////////////
18 #pragma once
19 #include "api/CPP/reorder.hpp"
20 #include "primitive_inst.h"
21
22 namespace cldnn
23 {
24
25 template <>
26 struct typed_program_node<reorder> : public typed_program_node_base<reorder>
27 {
28     using parent = typed_program_node_base<reorder>;
29
30 public:
31     using parent::parent;
32
33     decltype(auto) input() const { return get_dependency(0); }
34     decltype(auto) mean() const { return get_dependency(1); }
35
36     bool has_mean() const { return !typed_desc()->mean.empty(); }
37
38     auto requires_reinterpret() const { return req_reinterpr; }
39     void requires_reinterpret(bool val) { req_reinterpr = (optimized && val); }
40
41     void set_input_offset(tensor const& io) { input_offset = io; }
42     tensor get_input_offset() const { return input_offset; }
43
44 private:
45     bool req_reinterpr = false;
46     tensor input_offset = tensor{ 0 }; //used by reorder to winograd domain
47 };
48
49 using reorder_node = typed_program_node<reorder>;
50
51 template <>
52 class typed_primitive_inst<reorder> : public typed_primitive_inst_base<reorder>
53 {
54     using parent = typed_primitive_inst_base<reorder>;
55
56 public:
57     static layout calc_output_layout(reorder_node const& node);
58     static std::string to_string(reorder_node const& node);
59
60 public:
61     typed_primitive_inst(network_impl& network, reorder_node const& node);
62
63     decltype(auto) mean_memory() const { return dep_memory(1); }
64
65     bool has_mean() const { return !argument.mean.empty(); }
66
67 private:
68     void on_execute() override;
69     void reuse_input();
70 };
71
72 using reorder_inst = typed_primitive_inst<reorder>;
73
74 }