From d9eb27597eabe5b7c17520f4f9b3f8a282d72573 Mon Sep 17 00:00:00 2001 From: Georgios Pinitas Date: Tue, 3 Apr 2018 13:44:29 +0100 Subject: COMPMID-797: Switch to new graph. - Cleaned up build system Change-Id: If2faa27ee5b31fa8b972836960ab3ef671059c8d Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/126435 Tested-by: Jenkins Reviewed-by: Pablo Tello --- arm_compute/graph/GraphContext.h | 90 +++++++++++++++++++++------------------- 1 file changed, 48 insertions(+), 42 deletions(-) (limited to 'arm_compute/graph/GraphContext.h') diff --git a/arm_compute/graph/GraphContext.h b/arm_compute/graph/GraphContext.h index 98bc8c02f8..2f9ab665ce 100644 --- a/arm_compute/graph/GraphContext.h +++ b/arm_compute/graph/GraphContext.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 ARM Limited. + * Copyright (c) 2018 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -21,68 +21,74 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -#ifndef __ARM_COMPUTE_GRAPH_CONTEXT_H__ -#define __ARM_COMPUTE_GRAPH_CONTEXT_H__ +#ifndef __ARM_COMPUTE_GRAPH_GRAPH_CONTEXT_H__ +#define __ARM_COMPUTE_GRAPH_GRAPH_CONTEXT_H__ #include "arm_compute/graph/Types.h" +#include "arm_compute/runtime/IMemoryManager.h" + +#include +#include + namespace arm_compute { namespace graph { -/** Hints that can be passed to the graph to expose parameterization */ -class GraphHints +/** Contains structs required for memory management */ +struct MemoryManagerContext +{ + Target target = { Target::UNSPECIFIED }; /**< Target */ + std::shared_ptr mm = { nullptr }; /**< Memory manager */ +}; + +/** Graph context **/ +class GraphContext final { public: - /** Default Constructor */ - GraphHints(TargetHint target_hint = TargetHint::DONT_CARE, - ConvolutionMethodHint conv_method_hint = ConvolutionMethodHint::GEMM); - /** Sets target execution hint + /** Constructor */ + GraphContext(); + /** Prevent instances of this class from being copied (As this class contains pointers) */ + GraphContext(const GraphContext &) = delete; + /** Default move constructor */ + GraphContext(GraphContext &&) = default; + /** Prevent instances of this class from being copied (As this class contains pointers) */ + GraphContext &operator=(const GraphContext &) = delete; + /** Default move assignment operator */ + GraphContext &operator=(GraphContext &&) = default; + /** Graph configuration accessor * - * @param target_hint Target execution hint - */ - void set_target_hint(TargetHint target_hint); - /** Sets convolution method to use + * @note Every alteration has to be done before graph finalization * - * @param convolution_method Convolution method to use + * @return The graph configuration */ - void set_convolution_method_hint(ConvolutionMethodHint convolution_method); - /** Returns target execution hint + const GraphConfig &config() const; + /** Sets graph configuration * - * @return target execution hint + * @param[in] config Configuration to use */ - TargetHint target_hint() const; - /** Returns convolution method hint + void set_config(const GraphConfig &config); + /** Inserts a memory manager context * - * @return convolution method hint - */ - ConvolutionMethodHint convolution_method_hint() const; - -private: - TargetHint _target_hint; /**< Target execution hint */ - ConvolutionMethodHint _convolution_method_hint; /**< Convolution method hint */ -}; - -/** Graph context */ -class GraphContext -{ -public: - /** Default Constuctor */ - GraphContext(); - /** Returns graph hints + * @param[in] memory_ctx Memory manage context * - * @return Graph hints + * @return If the insertion succeeded else false */ - GraphHints &hints(); - /** Returns graph hints + bool insert_memory_management_ctx(MemoryManagerContext &&memory_ctx); + /** Gets a memory manager context for a given target + * + * @param[in] target To retrieve the management context * - * @return Graph hints + * @return Management context for the target if exists else nullptr */ - const GraphHints &hints() const; + MemoryManagerContext *memory_management_ctx(Target target); + /** Finalizes memory managers in graph context */ + void finalize(); private: - GraphHints _hints; /**< Graph hints */ + GraphConfig _config; /**< Graph configuration */ + std::map _memory_managers; /**< Memory managers for each target */ }; } // namespace graph } // namespace arm_compute -#endif /* __ARM_COMPUTE_GRAPH_CONTEXT_H__ */ +#endif /* __ARM_COMPUTE_GRAPH_GRAPH_CONTEXT_H__ */ -- cgit v1.2.1