ArmNN
 21.08
LayerWithParameters.hpp
Go to the documentation of this file.
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 
18  const Parameters& GetParameters() const { return m_Param; }
19 
20  /// Helper to serialize the layer parameters to string
21  /// (currently used in DotSerializer and company).
23  {
26  }
27 
28 protected:
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>
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  void ExecuteStrategy(IStrategy& strategy) const override
53  {
54  strategy.ExecuteStrategy(this, GetParameters(), {}, GetName());
55  }
56 };
57 
58 } // namespace
void ExecuteStrategy(IStrategy &strategy) const override
Apply a visitor to this layer.
LayerWithParameters(unsigned int numInputSlots, unsigned int numOutputSlots, LayerType type, const Parameters &param, const char *name)
Parameters m_Param
The parameters for the layer (not including tensor-valued weights etc.).
const Parameters & GetParameters() const
virtual void ExecuteStrategy(const armnn::IConnectableLayer *layer, const armnn::BaseDescriptor &descriptor, const std::vector< armnn::ConstTensor > &constants, const char *name, const armnn::LayerBindingId id=0)=0
void SerializeLayerParameters(ParameterStringifyFunction &fn) const override
Helper to serialize the layer parameters to string (currently used in DotSerializer and company)...
Copyright (c) 2021 ARM Limited and Contributors.
A ResizeDescriptor for the ResizeLayer.
WorkloadInfo PrepInfoAndDesc(QueueDescriptor &descriptor) const
Helper function to reduce duplication in *LayerCreateWorkload.
Definition: Layer.hpp:381
WorkloadInfo PrepInfoAndDesc(QueueDescriptor &descriptor) const
Helper function to reduce duplication in *LayerCreateWorkload.
virtual void SerializeLayerParameters(ParameterStringifyFunction &fn) const
Helper to serialize the layer parameters to string.
Definition: Layer.cpp:447
Contains information about TensorInfos of a layer.
const char * GetName() const override
Returns the name of the layer.
Definition: Layer.hpp:311
std::function< void(const std::string &name, const std::string &value)> ParameterStringifyFunction
static void Serialize(ParameterStringifyFunction &, const LayerParameter &)
LayerType
When adding a new layer, adapt also the LastLayer enum value in the enum class LayerType below...
Definition: Types.hpp:405