• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 #include "FillLayer.hpp"
6 
7 #include "LayerCloneBase.hpp"
8 
9 #include <armnn/TypesUtils.hpp>
10 #include <backendsCommon/WorkloadData.hpp>
11 #include <backendsCommon/WorkloadFactory.hpp>
12 
13 namespace armnn
14 {
15 
FillLayer(const FillDescriptor & param,const char * name)16 FillLayer::FillLayer(const FillDescriptor& param, const char* name)
17     : LayerWithParameters(1, 1, LayerType::Fill, param, name)
18 {
19 }
20 
CreateWorkload(const IWorkloadFactory & factory) const21 std::unique_ptr<IWorkload> FillLayer::CreateWorkload(const IWorkloadFactory& factory) const
22 {
23     FillQueueDescriptor descriptor;
24     SetAdditionalInfo(descriptor);
25 
26     return factory.CreateFill(descriptor, PrepInfoAndDesc(descriptor) );
27 }
28 
Clone(Graph & graph) const29 FillLayer* FillLayer::Clone(Graph& graph) const
30 {
31     return CloneBase<FillLayer>(graph, m_Param, GetName());
32 }
33 
ValidateTensorShapesFromInputs()34 void FillLayer::ValidateTensorShapesFromInputs()
35 {
36     VerifyLayerConnections(1, CHECK_LOCATION());
37 
38     const TensorShape& outputShape = GetOutputSlot(0).GetTensorInfo().GetShape();
39 
40     VerifyShapeInferenceType(outputShape, m_ShapeInferenceMethod);
41 
42     auto inferredShapes = InferOutputShapes({ GetInputSlot(0).GetConnection()->GetTensorInfo().GetShape() });
43 
44     ARMNN_ASSERT(inferredShapes.size() == 1);
45 
46     // Cannot validate the output shape from the input shape. but we can validate that the correct dims have been
47     // inferred
48     ConditionalThrowIfNotEqual<LayerValidationException>(
49         "FillLayer: TensorShape set on OutputSlot[0] does not match the inferred shape.",
50         GetOutputSlot(0).GetTensorInfo().GetNumDimensions(),
51         inferredShapes[0][0]);
52 }
53 
Accept(ILayerVisitor & visitor) const54 void FillLayer::Accept(ILayerVisitor& visitor) const
55 {
56     visitor.VisitFillLayer(this, GetParameters(), GetName());
57 }
58 
59 } // namespace armnn
60