Release 18.05.01
[platform/upstream/armnn.git] / src / armnn / layers / NormalizationLayer.cpp
1 //
2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // See LICENSE file in the project root for full license information.
4 //
5 #include "NormalizationLayer.hpp"
6
7 #include "LayerCloneBase.hpp"
8
9 #include <armnn/TypesUtils.hpp>
10 #include <backends/WorkloadData.hpp>
11 #include <backends/WorkloadFactory.hpp>
12
13 namespace armnn
14 {
15
16 NormalizationLayer::NormalizationLayer(const NormalizationDescriptor& param, const char* name)
17     : LayerWithParameters(1, 1, LayerType::Normalization, param, name)
18 {
19 }
20
21 std::unique_ptr<IWorkload> NormalizationLayer::CreateWorkload(const Graph& graph, const IWorkloadFactory& factory) const
22 {
23     NormalizationQueueDescriptor descriptor;
24     return factory.CreateNormalization(descriptor, PrepInfoAndDesc(descriptor, graph));
25 }
26
27 NormalizationLayer* NormalizationLayer::Clone(Graph& graph) const
28 {
29     return CloneBase<NormalizationLayer>(graph, m_Param, GetName());
30 }
31
32 void NormalizationLayer::ValidateTensorShapesFromInputs()
33 {
34     ConditionalThrow<LayerValidationException>(GetInputSlot(0).GetConnection() != nullptr,
35                                                "NormalizationLayer: Input slot must be connected.");
36
37     const TensorShape& outShape = GetInputSlot(0).GetConnection()->GetTensorInfo().GetShape();
38     ConditionalThrowIfNotEqual<LayerValidationException>(
39         "NormalizationLayer: TensorShape set on OutputSlot[0] does not match the inferred shape.",
40         GetOutputSlot(0).GetTensorInfo().GetShape(),
41         outShape);
42 }
43
44 } // namespace armnn