2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // See LICENSE file in the project root for full license information.
5 #include "L2NormalizationLayer.hpp"
7 #include "LayerCloneBase.hpp"
9 #include <armnn/TypesUtils.hpp>
10 #include <backends/WorkloadData.hpp>
11 #include <backends/WorkloadFactory.hpp>
16 L2NormalizationLayer::L2NormalizationLayer(const char* name)
17 : Layer(1, 1, LayerType::L2Normalization, name)
21 std::unique_ptr<IWorkload> L2NormalizationLayer::CreateWorkload(const Graph& graph,
22 const IWorkloadFactory& factory) const
24 L2NormalizationQueueDescriptor descriptor;
25 return factory.CreateL2Normalization(descriptor, PrepInfoAndDesc(descriptor, graph));
28 L2NormalizationLayer* L2NormalizationLayer::Clone(Graph& graph) const
30 return CloneBase<L2NormalizationLayer>(graph, GetName());
33 void L2NormalizationLayer::ValidateTensorShapesFromInputs()
35 ConditionalThrow<LayerValidationException>(GetInputSlot(0).GetConnection() != nullptr,
36 "L2NormalizationLayer: InputSlot must be connected to an OutputSlot");
37 ConditionalThrow<LayerValidationException>(GetInputSlot(0).GetConnection()->IsTensorInfoSet(),
38 "L2NormalizationLayer: TensorInfo must be set on connected OutputSlot.");
40 IOutputSlot* input = GetInputSlot(0).GetConnection();
42 // input and output shapes are the same
43 TensorShape const& outShape = input->GetTensorInfo().GetShape();
44 ConditionalThrowIfNotEqual<LayerValidationException>(
45 "L2NormalizationLayer: TensorShape set on OutputSlot[0] does not match the inferred shape.",
46 GetOutputSlot(0).GetTensorInfo().GetShape(),