blob: ae48e818ecf7b2422a21b81e56c2825854ba3a1d [file] [log] [blame]
Georgios Pinitasd8734b52017-12-22 15:27:52 +00001/*
Michele Di Giorgiod9eaf612020-07-08 11:12:57 +01002 * Copyright (c) 2018-2019 Arm Limited.
Georgios Pinitasd8734b52017-12-22 15:27:52 +00003 *
4 * SPDX-License-Identifier: MIT
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to
8 * deal in the Software without restriction, including without limitation the
9 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in all
14 * copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 */
Michalis Spyrouf4643372019-11-29 16:17:13 +000024#ifndef ARM_COMPUTE_GRAPH_GRAPH_MANAGER_H
25#define ARM_COMPUTE_GRAPH_GRAPH_MANAGER_H
Georgios Pinitasd8734b52017-12-22 15:27:52 +000026
Georgios Pinitasd9eb2752018-04-03 13:44:29 +010027#include "arm_compute/graph/Types.h"
28#include "arm_compute/graph/Workload.h"
Georgios Pinitasd8734b52017-12-22 15:27:52 +000029
30#include <map>
31
32namespace arm_compute
33{
Georgios Pinitasd9eb2752018-04-03 13:44:29 +010034namespace graph
Georgios Pinitasd8734b52017-12-22 15:27:52 +000035{
36// Forward declaration
37class Graph;
38class GraphContext;
39class PassManager;
40
41/** Graph manager class
42 *
43 * Manages a list of graphs along with their resources
44 */
45class GraphManager final
46{
47public:
48 /** Default Constructor **/
49 GraphManager();
50 /** Prevent instances of this class from being copied (As this class contains pointers) */
51 GraphManager(const GraphManager &) = delete;
52 /** Default move constructor */
53 GraphManager(GraphManager &&) = default;
54 /** Prevent instances of this class from being copied (As this class contains pointers) */
55 GraphManager &operator=(const GraphManager &) = delete;
56 /** Default move assignment operator */
57 GraphManager &operator=(GraphManager &&) = default;
58 /** Finalizes a given graph
59 *
60 * @warning At this given time finalize_graph will alter the passed graph,
61 * plan is to avoid by copying the graph structure,
62 * or provide another entry-point for this functionality as it will increase the memory requirements
63 *
64 * @param[in] graph Graph to finalize
65 * @param[in] ctx Graph context
66 * @param[in] pm Pass manager to use for any optimization passes
67 * @param[in] target Execution target (Single target execution is currently supported)
68 */
69 void finalize_graph(Graph &graph, GraphContext &ctx, PassManager &pm, Target target);
70 /** Executes a graph
71 *
72 * @param[in] graph Graph to execute
73 */
74 void execute_graph(Graph &graph);
75 /** Invalidates the graph execution workload
76 *
77 * @param[in] graph Graph to invalidate
78 */
79 void invalidate_graph(Graph &graph);
80
81private:
82 std::map<GraphID, ExecutionWorkload> _workloads = {}; /**< Graph workloads */
83};
Georgios Pinitasd9eb2752018-04-03 13:44:29 +010084} // namespace graph
Georgios Pinitasd8734b52017-12-22 15:27:52 +000085} // namespace arm_compute
Michalis Spyrouf4643372019-11-29 16:17:13 +000086#endif /* ARM_COMPUTE_GRAPH_GRAPH_MANAGER_H */