IVGCVSW-2547 Add Accept function to IConnectableLayer
authorjimfly01 <jim.flynn@arm.com>
Thu, 24 Jan 2019 22:29:33 +0000 (22:29 +0000)
committerNarumol Prangnawarat <narumol.prangnawarat@arm.com>
Fri, 25 Jan 2019 14:10:53 +0000 (14:10 +0000)
* Layers which callback VisitXXXLayer with ConstTensor
  have been implemented with dummies to speed up implementation
  and unblock IVGCVSW-2531

Change-Id: I49b8035f12ec72d6bd6cee95075692f98c48e193

84 files changed:
include/armnn/ILayerVisitor.hpp
include/armnn/INetwork.hpp
src/armnn/layers/ActivationLayer.cpp
src/armnn/layers/ActivationLayer.hpp
src/armnn/layers/AdditionLayer.cpp
src/armnn/layers/AdditionLayer.hpp
src/armnn/layers/BatchNormalizationLayer.cpp
src/armnn/layers/BatchNormalizationLayer.hpp
src/armnn/layers/BatchToSpaceNdLayer.cpp
src/armnn/layers/BatchToSpaceNdLayer.hpp
src/armnn/layers/ConstantLayer.cpp
src/armnn/layers/ConstantLayer.hpp
src/armnn/layers/ConvertFp16ToFp32Layer.cpp
src/armnn/layers/ConvertFp16ToFp32Layer.hpp
src/armnn/layers/ConvertFp32ToFp16Layer.cpp
src/armnn/layers/ConvertFp32ToFp16Layer.hpp
src/armnn/layers/Convolution2dLayer.cpp
src/armnn/layers/Convolution2dLayer.hpp
src/armnn/layers/DebugLayer.cpp
src/armnn/layers/DebugLayer.hpp
src/armnn/layers/DepthwiseConvolution2dLayer.cpp
src/armnn/layers/DepthwiseConvolution2dLayer.hpp
src/armnn/layers/DetectionPostProcessLayer.cpp
src/armnn/layers/DetectionPostProcessLayer.hpp
src/armnn/layers/DivisionLayer.cpp
src/armnn/layers/DivisionLayer.hpp
src/armnn/layers/EqualLayer.cpp
src/armnn/layers/EqualLayer.hpp
src/armnn/layers/FakeQuantizationLayer.cpp
src/armnn/layers/FakeQuantizationLayer.hpp
src/armnn/layers/FloorLayer.cpp
src/armnn/layers/FloorLayer.hpp
src/armnn/layers/FullyConnectedLayer.cpp
src/armnn/layers/FullyConnectedLayer.hpp
src/armnn/layers/GatherLayer.cpp
src/armnn/layers/GatherLayer.hpp
src/armnn/layers/GreaterLayer.cpp
src/armnn/layers/GreaterLayer.hpp
src/armnn/layers/InputLayer.cpp
src/armnn/layers/InputLayer.hpp
src/armnn/layers/L2NormalizationLayer.cpp
src/armnn/layers/L2NormalizationLayer.hpp
src/armnn/layers/LstmLayer.cpp
src/armnn/layers/LstmLayer.hpp
src/armnn/layers/MaximumLayer.cpp
src/armnn/layers/MaximumLayer.hpp
src/armnn/layers/MeanLayer.cpp
src/armnn/layers/MeanLayer.hpp
src/armnn/layers/MemCopyLayer.cpp
src/armnn/layers/MemCopyLayer.hpp
src/armnn/layers/MergerLayer.cpp
src/armnn/layers/MergerLayer.hpp
src/armnn/layers/MinimumLayer.cpp
src/armnn/layers/MinimumLayer.hpp
src/armnn/layers/MultiplicationLayer.cpp
src/armnn/layers/MultiplicationLayer.hpp
src/armnn/layers/NormalizationLayer.cpp
src/armnn/layers/NormalizationLayer.hpp
src/armnn/layers/OutputLayer.cpp
src/armnn/layers/OutputLayer.hpp
src/armnn/layers/PadLayer.cpp
src/armnn/layers/PadLayer.hpp
src/armnn/layers/PermuteLayer.cpp
src/armnn/layers/PermuteLayer.hpp
src/armnn/layers/Pooling2dLayer.cpp
src/armnn/layers/Pooling2dLayer.hpp
src/armnn/layers/PreCompiledLayer.cpp
src/armnn/layers/PreCompiledLayer.hpp
src/armnn/layers/ReshapeLayer.cpp
src/armnn/layers/ReshapeLayer.hpp
src/armnn/layers/ResizeBilinearLayer.cpp
src/armnn/layers/ResizeBilinearLayer.hpp
src/armnn/layers/RsqrtLayer.cpp
src/armnn/layers/RsqrtLayer.hpp
src/armnn/layers/SoftmaxLayer.cpp
src/armnn/layers/SoftmaxLayer.hpp
src/armnn/layers/SpaceToBatchNdLayer.cpp
src/armnn/layers/SpaceToBatchNdLayer.hpp
src/armnn/layers/SplitterLayer.cpp
src/armnn/layers/SplitterLayer.hpp
src/armnn/layers/StridedSliceLayer.cpp
src/armnn/layers/StridedSliceLayer.hpp
src/armnn/layers/SubtractionLayer.cpp
src/armnn/layers/SubtractionLayer.hpp

