From 72219330fd85b1271e714d4ba894d6d8e26340c9 Mon Sep 17 00:00:00 2001 From: Georgios Pinitas Date: Tue, 5 Jun 2018 14:56:06 +0100 Subject: 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 Tested-by: Jenkins Reviewed-by: Pablo Tello Reviewed-by: Michele DiGiorgio --- .../NEON/functions/NEGEMMConvolutionLayer.cpp | 65 ++++++++++++++-------- 1 file changed, 42 insertions(+), 23 deletions(-) (limited to 'src/runtime/NEON/functions/NEGEMMConvolutionLayer.cpp') diff --git a/src/runtime/NEON/functions/NEGEMMConvolutionLayer.cpp b/src/runtime/NEON/functions/NEGEMMConvolutionLayer.cpp index 303691aa7a..d4400b8864 100644 --- a/src/runtime/NEON/functions/NEGEMMConvolutionLayer.cpp +++ b/src/runtime/NEON/functions/NEGEMMConvolutionLayer.cpp @@ -231,7 +231,7 @@ NEGEMMConvolutionLayer::NEGEMMConvolutionLayer(const std::shared_ptrinfo()->fixed_point_position(); const ITensor *biases_to_use = (_append_bias) ? biases : nullptr; @@ -442,12 +443,6 @@ void NEGEMMConvolutionLayer::configure(const ITensor *input, const ITensor *weig ARM_COMPUTE_ERROR_ON_MSG((output->info()->dimension(idx_width) != conv_w) || (output->info()->dimension(idx_height) != conv_h), "Output shape does not match the expected one"); - // Allocate intermediate tensor - if(!_are_weights_reshaped) - { - _weights_reshaped.allocator()->allocate(); - } - //Configure Activation Layer if(_is_activationlayer_enabled) { @@ -585,17 +580,7 @@ Status NEGEMMConvolutionLayer::validate(const ITensorInfo *input, const ITensorI void NEGEMMConvolutionLayer::run() { - // Run weights reshaping (Runs once for every configure) - if(!_are_weights_reshaped) - { - ARM_COMPUTE_ERROR_ON(!_original_weights->is_used()); - - _are_weights_reshaped = true; - _reshape_weights.run(); - - // Mark original weights tensor as unused - _original_weights->mark_as_unused(); - } + prepare(); _memory_group.acquire(); @@ -610,11 +595,6 @@ void NEGEMMConvolutionLayer::run() if(_asm_glue._optimised_kernel != nullptr) { _asm_glue.run(); - // Release weights in case buffer is pretransposed - if(!_weights_reshaped.is_used()) - { - _weights_reshaped.allocator()->free(); - } } else { @@ -659,4 +639,43 @@ void NEGEMMConvolutionLayer::run() _memory_group.release(); } + +void NEGEMMConvolutionLayer::prepare() +{ + if(!_is_prepared) + { + // Run weights reshaping (Runs once for every configure) + if(!_are_weights_reshaped) + { + ARM_COMPUTE_ERROR_ON(!_original_weights->is_used()); + + _weights_reshaped.allocator()->allocate(); + _reshape_weights.run(); + _reshape_weights = NEConvolutionLayerReshapeWeights(); + _original_weights->mark_as_unused(); + _are_weights_reshaped = true; + } + + // Run GEMM prepare stage + if(_asm_glue._optimised_kernel) + { + _asm_glue.prepare(); + } + else + { + if(_is_quantized) + { + _mm_gemmlowp.prepare(); + } + } + + // Release weights in case buffer is pretransposed + if(!_weights_reshaped.is_used()) + { + _weights_reshaped.allocator()->free(); + } + + _is_prepared = true; + } +} } // namespace arm_compute -- cgit v1.2.1