1 //
2 // Copyright © 2017 Arm Ltd and Contributors. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 #include "ActivationLayer.hpp"
6 #include "LayerCloneBase.hpp"
7
8 #include <armnn/TypesUtils.hpp>
9 #include <armnn/backends/WorkloadData.hpp>
10 #include <armnn/backends/WorkloadFactory.hpp>
11
12 namespace armnn
13 {
14
ActivationLayer(const ActivationDescriptor & param,const char * name)15 ActivationLayer::ActivationLayer(const ActivationDescriptor& param, const char* name)
16 : LayerWithParameters(1, 1, LayerType::Activation, param, name)
17 {
18 }
19
CreateWorkload(const IWorkloadFactory & factory) const20 std::unique_ptr<IWorkload> ActivationLayer::CreateWorkload(const IWorkloadFactory& factory) const
21 {
22 ActivationQueueDescriptor descriptor;
23 SetAdditionalInfo(descriptor);
24
25 return factory.CreateWorkload(LayerType::Activation, descriptor, PrepInfoAndDesc(descriptor));
26 }
27
Clone(Graph & graph) const28 ActivationLayer* ActivationLayer::Clone(Graph& graph) const
29 {
30 return CloneBase<ActivationLayer>(graph, m_Param, GetName());
31 }
32
ValidateTensorShapesFromInputs()33 void ActivationLayer::ValidateTensorShapesFromInputs()
34 {
35 VerifyLayerConnections(1, CHECK_LOCATION());
36
37 const TensorShape& outputShape = GetOutputSlot(0).GetTensorInfo().GetShape();
38
39 VerifyShapeInferenceType(outputShape, m_ShapeInferenceMethod);
40
41 auto inferredShapes = InferOutputShapes({ GetInputSlot(0).GetConnection()->GetTensorInfo().GetShape() });
42
43 ARMNN_ASSERT(inferredShapes.size() == 1);
44
45 ValidateAndCopyShape(outputShape, inferredShapes[0], m_ShapeInferenceMethod, "ActivationLayer");
46 }
47
ExecuteStrategy(IStrategy & strategy) const48 void ActivationLayer::ExecuteStrategy(IStrategy &strategy) const
49 {
50 strategy.ExecuteStrategy(this, GetParameters(), {}, GetName());
51 }
52
53 } // namespace armnn
54