Publishing 2019 R1 content
[platform/upstream/dldt.git] / inference-engine / thirdparty / clDNN / src / graph_optimizer / calculate_prior_boxes.cpp
1 /*
2 // Copyright (c) 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 ///////////////////////////////////////////////////////////////////////////////////////////////////
18
19 #include "pass_manager.h"
20 #include "prior_box_inst.h"
21 #include "program_node.h"
22 #include "program_impl.h"
23
24 using namespace cldnn;
25
26 void calculate_prior_boxes::run(program_impl& p)
27 {
28     auto itr = p.get_processing_order().begin();
29     while (itr != p.get_processing_order().end())
30     {
31         auto& node = (*itr++);
32         if (!node->is_type<prior_box>())
33             continue;
34
35         auto& pb_node = node->as<prior_box>();
36
37         pb_node.calc_result();
38         p.remove_connection(pb_node.input(), pb_node);
39
40         auto& result = pb_node.get_result_buffer();
41         result.add_ref(); // need to inc ref count since we will be assigning this memory as cldnn_memory in next line that is not ref_count_obj
42         auto cpp_mem = details::memory_c_to_cpp_converter::convert(api_cast(&result));
43
44         auto& data_node = p.get_or_create(std::make_shared<data>("_cldnn_tmp_" + pb_node.id() + "_result", cpp_mem));
45         p.replace(pb_node, data_node);
46     }
47 }