ArmNN  NotReleased
DebugLayer.cpp
Go to the documentation of this file.
1 //
2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 #include "DebugLayer.hpp"
6 
7 #include "LayerCloneBase.hpp"
8 
11 
12 #include <boost/core/ignore_unused.hpp>
13 
14 namespace armnn
15 {
16 
17 DebugLayer::DebugLayer(const char* name)
18  : Layer(1, 1, LayerType::Debug, name)
19 {}
20 
21 std::unique_ptr<IWorkload> DebugLayer::CreateWorkload(const IWorkloadFactory& factory) const
22 {
23  const Layer& prevLayer = GetInputSlot(0).GetConnectedOutputSlot()->GetOwningLayer();
24 
25  DebugQueueDescriptor descriptor;
26  descriptor.m_Guid = prevLayer.GetGuid();
27  descriptor.m_LayerName = prevLayer.GetNameStr();
29 
30  return factory.CreateDebug(descriptor, PrepInfoAndDesc(descriptor));
31 }
32 
34 {
35  return CloneBase<DebugLayer>(graph, GetName());
36 }
37 
39 {
41 
42  std::vector<TensorShape> inferredShapes = InferOutputShapes({
44 
45  BOOST_ASSERT(inferredShapes.size() == 1);
46 
47  ConditionalThrowIfNotEqual<LayerValidationException>(
48  "DebugLayer: TensorShape set on OutputSlot[0] does not match the inferred shape.",
50  inferredShapes[0]);
51 }
52 
53 void DebugLayer::Accept(ILayerVisitor& visitor) const
54 {
55  // by design debug layers are never in input graphs
56  boost::ignore_unused(visitor);
57  throw armnn::Exception("DebugLayer should never appear in an input graph");
58 }
59 
60 } // namespace armnn
LayerGuid GetGuid() const final
Definition: Layer.hpp:316
const OutputSlot * GetConnectedOutputSlot() const
Definition: Layer.hpp:55
const char * GetName() const override
Definition: Layer.hpp:305
std::vector< TensorShape > InferOutputShapes(const std::vector< TensorShape > &inputShapes) const override
Definition: Layer.cpp:370
virtual const TensorInfo & GetTensorInfo() const =0
void Debug(const TensorInfo &inputInfo, const T *inputData, LayerGuid guid, const std::string &layerName, unsigned int slotIndex)
Definition: Debug.cpp:19
WorkloadInfo PrepInfoAndDesc(QueueDescriptor &descriptor) const
Helper function to reduce duplication in *LayerCreateWorkload.
Definition: Layer.hpp:344
virtual std::unique_ptr< IWorkload > CreateWorkload(const IWorkloadFactory &factory) const override
Definition: DebugLayer.cpp:21
const std::string & GetNameStr() const
Definition: Layer.hpp:216
#define CHECK_LOCATION()
Definition: Exceptions.hpp:169
void ValidateTensorShapesFromInputs() override
Definition: DebugLayer.cpp:38
const IOutputSlot * GetConnection() const override
Definition: Layer.hpp:199
unsigned int CalculateIndexOnOwner() const override
Definition: Layer.cpp:125
void VerifyLayerConnections(unsigned int expectedConnections, const CheckLocation &location) const
Definition: Layer.cpp:337
void Accept(ILayerVisitor &visitor) const override
Definition: DebugLayer.cpp:53
Base class for all ArmNN exceptions so that users can filter to just those.
Definition: Exceptions.hpp:46
DebugLayer * Clone(Graph &graph) const override
Definition: DebugLayer.cpp:33
This layer visualizes the data flowing through the network.
Definition: DebugLayer.hpp:13
DebugLayer(const char *name)
Definition: DebugLayer.cpp:17
virtual std::unique_ptr< IWorkload > CreateDebug(const DebugQueueDescriptor &descriptor, const WorkloadInfo &info) const
const TensorShape & GetShape() const
Definition: Tensor.hpp:88
const TensorInfo & GetTensorInfo() const override
Definition: Layer.cpp:63
Layer & GetOwningLayer() const
Definition: Layer.hpp:115
const OutputSlot & GetOutputSlot(unsigned int index=0) const override
Definition: Layer.hpp:312
const InputSlot & GetInputSlot(unsigned int index) const override
Definition: Layer.hpp:310