1 //
2 // Copyright © 2017 Arm Ltd and Contributors. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 #include "DebugLayer.hpp"
6
7 #include "LayerCloneBase.hpp"
8
9 #include <backendsCommon/WorkloadData.hpp>
10 #include <backendsCommon/WorkloadFactory.hpp>
11 #include <armnn/utility/IgnoreUnused.hpp>
12
13 namespace armnn
14 {
15
DebugLayer(const char * name)16 DebugLayer::DebugLayer(const char* name)
17 : Layer(1, 1, LayerType::Debug, name)
18 {}
19
CreateWorkload(const IWorkloadFactory & factory) const20 std::unique_ptr<IWorkload> DebugLayer::CreateWorkload(const IWorkloadFactory& factory) const
21 {
22 const Layer& prevLayer = GetInputSlot(0).GetConnectedOutputSlot()->GetOwningLayer();
23
24 DebugQueueDescriptor descriptor;
25 descriptor.m_Guid = prevLayer.GetGuid();
26 descriptor.m_LayerName = prevLayer.GetNameStr();
27 descriptor.m_SlotIndex = GetInputSlot(0).GetConnectedOutputSlot()->CalculateIndexOnOwner();
28
29 SetAdditionalInfo(descriptor);
30
31 return factory.CreateDebug(descriptor, PrepInfoAndDesc(descriptor));
32 }
33
Clone(Graph & graph) const34 DebugLayer* DebugLayer::Clone(Graph& graph) const
35 {
36 return CloneBase<DebugLayer>(graph, GetName());
37 }
38
ValidateTensorShapesFromInputs()39 void DebugLayer::ValidateTensorShapesFromInputs()
40 {
41 VerifyLayerConnections(1, CHECK_LOCATION());
42
43 const TensorShape& outputShape = GetOutputSlot(0).GetTensorInfo().GetShape();
44
45 VerifyShapeInferenceType(outputShape, m_ShapeInferenceMethod);
46
47 std::vector<TensorShape> inferredShapes = InferOutputShapes({
48 GetInputSlot(0).GetConnection()->GetTensorInfo().GetShape() });
49
50 ARMNN_ASSERT(inferredShapes.size() == 1);
51
52 ValidateAndCopyShape(outputShape, inferredShapes[0], m_ShapeInferenceMethod, "DebugLayer");
53 }
54
Accept(ILayerVisitor & visitor) const55 void DebugLayer::Accept(ILayerVisitor& visitor) const
56 {
57 // by design debug layers are never in input graphs
58 IgnoreUnused(visitor);
59 throw armnn::Exception("DebugLayer should never appear in an input graph");
60 }
61
62 } // namespace armnn
63