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 | |
David Monahan | 3826ab6 | 2022-02-21 12:26:16 +0000 | [diff] [blame] | 43 | bool SupportsTensorHandleReplacement() const override |
| 44 | { |
| 45 | // NCHW DataLayout on ACL still uses paddding for alignment on the Conv2d workload so importing is unreliable. |
| 46 | if (m_Data.m_Parameters.m_DataLayout == DataLayout::NCHW) |
| 47 | { |
| 48 | return false; |
| 49 | } |
| 50 | else |
| 51 | { |
| 52 | return true; |
| 53 | } |
| 54 | } |
| 55 | |
Finn Williams | 73c547d | 2022-02-15 20:47:34 +0000 | [diff] [blame] | 56 | |
Narumol Prangnawarat | e2af6f4 | 2022-01-28 17:59:18 +0000 | [diff] [blame] | 57 | protected: |
| 58 | void Reconfigure() override; |
| 59 | |
Matthew Bentham | d806792 | 2018-10-03 17:18:04 +0100 | [diff] [blame] | 60 | private: |
| 61 | mutable arm_compute::CLConvolutionLayer m_ConvolutionLayer; |
| 62 | |
| 63 | std::unique_ptr<arm_compute::CLTensor> m_KernelTensor; |
| 64 | std::unique_ptr<arm_compute::CLTensor> m_BiasTensor; |
| 65 | |
Sadik Armagan | 04a7297 | 2020-09-14 15:44:18 +0100 | [diff] [blame] | 66 | arm_compute::ConvolutionMethod m_ConvolutionMethod; |
| 67 | |
Matthew Bentham | d806792 | 2018-10-03 17:18:04 +0100 | [diff] [blame] | 68 | void FreeUnusedTensors(); |
Narumol Prangnawarat | e2af6f4 | 2022-01-28 17:59:18 +0000 | [diff] [blame] | 69 | |
| 70 | std::unique_ptr<ICLTensorProxy> m_InputProxy; |
| 71 | std::unique_ptr<ICLTensorProxy> m_OutputProxy; |
Matthew Bentham | d806792 | 2018-10-03 17:18:04 +0100 | [diff] [blame] | 72 | }; |
| 73 | |
| 74 | } //namespace armnn |
| 75 | |