blob: db22f6d91b4b78379efc033a7a9ead0086606f8c [file] [log] [blame]
Georgios Pinitasd8734b52017-12-22 15:27:52 +00001/*
Michele Di Giorgiod9eaf612020-07-08 11:12:57 +01002 * Copyright (c) 2018-2020 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_STREAM_H
25#define ARM_COMPUTE_GRAPH_STREAM_H
Georgios Pinitasd8734b52017-12-22 15:27:52 +000026
Georgios Pinitasd9eb2752018-04-03 13:44:29 +010027#include "arm_compute/graph/frontend/IStream.h"
28#include "arm_compute/graph/frontend/IStreamOperators.h"
29#include "arm_compute/graph/frontend/Types.h"
Georgios Pinitasd8734b52017-12-22 15:27:52 +000030
Georgios Pinitasd9eb2752018-04-03 13:44:29 +010031#include "arm_compute/graph/Graph.h"
32#include "arm_compute/graph/GraphContext.h"
33#include "arm_compute/graph/GraphManager.h"
Georgios Pinitasd8734b52017-12-22 15:27:52 +000034
35namespace arm_compute
36{
Georgios Pinitasd9eb2752018-04-03 13:44:29 +010037namespace graph
Georgios Pinitasd8734b52017-12-22 15:27:52 +000038{
39namespace frontend
40{
41// Forward Declarations
42class ILayer;
43
44/** Stream frontend class to construct simple graphs in a stream fashion */
45class Stream final : public IStream
46{
47public:
48 /** Constructor
49 *
50 * @param[in] id Stream id
51 * @param[in] name Stream name
52 */
53 Stream(size_t id, std::string name);
54 /** Prevent instances of this class from being copied (As this class contains pointers) */
55 Stream(const Stream &) = delete;
Georgios Pinitasd8734b52017-12-22 15:27:52 +000056 /** Prevent instances of this class from being copied (As this class contains pointers) */
57 Stream &operator=(const Stream &) = delete;
Georgios Pinitasd8734b52017-12-22 15:27:52 +000058 /** Finalizes the stream for an execution target
59 *
Georgios Pinitas9a8c6722018-03-21 17:52:35 +000060 * @param[in] target Execution target
61 * @param[in] config (Optional) Graph configuration to use
Georgios Pinitasd8734b52017-12-22 15:27:52 +000062 */
Georgios Pinitas9a8c6722018-03-21 17:52:35 +000063 void finalize(Target target, const GraphConfig &config);
Georgios Pinitasd8734b52017-12-22 15:27:52 +000064 /** Executes the stream **/
65 void run();
66
67 // Inherited overridden methods
68 void add_layer(ILayer &layer) override;
69 Graph &graph() override;
70 const Graph &graph() const override;
71
72private:
Anthony Barbierb6eb3532018-08-08 13:20:04 +010073 //Important: GraphContext must be declared *before* the GraphManager because the GraphManager
Anthony Barbier5a65cfd2018-08-10 14:10:08 +010074 //allocates resources from the context and therefore needs to be destroyed before the context during clean up.
Georgios Pinitasd8734b52017-12-22 15:27:52 +000075 GraphContext _ctx; /**< Graph context to use */
Anthony Barbierb6eb3532018-08-08 13:20:04 +010076 GraphManager _manager; /**< Graph manager */
Georgios Pinitasd8734b52017-12-22 15:27:52 +000077 Graph _g; /**< Internal graph representation of the stream */
78};
79} // namespace frontend
Georgios Pinitasd9eb2752018-04-03 13:44:29 +010080} // namespace graph
Georgios Pinitasd8734b52017-12-22 15:27:52 +000081} // namespace arm_compute
Michalis Spyrouf4643372019-11-29 16:17:13 +000082#endif /* ARM_COMPUTE_GRAPH_STREAM_H */