From e9e7bfd09e3435d2bbb334e07c6a0a2514c80048 Mon Sep 17 00:00:00 2001 From: jimfly01 Date: Thu, 24 Jan 2019 22:29:33 +0000 Subject: [PATCH] IVGCVSW-2547 Add Accept function to IConnectableLayer * Layers which callback VisitXXXLayer with ConstTensor have been implemented with dummies to speed up implementation and unblock IVGCVSW-2531 Change-Id: I49b8035f12ec72d6bd6cee95075692f98c48e193 --- include/armnn/ILayerVisitor.hpp | 13 +++++++++++++ include/armnn/INetwork.hpp | 3 +++ src/armnn/layers/ActivationLayer.cpp | 5 +++++ src/armnn/layers/ActivationLayer.hpp | 3 +++ src/armnn/layers/AdditionLayer.cpp | 5 +++++ src/armnn/layers/AdditionLayer.hpp | 2 ++ src/armnn/layers/BatchNormalizationLayer.cpp | 6 ++++++ src/armnn/layers/BatchNormalizationLayer.hpp | 2 ++ src/armnn/layers/BatchToSpaceNdLayer.cpp | 6 ++++++ src/armnn/layers/BatchToSpaceNdLayer.hpp | 2 ++ src/armnn/layers/ConstantLayer.cpp | 6 ++++++ src/armnn/layers/ConstantLayer.hpp | 2 ++ src/armnn/layers/ConvertFp16ToFp32Layer.cpp | 7 +++++++ src/armnn/layers/ConvertFp16ToFp32Layer.hpp | 2 ++ src/armnn/layers/ConvertFp32ToFp16Layer.cpp | 7 +++++++ src/armnn/layers/ConvertFp32ToFp16Layer.hpp | 2 ++ src/armnn/layers/Convolution2dLayer.cpp | 13 +++++++++++++ src/armnn/layers/Convolution2dLayer.hpp | 2 ++ src/armnn/layers/DebugLayer.cpp | 6 ++++++ src/armnn/layers/DebugLayer.hpp | 2 ++ src/armnn/layers/DepthwiseConvolution2dLayer.cpp | 13 +++++++++++++ src/armnn/layers/DepthwiseConvolution2dLayer.hpp | 2 ++ src/armnn/layers/DetectionPostProcessLayer.cpp | 5 +++++ src/armnn/layers/DetectionPostProcessLayer.hpp | 2 ++ src/armnn/layers/DivisionLayer.cpp | 5 +++++ src/armnn/layers/DivisionLayer.hpp | 2 ++ src/armnn/layers/EqualLayer.cpp | 5 +++++ src/armnn/layers/EqualLayer.hpp | 2 ++ src/armnn/layers/FakeQuantizationLayer.cpp | 5 +++++ src/armnn/layers/FakeQuantizationLayer.hpp | 2 ++ src/armnn/layers/FloorLayer.cpp | 5 +++++ src/armnn/layers/FloorLayer.hpp | 2 ++ src/armnn/layers/FullyConnectedLayer.cpp | 13 +++++++++++++ src/armnn/layers/FullyConnectedLayer.hpp | 2 ++ src/armnn/layers/GatherLayer.cpp | 5 +++++ src/armnn/layers/GatherLayer.hpp | 2 ++ src/armnn/layers/GreaterLayer.cpp | 5 +++++ src/armnn/layers/GreaterLayer.hpp | 2 ++ src/armnn/layers/InputLayer.cpp | 5 +++++ src/armnn/layers/InputLayer.hpp | 2 ++ src/armnn/layers/L2NormalizationLayer.cpp | 5 +++++ src/armnn/layers/L2NormalizationLayer.hpp | 2 ++ src/armnn/layers/LstmLayer.cpp | 6 ++++++ src/armnn/layers/LstmLayer.hpp | 2 ++ src/armnn/layers/MaximumLayer.cpp | 5 +++++ src/armnn/layers/MaximumLayer.hpp | 2 ++ src/armnn/layers/MeanLayer.cpp | 5 +++++ src/armnn/layers/MeanLayer.hpp | 2 ++ src/armnn/layers/MemCopyLayer.cpp | 5 +++++ src/armnn/layers/MemCopyLayer.hpp | 2 ++ src/armnn/layers/MergerLayer.cpp | 5 +++++ src/armnn/layers/MergerLayer.hpp | 2 ++ src/armnn/layers/MinimumLayer.cpp | 5 +++++ src/armnn/layers/MinimumLayer.hpp | 2 ++ src/armnn/layers/MultiplicationLayer.cpp | 5 +++++ src/armnn/layers/MultiplicationLayer.hpp | 2 ++ src/armnn/layers/NormalizationLayer.cpp | 5 +++++ src/armnn/layers/NormalizationLayer.hpp | 2 ++ src/armnn/layers/OutputLayer.cpp | 5 +++++ src/armnn/layers/OutputLayer.hpp | 2 ++ src/armnn/layers/PadLayer.cpp | 5 +++++ src/armnn/layers/PadLayer.hpp | 2 ++ src/armnn/layers/PermuteLayer.cpp | 5 +++++ src/armnn/layers/PermuteLayer.hpp | 2 ++ src/armnn/layers/Pooling2dLayer.cpp | 5 +++++ src/armnn/layers/Pooling2dLayer.hpp | 2 ++ src/armnn/layers/PreCompiledLayer.cpp | 5 +++++ src/armnn/layers/PreCompiledLayer.hpp | 2 ++ src/armnn/layers/ReshapeLayer.cpp | 5 +++++ src/armnn/layers/ReshapeLayer.hpp | 2 ++ src/armnn/layers/ResizeBilinearLayer.cpp | 5 +++++ src/armnn/layers/ResizeBilinearLayer.hpp | 2 ++ src/armnn/layers/RsqrtLayer.cpp | 5 +++++ src/armnn/layers/RsqrtLayer.hpp | 2 ++ src/armnn/layers/SoftmaxLayer.cpp | 5 +++++ src/armnn/layers/SoftmaxLayer.hpp | 2 ++ src/armnn/layers/SpaceToBatchNdLayer.cpp | 5 +++++ src/armnn/layers/SpaceToBatchNdLayer.hpp | 2 ++ src/armnn/layers/SplitterLayer.cpp | 5 +++++ src/armnn/layers/SplitterLayer.hpp | 2 ++ src/armnn/layers/StridedSliceLayer.cpp | 5 +++++ src/armnn/layers/StridedSliceLayer.hpp | 2 ++ src/armnn/layers/SubtractionLayer.cpp | 5 +++++ src/armnn/layers/SubtractionLayer.hpp | 2 ++ 84 files changed, 337 insertions(+) diff --git a/include/armnn/ILayerVisitor.hpp b/include/armnn/ILayerVisitor.hpp index dd73a6f..c56be81 100644 --- a/include/armnn/ILayerVisitor.hpp +++ b/include/armnn/ILayerVisitor.hpp @@ -13,6 +13,10 @@ namespace armnn { class ILayerVisitor { +protected: + ILayerVisitor() {} + virtual ~ILayerVisitor() {} + public: /// Function that an InputLayer should call back to when its Accept(ILayerVisitor&) function is invoked. /// @param layer - pointer to the layer which is calling back to this visit function. @@ -58,6 +62,15 @@ public: const ConstTensor& weights, const char* name = nullptr) = 0; + /// Function that a Detection PostProcess layer should call back to when its + /// Accept(ILayerVisitor&) function is invoked. + /// @param layer - pointer to the layer which is calling back to this visit function. + /// @param descriptor - Description of the Detection PostProcess layer. + /// @param name - Optional name for the layer. + virtual void VisitDetectionPostProcessLayer(const IConnectableLayer* layer, + const DetectionPostProcessDescriptor& descriptor, + const char* name = nullptr) = 0; + /// Function that a 2D depthwise convolution layer with biases should call back to when its /// Accept(ILayerVisitor&) function is invoked. /// @param layer - pointer to the layer which is calling back to this visit function. diff --git a/include/armnn/INetwork.hpp b/include/armnn/INetwork.hpp index 1f7354d..2213cee 100644 --- a/include/armnn/INetwork.hpp +++ b/include/armnn/INetwork.hpp @@ -8,6 +8,7 @@ #include #include #include +#include #include @@ -70,6 +71,8 @@ public: virtual std::vector InferOutputShapes(const std::vector& inputShapes) const = 0; virtual LayerGuid GetGuid() const = 0; + + virtual void Accept(ILayerVisitor& visitor) const = 0; protected: /// Objects are not deletable via the handle ~IConnectableLayer() {} diff --git a/src/armnn/layers/ActivationLayer.cpp b/src/armnn/layers/ActivationLayer.cpp index 401ab29..6f80cce 100644 --- a/src/armnn/layers/ActivationLayer.cpp +++ b/src/armnn/layers/ActivationLayer.cpp @@ -42,4 +42,9 @@ void ActivationLayer::ValidateTensorShapesFromInputs() inferredShapes[0]); } +void ActivationLayer::Accept(ILayerVisitor& visitor) const +{ + visitor.VisitActivationLayer(this, GetParameters(), GetName()); +} + } // namespace armnn diff --git a/src/armnn/layers/ActivationLayer.hpp b/src/armnn/layers/ActivationLayer.hpp index 390955a..aac05f3 100644 --- a/src/armnn/layers/ActivationLayer.hpp +++ b/src/armnn/layers/ActivationLayer.hpp @@ -26,6 +26,9 @@ public: /// Check if the input tensor shape(s) will lead to a valid configuration of @ref ActivationLayer. void ValidateTensorShapesFromInputs() override; + void Accept(ILayerVisitor& visitor) const override; + + protected: /// Constructor to create an ActivationLayer. /// @param [in] param ActivationDescriptor to configure the activation operation. diff --git a/src/armnn/layers/AdditionLayer.cpp b/src/armnn/layers/AdditionLayer.cpp index 2762266..02ee306 100644 --- a/src/armnn/layers/AdditionLayer.cpp +++ b/src/armnn/layers/AdditionLayer.cpp @@ -31,4 +31,9 @@ AdditionLayer* AdditionLayer::Clone(Graph& graph) const return CloneBase(graph, GetName()); } +void AdditionLayer::Accept(ILayerVisitor& visitor) const +{ + visitor.VisitAdditionLayer(this, GetName()); +} + } // namespace armnn diff --git a/src/armnn/layers/AdditionLayer.hpp b/src/armnn/layers/AdditionLayer.hpp index 4a6b8d9..1c2acab 100644 --- a/src/armnn/layers/AdditionLayer.hpp +++ b/src/armnn/layers/AdditionLayer.hpp @@ -23,6 +23,8 @@ public: /// Creates a dynamically-allocated copy of this layer. /// @param [in] graph The graph into which this layer is being cloned. AdditionLayer* Clone(Graph& graph) const override; + + void Accept(ILayerVisitor& visitor) const override; protected: /// Constructor to create an AdditionLayer. diff --git a/src/armnn/layers/BatchNormalizationLayer.cpp b/src/armnn/layers/BatchNormalizationLayer.cpp index f461c80..dfba2d7 100644 --- a/src/armnn/layers/BatchNormalizationLayer.cpp +++ b/src/armnn/layers/BatchNormalizationLayer.cpp @@ -69,4 +69,10 @@ Layer::ConstantTensors BatchNormalizationLayer::GetConstantTensorsByRef() return {m_Mean, m_Variance, m_Beta, m_Gamma}; } +void BatchNormalizationLayer::Accept(ILayerVisitor& visitor) const +{ + ConstTensor dummy; + visitor.VisitBatchNormalizationLayer(this, GetParameters(), dummy, dummy, dummy, dummy); +} + } // namespace armnn diff --git a/src/armnn/layers/BatchNormalizationLayer.hpp b/src/armnn/layers/BatchNormalizationLayer.hpp index 02d8456..55390b7 100644 --- a/src/armnn/layers/BatchNormalizationLayer.hpp +++ b/src/armnn/layers/BatchNormalizationLayer.hpp @@ -39,6 +39,8 @@ public: /// will lead to a valid configuration of @ref BatchNormalizationLayer. void ValidateTensorShapesFromInputs() override; + void Accept(ILayerVisitor& visitor) const override; + protected: /// Constructor to create a BatchNormalizationLayer. /// @param [in] param BatchNormalizationDescriptor to configure the batch normalization operation. diff --git a/src/armnn/layers/BatchToSpaceNdLayer.cpp b/src/armnn/layers/BatchToSpaceNdLayer.cpp index 8ac4cb9..9accf28 100644 --- a/src/armnn/layers/BatchToSpaceNdLayer.cpp +++ b/src/armnn/layers/BatchToSpaceNdLayer.cpp @@ -118,4 +118,10 @@ std::vector BatchToSpaceNdLayer::InferOutputShapes(const std::vecto return std::vector({ TensorShape({ outputBatchSize, channelSize, outputHeight, outputWidth }) }); } } + +void BatchToSpaceNdLayer::Accept(ILayerVisitor& visitor) const +{ + visitor.VisitBatchToSpaceNdLayer(this, GetParameters(), GetName()); +} + } // namespace armnn diff --git a/src/armnn/layers/BatchToSpaceNdLayer.hpp b/src/armnn/layers/BatchToSpaceNdLayer.hpp index fc4dd71..21ed616 100644 --- a/src/armnn/layers/BatchToSpaceNdLayer.hpp +++ b/src/armnn/layers/BatchToSpaceNdLayer.hpp @@ -34,6 +34,8 @@ public: /// @return A vector to the inferred output shape. std::vector InferOutputShapes(const std::vector& inputShapes) const override; + void Accept(ILayerVisitor& visitor) const override; + protected: /// Constructor to create a BatchToSpaceNdLayer. /// @param [in] param BatchToSpaceNdDescriptor to configure the BatchToSpaceNd operation. diff --git a/src/armnn/layers/ConstantLayer.cpp b/src/armnn/layers/ConstantLayer.cpp index d8f265b..8b94fdb 100644 --- a/src/armnn/layers/ConstantLayer.cpp +++ b/src/armnn/layers/ConstantLayer.cpp @@ -51,4 +51,10 @@ void ConstantLayer::ValidateTensorShapesFromInputs() outShape); } +void ConstantLayer::Accept(ILayerVisitor& visitor) const +{ + ConstTensor dummy; + visitor.VisitConstantLayer(this, dummy, GetName()); +} + } // namespace armnn diff --git a/src/armnn/layers/ConstantLayer.hpp b/src/armnn/layers/ConstantLayer.hpp index c3316b7..d045952 100644 --- a/src/armnn/layers/ConstantLayer.hpp +++ b/src/armnn/layers/ConstantLayer.hpp @@ -39,6 +39,8 @@ public: /// Free up the constant source data stored by the layer. void ReleaseConstantData() override {}; + void Accept(ILayerVisitor& visitor) const override; + std::unique_ptr m_LayerOutput; protected: /// Constructor to create a ConstantLayer. diff --git a/src/armnn/layers/ConvertFp16ToFp32Layer.cpp b/src/armnn/layers/ConvertFp16ToFp32Layer.cpp index 10c4ba4..d3c2462 100644 --- a/src/armnn/layers/ConvertFp16ToFp32Layer.cpp +++ b/src/armnn/layers/ConvertFp16ToFp32Layer.cpp @@ -45,4 +45,11 @@ void ConvertFp16ToFp32Layer::ValidateTensorShapesFromInputs() inferredShapes[0]); } +void ConvertFp16ToFp32Layer::Accept(ILayerVisitor& visitor) const +{ + // these conversion layers are only inserted by the + // optimizer and so will never be in an input graph. + throw armnn::Exception("ConvertFp16ToFp32Layer should never appear in an input graph"); +} + } // namespace armnn diff --git a/src/armnn/layers/ConvertFp16ToFp32Layer.hpp b/src/armnn/layers/ConvertFp16ToFp32Layer.hpp index bdfc981..89046fc 100644 --- a/src/armnn/layers/ConvertFp16ToFp32Layer.hpp +++ b/src/armnn/layers/ConvertFp16ToFp32Layer.hpp @@ -29,6 +29,8 @@ public: /// will lead to a valid configuration of @ref ConvertFp16ToFp32Layer. void ValidateTensorShapesFromInputs() override; + void Accept(ILayerVisitor& visitor) const override; + protected: /// Constructor to create a ConvertFp16ToFp32Layer. /// @param [in] name Optional name for the layer. diff --git a/src/armnn/layers/ConvertFp32ToFp16Layer.cpp b/src/armnn/layers/ConvertFp32ToFp16Layer.cpp index 2bcc4e1..068594b 100644 --- a/src/armnn/layers/ConvertFp32ToFp16Layer.cpp +++ b/src/armnn/layers/ConvertFp32ToFp16Layer.cpp @@ -44,4 +44,11 @@ void ConvertFp32ToFp16Layer::ValidateTensorShapesFromInputs() inferredShapes[0]); } +void ConvertFp32ToFp16Layer::Accept(ILayerVisitor& visitor) const +{ + // These conversion layers are only inserted by the + // optimizer and so will never be in an input graph. + throw armnn::Exception("ConvertFp32ToFp16Layer should never appear in an input graph"); +} + } // namespace armnn diff --git a/src/armnn/layers/ConvertFp32ToFp16Layer.hpp b/src/armnn/layers/ConvertFp32ToFp16Layer.hpp index 524f974..9f8b09b 100644 --- a/src/armnn/layers/ConvertFp32ToFp16Layer.hpp +++ b/src/armnn/layers/ConvertFp32ToFp16Layer.hpp @@ -28,6 +28,8 @@ public: /// will lead to a valid configuration of @ref ConvertFp32ToFp16Layer. void ValidateTensorShapesFromInputs() override; + void Accept(ILayerVisitor& visitor) const override; + protected: /// Constructor to create a ConvertFp32ToFp16Layer. /// @param [in] name Optional name for the layer. diff --git a/src/armnn/layers/Convolution2dLayer.cpp b/src/armnn/layers/Convolution2dLayer.cpp index 4756e1d..86eb71d 100644 --- a/src/armnn/layers/Convolution2dLayer.cpp +++ b/src/armnn/layers/Convolution2dLayer.cpp @@ -110,4 +110,17 @@ Layer::ConstantTensors Convolution2dLayer::GetConstantTensorsByRef() return {m_Weight, m_Bias}; } +void Convolution2dLayer::Accept(ILayerVisitor& visitor) const +{ + ConstTensor dummy; + if (GetParameters().m_BiasEnabled) + { + visitor.VisitConvolution2dLayer(this, GetParameters(), dummy, dummy, GetName()); + } + else + { + visitor.VisitConvolution2dLayer(this, GetParameters(), dummy, GetName()); + } +} + } // namespace armnn diff --git a/src/armnn/layers/Convolution2dLayer.hpp b/src/armnn/layers/Convolution2dLayer.hpp index b812b1b..05a26da 100644 --- a/src/armnn/layers/Convolution2dLayer.hpp +++ b/src/armnn/layers/Convolution2dLayer.hpp @@ -41,6 +41,8 @@ public: /// @return A vector to the inferred output shape. std::vector InferOutputShapes(const std::vector& inputShapes) const override; + void Accept(ILayerVisitor& visitor) const override; + protected: /// Constructor to create a Convolution2dLayer. /// @param [in] param Convolution2dDescriptor to configure the convolution2d operation. diff --git a/src/armnn/layers/DebugLayer.cpp b/src/armnn/layers/DebugLayer.cpp index e83b17e..6fccca6 100644 --- a/src/armnn/layers/DebugLayer.cpp +++ b/src/armnn/layers/DebugLayer.cpp @@ -46,4 +46,10 @@ void DebugLayer::ValidateTensorShapesFromInputs() inferredShapes[0]); } +void DebugLayer::Accept(ILayerVisitor& visitor) const +{ + // by design debug layers are never in input graphs + throw armnn::Exception("DebugLayer should never appear in an input graph"); +} + } // namespace armnn diff --git a/src/armnn/layers/DebugLayer.hpp b/src/armnn/layers/DebugLayer.hpp index fc777a8..bc64541 100644 --- a/src/armnn/layers/DebugLayer.hpp +++ b/src/armnn/layers/DebugLayer.hpp @@ -28,6 +28,8 @@ public: /// will lead to a valid configuration of @ref DebugLayer. void ValidateTensorShapesFromInputs() override; + void Accept(ILayerVisitor& visitor) const override; + protected: /// Constructor to create a DebugLayer. /// @param [in] param DebugDescriptor to configure the debug layer. diff --git a/src/armnn/layers/DepthwiseConvolution2dLayer.cpp b/src/armnn/layers/DepthwiseConvolution2dLayer.cpp index c4edc20..b2d9814 100644 --- a/src/armnn/layers/DepthwiseConvolution2dLayer.cpp +++ b/src/armnn/layers/DepthwiseConvolution2dLayer.cpp @@ -120,4 +120,17 @@ Layer::ConstantTensors DepthwiseConvolution2dLayer::GetConstantTensorsByRef() return {m_Weight, m_Bias}; } +void DepthwiseConvolution2dLayer::Accept(ILayerVisitor& visitor) const +{ + ConstTensor dummy; + if (GetParameters().m_BiasEnabled) + { + visitor.VisitDepthwiseConvolution2dLayer(this, GetParameters(), dummy, dummy, GetName()); + } + else + { + visitor.VisitDepthwiseConvolution2dLayer(this, GetParameters(), dummy, GetName()); + } +} + } // namespace armnn diff --git a/src/armnn/layers/DepthwiseConvolution2dLayer.hpp b/src/armnn/layers/DepthwiseConvolution2dLayer.hpp index 9d5b658..065ba6c 100644 --- a/src/armnn/layers/DepthwiseConvolution2dLayer.hpp +++ b/src/armnn/layers/DepthwiseConvolution2dLayer.hpp @@ -41,6 +41,8 @@ public: /// @return A vector to the inferred output shape. std::vector InferOutputShapes(const std::vector& inputShapes) const override; + void Accept(ILayerVisitor& visitor) const override; + protected: /// Constructor to create a DepthwiseConvolution2dLayer. /// @param [in] param DepthwiseConvolution2dDescriptor to configure the depthwise convolution2d. diff --git a/src/armnn/layers/DetectionPostProcessLayer.cpp b/src/armnn/layers/DetectionPostProcessLayer.cpp index 99aaac7..7858922 100644 --- a/src/armnn/layers/DetectionPostProcessLayer.cpp +++ b/src/armnn/layers/DetectionPostProcessLayer.cpp @@ -36,4 +36,9 @@ void DetectionPostProcessLayer::ValidateTensorShapesFromInputs() VerifyLayerConnections(2, CHECK_LOCATION()); } +void DetectionPostProcessLayer::Accept(ILayerVisitor& visitor) const +{ + visitor.VisitDetectionPostProcessLayer(this, GetParameters(), GetName()); +} + } // namespace armnn diff --git a/src/armnn/layers/DetectionPostProcessLayer.hpp b/src/armnn/layers/DetectionPostProcessLayer.hpp index b5a1cf1..629e386 100644 --- a/src/armnn/layers/DetectionPostProcessLayer.hpp +++ b/src/armnn/layers/DetectionPostProcessLayer.hpp @@ -29,6 +29,8 @@ public: /// will lead to a valid configuration of @ref DetectionPostProcessLayer. void ValidateTensorShapesFromInputs() override; + void Accept(ILayerVisitor& visitor) const override; + protected: /// Constructor to create a DetectionPostProcessLayer. /// @param [in] param DetectionPostProcessDescriptor to configure the detection postprocess. diff --git a/src/armnn/layers/DivisionLayer.cpp b/src/armnn/layers/DivisionLayer.cpp index 0316499..aa54ef6 100644 --- a/src/armnn/layers/DivisionLayer.cpp +++ b/src/armnn/layers/DivisionLayer.cpp @@ -31,4 +31,9 @@ DivisionLayer* DivisionLayer::Clone(Graph& graph) const return CloneBase(graph, GetName()); } +void DivisionLayer::Accept(ILayerVisitor& visitor) const +{ + visitor.VisitDivisionLayer(this, GetName()); +} + } // namespace armnn diff --git a/src/armnn/layers/DivisionLayer.hpp b/src/armnn/layers/DivisionLayer.hpp index e1dca2f..fdeadba 100644 --- a/src/armnn/layers/DivisionLayer.hpp +++ b/src/armnn/layers/DivisionLayer.hpp @@ -25,6 +25,8 @@ public: /// @param [in] graph The graph into which this layer is being cloned. DivisionLayer* Clone(Graph& graph) const override; + void Accept(ILayerVisitor& visitor) const override; + protected: /// Constructor to create a DivisionLayer. /// @param [in] name Optional name for the layer. diff --git a/src/armnn/layers/EqualLayer.cpp b/src/armnn/layers/EqualLayer.cpp index e0d2e65..7d16668 100644 --- a/src/armnn/layers/EqualLayer.cpp +++ b/src/armnn/layers/EqualLayer.cpp @@ -31,4 +31,9 @@ EqualLayer* EqualLayer::Clone(Graph& graph) const return CloneBase(graph, GetName()); } +void EqualLayer::Accept(ILayerVisitor& visitor) const +{ + visitor.VisitEqualLayer(this, GetName()); +} + } // namespace armnn diff --git a/src/armnn/layers/EqualLayer.hpp b/src/armnn/layers/EqualLayer.hpp index 198bae7..b6a01ef 100644 --- a/src/armnn/layers/EqualLayer.hpp +++ b/src/armnn/layers/EqualLayer.hpp @@ -24,6 +24,8 @@ public: /// @param [in] graph The graph into which this layer is being cloned. EqualLayer* Clone(Graph& graph) const override; + void Accept(ILayerVisitor& visitor) const override; + protected: /// Constructor to create a EqualLayer. /// @param [in] name Optional name for the layer. diff --git a/src/armnn/layers/FakeQuantizationLayer.cpp b/src/armnn/layers/FakeQuantizationLayer.cpp index 15f862e..d61a80f 100644 --- a/src/armnn/layers/FakeQuantizationLayer.cpp +++ b/src/armnn/layers/FakeQuantizationLayer.cpp @@ -44,4 +44,9 @@ void FakeQuantizationLayer::ValidateTensorShapesFromInputs() inferredShapes[0]); } +void FakeQuantizationLayer::Accept(ILayerVisitor& visitor) const +{ + throw armnn::Exception("FakeQuantizationLayer should not appear in an input graph"); +} + } // namespace armnn diff --git a/src/armnn/layers/FakeQuantizationLayer.hpp b/src/armnn/layers/FakeQuantizationLayer.hpp index 5e7b5cb..81e5444 100644 --- a/src/armnn/layers/FakeQuantizationLayer.hpp +++ b/src/armnn/layers/FakeQuantizationLayer.hpp @@ -28,6 +28,8 @@ public: /// will lead to a valid configuration of @ref FakeQuantizationLayer. void ValidateTensorShapesFromInputs() override; + void Accept(ILayerVisitor& visitor) const override; + protected: /// Constructor to create a FakeQuantizationLayer. /// @param [in] param FakeQuantizationDescriptor to configure the fake quantization operation. diff --git a/src/armnn/layers/FloorLayer.cpp b/src/armnn/layers/FloorLayer.cpp index ddf1294..34ad7f6 100644 --- a/src/armnn/layers/FloorLayer.cpp +++ b/src/armnn/layers/FloorLayer.cpp @@ -44,4 +44,9 @@ void FloorLayer::ValidateTensorShapesFromInputs() inferredShapes[0]); } +void FloorLayer::Accept(ILayerVisitor& visitor) const +{ + visitor.VisitFloorLayer(this, GetName()); +} + } // namespace armnn diff --git a/src/armnn/layers/FloorLayer.hpp b/src/armnn/layers/FloorLayer.hpp index 546d136..9bc6de7 100644 --- a/src/armnn/layers/FloorLayer.hpp +++ b/src/armnn/layers/FloorLayer.hpp @@ -28,6 +28,8 @@ public: /// will lead to a valid configuration of @ref FloorLayer. void ValidateTensorShapesFromInputs() override; + void Accept(ILayerVisitor& visitor) const override; + protected: /// Constructor to create a FloorLayer. /// @param [in] name Optional name for the layer. diff --git a/src/armnn/layers/FullyConnectedLayer.cpp b/src/armnn/layers/FullyConnectedLayer.cpp index e003c73..977c276 100644 --- a/src/armnn/layers/FullyConnectedLayer.cpp +++ b/src/armnn/layers/FullyConnectedLayer.cpp @@ -86,4 +86,17 @@ Layer::ConstantTensors FullyConnectedLayer::GetConstantTensorsByRef() return {m_Weight, m_Bias}; } +void FullyConnectedLayer::Accept(ILayerVisitor& visitor) const +{ + ConstTensor dummy; + if (GetParameters().m_BiasEnabled) + { + visitor.VisitFullyConnectedLayer(this, GetParameters(), dummy, dummy, GetName()); + } + else + { + visitor.VisitFullyConnectedLayer(this, GetParameters(), dummy, GetName()); + } +} + } // namespace armnn diff --git a/src/armnn/layers/FullyConnectedLayer.hpp b/src/armnn/layers/FullyConnectedLayer.hpp index 0a404b7..d756d43 100644 --- a/src/armnn/layers/FullyConnectedLayer.hpp +++ b/src/armnn/layers/FullyConnectedLayer.hpp @@ -41,6 +41,8 @@ public: /// @return A vector to the inferred output shape. std::vector InferOutputShapes(const std::vector& inputShapes) const override; + void Accept(ILayerVisitor& visitor) const override; + protected: /// Constructor to create a FullyConnectedLayer. /// @param [in] param FullyConnectedDescriptor to configure the fully connected operation. diff --git a/src/armnn/layers/GatherLayer.cpp b/src/armnn/layers/GatherLayer.cpp index d7ed4b2..e3ce6b3 100644 --- a/src/armnn/layers/GatherLayer.cpp +++ b/src/armnn/layers/GatherLayer.cpp @@ -60,4 +60,9 @@ void GatherLayer::ValidateTensorShapesFromInputs() inferredShape); } +void GatherLayer::Accept(ILayerVisitor& visitor) const +{ + visitor.VisitGatherLayer(this, GetName()); +} + } // namespace armnn diff --git a/src/armnn/layers/GatherLayer.hpp b/src/armnn/layers/GatherLayer.hpp index 7b3aebe..9acec52 100644 --- a/src/armnn/layers/GatherLayer.hpp +++ b/src/armnn/layers/GatherLayer.hpp @@ -29,6 +29,8 @@ public: /// will lead to a valid configuration of @ref GatherLayer. void ValidateTensorShapesFromInputs() override; + void Accept(ILayerVisitor& visitor) const override; + protected: /// Constructor to create a GatherLayer. /// @param [in] name Optional name for the layer. diff --git a/src/armnn/layers/GreaterLayer.cpp b/src/armnn/layers/GreaterLayer.cpp index d40c17c..a9fe5e0 100644 --- a/src/armnn/layers/GreaterLayer.cpp +++ b/src/armnn/layers/GreaterLayer.cpp @@ -31,4 +31,9 @@ GreaterLayer* GreaterLayer::Clone(Graph& graph) const return CloneBase(graph, GetName()); } +void GreaterLayer::Accept(ILayerVisitor& visitor) const +{ + visitor.VisitGreaterLayer(this, GetName()); +} + } // namespace armnn diff --git a/src/armnn/layers/GreaterLayer.hpp b/src/armnn/layers/GreaterLayer.hpp index 8b33f41..bdee948 100644 --- a/src/armnn/layers/GreaterLayer.hpp +++ b/src/armnn/layers/GreaterLayer.hpp @@ -25,6 +25,8 @@ public: /// @param [in] graph The graph into which this layer is being cloned. GreaterLayer* Clone(Graph& graph) const override; + void Accept(ILayerVisitor& visitor) const override; + protected: /// Constructor to create a GreaterLayer. /// @param [in] name Optional name for the layer. diff --git a/src/armnn/layers/InputLayer.cpp b/src/armnn/layers/InputLayer.cpp index 0b6d5d2..f56c5b4 100644 --- a/src/armnn/layers/InputLayer.cpp +++ b/src/armnn/layers/InputLayer.cpp @@ -34,4 +34,9 @@ void InputLayer::ValidateTensorShapesFromInputs() "InputLayer should already have the TensorInfo set."); } +void InputLayer::Accept(ILayerVisitor& visitor) const +{ + visitor.VisitInputLayer(this, this->GetBindingId(), GetName()); +} + } // namespace diff --git a/src/armnn/layers/InputLayer.hpp b/src/armnn/layers/InputLayer.hpp index 1f6f245..faa48fb 100644 --- a/src/armnn/layers/InputLayer.hpp +++ b/src/armnn/layers/InputLayer.hpp @@ -28,6 +28,8 @@ public: /// will lead to a valid configuration of @ref InputLayer. void ValidateTensorShapesFromInputs() override; + void Accept(ILayerVisitor& visitor) const override; + protected: /// Constructor to create an InputLayer. /// @param id The layer binding id number. diff --git a/src/armnn/layers/L2NormalizationLayer.cpp b/src/armnn/layers/L2NormalizationLayer.cpp index 2a9fde9..88c3992 100644 --- a/src/armnn/layers/L2NormalizationLayer.cpp +++ b/src/armnn/layers/L2NormalizationLayer.cpp @@ -44,4 +44,9 @@ void L2NormalizationLayer::ValidateTensorShapesFromInputs() inferredShapes[0]); } +void L2NormalizationLayer::Accept(ILayerVisitor& visitor) const +{ + visitor.VisitL2NormalizationLayer(this, GetParameters(), GetName()); +} + } // namespace armnn diff --git a/src/armnn/layers/L2NormalizationLayer.hpp b/src/armnn/layers/L2NormalizationLayer.hpp index bae3d82..0c4b243 100644 --- a/src/armnn/layers/L2NormalizationLayer.hpp +++ b/src/armnn/layers/L2NormalizationLayer.hpp @@ -28,6 +28,8 @@ public: /// will lead to a valid configuration of @ref L2NormalizationLayer. void ValidateTensorShapesFromInputs() override; + void Accept(ILayerVisitor& visitor) const override; + protected: /// Constructor to create a L2NormalizationLayer. /// @param [in] param L2NormalizationDescriptor to configure the L2 normalization operation. diff --git a/src/armnn/layers/LstmLayer.cpp b/src/armnn/layers/LstmLayer.cpp index bd104d4..942038a 100644 --- a/src/armnn/layers/LstmLayer.cpp +++ b/src/armnn/layers/LstmLayer.cpp @@ -249,4 +249,10 @@ Layer::ConstantTensors LstmLayer::GetConstantTensorsByRef() m_PeepholeParameters.m_CellToOutputWeights}; } +void LstmLayer::Accept(ILayerVisitor& visitor) const +{ + LstmInputParams dummy; + visitor.VisitLstmLayer(this, GetParameters(), dummy, GetName()); +} + } // namespace armnn diff --git a/src/armnn/layers/LstmLayer.hpp b/src/armnn/layers/LstmLayer.hpp index 6004d96..bfea5d8 100644 --- a/src/armnn/layers/LstmLayer.hpp +++ b/src/armnn/layers/LstmLayer.hpp @@ -92,6 +92,8 @@ public: /// @return A vector to the inferred output shape. std::vector InferOutputShapes(const std::vector& inputShapes) const override; + void Accept(ILayerVisitor& visitor) const override; + protected: /// Constructor to create a LstmLayer. /// @param [in] param LstmDescriptor to configure the lstm operation. diff --git a/src/armnn/layers/MaximumLayer.cpp b/src/armnn/layers/MaximumLayer.cpp index c0da8d6..5f69a47 100644 --- a/src/armnn/layers/MaximumLayer.cpp +++ b/src/armnn/layers/MaximumLayer.cpp @@ -30,4 +30,9 @@ MaximumLayer* MaximumLayer::Clone(Graph& graph) const return CloneBase(graph, GetName()); } +void MaximumLayer::Accept(ILayerVisitor& visitor) const +{ + visitor.VisitMaximumLayer(this, GetName()); +} + } // namespace armnn diff --git a/src/armnn/layers/MaximumLayer.hpp b/src/armnn/layers/MaximumLayer.hpp index 82ee6e8..9534b07 100644 --- a/src/armnn/layers/MaximumLayer.hpp +++ b/src/armnn/layers/MaximumLayer.hpp @@ -25,6 +25,8 @@ public: /// @param [in] graph The graph into which this layer is being cloned. MaximumLayer* Clone(Graph& graph) const override; + void Accept(ILayerVisitor& visitor) const override; + protected: /// Constructor to create a MaximumLayer. /// @param [in] name Optional name for the layer. diff --git a/src/armnn/layers/MeanLayer.cpp b/src/armnn/layers/MeanLayer.cpp index e45f1a8..c72d79b 100644 --- a/src/armnn/layers/MeanLayer.cpp +++ b/src/armnn/layers/MeanLayer.cpp @@ -100,4 +100,9 @@ void MeanLayer::ValidateTensorShapesFromInputs() inferredShape); } +void MeanLayer::Accept(ILayerVisitor& visitor) const +{ + visitor.VisitMeanLayer(this, GetParameters(), GetName()); +} + } // namespace armnn diff --git a/src/armnn/layers/MeanLayer.hpp b/src/armnn/layers/MeanLayer.hpp index 3896569..d70302f 100644 --- a/src/armnn/layers/MeanLayer.hpp +++ b/src/armnn/layers/MeanLayer.hpp @@ -29,6 +29,8 @@ public: /// will lead to a valid configuration of @ref MeanLayer. void ValidateTensorShapesFromInputs() override; + void Accept(ILayerVisitor& visitor) const override; + protected: /// Constructor to create a MeanLayer. /// @param [in] param MeanDescriptor to configure the mean operation. diff --git a/src/armnn/layers/MemCopyLayer.cpp b/src/armnn/layers/MemCopyLayer.cpp index e3138d2..6f3f559 100644 --- a/src/armnn/layers/MemCopyLayer.cpp +++ b/src/armnn/layers/MemCopyLayer.cpp @@ -46,4 +46,9 @@ void MemCopyLayer::ValidateTensorShapesFromInputs() inferredShapes[0]); } +void MemCopyLayer::Accept(ILayerVisitor& visitor) const +{ + throw armnn::Exception("MemCopyLayer should not appear in an input graph"); +} + } // namespace armnn diff --git a/src/armnn/layers/MemCopyLayer.hpp b/src/armnn/layers/MemCopyLayer.hpp index 051b18f..2c696a4 100644 --- a/src/armnn/layers/MemCopyLayer.hpp +++ b/src/armnn/layers/MemCopyLayer.hpp @@ -28,6 +28,8 @@ public: /// will lead to a valid configuration of @ref MemCopyLayer. void ValidateTensorShapesFromInputs() override; + void Accept(ILayerVisitor& visitor) const override; + protected: /// Constructor to create a MemCopyLayer. /// @param [in] name Optional name for the layer. diff --git a/src/armnn/layers/MergerLayer.cpp b/src/armnn/layers/MergerLayer.cpp index b4b5d3c..f87f349 100644 --- a/src/armnn/layers/MergerLayer.cpp +++ b/src/armnn/layers/MergerLayer.cpp @@ -195,4 +195,9 @@ void MergerLayer::ValidateTensorShapesFromInputs() inferredShapes[0]); } +void MergerLayer::Accept(ILayerVisitor& visitor) const +{ + visitor.VisitMergerLayer(this, GetParameters(), GetName()); +} + } // namespace armnn armnn diff --git a/src/armnn/layers/MergerLayer.hpp b/src/armnn/layers/MergerLayer.hpp index f0bf62b..6f0c148 100644 --- a/src/armnn/layers/MergerLayer.hpp +++ b/src/armnn/layers/MergerLayer.hpp @@ -40,6 +40,8 @@ public: /// @return A vector to the inferred output shape. std::vector InferOutputShapes(const std::vector& inputShapes) const override; + void Accept(ILayerVisitor& visitor) const override; + protected: /// Constructor to create a MergerLayer. /// @param [in] param OriginsDescriptor to configure the merger operation. diff --git a/src/armnn/layers/MinimumLayer.cpp b/src/armnn/layers/MinimumLayer.cpp index 8e76041..810ee18 100644 --- a/src/armnn/layers/MinimumLayer.cpp +++ b/src/armnn/layers/MinimumLayer.cpp @@ -31,4 +31,9 @@ MinimumLayer* MinimumLayer::Clone(Graph& graph) const return CloneBase(graph, GetName()); } +void MinimumLayer::Accept(ILayerVisitor& visitor) const +{ + visitor.VisitMinimumLayer(this, GetName()); +} + } // namespace armnn diff --git a/src/armnn/layers/MinimumLayer.hpp b/src/armnn/layers/MinimumLayer.hpp index 3801c62..4a7bc17 100644 --- a/src/armnn/layers/MinimumLayer.hpp +++ b/src/armnn/layers/MinimumLayer.hpp @@ -25,6 +25,8 @@ public: /// @param [in] graph The graph into which this layer is being cloned. MinimumLayer* Clone(Graph& graph) const override; + void Accept(ILayerVisitor& visitor) const override; + protected: /// Constructor to create a MinimumLayer. /// @param [in] name Optional name for the layer. diff --git a/src/armnn/layers/MultiplicationLayer.cpp b/src/armnn/layers/MultiplicationLayer.cpp index 9448935..4556a87 100644 --- a/src/armnn/layers/MultiplicationLayer.cpp +++ b/src/armnn/layers/MultiplicationLayer.cpp @@ -31,4 +31,9 @@ MultiplicationLayer* MultiplicationLayer::Clone(Graph& graph) const return CloneBase(graph, GetName()); } +void MultiplicationLayer::Accept(ILayerVisitor& visitor) const +{ + visitor.VisitMultiplicationLayer(this, GetName()); +} + } // namespace armnn diff --git a/src/armnn/layers/MultiplicationLayer.hpp b/src/armnn/layers/MultiplicationLayer.hpp index 9f15e3a..b9fd35a 100644 --- a/src/armnn/layers/MultiplicationLayer.hpp +++ b/src/armnn/layers/MultiplicationLayer.hpp @@ -25,6 +25,8 @@ public: /// @param [in] graph The graph into which this layer is being cloned. MultiplicationLayer* Clone(Graph& graph) const override; + void Accept(ILayerVisitor& visitor) const override; + protected: /// Constructor to create a MultiplicationLayer. /// @param [in] name Optional name for the layer diff --git a/src/armnn/layers/NormalizationLayer.cpp b/src/armnn/layers/NormalizationLayer.cpp index 140d628..f5b9284 100644 --- a/src/armnn/layers/NormalizationLayer.cpp +++ b/src/armnn/layers/NormalizationLayer.cpp @@ -43,4 +43,9 @@ void NormalizationLayer::ValidateTensorShapesFromInputs() inferredShapes[0]); } +void NormalizationLayer::Accept(ILayerVisitor& visitor) const +{ + visitor.VisitNormalizationLayer(this, GetParameters(), GetName()); +} + } // namespace armnn diff --git a/src/armnn/layers/NormalizationLayer.hpp b/src/armnn/layers/NormalizationLayer.hpp index 9fd7875..0027acc 100644 --- a/src/armnn/layers/NormalizationLayer.hpp +++ b/src/armnn/layers/NormalizationLayer.hpp @@ -28,6 +28,8 @@ public: /// will lead to a valid configuration of @ref NormalizationLayer. void ValidateTensorShapesFromInputs() override; + void Accept(ILayerVisitor& visitor) const override; + protected: /// Constructor to create a NormalizationLayer. /// @param [in] param NormalizationDescriptor to configure the normalization operation. diff --git a/src/armnn/layers/OutputLayer.cpp b/src/armnn/layers/OutputLayer.cpp index db11a3d..9b4cb70 100644 --- a/src/armnn/layers/OutputLayer.cpp +++ b/src/armnn/layers/OutputLayer.cpp @@ -34,4 +34,9 @@ void OutputLayer::ValidateTensorShapesFromInputs() "OutputLayer: Input slot must be connected."); } +void OutputLayer::Accept(ILayerVisitor& visitor) const +{ + visitor.VisitOutputLayer(this, GetBindingId(), GetName()); +} + } // namespace armnn diff --git a/src/armnn/layers/OutputLayer.hpp b/src/armnn/layers/OutputLayer.hpp index 080b301..b86f8e2 100644 --- a/src/armnn/layers/OutputLayer.hpp +++ b/src/armnn/layers/OutputLayer.hpp @@ -37,6 +37,8 @@ public: /// will lead to a valid configuration of @ref OutputLayer. void ValidateTensorShapesFromInputs() override; + void Accept(ILayerVisitor& visitor) const override; + protected: /// Constructor to create an OutputLayer. /// @param id The layer binding id number. diff --git a/src/armnn/layers/PadLayer.cpp b/src/armnn/layers/PadLayer.cpp index 5e5f8ca..9e08da4 100644 --- a/src/armnn/layers/PadLayer.cpp +++ b/src/armnn/layers/PadLayer.cpp @@ -42,4 +42,9 @@ void PadLayer::ValidateTensorShapesFromInputs() return; } +void PadLayer::Accept(ILayerVisitor& visitor) const +{ + visitor.VisitPadLayer(this, GetParameters(), GetName()); +} + } // namespace armnn \ No newline at end of file diff --git a/src/armnn/layers/PadLayer.hpp b/src/armnn/layers/PadLayer.hpp index 569365a..8174fa8 100644 --- a/src/armnn/layers/PadLayer.hpp +++ b/src/armnn/layers/PadLayer.hpp @@ -29,6 +29,8 @@ public: /// will lead to a valid configuration of @ref PadLayer. void ValidateTensorShapesFromInputs() override; + void Accept(ILayerVisitor& visitor) const override; + protected: /// Constructor to create a PadLayer. /// @param [in] param PadDescriptor to configure the pad operation. diff --git a/src/armnn/layers/PermuteLayer.cpp b/src/armnn/layers/PermuteLayer.cpp index 6d0d7e0..e6a7a38 100644 --- a/src/armnn/layers/PermuteLayer.cpp +++ b/src/armnn/layers/PermuteLayer.cpp @@ -52,4 +52,9 @@ void PermuteLayer::ValidateTensorShapesFromInputs() inferredShapes[0]); } +void PermuteLayer::Accept(ILayerVisitor& visitor) const +{ + visitor.VisitPermuteLayer(this, GetParameters(), GetName()); +} + } // namespace armnn diff --git a/src/armnn/layers/PermuteLayer.hpp b/src/armnn/layers/PermuteLayer.hpp index e1f391a..8413322 100644 --- a/src/armnn/layers/PermuteLayer.hpp +++ b/src/armnn/layers/PermuteLayer.hpp @@ -58,6 +58,8 @@ public: GetPermutation().IsEqual(boost::polymorphic_downcast(&other)->GetPermutation()); } + void Accept(ILayerVisitor& visitor) const override; + protected: /// Constructor to create a PermuteLayer. /// @param [in] param PermuteDescriptor to configure the permute operation. diff --git a/src/armnn/layers/Pooling2dLayer.cpp b/src/armnn/layers/Pooling2dLayer.cpp index d4af056..7c5be01 100644 --- a/src/armnn/layers/Pooling2dLayer.cpp +++ b/src/armnn/layers/Pooling2dLayer.cpp @@ -114,4 +114,9 @@ void Pooling2dLayer::ValidateTensorShapesFromInputs() inferredShapes[0]); } +void Pooling2dLayer::Accept(ILayerVisitor& visitor) const +{ + visitor.VisitPooling2dLayer(this, GetParameters(), GetName()); +} + } // namespace armnn diff --git a/src/armnn/layers/Pooling2dLayer.hpp b/src/armnn/layers/Pooling2dLayer.hpp index ee6a6ac..f70ae78 100644 --- a/src/armnn/layers/Pooling2dLayer.hpp +++ b/src/armnn/layers/Pooling2dLayer.hpp @@ -34,6 +34,8 @@ public: /// @return A vector to the inferred output shape. std::vector InferOutputShapes(const std::vector& inputShapes) const override; + void Accept(ILayerVisitor& visitor) const override; + protected: /// Constructor to create a Pooling2dLayer. /// @param [in] param Pooling2dDescriptor to configure the pooling2d operation. diff --git a/src/armnn/layers/PreCompiledLayer.cpp b/src/armnn/layers/PreCompiledLayer.cpp index c443f9a..1106421 100644 --- a/src/armnn/layers/PreCompiledLayer.cpp +++ b/src/armnn/layers/PreCompiledLayer.cpp @@ -53,4 +53,9 @@ void PreCompiledLayer::SetPreCompiledObject(const std::shared_ptr& preComp m_PreCompiledObject = preCompiledObject; } +void PreCompiledLayer::Accept(ILayerVisitor& visitor) const +{ + throw armnn::Exception("PreCompiledLayer should not appear in an input graph"); +} + } // namespace armnn diff --git a/src/armnn/layers/PreCompiledLayer.hpp b/src/armnn/layers/PreCompiledLayer.hpp index fd28d0e..854a78c 100644 --- a/src/armnn/layers/PreCompiledLayer.hpp +++ b/src/armnn/layers/PreCompiledLayer.hpp @@ -32,6 +32,8 @@ public: void SetPreCompiledObject(const std::shared_ptr& preCompiledObject); + void Accept(ILayerVisitor& visitor) const override; + private: PreCompiledLayer(const PreCompiledLayer& other) = delete; PreCompiledLayer& operator=(const PreCompiledLayer& other) = delete; diff --git a/src/armnn/layers/ReshapeLayer.cpp b/src/armnn/layers/ReshapeLayer.cpp index 2a06980..cfce712 100644 --- a/src/armnn/layers/ReshapeLayer.cpp +++ b/src/armnn/layers/ReshapeLayer.cpp @@ -49,4 +49,9 @@ void ReshapeLayer::ValidateTensorShapesFromInputs() inferredShapes[0]); } +void ReshapeLayer::Accept(ILayerVisitor& visitor) const +{ + visitor.VisitReshapeLayer(this, GetParameters(), GetName()); +} + } // namespace armnn diff --git a/src/armnn/layers/ReshapeLayer.hpp b/src/armnn/layers/ReshapeLayer.hpp index 13e73be..c4743d1 100644 --- a/src/armnn/layers/ReshapeLayer.hpp +++ b/src/armnn/layers/ReshapeLayer.hpp @@ -43,6 +43,8 @@ public: m_Param.m_TargetShape == boost::polymorphic_downcast(&other)->m_Param.m_TargetShape; } + void Accept(ILayerVisitor& visitor) const override; + protected: /// Constructor to create a ReshapeLayer. /// @param [in] param ReshapeDescriptor to configure the reshape operation. diff --git a/src/armnn/layers/ResizeBilinearLayer.cpp b/src/armnn/layers/ResizeBilinearLayer.cpp index c7c92d7..03fe317 100644 --- a/src/armnn/layers/ResizeBilinearLayer.cpp +++ b/src/armnn/layers/ResizeBilinearLayer.cpp @@ -66,4 +66,9 @@ void ResizeBilinearLayer::ValidateTensorShapesFromInputs() inferredShapes[0]); } +void ResizeBilinearLayer::Accept(ILayerVisitor& visitor) const +{ + visitor.VisitResizeBilinearLayer(this, GetParameters(), GetName()); +} + } // namespace armnn diff --git a/src/armnn/layers/ResizeBilinearLayer.hpp b/src/armnn/layers/ResizeBilinearLayer.hpp index 185d8a5..4bf264c 100644 --- a/src/armnn/layers/ResizeBilinearLayer.hpp +++ b/src/armnn/layers/ResizeBilinearLayer.hpp @@ -34,6 +34,8 @@ public: /// @return A vector to the inferred output shape. std::vector InferOutputShapes(const std::vector& inputShapes) const override; + void Accept(ILayerVisitor& visitor) const override; + protected: /// Constructor to create a ResizeBilinearLayerLayer. /// @param [in] param ResizeBilinearDescriptor to configure the resize bilinear operation. diff --git a/src/armnn/layers/RsqrtLayer.cpp b/src/armnn/layers/RsqrtLayer.cpp index d516810..a21564e 100644 --- a/src/armnn/layers/RsqrtLayer.cpp +++ b/src/armnn/layers/RsqrtLayer.cpp @@ -45,4 +45,9 @@ void RsqrtLayer::ValidateTensorShapesFromInputs() inferredShapes[0]); } +void RsqrtLayer::Accept(ILayerVisitor& visitor) const +{ + visitor.VisitRsqrtLayer(this, GetName()); +} + } // namespace armnn \ No newline at end of file diff --git a/src/armnn/layers/RsqrtLayer.hpp b/src/armnn/layers/RsqrtLayer.hpp index 47a4cce..526a664 100644 --- a/src/armnn/layers/RsqrtLayer.hpp +++ b/src/armnn/layers/RsqrtLayer.hpp @@ -28,6 +28,8 @@ public: /// will lead to a valid configuration of @ref RsqrtLayer. void ValidateTensorShapesFromInputs() override; + void Accept(ILayerVisitor& visitor) const override; + protected: /// Constructor to create an RsqrtLayer. /// @param [in] name Optional name for the layer. diff --git a/src/armnn/layers/SoftmaxLayer.cpp b/src/armnn/layers/SoftmaxLayer.cpp index 4c2456d..90891b4 100644 --- a/src/armnn/layers/SoftmaxLayer.cpp +++ b/src/armnn/layers/SoftmaxLayer.cpp @@ -43,4 +43,9 @@ void SoftmaxLayer::ValidateTensorShapesFromInputs() inferredShapes[0]); } +void SoftmaxLayer::Accept(ILayerVisitor& visitor) const +{ + visitor.VisitSoftmaxLayer(this, GetParameters(), GetName()); +} + } // namespace armnn diff --git a/src/armnn/layers/SoftmaxLayer.hpp b/src/armnn/layers/SoftmaxLayer.hpp index f6bc894..82c2099 100644 --- a/src/armnn/layers/SoftmaxLayer.hpp +++ b/src/armnn/layers/SoftmaxLayer.hpp @@ -28,6 +28,8 @@ public: /// will lead to a valid configuration of @ref SoftmaxLayer. void ValidateTensorShapesFromInputs() override; + void Accept(ILayerVisitor& visitor) const override; + protected: /// Constructor to create a SoftmaxLayer. /// @param [in] param SoftmaxDescriptor to configure the softmax operation. diff --git a/src/armnn/layers/SpaceToBatchNdLayer.cpp b/src/armnn/layers/SpaceToBatchNdLayer.cpp index 38540d5..6d5827e 100644 --- a/src/armnn/layers/SpaceToBatchNdLayer.cpp +++ b/src/armnn/layers/SpaceToBatchNdLayer.cpp @@ -82,4 +82,9 @@ void SpaceToBatchNdLayer::ValidateTensorShapesFromInputs() inferredShapes[0]); } +void SpaceToBatchNdLayer::Accept(ILayerVisitor& visitor) const +{ + visitor.VisitSpaceToBatchNdLayer(this, GetParameters(), GetName()); +} + } // namespace diff --git a/src/armnn/layers/SpaceToBatchNdLayer.hpp b/src/armnn/layers/SpaceToBatchNdLayer.hpp index 3e91bbd..f6616bc 100644 --- a/src/armnn/layers/SpaceToBatchNdLayer.hpp +++ b/src/armnn/layers/SpaceToBatchNdLayer.hpp @@ -35,6 +35,8 @@ public: /// will lead to a valid configuration of @ref SpaceToBatchNdLayer. void ValidateTensorShapesFromInputs() override; + void Accept(ILayerVisitor& visitor) const override; + protected: /// Constructor to create a SpaceToBatchNdLayer. /// @param [in] param SpaceToBatchNdDescriptor to configure the SpaceToBatchNdLayer operation. diff --git a/src/armnn/layers/SplitterLayer.cpp b/src/armnn/layers/SplitterLayer.cpp index 5cf1f6b..b3a1094 100644 --- a/src/armnn/layers/SplitterLayer.cpp +++ b/src/armnn/layers/SplitterLayer.cpp @@ -98,4 +98,9 @@ void SplitterLayer::ValidateTensorShapesFromInputs() } } +void SplitterLayer::Accept(ILayerVisitor& visitor) const +{ + visitor.VisitSplitterLayer(this, GetParameters(), GetName()); +} + } // namespace armnn diff --git a/src/armnn/layers/SplitterLayer.hpp b/src/armnn/layers/SplitterLayer.hpp index 6a73510..19b0556 100644 --- a/src/armnn/layers/SplitterLayer.hpp +++ b/src/armnn/layers/SplitterLayer.hpp @@ -40,6 +40,8 @@ public: /// @return A vector to the inferred output shape. std::vector InferOutputShapes(const std::vector& inputShapes) const override; + void Accept(ILayerVisitor& visitor) const override; + protected: /// Constructor to create a SplitterLayer. /// @param [in] param ViewsDescriptor to configure the splitter operation. diff --git a/src/armnn/layers/StridedSliceLayer.cpp b/src/armnn/layers/StridedSliceLayer.cpp index 4ad9b89..03d451c 100644 --- a/src/armnn/layers/StridedSliceLayer.cpp +++ b/src/armnn/layers/StridedSliceLayer.cpp @@ -88,4 +88,9 @@ void StridedSliceLayer::ValidateTensorShapesFromInputs() inferredShapes[0]); } +void StridedSliceLayer::Accept(ILayerVisitor& visitor) const +{ + visitor.VisitStridedSliceLayer(this, GetParameters(), GetName()); +} + } // namespace armnn diff --git a/src/armnn/layers/StridedSliceLayer.hpp b/src/armnn/layers/StridedSliceLayer.hpp index 761dc5e..97b8ee2 100644 --- a/src/armnn/layers/StridedSliceLayer.hpp +++ b/src/armnn/layers/StridedSliceLayer.hpp @@ -34,6 +34,8 @@ public: /// will lead to a valid configuration of @ref StridedSliceLayer. void ValidateTensorShapesFromInputs() override; + void Accept(ILayerVisitor& visitor) const override; + protected: /// Constructor to create a StridedSliceLayer. /// @param [in] param StridedSliceDescriptor to configure the strided slice layer. diff --git a/src/armnn/layers/SubtractionLayer.cpp b/src/armnn/layers/SubtractionLayer.cpp index 18d8661..6becfdc 100644 --- a/src/armnn/layers/SubtractionLayer.cpp +++ b/src/armnn/layers/SubtractionLayer.cpp @@ -31,4 +31,9 @@ SubtractionLayer* SubtractionLayer::Clone(Graph& graph) const return CloneBase(graph, GetName()); } +void SubtractionLayer::Accept(ILayerVisitor& visitor) const +{ + visitor.VisitSubtractionLayer(this, GetName()); +} + } // namespace armnn diff --git a/src/armnn/layers/SubtractionLayer.hpp b/src/armnn/layers/SubtractionLayer.hpp index 15d5684..557da65 100644 --- a/src/armnn/layers/SubtractionLayer.hpp +++ b/src/armnn/layers/SubtractionLayer.hpp @@ -25,6 +25,8 @@ public: /// @param [in] graph The graph into which this layer is being cloned. SubtractionLayer* Clone(Graph& graph) const override; + void Accept(ILayerVisitor& visitor) const override; + protected: /// Constructor to create a SubtractionLayer. /// @param [in] name Optional name for the layer. -- 2.7.4