blob: 076b9ac11f8c06c16a441e0176064925168b517a [file] [log] [blame]
Georgios Pinitasd8734b52017-12-22 15:27:52 +00001/*
2 * Copyright (c) 2018 ARM Limited.
3 *
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 */
24#include "arm_compute/graph2/frontend/Stream.h"
25
26#include "arm_compute/graph2/Utils.h"
27#include "arm_compute/graph2/frontend/ILayer.h"
28
29namespace arm_compute
30{
31namespace graph2
32{
33namespace frontend
34{
35Stream::Stream(size_t id, std::string name)
36 : _manager(), _ctx(), _g(id, std::move(name))
37{
38}
39
40void Stream::finalize(Target target, bool enable_tuning, bool enable_memory_management)
41{
42 PassManager pm = create_default_pass_manager();
43 _ctx.enable_tuning(enable_tuning);
44 _ctx.enable_memory_managenent(enable_memory_management);
45 _manager.finalize_graph(_g, _ctx, pm, target);
46}
47
48void Stream::run()
49{
50 _manager.execute_graph(_g);
51}
52
53void Stream::add_layer(ILayer &layer)
54{
55 auto nid = layer.create_layer(*this);
56 _tail_node = nid;
57}
58
59const Graph &Stream::graph() const
60{
61 return _g;
62}
63
64Graph &Stream::graph()
65{
66 return _g;
67}
68} // namespace frontend
69} // namespace graph2
70} // namespace arm_compute