blob: 025c43bbfc8c64f0bf9231b116d752574520afa6 [file] [log] [blame]
Laurent Carlier749294b2020-06-01 09:03:17 +01001//
telsoa014fcda012018-03-09 14:13:49 +00002// Copyright © 2017 Arm Ltd. All rights reserved.
David Beckecb56cd2018-09-05 12:52:57 +01003// SPDX-License-Identifier: MIT
telsoa014fcda012018-03-09 14:13:49 +00004//
5#pragma once
6
7#include <vector>
telsoa01c577f2c2018-08-31 09:22:23 +01008#include <memory>
9#include "optimizations/All.hpp"
telsoa014fcda012018-03-09 14:13:49 +000010
11namespace armnn
12{
13
telsoa014fcda012018-03-09 14:13:49 +000014class Optimizer
15{
16public:
telsoa01c577f2c2018-08-31 09:22:23 +010017 using OptimizationPtr = std::unique_ptr<Optimization>;
18 using Optimizations = std::vector<OptimizationPtr>;
telsoa014fcda012018-03-09 14:13:49 +000019
telsoa01c577f2c2018-08-31 09:22:23 +010020 static void Pass(Graph& graph, const Optimizations& optimizations);
telsoa014fcda012018-03-09 14:13:49 +000021
22private:
23 ~Optimizer() = default;
24
surmeh01bceff2f2018-03-29 16:29:27 +010025 Optimizer();
telsoa014fcda012018-03-09 14:13:49 +000026};
27
telsoa01c577f2c2018-08-31 09:22:23 +010028
29template<typename T>
30void Append(Optimizer::Optimizations& optimizations, T&& optimization)
31{
32 optimizations.emplace_back(new T(optimization));
33};
34
35template<typename Front, typename... Others>
36void Append(Optimizer::Optimizations& optimizations, Front&& front, Others&&... others)
37{
38 Append<Front>(optimizations, std::forward<Front>(front));
39 Append<Others...>(optimizations, std::forward<Others>(others)...);
40};
41
42template<typename... Args>
43Optimizer::Optimizations MakeOptimizations(Args&&... args)
44{
45 Optimizer::Optimizations optimizations;
46
47 Append(optimizations, std::forward<Args>(args)...);
48
49 return optimizations;
50}
51
telsoa014fcda012018-03-09 14:13:49 +000052} // namespace armnn