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.
18 #include "primitive_type_base.h"
19 #include "error_handler.h"
20 #include "json_object.h"
24 primitive_type_id lrn_type_id()
26 static primitive_type_base<lrn> instance;
30 layout lrn_inst::calc_output_layout(lrn_node const& node)
32 assert((bool)node.get_primitive()->output_data_type == false
33 && "Output data type forcing is not supported for lrn_node!");
34 return node.input().get_non_padded_output_layout();
37 std::string lrn_inst::to_string(lrn_node const& node)
39 auto node_info = node.desc_to_json();
40 auto desc = node.get_primitive();
41 auto norm_size = desc->size;
43 auto alpha = desc->alpha;
44 auto beta = desc->beta;
45 auto norm_region = desc->norm_region == cldnn_lrn_norm_region::cldnn_lrn_norm_region_across_channel ? "across channel" : "within channel";
46 auto& input = node.input();
48 std::stringstream primitive_description;
50 json_composite lrn_info;
51 lrn_info.add("input id", input.id());
53 lrn_info.add("alpha", alpha);
54 lrn_info.add("beta", beta);
55 lrn_info.add("size of normalization", norm_size);
56 lrn_info.add("normalization region", norm_region);
58 node_info->add("lrn info", lrn_info);
59 node_info->dump(primitive_description);
61 return primitive_description.str();
64 lrn_inst::typed_primitive_inst(network_impl& network, lrn_node const& desc)
65 :parent(network, desc)
67 CLDNN_ERROR_LESS_OR_EQUAL_THAN(desc.id(), "LRN argument size", argument.size, "value", static_cast<uint32_t>(0), "LRN size must be greater than 0!");