diff options
Diffstat (limited to 'arm_compute')
-rw-r--r-- | arm_compute/graph/Workload.h | 11 | ||||
-rw-r--r-- | arm_compute/graph/detail/ExecutionHelpers.h | 21 | ||||
-rw-r--r-- | arm_compute/runtime/CL/functions/CLConvolutionLayer.h | 3 | ||||
-rw-r--r-- | arm_compute/runtime/CL/functions/CLFullyConnectedLayer.h | 1 | ||||
-rw-r--r-- | arm_compute/runtime/CL/functions/CLGEMM.h | 3 | ||||
-rw-r--r-- | arm_compute/runtime/CL/functions/CLGEMMConvolutionLayer.h | 3 | ||||
-rw-r--r-- | arm_compute/runtime/CL/functions/CLWinogradConvolutionLayer.h | 12 | ||||
-rw-r--r-- | arm_compute/runtime/IFunction.h | 14 |
8 files changed, 58 insertions, 10 deletions
diff --git a/arm_compute/graph/Workload.h b/arm_compute/graph/Workload.h index b19c932636..11bb22ea9a 100644 --- a/arm_compute/graph/Workload.h +++ b/arm_compute/graph/Workload.h @@ -37,6 +37,7 @@ namespace graph class ITensorHandle; class INode; class Tensor; +class Graph; /** Execution task * @@ -52,14 +53,18 @@ struct ExecutionTask /** Function operator */ void operator()(); + + /** Prepare execution task */ + void prepare(); }; /** Execution workload */ struct ExecutionWorkload { - std::vector<Tensor *> inputs = {}; /**< Input handles */ - std::vector<Tensor *> outputs = {}; /**< Output handles */ - std::vector<ExecutionTask> tasks = {}; /**< Execution workload */ + std::vector<Tensor *> inputs = {}; /**< Input handles */ + std::vector<Tensor *> outputs = {}; /**< Output handles */ + std::vector<ExecutionTask> tasks = {}; /**< Execution workload */ + Graph *graph = nullptr; /**< Graph bound to the workload */ }; } // namespace graph } // namespace arm_compute diff --git a/arm_compute/graph/detail/ExecutionHelpers.h b/arm_compute/graph/detail/ExecutionHelpers.h index 52304d6836..a868df8a5d 100644 --- a/arm_compute/graph/detail/ExecutionHelpers.h +++ b/arm_compute/graph/detail/ExecutionHelpers.h @@ -35,6 +35,7 @@ class Graph; class GraphContext; class ExecutionWorkload; class Tensor; +class INode; namespace detail { @@ -45,6 +46,21 @@ void default_initialize_backends(); * @param[in] g Graph to configure */ void configure_all_tensors(Graph &g); +/** Allocates all input tensors of a node. + * + * @param[in] node Node to allocate the input tensor of + */ +void allocate_all_input_tensors(INode &node); +/** Allocates all output tensors of a node. + * + * @param[in] node Node to allocate the output tensor of + */ +void allocate_all_output_tensors(INode &node); +/** Allocates const tensor of a given graph + * + * @param[in] g Graph to allocate the tensors + */ +void allocate_const_tensors(Graph &g); /** Allocates all tensors of a graph * * @param[in] g Graph to allocate the tensors @@ -88,6 +104,11 @@ void call_all_input_node_accessors(ExecutionWorkload &workload); * @param[in] workload Workload to execute */ void call_all_output_node_accessors(ExecutionWorkload &workload); +/** Prepares all tasks for execution + * + * @param[in] workload Workload to prepare + */ +void prepare_all_tasks(ExecutionWorkload &workload); /** Executes all tasks of a workload * * @param[in] workload Workload to execute diff --git a/arm_compute/runtime/CL/functions/CLConvolutionLayer.h b/arm_compute/runtime/CL/functions/CLConvolutionLayer.h index 5c05334a56..97998b5595 100644 --- a/arm_compute/runtime/CL/functions/CLConvolutionLayer.h +++ b/arm_compute/runtime/CL/functions/CLConvolutionLayer.h @@ -106,10 +106,11 @@ public: const WeightsInfo &weights_info, const ActivationLayerInfo &act_info, const GPUTarget gpu_target, const Size2D &dilation = Size2D(1U, 1U), bool enable_fast_math = false); // Inherited methods overridden: void run() override; + void prepare() override; private: std::shared_ptr<IMemoryManager> _memory_manager; - std::unique_ptr<IFunction> _function; /**< Function to run */ + std::unique_ptr<IFunction> _function; }; } #endif /* __ARM_COMPUTE_CLCONVOLUTIONLAYER_H__ */ diff --git a/arm_compute/runtime/CL/functions/CLFullyConnectedLayer.h b/arm_compute/runtime/CL/functions/CLFullyConnectedLayer.h index 67c0467f3a..7fb5af9229 100644 --- a/arm_compute/runtime/CL/functions/CLFullyConnectedLayer.h +++ b/arm_compute/runtime/CL/functions/CLFullyConnectedLayer.h @@ -109,6 +109,7 @@ public: //Inherited methods override void run() override; + void prepare() override; private: void configure_fc_fc(const ICLTensor *input, const ICLTensor *weights, ICLTensor *output); diff --git a/arm_compute/runtime/CL/functions/CLGEMM.h b/arm_compute/runtime/CL/functions/CLGEMM.h index c5d7b86384..60ff32c6fa 100644 --- a/arm_compute/runtime/CL/functions/CLGEMM.h +++ b/arm_compute/runtime/CL/functions/CLGEMM.h @@ -100,6 +100,7 @@ public: // Inherited methods overridden: void run() override; + void prepare() override; private: CLMemoryGroup _memory_group; @@ -112,8 +113,8 @@ private: const ICLTensor *_original_b; bool _is_interleaved_transposed; bool _run_addition; - bool _is_first_run; bool _reshape_b_only_on_first_run; + bool _is_prepared; }; } diff --git a/arm_compute/runtime/CL/functions/CLGEMMConvolutionLayer.h b/arm_compute/runtime/CL/functions/CLGEMMConvolutionLayer.h index a24ac3ac1f..3dde52989b 100644 --- a/arm_compute/runtime/CL/functions/CLGEMMConvolutionLayer.h +++ b/arm_compute/runtime/CL/functions/CLGEMMConvolutionLayer.h @@ -153,6 +153,7 @@ public: // Inherited methods overridden: void run() override; + void prepare() override; private: /** Configures the appropriate matrix multiply routine @@ -192,8 +193,8 @@ private: CLTensor _tmp_output; bool _is_quantized; - bool _is_first_run; bool _is_activationlayer_enabled; + bool _is_prepared; }; } #endif /* __ARM_COMPUTE_CLGEMMCONVOLUTIONLAYER_H__ */ diff --git a/arm_compute/runtime/CL/functions/CLWinogradConvolutionLayer.h b/arm_compute/runtime/CL/functions/CLWinogradConvolutionLayer.h index a27976959c..594d6028e1 100644 --- a/arm_compute/runtime/CL/functions/CLWinogradConvolutionLayer.h +++ b/arm_compute/runtime/CL/functions/CLWinogradConvolutionLayer.h @@ -49,6 +49,14 @@ class CLWinogradConvolutionLayer : public IFunction public: /** Default constructor */ CLWinogradConvolutionLayer(std::shared_ptr<IMemoryManager> memory_manager = nullptr); + /** Prevent instances of this class from being copied (As this class contains pointers) */ + CLWinogradConvolutionLayer(const CLWinogradConvolutionLayer &) = delete; + /** Default move constructor */ + CLWinogradConvolutionLayer(CLWinogradConvolutionLayer &&) = default; + /** Prevent instances of this class from being copied (As this class contains pointers) */ + CLWinogradConvolutionLayer &operator=(const CLWinogradConvolutionLayer &) = delete; + /** Default move assignment operator */ + CLWinogradConvolutionLayer &operator=(CLWinogradConvolutionLayer &&) = default; /** Set the input and output tensors. * * @note: This function only works with 3x3 and 5x5 kernels along with unit strides @@ -92,6 +100,7 @@ public: // Inherited methods overridden: void run() override; + void prepare() override; private: CLMemoryGroup _memory_group; @@ -103,7 +112,8 @@ private: CLTensor _input0; CLTensor _input1; CLTensor _batched_mm_output; - bool _is_first_run; + const ICLTensor *_original_weights; + bool _is_prepared; bool _is_activationlayer_enabled; }; } diff --git a/arm_compute/runtime/IFunction.h b/arm_compute/runtime/IFunction.h index a4e7ed15e0..f64b2be998 100644 --- a/arm_compute/runtime/IFunction.h +++ b/arm_compute/runtime/IFunction.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2017 ARM Limited. + * Copyright (c) 2016-2018 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -30,6 +30,8 @@ namespace arm_compute class IFunction { public: + /** Destructor */ + virtual ~IFunction() = default; /** Run the kernels contained in the function * * For NEON kernels: @@ -43,12 +45,18 @@ public: * - The queue is then flushed. * * @note The function will not block until the kernels are executed. It is the user's responsibility to wait. + * @note Will call prepare() on first run if hasn't been done */ virtual void run() = 0; - /** Destructor + /** Prepare the function for executing + * + * Any one off pre-processing step required by the function is handled here * + * @note Prepare stage might not need all the function's buffers' backing memory to be available in order to execute */ - virtual ~IFunction() = default; + virtual void prepare() + { + } }; } #endif /*__ARM_COMPUTE_IFUNCTION_H__ */ |