David Beck | f98d21a | 2018-10-26 16:03:03 +0100 | [diff] [blame^] | 1 | // |
| 2 | // Copyright © 2017 Arm Ltd. All rights reserved. |
| 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | #pragma once |
| 6 | |
| 7 | #include "SubGraph.hpp" |
| 8 | #include <functional> |
| 9 | #include <memory> |
| 10 | |
| 11 | namespace armnn |
| 12 | { |
| 13 | |
| 14 | class Layer; |
| 15 | class Graph; |
| 16 | |
| 17 | class SubGraphSelector final |
| 18 | { |
| 19 | public: |
| 20 | using SubGraphPtr = std::unique_ptr<SubGraph>; |
| 21 | using SubGraphs = std::vector<SubGraphPtr>; |
| 22 | using LayerSelectorFunction = std::function<bool(const Layer&)>; |
| 23 | |
| 24 | /// Selects subgraphs of a graph based on the selector function |
| 25 | /// and the algorithm. Since the SubGraphs returns modifiable pointers |
| 26 | /// the input and output slots of the graph: |
| 27 | /// 1) the graph cannot be const |
| 28 | /// 2) the caller need to make sure that the SubGraphs lifetime is |
| 29 | /// shorter than the graph's |
| 30 | static SubGraphs SelectSubGraphs(Graph& graph, |
| 31 | const LayerSelectorFunction& selector); |
| 32 | |
| 33 | private: |
| 34 | // this is a utility class, don't construct or copy |
| 35 | SubGraphSelector() = delete; |
| 36 | SubGraphSelector(const SubGraphSelector&) = delete; |
| 37 | SubGraphSelector & operator=(const SubGraphSelector&) = delete; |
| 38 | }; |
| 39 | |
| 40 | } // namespace armnn |