index dd73a6f..c56be81 100644 (file)
@@ -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.
index 1f7354d..2213cee 100644 (file)
@@ -8,6 +8,7 @@
 #include <armnn/DescriptorsFwd.hpp>
 #include <armnn/TensorFwd.hpp>
 #include <armnn/Optional.hpp>
+#include <armnn/ILayerVisitor.hpp>
 
 #include <armnn/Types.hpp>
 
@@ -70,6 +71,8 @@ public:
     virtual std::vector<TensorShape> InferOutputShapes(const std::vector<TensorShape>& inputShapes) const = 0;
 
     virtual LayerGuid GetGuid() const = 0;
+
+    virtual void Accept(ILayerVisitor& visitor) const = 0;
 protected:
       /// Objects are not deletable via the handle
     ~IConnectableLayer() {}
index 401ab29..6f80cce 100644 (file)
@@ -42,4 +42,9 @@ void ActivationLayer::ValidateTensorShapesFromInputs()
         inferredShapes[0]);
 }
 
+void ActivationLayer::Accept(ILayerVisitor& visitor) const
+{
+    visitor.VisitActivationLayer(this, GetParameters(), GetName());
+}
+
 } // namespace armnn
index 390955a..aac05f3 100644 (file)
@@ -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.
index 2762266..02ee306 100644 (file)
@@ -31,4 +31,9 @@ AdditionLayer* AdditionLayer::Clone(Graph& graph) const
     return CloneBase<AdditionLayer>(graph, GetName());
 }
 
+void AdditionLayer::Accept(ILayerVisitor& visitor) const
+{
+    visitor.VisitAdditionLayer(this, GetName());
+}
+
 } // namespace armnn
index 4a6b8d9..1c2acab 100644 (file)
@@ -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.
index f461c80..dfba2d7 100644 (file)
@@ -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
index 02d8456..55390b7 100644 (file)
@@ -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.
index 8ac4cb9..9accf28 100644 (file)
@@ -118,4 +118,10 @@ std::vector<TensorShape> BatchToSpaceNdLayer::InferOutputShapes(const std::vecto
         return std::vector<TensorShape>({ TensorShape({ outputBatchSize, channelSize, outputHeight, outputWidth }) });
     }
 }
+
+void BatchToSpaceNdLayer::Accept(ILayerVisitor& visitor) const
+{
+    visitor.VisitBatchToSpaceNdLayer(this, GetParameters(), GetName());
+}
+
 } // namespace armnn
index fc4dd71..21ed616 100644 (file)
@@ -34,6 +34,8 @@ public:
     /// @return A vector to the inferred output shape.
     std::vector<TensorShape> InferOutputShapes(const std::vector<TensorShape>& inputShapes) const override;
 
+    void Accept(ILayerVisitor& visitor) const override;
+
 protected:
     /// Constructor to create a BatchToSpaceNdLayer.
     /// @param [in] param BatchToSpaceNdDescriptor to configure the BatchToSpaceNd operation.
index d8f265b..8b94fdb 100644 (file)
@@ -51,4 +51,10 @@ void ConstantLayer::ValidateTensorShapesFromInputs()
         outShape);
 }
 
