• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright © 2017 Arm Ltd and Contributors. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 #include "MemCopyLayer.hpp"
6 
7 #include "LayerCloneBase.hpp"
8 
9 #include <armnn/TypesUtils.hpp>
10 #include <backendsCommon/WorkloadData.hpp>
11 #include <backendsCommon/WorkloadFactory.hpp>
12 #include <backendsCommon/MemCopyWorkload.hpp>
13 
14 namespace armnn
15 {
16 
MemCopyLayer(const char * name)17 MemCopyLayer::MemCopyLayer(const char* name)
18     : Layer(1, 1, LayerType::MemCopy, name)
19 {
20 }
21 
Clone(Graph & graph) const22 MemCopyLayer* MemCopyLayer::Clone(Graph& graph) const
23 {
24     return CloneBase<MemCopyLayer>(graph, GetName());
25 }
26 
CreateWorkload(const IWorkloadFactory & factory) const27 std::unique_ptr<IWorkload> MemCopyLayer::CreateWorkload(const IWorkloadFactory& factory) const
28 {
29     IgnoreUnused(factory);
30     MemCopyQueueDescriptor descriptor;
31     SetAdditionalInfo(descriptor);
32 
33     //This is different from other workloads. Does not get created by the workload factory.
34     return std::make_unique<CopyMemGenericWorkload>(descriptor, PrepInfoAndDesc(descriptor));
35 }
36 
ValidateTensorShapesFromInputs()37 void MemCopyLayer::ValidateTensorShapesFromInputs()
38 {
39     VerifyLayerConnections(1, CHECK_LOCATION());
40 
41     const TensorShape& outputShape = GetOutputSlot(0).GetTensorInfo().GetShape();
42 
43     VerifyShapeInferenceType(outputShape, m_ShapeInferenceMethod);
44 
45     auto inferredShapes = InferOutputShapes({ GetInputSlot(0).GetConnection()->GetTensorInfo().GetShape() });
46 
47     ARMNN_ASSERT(inferredShapes.size() == 1);
48 
49     ValidateAndCopyShape(outputShape, inferredShapes[0], m_ShapeInferenceMethod, "MemCopyLayer");
50 }
51 
Accept(ILayerVisitor & visitor) const52 void MemCopyLayer::Accept(ILayerVisitor& visitor) const
53 {
54     IgnoreUnused(visitor);
55     throw armnn::Exception("MemCopyLayer should not appear in an input graph");
56 }
57 
58 } // namespace armnn
59