aboutsummaryrefslogtreecommitdiff
path: root/include/armnn/StrategyBase.hpp
blob: 78f393f44f2ad70d6b2f8658c66602a9e243eceb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//
// Copyright © 2021 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
#pragma once


#include <armnn/INetwork.hpp>
#include <armnn/IStrategy.hpp>
#include <armnn/utility/IgnoreUnused.hpp>

namespace armnn
{

struct ThrowingStrategy
{
    void Apply(const std::string& errorMessage = "") { throw UnimplementedException(errorMessage); };
};

struct NoThrowStrategy
{
    void Apply(const std::string&) {};
};

/// Strategy base class with empty implementations.
template <typename DefaultStrategy>
class StrategyBase : public IStrategy
{
protected:
    virtual ~StrategyBase() {};

public:
    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
    {
        armnn::IgnoreUnused(descriptor, constants, id, name);
        switch (layer->GetType())
        {
            default:
            {
                m_DefaultStrategy.Apply(GetLayerTypeAsCString(layer->GetType()));
            }
        }
    }

protected:
    DefaultStrategy m_DefaultStrategy;

};


} // namespace armnn