+void ConstantLayer::Accept(ILayerVisitor& visitor) const
+{
+    ConstTensor dummy;
+    visitor.VisitConstantLayer(this, dummy, GetName());
+}
+
 } // namespace armnn
index c3316b7..d045952 100644 (file)
@@ -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<ScopedCpuTensorHandle> m_LayerOutput;
 protected:
     /// Constructor to create a ConstantLayer.
index 10c4ba4..d3c2462 100644 (file)
@@ -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
index bdfc981..89046fc 100644 (file)
@@ -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.
index 2bcc4e1..068594b 100644 (file)
@@ -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
index 524f974..9f8b09b 100644 (file)
@@ -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.
index 4756e1d..86eb71d 100644 (file)
@@ -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
index b812b1b..05a26da 100644 (file)
@@ -41,6 +41,8 @@ public:
     /// @return A vector to the inferred output shape.
     std::vector<TensorShape> InferOutputShapes(const std::vector<TensorShape>& inputShapes) const override;
 
+    void Accept(ILayerVisitor& visitor) const override;
+
 protected:
     /// Constructor to create a Convolution2dLayer.
     /// @param [in] param Convolution2dDescriptor to configure the convolution2d operation.
index e83b17e..6fccca6 100644 (file)
@@ -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
index fc777a8..bc64541 100644 (file)
@@ -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.
index c4edc20..b2d9814 100644 (file)
@@ -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
index 9d5b658..065ba6c 100644 (file)
@@ -41,6 +41,8 @@ public:
     /// @return A vector to the inferred output shape.
     std::vector<TensorShape> InferOutputShapes(const std::vector<TensorShape>& inputShapes) const override;
 
+    void Accept(ILayerVisitor& visitor) const override;
+
 protected:
     /// Constructor to create a DepthwiseConvolution2dLayer.
     /// @param [in] param DepthwiseConvolution2dDescriptor to configure the depthwise convolution2d.
index 99aaac7..7858922 100644 (file)
@@ -36,4 +36,9 @@ void DetectionPostProcessLayer::ValidateTensorShapesFromInputs()
     VerifyLayerConnections(2, CHECK_LOCATION());
 }
 
+void DetectionPostProcessLayer::Accept(ILayerVisitor& visitor) const
+{
+    visitor.VisitDetectionPostProcessLayer(this, GetParameters(), GetName());
+}
+
 } // namespace armnn
index b5a1cf1..629e386 100644 (file)
@@ -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.
index 0316499..aa54ef6 100644 (file)
@@ -31,4 +31,9 @@ DivisionLayer* DivisionLayer::Clone(Graph& graph) const
     return CloneBase<DivisionLayer>(graph, GetName());
 }
 
+void DivisionLayer::Accept(ILayerVisitor& visitor) const
+{
+    visitor.VisitDivisionLayer(this, GetName());
+}
+
 } // namespace armnn
index e1dca2f..fdeadba 100644 (file)
@@ -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.
index e0d2e65..7d16668 100644 (file)
@@ -31,4 +31,9 @@ EqualLayer* EqualLayer::Clone(Graph& graph) const
     return CloneBase<EqualLayer>(graph, GetName());
 }
 
+void EqualLayer::Accept(ILayerVisitor& visitor) const
+{
+    visitor.VisitEqualLayer(this, GetName());
+}
+
 } // namespace armnn
index 198bae7..b6a01ef 100644 (file)
@@ -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.
index 15f862e..d61a80f 100644 (file)
@@ -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
index 5e7b5cb..81e5444 100644 (file)
@@ -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.
index ddf1294..34ad7f6 100644 (file)
@@ -44,4 +44,9 @@ void FloorLayer::ValidateTensorShapesFromInputs()
         inferredShapes[0]);
 }
 
+void FloorLayer::Accept(ILayerVisitor& visitor) const
+{
+    visitor.VisitFloorLayer(this, GetName());
+}
+
 } // namespace armnn
