Publishing 2019 R1 content
[platform/upstream/dldt.git] / inference-engine / thirdparty / clDNN / src / lrn.cpp
1 /*
2 // Copyright (c) 2016 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 "lrn_inst.h"
18 #include "primitive_type_base.h"
19 #include "error_handler.h"
20 #include "json_object.h"
21
22 namespace cldnn
23 {
24 primitive_type_id lrn_type_id()
25 {
26     static primitive_type_base<lrn> instance;
27     return &instance;
28 }
29
30 layout lrn_inst::calc_output_layout(lrn_node const& node)
31 {
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();
35 }
36
37 std::string lrn_inst::to_string(lrn_node const& node)
38 {
39     auto node_info   = node.desc_to_json();
40     auto desc        = node.get_primitive();
41     auto norm_size   = desc->size;
42     auto k           = desc->k;
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();
47
48     std::stringstream primitive_description;
49
50     json_composite lrn_info;
51     lrn_info.add("input id", input.id());
52     lrn_info.add("k", k);
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);
57
58     node_info->add("lrn info", lrn_info);
59     node_info->dump(primitive_description);
60    
61     return primitive_description.str();
62 }
63
64 lrn_inst::typed_primitive_inst(network_impl& network, lrn_node const& desc)
65     :parent(network, desc)
66 {
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!");
68 }
69 }