2 // Copyright (c) 2018 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 #include "scale_grad_input_inst.h"
18 #include "primitive_type_base.h"
19 #include "error_handler.h"
20 #include "json_object.h"
24 primitive_type_id scale_grad_input_type_id()
26 static primitive_type_base<scale_grad_input> instance;
30 layout scale_grad_input_inst::calc_output_layout(scale_grad_input_node const& node)
32 assert((bool)node.get_primitive()->output_data_type == false
33 && "Output data type forcing is not supported for "
34 "scale_grad_input_node!");
35 auto result = node.input().get_non_padded_output_layout();
37 auto scale_in_sizes = node.scale_in().get_non_padded_output_layout().size;
38 auto input_sizes = result.size;
40 auto scale_in_x_size = scale_in_sizes.spatial[0];
41 auto scale_in_y_size = scale_in_sizes.spatial[1];
43 auto input_x_size = input_sizes.spatial[0];
44 auto input_y_size = input_sizes.spatial[1];
46 if (scale_in_x_size != 1)
48 CLDNN_ERROR_NOT_EQUAL(node.id(), "Scale x size", scale_in_x_size, "input x size", input_x_size, "");
50 if (scale_in_y_size != 1)
52 CLDNN_ERROR_NOT_EQUAL(node.id(), "Scale y size", scale_in_y_size, "input y size", input_y_size, "");
58 std::string scale_grad_input_inst::to_string(scale_grad_input_node const& node)
60 auto desc = node.get_primitive();
61 auto node_info = node.desc_to_json();
62 auto& input = node.input();
63 auto& scale_input = node.scale_in();
65 std::stringstream primitive_description;
67 json_composite scale_grad_input_info;
68 scale_grad_input_info.add("input", input.id());
69 scale_grad_input_info.add("scale input", scale_input.id());
71 node_info->add("scale_grad_input info", scale_grad_input_info);
72 node_info->dump(primitive_description);
74 return primitive_description.str();
77 scale_grad_input_inst::typed_primitive_inst(network_impl& network, scale_grad_input_node const& node)
78 :parent(network, node)
80 auto scale_input_layout = node.scale_in().get_output_layout();
81 auto scale_input_batch_size = scale_input_layout.size.batch[0];
82 auto scale_input_feature_size = scale_input_layout.size.feature[0];
84 auto input_layout = node.input().get_output_layout();
85 auto input_batch_size = input_layout.size.batch[0];
86 auto input_feature_size = input_layout.size.feature[0];
88 if (scale_input_batch_size != 1)
90 CLDNN_ERROR_NOT_EQUAL(node.id(), "Scale batch size", scale_input_batch_size, "input batch size", input_batch_size, "");
93 if (scale_input_feature_size != 1)
95 CLDNN_ERROR_NOT_EQUAL(node.id(), "Scale feature size", scale_input_feature_size, "input feature size", input_feature_size, "");