ArmNN
 22.05
StrategyBase.hpp
Go to the documentation of this file.
1 //
2 // Copyright © 2021 Arm Ltd and Contributors. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 #pragma once
6 
7 
8 #include <armnn/INetwork.hpp>
9 #include <armnn/IStrategy.hpp>
11 
12 namespace armnn
13 {
14 
16 {
17  void Apply(const std::string& errorMessage = "") { throw UnimplementedException(errorMessage); };
18 };
19 
21 {
22  void Apply(const std::string&) {};
23 };
24 
25 /// Strategy base class with empty implementations.
26 template <typename DefaultStrategy>
27 class StrategyBase : public IStrategy
28 {
29 protected:
30  virtual ~StrategyBase() {};
31 
32 public:
33  virtual void ExecuteStrategy(const armnn::IConnectableLayer* layer,
34  const armnn::BaseDescriptor& descriptor,
35  const std::vector<armnn::ConstTensor>& constants,
36  const char* name,
37  const armnn::LayerBindingId id = 0) override
38  {
39  armnn::IgnoreUnused(descriptor, constants, id, name);
40  switch (layer->GetType())
41  {
42  default:
43  {
44  m_DefaultStrategy.Apply(GetLayerTypeAsCString(layer->GetType()));
45  }
46  }
47  }
48 
49 protected:
50  DefaultStrategy m_DefaultStrategy;
51 
52 };
53 
54 
55 } // namespace armnn
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
Definition: INetwork.hpp:66
void Apply(const std::string &errorMessage="")
Copyright (c) 2021 ARM Limited and Contributors.
void IgnoreUnused(Ts &&...)
int LayerBindingId
Type of identifiers for bindable layers (inputs, outputs).
Definition: Types.hpp:290
Base class for all descriptors.
Definition: Descriptors.hpp:22
Strategy base class with empty implementations.
DefaultStrategy m_DefaultStrategy
void Apply(const std::string &)
virtual LayerType GetType() const =0
Returns the armnn::LayerType of this layer.
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) override
const char * GetLayerTypeAsCString(LayerType type)