index 546d136..9bc6de7 100644 (file)
@@ -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.
index e003c73..977c276 100644 (file)
@@ -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
index 0a404b7..d756d43 100644 (file)
@@ -41,6 +41,8 @@ public:
     /// @return A vector to the inferred output shape.
     std::vector<TensorShape> InferOutputShapes(const std::vector<TensorShape>& 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.
index d7ed4b2..e3ce6b3 100644 (file)
@@ -60,4 +60,9 @@ void GatherLayer::ValidateTensorShapesFromInputs()
         inferredShape);
 }
 
+void GatherLayer::Accept(ILayerVisitor& visitor) const
+{
+    visitor.VisitGatherLayer(this, GetName());
+}
+
 } // namespace armnn
index 7b3aebe..9acec52 100644 (file)
@@ -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.
index d40c17c..a9fe5e0 100644 (file)
@@ -31,4 +31,9 @@ GreaterLayer* GreaterLayer::Clone(Graph& graph) const
     return CloneBase<GreaterLayer>(graph, GetName());
 }
 
+void GreaterLayer::Accept(ILayerVisitor& visitor) const
+{
+    visitor.VisitGreaterLayer(this, GetName());
+}
+
 } // namespace armnn
index 8b33f41..bdee948 100644 (file)
@@ -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.
index 0b6d5d2..f56c5b4 100644 (file)
@@ -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
index 1f6f245..faa48fb 100644 (file)
@@ -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.
index 2a9fde9..88c3992 100644 (file)
@@ -44,4 +44,9 @@ void L2NormalizationLayer::ValidateTensorShapesFromInputs()
         inferredShapes[0]);
 }
 
+void L2NormalizationLayer::Accept(ILayerVisitor& visitor) const
+{
+    visitor.VisitL2NormalizationLayer(this, GetParameters(), GetName());
+}
+
 } // namespace armnn
index bae3d82..0c4b243 100644 (file)
@@ -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.
index bd104d4..942038a 100644 (file)
@@ -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
index 6004d96..bfea5d8 100644 (file)
@@ -92,6 +92,8 @@ public:
     /// @return A vector to the inferred output shape.
     std::vector<TensorShape> InferOutputShapes(const std::vector<TensorShape>& inputShapes) const override;
 
+    void Accept(ILayerVisitor& visitor) const override;
+
 protected:
     /// Constructor to create a LstmLayer.
     /// @param [in] param LstmDescriptor to configure the lstm operation.
index c0da8d6..5f69a47 100644 (file)
@@ -30,4 +30,9 @@ MaximumLayer* MaximumLayer::Clone(Graph& graph) const
     return CloneBase<MaximumLayer>(graph, GetName());
 }
 
+void MaximumLayer::Accept(ILayerVisitor& visitor) const
+{
+    visitor.VisitMaximumLayer(this, GetName());
+}
+
 } // namespace armnn
index 82ee6e8..9534b07 100644 (file)
@@ -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.
index e45f1a8..c72d79b 100644 (file)
@@ -100,4 +100,9 @@ void MeanLayer::ValidateTensorShapesFromInputs()
         inferredShape);
 }
 
+void MeanLayer::Accept(ILayerVisitor& visitor) const
+{
+    visitor.VisitMeanLayer(this, GetParameters(), GetName());
+}
+
 } // namespace armnn
index 3896569..d70302f 100644 (file)
@@ -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.
index e3138d2..6f3f559 100644 (file)
@@ -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
index 051b18f..2c696a4 100644 (file)
@@ -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.
index b4b5d3c..f87f349 100644 (file)
@@ -195,4 +195,9 @@ void MergerLayer::ValidateTensorShapesFromInputs()
         inferredShapes[0]);
 }
 
+void MergerLayer::Accept(ILayerVisitor& visitor) const
+{
+    visitor.VisitMergerLayer(this, GetParameters(), GetName());
+}
+
 } // namespace armnn armnn
index f0bf62b..6f0c148 100644 (file)
@@ -40,6 +40,8 @@ public:
     /// @return A vector to the inferred output shape.
     std::vector<TensorShape> InferOutputShapes(const std::vector<TensorShape>& inputShapes) const override;
 
+    void Accept(ILayerVisitor& visitor) const override;
+
 protected:
     /// Constructor to create a MergerLayer.
     /// @param [in] param OriginsDescriptor to configure the merger operation.
