blob: d0f7a5b251028ebe56d5f1ba3844ea5e75cc1f57 [file] [log] [blame]
Matthew Benthamd8067922018-10-03 17:18:04 +01001//
2// Copyright © 2017 Arm Ltd. All rights reserved.
3// SPDX-License-Identifier: MIT
4//
5
6#pragma once
7
8#include <armnn/Tensor.hpp>
9#include <armnn/Descriptors.hpp>
10
Aron Virginas-Tarc9cc8042018-11-01 16:15:57 +000011#include <backendsCommon/Workload.hpp>
Matthew Benthamd8067922018-10-03 17:18:04 +010012
13#include <arm_compute/runtime/CL/functions/CLConvolutionLayer.h>
14#include <arm_compute/runtime/MemoryManagerOnDemand.h>
15
Matthew Benthamd8067922018-10-03 17:18:04 +010016#include <memory>
17
18namespace armnn
19{
20
21arm_compute::Status ClConvolution2dWorkloadValidate(const TensorInfo& input,
22 const TensorInfo& output,
23 const Convolution2dDescriptor& descriptor,
24 const TensorInfo& weights,
Sadik Armagan045f6be2020-09-10 13:37:32 +010025 const Optional<TensorInfo>& biases,
Mike Kelly07810fc2020-11-12 10:58:48 +000026 bool isFastMathEnabled = false,
27 const ActivationDescriptor* activationDescriptor = nullptr);
Matthew Benthamd8067922018-10-03 17:18:04 +010028
29class ClConvolution2dWorkload : public BaseWorkload<Convolution2dQueueDescriptor>
30{
31public:
Sadik Armagan04a72972020-09-14 15:44:18 +010032 ClConvolution2dWorkload(const Convolution2dQueueDescriptor& descriptor,
33 const WorkloadInfo& info,
34 std::shared_ptr<arm_compute::MemoryManagerOnDemand>& memoryManager,
Sadik Armagane9444752020-12-02 11:28:58 +000035 const arm_compute::CLCompileContext& clCompileContext,
Sadik Armagan04a72972020-09-14 15:44:18 +010036 const bool isFastMathEnabled = false);
Matthew Benthamd8067922018-10-03 17:18:04 +010037 void Execute() const override;
38
Sadik Armagan04a72972020-09-14 15:44:18 +010039 arm_compute::ConvolutionMethod GetConvolutionMethod() const;
40
Matthew Benthamd8067922018-10-03 17:18:04 +010041private:
42 mutable arm_compute::CLConvolutionLayer m_ConvolutionLayer;
43
44 std::unique_ptr<arm_compute::CLTensor> m_KernelTensor;
45 std::unique_ptr<arm_compute::CLTensor> m_BiasTensor;
46
Sadik Armagan04a72972020-09-14 15:44:18 +010047 arm_compute::ConvolutionMethod m_ConvolutionMethod;
48
Matthew Benthamd8067922018-10-03 17:18:04 +010049 void FreeUnusedTensors();
50};
51
52} //namespace armnn
53