diff options
author | Georgios Pinitas <georgios.pinitas@arm.com> | 2018-06-05 14:56:06 +0100 |
---|---|---|
committer | Anthony Barbier <anthony.barbier@arm.com> | 2018-11-02 16:53:09 +0000 |
commit | 72219330fd85b1271e714d4ba894d6d8e26340c9 (patch) | |
tree | 9ae0510087a1ca77b1695252a8621de3f2ab98af /src/runtime/GLES_COMPUTE/functions/GCConvolutionLayer.cpp | |
parent | c42f28d45e9b990276d54880d2cee9c9ee675a41 (diff) | |
download | ComputeLibrary-72219330fd85b1271e714d4ba894d6d8e26340c9.tar.gz |
COMPMID-1145: (API) Introduce prepare() stage (NEON/CL/GLES)
Change-Id: I5b46764f9c3154ec3e3b9c951cc9e6dfbcb81dfb
Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/134255
Reviewed-by: Anthony Barbier <anthony.barbier@arm.com>
Tested-by: Jenkins <bsgcomp@arm.com>
Reviewed-by: Pablo Tello <pablo.tello@arm.com>
Reviewed-by: Michele DiGiorgio <michele.digiorgio@arm.com>
Diffstat (limited to 'src/runtime/GLES_COMPUTE/functions/GCConvolutionLayer.cpp')
-rw-r--r-- | src/runtime/GLES_COMPUTE/functions/GCConvolutionLayer.cpp | 42 |
1 files changed, 23 insertions, 19 deletions
diff --git a/src/runtime/GLES_COMPUTE/functions/GCConvolutionLayer.cpp b/src/runtime/GLES_COMPUTE/functions/GCConvolutionLayer.cpp index d1ef87d32c..67b2ae9d61 100644 --- a/src/runtime/GLES_COMPUTE/functions/GCConvolutionLayer.cpp +++ b/src/runtime/GLES_COMPUTE/functions/GCConvolutionLayer.cpp @@ -37,7 +37,7 @@ using namespace arm_compute; GCConvolutionLayerReshapeWeights::GCConvolutionLayerReshapeWeights() - : _weights_reshape_kernel(), _weights_reshaped() + : _weights_reshape_kernel() { } @@ -68,7 +68,7 @@ void GCConvolutionLayerReshapeWeights::run() GCConvolutionLayer::GCConvolutionLayer(std::shared_ptr<IMemoryManager> memory_manager) : _memory_group(std::move(memory_manager)), _reshape_weights(), _input_im2col_kernel(), _mm_gemm(), _output_col2im_kernel(), _fill_border(), _activationlayer_function(), _original_weights(nullptr), - _input_im2col_reshaped(), _input_interleaved_reshaped(), _weights_reshaped(), _weights_transposed(), _gemm_output(), _tmp_output(), _is_first_run(true), _is_activationlayer_enabled(false) + _input_im2col_reshaped(), _input_interleaved_reshaped(), _weights_reshaped(), _weights_transposed(), _gemm_output(), _tmp_output(), _is_activationlayer_enabled(false), _is_prepared(false) { } @@ -97,7 +97,7 @@ void GCConvolutionLayer::configure(const IGCTensor *input, const IGCTensor *weig ARM_COMPUTE_ERROR_ON(weights->info()->dimension(2) != input->info()->dimension(2)); ARM_COMPUTE_ERROR_ON(weights->info()->num_dimensions() > 4); - _is_first_run = true; + _is_prepared = false; _original_weights = weights; if(biases != nullptr) @@ -184,9 +184,6 @@ void GCConvolutionLayer::configure(const IGCTensor *input, const IGCTensor *weig ARM_COMPUTE_ERROR_ON_MSG((output->info()->dimension(0) != conv_w) || (output->info()->dimension(1) != conv_h), "Output shape does not match the expected one"); - // Allocate intermediate tensor - _weights_reshaped.allocator()->allocate(); - //Configure Activation Layer _is_activationlayer_enabled = act_info.enabled(); @@ -200,17 +197,7 @@ void GCConvolutionLayer::configure(const IGCTensor *input, const IGCTensor *weig void GCConvolutionLayer::run() { - // Run weights reshaping (Runs once for every configure) - if(_is_first_run) - { - ARM_COMPUTE_ERROR_ON(!_original_weights->is_used()); - - _reshape_weights.run(); - _is_first_run = false; - - // Mark original weights tensor as unused - _original_weights->mark_as_unused(); - } + prepare(); _memory_group.acquire(); @@ -221,17 +208,34 @@ void GCConvolutionLayer::run() // Run gemm on reshaped matrices _mm_gemm.run(); - GCScheduler::get().memory_barrier(); + // Reshape output matrix GCScheduler::get().dispatch(_output_col2im_kernel, false); + GCScheduler::get().memory_barrier(); _memory_group.release(); - GCScheduler::get().memory_barrier(); // Run Activation Layer if(_is_activationlayer_enabled) { _activationlayer_function.run(); } } + +void GCConvolutionLayer::prepare() +{ + if(!_is_prepared) + { + ARM_COMPUTE_ERROR_ON(!_original_weights->is_used()); + + // Run weights reshaping and mark as unused + _weights_reshaped.allocator()->allocate(); + _reshape_weights.run(); + + // Mark original weights tensor as unused + _original_weights->mark_as_unused(); + + _is_prepared = true; + } +} |