index 8e76041..810ee18 100644 (file)
@@ -31,4 +31,9 @@ MinimumLayer* MinimumLayer::Clone(Graph& graph) const
     return CloneBase<MinimumLayer>(graph, GetName());
 }
 
+void MinimumLayer::Accept(ILayerVisitor& visitor) const
+{
+    visitor.VisitMinimumLayer(this, GetName());
+}
+
 } // namespace armnn
index 3801c62..4a7bc17 100644 (file)
@@ -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.
index 9448935..4556a87 100644 (file)
@@ -31,4 +31,9 @@ MultiplicationLayer* MultiplicationLayer::Clone(Graph& graph) const
     return CloneBase<MultiplicationLayer>(graph, GetName());
 }
 
+void MultiplicationLayer::Accept(ILayerVisitor& visitor) const
+{
+    visitor.VisitMultiplicationLayer(this, GetName());
+}
+
 } // namespace armnn
index 9f15e3a..b9fd35a 100644 (file)
@@ -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
index 140d628..f5b9284 100644 (file)
@@ -43,4 +43,9 @@ void NormalizationLayer::ValidateTensorShapesFromInputs()
         inferredShapes[0]);
 }
 
+void NormalizationLayer::Accept(ILayerVisitor& visitor) const
+{
+    visitor.VisitNormalizationLayer(this, GetParameters(), GetName());
+}
+
 } // namespace armnn
index 9fd7875..0027acc 100644 (file)
@@ -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.
index db11a3d..9b4cb70 100644 (file)
@@ -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
index 080b301..b86f8e2 100644 (file)
@@ -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.
index 5e5f8ca..9e08da4 100644 (file)
@@ -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
index 569365a..8174fa8 100644 (file)
@@ -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.
index 6d0d7e0..e6a7a38 100644 (file)
@@ -52,4 +52,9 @@ void PermuteLayer::ValidateTensorShapesFromInputs()
         inferredShapes[0]);
 }
 
+void PermuteLayer::Accept(ILayerVisitor& visitor) const
+{
+    visitor.VisitPermuteLayer(this, GetParameters(), GetName());
+}
+
 } // namespace armnn
index e1f391a..8413322 100644 (file)
@@ -58,6 +58,8 @@ public:
                GetPermutation().IsEqual(boost::polymorphic_downcast<const PermuteLayer*>(&other)->GetPermutation());
     }
 
+    void Accept(ILayerVisitor& visitor) const override;
+
 protected:
     /// Constructor to create a PermuteLayer.
     /// @param [in] param PermuteDescriptor to configure the permute operation.
index d4af056..7c5be01 100644 (file)
@@ -114,4 +114,9 @@ void Pooling2dLayer::ValidateTensorShapesFromInputs()
         inferredShapes[0]);
 }
 
+void Pooling2dLayer::Accept(ILayerVisitor& visitor) const
+{
+    visitor.VisitPooling2dLayer(this, GetParameters(), GetName());
+}
+
 } // namespace armnn
index ee6a6ac..f70ae78 100644 (file)
@@ -34,6 +34,8 @@ public:
     /// @return A vector to the inferred output shape.
     std::vector<TensorShape> InferOutputShapes(const std::vector<TensorShape>& inputShapes) const override;
 
+    void Accept(ILayerVisitor& visitor) const override;
+
 protected:
     /// Constructor to create a Pooling2dLayer.
     /// @param [in] param Pooling2dDescriptor to configure the pooling2d operation.
index c443f9a..1106421 100644 (file)
@@ -53,4 +53,9 @@ void PreCompiledLayer::SetPreCompiledObject(const std::shared_ptr<void>& preComp
     m_PreCompiledObject = preCompiledObject;
 }
 
+void PreCompiledLayer::Accept(ILayerVisitor& visitor) const
+{
+    throw armnn::Exception("PreCompiledLayer should not appear in an input graph");
+}
+
 } // namespace armnn
index fd28d0e..854a78c 100644 (file)
@@ -32,6 +32,8 @@ public:
 
     void SetPreCompiledObject(const std::shared_ptr<void>& preCompiledObject);
 
+    void Accept(ILayerVisitor& visitor) const override;
+
 private:
     PreCompiledLayer(const PreCompiledLayer& other) = delete;
     PreCompiledLayer& operator=(const PreCompiledLayer& other) = delete;
