Publishing 2019 R1 content
[platform/upstream/dldt.git] / inference-engine / thirdparty / clDNN / src / reorg_yolo.cpp
1 /*
2 // Copyright (c) 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 #include "reorg_yolo_inst.h"
18 #include "primitive_type_base.h"
19 #include "json_object.h"
20
21 namespace cldnn
22 {
23     primitive_type_id reorg_yolo_type_id()
24     {
25         static primitive_type_base<reorg_yolo> instance;
26         return &instance;
27     }
28
29     layout reorg_yolo_inst::calc_output_layout(reorg_yolo_node const& node)
30     {
31         assert((bool)node.get_primitive()->output_data_type == false
32                && "Output data type forcing is not supported for "
33                   "reorg_yolo_node!");
34         auto input_layout = node.input().get_output_layout();
35         auto desc = node.get_primitive();
36         auto stride = desc->stride;
37
38         cldnn::layout layoutTemp = cldnn::layout(input_layout.data_type, input_layout.format, tensor(input_layout.size.batch[0],
39             input_layout.size.feature[0] * stride * stride, input_layout.size.spatial[0] / stride,
40             input_layout.size.spatial[1] / stride));
41         return layoutTemp;
42     }
43
44     std::string reorg_yolo_inst::to_string(reorg_yolo_node const& node)
45     {
46         auto desc = node.get_primitive();
47         auto node_info = node.desc_to_json();
48         auto stride = desc->stride;
49
50         std::stringstream primitive_description;
51
52         json_composite reorg_yolo_info;
53         reorg_yolo_info.add("stride", stride);
54
55
56         node_info->add("reorg yolo info", reorg_yolo_info);
57         node_info->dump(primitive_description);
58
59         return primitive_description.str();
60     }
61     reorg_yolo_inst::typed_primitive_inst(network_impl& network, reorg_yolo_node const& node)
62         : parent(network, node)
63     {
64     }
65 }