From 3e80c7fa601d5996e8ada3b2f6c69327f066ec17 Mon Sep 17 00:00:00 2001 From: Anton Lokhmotov Date: Mon, 20 Nov 2017 11:02:10 +0000 Subject: COMPMID-661: Optimize FC layer with 2 new Bifrost kernels and LWS tuning (#33) Change-Id: Ie56ac88dff5ff339572cec562e8cd62dc7f0aa8b Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/109805 Tested-by: BSG Visual Compute Jenkins server to access repositories on http://mpd-gerrit.cambridge.arm.com Reviewed-by: Gian Marco Iodice Reviewed-by: Anthony Barbier --- src/runtime/CL/functions/CLFullyConnectedLayer.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/runtime/CL/functions') diff --git a/src/runtime/CL/functions/CLFullyConnectedLayer.cpp b/src/runtime/CL/functions/CLFullyConnectedLayer.cpp index 03d5dbdfd1..72d374e9c2 100644 --- a/src/runtime/CL/functions/CLFullyConnectedLayer.cpp +++ b/src/runtime/CL/functions/CLFullyConnectedLayer.cpp @@ -45,7 +45,7 @@ CLFullyConnectedLayer::CLFullyConnectedLayer(std::shared_ptr mem { } -void CLFullyConnectedLayer::configure_conv_fc(const ICLTensor *input, const ICLTensor *weights, ICLTensor *output) +void CLFullyConnectedLayer::configure_conv_fc(const ICLTensor *input, const ICLTensor *weights, ICLTensor *output, const GPUTarget gpu_target) { ARM_COMPUTE_ERROR_ON((weights->info()->dimension(1) != (input->info()->dimension(0) * input->info()->dimension(1) * input->info()->dimension(2)))); @@ -67,17 +67,19 @@ void CLFullyConnectedLayer::configure_conv_fc(const ICLTensor *input, const ICLT _im2col_kernel.configure(input, &_im2col_output, Size2D(1, 1), PadStrideInfo(1, 1, 0, 0), false); // Configure matrix multiply kernel + _mm_kernel.set_target(gpu_target); _mm_kernel.configure(&_im2col_output, weights, output, 1.0f, false); // Allocate the output tensor for im2col once all the configure methods have been called _im2col_output.allocator()->allocate(); } -void CLFullyConnectedLayer::configure_fc_fc(const ICLTensor *input, const ICLTensor *weights, ICLTensor *output) +void CLFullyConnectedLayer::configure_fc_fc(const ICLTensor *input, const ICLTensor *weights, ICLTensor *output, const GPUTarget gpu_target) { ARM_COMPUTE_ERROR_ON(input->info()->dimension(0) != weights->info()->dimension(1)); // Configure matrix multiply kernel + _mm_kernel.set_target(gpu_target); _mm_kernel.configure(input, weights, output, 1.0f, false); } @@ -91,6 +93,9 @@ void CLFullyConnectedLayer::configure(const ICLTensor *input, const ICLTensor *w _is_fc_after_conv = true; _accumulate_biases = false; + // Get GPU target + const GPUTarget gpu_target = CLScheduler::get().target(); + if(biases != nullptr) { ARM_COMPUTE_ERROR_ON_MISMATCHING_DATA_TYPES(input, biases); @@ -98,6 +103,7 @@ void CLFullyConnectedLayer::configure(const ICLTensor *input, const ICLTensor *w _accumulate_biases = true; // Configure accumulate biases kernel + _accumulate_biases_kernel.set_target(gpu_target); _accumulate_biases_kernel.configure(output, biases); } @@ -134,12 +140,12 @@ void CLFullyConnectedLayer::configure(const ICLTensor *input, const ICLTensor *w if(_is_fc_after_conv) { // Fully Connected layer after a Convolution Layer without batches - configure_conv_fc(input, weights_to_use, output); + configure_conv_fc(input, weights_to_use, output, gpu_target); } else { // Fully Connected layer after a Fully Connected Layer without batches - configure_fc_fc(input, weights_to_use, output); + configure_fc_fc(input, weights_to_use, output, gpu_target); } // Allocate the transpose tensor if the are_weights_reshaped flag is false and once all the configure methods have been called -- cgit v1.2.1