2 // Copyright (c) 2016 Intel Corporation
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
8 // http://www.apache.org/licenses/LICENSE-2.0
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.
17 ///////////////////////////////////////////////////////////////////////////////////////////////////
18 #include "upsampling_inst.h"
19 #include "primitive_type_base.h"
20 #include "error_handler.h"
24 primitive_type_id upsampling_type_id()
26 static primitive_type_base<upsampling> instance;
30 layout upsampling_inst::calc_output_layout(upsampling_node const& node)
32 assert((bool)node.get_primitive()->output_data_type == false
33 && "Output data type forcing is not supported for upsampling_node!");
34 auto desc = node.get_primitive();
35 auto input_layout = node.input().get_output_layout();
36 auto scale = desc->scale;
38 auto result_sizes = tensor(input_layout.size.batch[0], input_layout.size.feature[0], static_cast<size_t>(input_layout.size.spatial[0] * scale),
39 static_cast<size_t>(input_layout.size.spatial[1] * scale));
40 auto result = layout({ input_layout.data_type, input_layout.format, result_sizes });
45 std::string upsampling_inst::to_string(upsampling_node const& node)
47 std::stringstream primitive_description;
48 auto desc = node.get_primitive();
49 auto& input_1 = node.input();
50 auto activation = desc->with_activation ? " true" : "false";
52 switch(desc->sample_type)
54 case upsampling_sample_type::nearest:
57 case upsampling_sample_type::bilinear:
58 str_type = "bilinear";
61 str_type = "not supported sample type";
65 primitive_description << "id: " << desc->id << ", type: upsampling" <<
66 "\n\tinput_1: " << input_1.id() << ", count: " << input_1.get_output_layout().count() << ", size: " << input_1.get_output_layout().size <<
67 "\n\tscale: " << desc->scale <<
68 "\n\tnum_filter: " << desc->num_filter <<
69 "\n\tsample_type: " << str_type <<
70 "\n\twith activation: " << activation << ", slope: " << desc->activation_negative_slope <<
71 "\n\toutput padding lower size: " << desc->output_padding.lower_size() <<
72 "\n\toutput padding upper size: " << desc->output_padding.upper_size() <<
73 "\n\toutput: count: " << node.get_output_layout().count() << ", size: " << node.get_output_layout().size << '\n';
75 return primitive_description.str();
78 upsampling_inst::typed_primitive_inst(network_impl& network, upsampling_node const& node)
79 :parent(network, node)
81 if(argument.sample_type == upsampling_sample_type::bilinear)
82 CLDNN_ERROR_MESSAGE(node.id(), "Upsampling primitive instance with bilinear filtering should be replaced by deconvolution!");