Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 1 | /* |
| 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 | #ifndef __ARM_COMPUTE_GRAPH2_STREAM_H__ |
| 25 | #define __ARM_COMPUTE_GRAPH2_STREAM_H__ |
| 26 | |
| 27 | #include "arm_compute/graph2/frontend/IStream.h" |
| 28 | #include "arm_compute/graph2/frontend/IStreamOperators.h" |
| 29 | #include "arm_compute/graph2/frontend/Types.h" |
| 30 | |
| 31 | #include "arm_compute/graph2/Graph.h" |
| 32 | #include "arm_compute/graph2/GraphContext.h" |
| 33 | #include "arm_compute/graph2/GraphManager.h" |
| 34 | |
| 35 | namespace arm_compute |
| 36 | { |
| 37 | namespace graph2 |
| 38 | { |
| 39 | namespace frontend |
| 40 | { |
| 41 | // Forward Declarations |
| 42 | class ILayer; |
| 43 | |
| 44 | /** Stream frontend class to construct simple graphs in a stream fashion */ |
| 45 | class Stream final : public IStream |
| 46 | { |
| 47 | public: |
| 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; |
| 56 | /** Default move constructor */ |
| 57 | Stream(Stream &&) = default; |
| 58 | /** Prevent instances of this class from being copied (As this class contains pointers) */ |
| 59 | Stream &operator=(const Stream &) = delete; |
| 60 | /** Default move assignment operator */ |
| 61 | Stream &operator=(Stream &&) = default; |
| 62 | /** Finalizes the stream for an execution target |
| 63 | * |
| 64 | * @note enable_tuning only works if the target is OpenCL. |
| 65 | * @note tuning increases the execution time of first run of the graph |
| 66 | * |
| 67 | * @param[in] target Execution target |
| 68 | * @param[in] enable_tuning (Optional) Enables the tuning interface. Defaults to false |
| 69 | * @param[in] enable_memory_management (Optional) Enables the memory management interface. Defaults to false |
| 70 | */ |
| 71 | void finalize(Target target, bool enable_tuning = false, bool enable_memory_management = false); |
| 72 | /** Executes the stream **/ |
| 73 | void run(); |
| 74 | |
| 75 | // Inherited overridden methods |
| 76 | void add_layer(ILayer &layer) override; |
| 77 | Graph &graph() override; |
| 78 | const Graph &graph() const override; |
| 79 | |
| 80 | private: |
| 81 | GraphManager _manager; /**< Graph manager */ |
| 82 | GraphContext _ctx; /**< Graph context to use */ |
| 83 | Graph _g; /**< Internal graph representation of the stream */ |
| 84 | }; |
| 85 | } // namespace frontend |
| 86 | } // namespace graph2 |
| 87 | } // namespace arm_compute |
| 88 | #endif /* __ARM_COMPUTE_GRAPH2_STREAM_H__ */ |