Matthew Bentham | d806792 | 2018-10-03 17:18:04 +0100 | [diff] [blame] | 1 | // |
Teresa Charlin | 588cbdf | 2022-01-19 15:55:37 +0000 | [diff] [blame] | 2 | // Copyright © 2017 Arm Ltd and Contributors. All rights reserved. |
Matthew Bentham | d806792 | 2018-10-03 17:18:04 +0100 | [diff] [blame] | 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | #pragma once |
| 7 | |
| 8 | #include <armnn/Tensor.hpp> |
| 9 | #include <armnn/Descriptors.hpp> |
| 10 | |
Teresa Charlin | 588cbdf | 2022-01-19 15:55:37 +0000 | [diff] [blame] | 11 | #include "ClBaseWorkload.hpp" |
Matthew Bentham | d806792 | 2018-10-03 17:18:04 +0100 | [diff] [blame] | 12 | |
| 13 | #include <arm_compute/runtime/CL/functions/CLConvolutionLayer.h> |
| 14 | #include <arm_compute/runtime/MemoryManagerOnDemand.h> |
| 15 | |
Narumol Prangnawarat | e2af6f4 | 2022-01-28 17:59:18 +0000 | [diff] [blame] | 16 | #include <cl/ICLTensorProxy.hpp> |
| 17 | |
Matthew Bentham | d806792 | 2018-10-03 17:18:04 +0100 | [diff] [blame] | 18 | #include <memory> |
| 19 | |
| 20 | namespace armnn |
| 21 | { |
| 22 | |
| 23 | arm_compute::Status ClConvolution2dWorkloadValidate(const TensorInfo& input, |
| 24 | const TensorInfo& output, |
| 25 | const Convolution2dDescriptor& descriptor, |
| 26 | const TensorInfo& weights, |
Sadik Armagan | 045f6be | 2020-09-10 13:37:32 +0100 | [diff] [blame] | 27 | const Optional<TensorInfo>& biases, |
Mike Kelly | 07810fc | 2020-11-12 10:58:48 +0000 | [diff] [blame] | 28 | bool isFastMathEnabled = false, |
| 29 | const ActivationDescriptor* activationDescriptor = nullptr); |
Matthew Bentham | d806792 | 2018-10-03 17:18:04 +0100 | [diff] [blame] | 30 | |
Teresa Charlin | 588cbdf | 2022-01-19 15:55:37 +0000 | [diff] [blame] | 31 | class ClConvolution2dWorkload : public ClBaseWorkload<Convolution2dQueueDescriptor> |
Matthew Bentham | d806792 | 2018-10-03 17:18:04 +0100 | [diff] [blame] | 32 | { |
| 33 | public: |
Sadik Armagan | 04a7297 | 2020-09-14 15:44:18 +0100 | [diff] [blame] | 34 | ClConvolution2dWorkload(const Convolution2dQueueDescriptor& descriptor, |
| 35 | const WorkloadInfo& info, |
| 36 | std::shared_ptr<arm_compute::MemoryManagerOnDemand>& memoryManager, |
Sadik Armagan | e944475 | 2020-12-02 11:28:58 +0000 | [diff] [blame] | 37 | const arm_compute::CLCompileContext& clCompileContext, |
Sadik Armagan | 04a7297 | 2020-09-14 15:44:18 +0100 | [diff] [blame] | 38 | const bool isFastMathEnabled = false); |
Matthew Bentham | d806792 | 2018-10-03 17:18:04 +0100 | [diff] [blame] | 39 | void Execute() const override; |
| 40 | |
Sadik Armagan | 04a7297 | 2020-09-14 15:44:18 +0100 | [diff] [blame] | 41 | arm_compute::ConvolutionMethod GetConvolutionMethod() const; |
| 42 | |
Narumol Prangnawarat | e2af6f4 | 2022-01-28 17:59:18 +0000 | [diff] [blame] | 43 | protected: |
| 44 | void Reconfigure() override; |
| 45 | |
Matthew Bentham | d806792 | 2018-10-03 17:18:04 +0100 | [diff] [blame] | 46 | private: |
| 47 | mutable arm_compute::CLConvolutionLayer m_ConvolutionLayer; |
| 48 | |
| 49 | std::unique_ptr<arm_compute::CLTensor> m_KernelTensor; |
| 50 | std::unique_ptr<arm_compute::CLTensor> m_BiasTensor; |
| 51 | |
Sadik Armagan | 04a7297 | 2020-09-14 15:44:18 +0100 | [diff] [blame] | 52 | arm_compute::ConvolutionMethod m_ConvolutionMethod; |
| 53 | |
Matthew Bentham | d806792 | 2018-10-03 17:18:04 +0100 | [diff] [blame] | 54 | void FreeUnusedTensors(); |
Narumol Prangnawarat | e2af6f4 | 2022-01-28 17:59:18 +0000 | [diff] [blame] | 55 | |
| 56 | std::unique_ptr<ICLTensorProxy> m_InputProxy; |
| 57 | std::unique_ptr<ICLTensorProxy> m_OutputProxy; |
Matthew Bentham | d806792 | 2018-10-03 17:18:04 +0100 | [diff] [blame] | 58 | }; |
| 59 | |
| 60 | } //namespace armnn |
| 61 | |