1 // 2 // Copyright © 2017 Arm Ltd. All rights reserved. 3 // SPDX-License-Identifier: MIT 4 // 5 #pragma once 6 7 #include <Layer.hpp> 8 9 namespace armnn 10 { 11 12 template <typename Parameters> 13 class LayerWithParameters : public Layer 14 { 15 public: 16 using DescriptorType = Parameters; 17 GetParameters() const18 const Parameters& GetParameters() const { return m_Param; } 19 20 /// Helper to serialize the layer parameters to string 21 /// (currently used in DotSerializer and company). SerializeLayerParameters(ParameterStringifyFunction & fn) const22 void SerializeLayerParameters(ParameterStringifyFunction& fn) const override 23 { 24 StringifyLayerParameters<Parameters>::Serialize(fn, m_Param); 25 Layer::SerializeLayerParameters(fn); 26 } 27 28 protected: LayerWithParameters(unsigned int numInputSlots,unsigned int numOutputSlots,LayerType type,const Parameters & param,const char * name)29 LayerWithParameters(unsigned int numInputSlots, 30 unsigned int numOutputSlots, 31 LayerType type, 32 const Parameters& param, 33 const char* name) 34 : Layer(numInputSlots, numOutputSlots, type, name) 35 , m_Param(param) 36 { 37 } 38 39 ~LayerWithParameters() = default; 40 41 /// Helper function to reduce duplication in *Layer::CreateWorkload. 42 template <typename QueueDescriptor> PrepInfoAndDesc(QueueDescriptor & descriptor) const43 WorkloadInfo PrepInfoAndDesc(QueueDescriptor& descriptor) const 44 { 45 descriptor.m_Parameters = m_Param; 46 return Layer::PrepInfoAndDesc(descriptor); 47 } 48 49 /// The parameters for the layer (not including tensor-valued weights etc.). 50 Parameters m_Param; 51 }; 52 53 } // namespace 54