clDNN
normalize.hpp
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 
18 #pragma once
19 #include "../C/normalize.h"
20 #include "primitive.hpp"
21 
22 namespace cldnn
23 {
30 
47 struct normalize :public primitive_base<normalize, CLDNN_PRIMITIVE_DESC(normalize)>
48 {
49  CLDNN_DECLATE_PRIMITIVE(normalize)
50 
51 
52  normalize(
60  const primitive_id& id,
61  const primitive_id& input,
63  const bool across_spatial = true,
64  const float epsilon = 1e-10f,
65  const padding& output_padding = padding()
66  )
70  , epsilon(epsilon)
71  {}
72 
74  normalize(const dto* dto)
78  , epsilon(dto->epsilon)
79  {}
80 
88  float epsilon;
89 
90 protected:
91 
92  std::vector<std::reference_wrapper<const primitive_id>> get_dependencies() const override
93  {
94  return{ scale_input };
95  }
96 
97  void update_dto(dto& dto) const override
98  {
99  dto.scale_input = scale_input.c_str();
100  dto.across_spatial = across_spatial;
101  dto.epsilon = epsilon;
102  }
103 };
107 }
Represents data padding information.
Definition: layout.hpp:125
bool across_spatial
Determines if the normalization is done across or within spatial (see documentation above)...
Definition: normalize.hpp:86
float epsilon
Epsilon for not dividing by zero while normalizing.
Definition: normalize.hpp:88
primitive_id scale_input
Scale input primitive id with values needed for scaling after the normalization. Scale x dimension sh...
Definition: normalize.hpp:84
Normalizes the input using an L2 norm and multiplies the output with scale value. The scale can be eq...
Definition: normalize.h:49
Normalizes the input using an L2 norm and multiplies the output with scale value. The scale can be eq...
Definition: normalize.hpp:47
normalize(const dto *dto)
Constructs a copy from C API cldnn_normalize_desc.
Definition: normalize.hpp:74
std::string primitive_id
Unique id of a primitive within a topology.
Definition: primitive.hpp:42
fixed_size_vector_ref input
List of ids of input primitives.
Definition: primitive.hpp:146
normalize(const primitive_id &id, const primitive_id &input, const primitive_id &scale_input, const bool across_spatial=true, const float epsilon=1e-10f, const padding &output_padding=padding())
Constructs normalize primitive.
Definition: normalize.hpp:59
base class for all primitives implementations.
Definition: primitive.hpp:190
padding output_padding
Requested output padding.
Definition: primitive.hpp:149