index 2a06980..cfce712 100644 (file)
@@ -49,4 +49,9 @@ void ReshapeLayer::ValidateTensorShapesFromInputs()
         inferredShapes[0]);
 }
 
+void ReshapeLayer::Accept(ILayerVisitor& visitor) const
+{
+    visitor.VisitReshapeLayer(this, GetParameters(), GetName());
+}
+
 } // namespace armnn
index 13e73be..c4743d1 100644 (file)
@@ -43,6 +43,8 @@ public:
                m_Param.m_TargetShape == boost::polymorphic_downcast<const ReshapeLayer*>(&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.
index c7c92d7..03fe317 100644 (file)
@@ -66,4 +66,9 @@ void ResizeBilinearLayer::ValidateTensorShapesFromInputs()
         inferredShapes[0]);
 }
 
+void ResizeBilinearLayer::Accept(ILayerVisitor& visitor) const
+{
+    visitor.VisitResizeBilinearLayer(this, GetParameters(), GetName());
+}
+
 } // namespace armnn
index 185d8a5..4bf264c 100644 (file)
@@ -34,6 +34,8 @@ public:
     /// @return A vector to the inferred output shape.
     std::vector<TensorShape> InferOutputShapes(const std::vector<TensorShape>& 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.
index d516810..a21564e 100644 (file)
@@ -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
index 47a4cce..526a664 100644 (file)
@@ -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.
index 4c2456d..90891b4 100644 (file)
@@ -43,4 +43,9 @@ void SoftmaxLayer::ValidateTensorShapesFromInputs()
         inferredShapes[0]);
 }
 
+void SoftmaxLayer::Accept(ILayerVisitor& visitor) const
+{
+    visitor.VisitSoftmaxLayer(this, GetParameters(), GetName());
+}
+
 } // namespace armnn
index f6bc894..82c2099 100644 (file)
@@ -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.
index 38540d5..6d5827e 100644 (file)
@@ -82,4 +82,9 @@ void SpaceToBatchNdLayer::ValidateTensorShapesFromInputs()
         inferredShapes[0]);
 }
 
+void SpaceToBatchNdLayer::Accept(ILayerVisitor& visitor) const
+{
+    visitor.VisitSpaceToBatchNdLayer(this, GetParameters(), GetName());
+}
+
 } // namespace
index 3e91bbd..f6616bc 100644 (file)
@@ -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.
index 5cf1f6b..b3a1094 100644 (file)
@@ -98,4 +98,9 @@ void SplitterLayer::ValidateTensorShapesFromInputs()
     }
 }
 
+void SplitterLayer::Accept(ILayerVisitor& visitor) const
+{
+    visitor.VisitSplitterLayer(this, GetParameters(), GetName());
+}
+
 } // namespace armnn
index 6a73510..19b0556 100644 (file)
@@ -40,6 +40,8 @@ public:
     /// @return A vector to the inferred output shape.
     std::vector<TensorShape> InferOutputShapes(const std::vector<TensorShape>& inputShapes) const override;
 
+    void Accept(ILayerVisitor& visitor) const override;
+
 protected:
     /// Constructor to create a SplitterLayer.
     /// @param [in] param ViewsDescriptor to configure the splitter operation.
index 4ad9b89..03d451c 100644 (file)
@@ -88,4 +88,9 @@ void StridedSliceLayer::ValidateTensorShapesFromInputs()
                     inferredShapes[0]);
 }
 
+void StridedSliceLayer::Accept(ILayerVisitor& visitor) const
+{
+    visitor.VisitStridedSliceLayer(this, GetParameters(), GetName());
+}
+
 } // namespace armnn
index 761dc5e..97b8ee2 100644 (file)
@@ -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.
index 18d8661..6becfdc 100644 (file)
@@ -31,4 +31,9 @@ SubtractionLayer* SubtractionLayer::Clone(Graph& graph) const
     return CloneBase<SubtractionLayer>(graph, GetName());
 }
 
+void SubtractionLayer::Accept(ILayerVisitor& visitor) const
+{
+    visitor.VisitSubtractionLayer(this, GetName());
+}
+
 } // namespace armnn
index 15d5684..557da65 100644 (file)
@@ -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.