surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2017 Arm Ltd. All rights reserved. |
David Beck | ecb56cd | 2018-09-05 12:52:57 +0100 | [diff] [blame] | 3 | // SPDX-License-Identifier: MIT |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 4 | // |
| 5 | |
| 6 | #include "ClConvolution2dBaseWorkload.hpp" |
David Beck | 711fa31 | 2018-09-24 10:46:38 +0100 | [diff] [blame] | 7 | #include <backends/ClLayerSupport.hpp> |
| 8 | #include <backends/ClTensorHandle.hpp> |
| 9 | #include <backends/aclCommon/ArmComputeUtils.hpp> |
| 10 | #include <backends/aclCommon/ArmComputeTensorUtils.hpp> |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 11 | |
Matthew Bentham | 14e4669 | 2018-09-20 15:35:30 +0100 | [diff] [blame] | 12 | #include <arm_compute/runtime/CL/functions/CLConvolutionLayer.h> |
| 13 | |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 14 | namespace armnn |
| 15 | { |
| 16 | using namespace armcomputetensorutils; |
| 17 | |
| 18 | arm_compute::Status ClConvolution2dWorkloadValidate(const TensorInfo& input, |
| 19 | const TensorInfo& output, |
| 20 | const Convolution2dDescriptor& descriptor, |
| 21 | const TensorInfo& weights, |
arovir01 | a682410 | 2018-08-28 17:40:45 +0100 | [diff] [blame] | 22 | const boost::optional<TensorInfo>& biases) |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 23 | { |
Francis Murtagh | 351d13d | 2018-09-24 15:01:18 +0100 | [diff] [blame] | 24 | const arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(input, descriptor.m_DataLayout); |
| 25 | const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output, descriptor.m_DataLayout); |
| 26 | const arm_compute::TensorInfo aclWeightsInfo = BuildArmComputeTensorInfo(weights, descriptor.m_DataLayout); |
arovir01 | a682410 | 2018-08-28 17:40:45 +0100 | [diff] [blame] | 27 | |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 28 | arm_compute::TensorInfo aclBiasesInfo; |
| 29 | arm_compute::TensorInfo *optionalAclBiasesInfo = nullptr; |
| 30 | |
| 31 | if (descriptor.m_BiasEnabled) |
| 32 | { |
arovir01 | a682410 | 2018-08-28 17:40:45 +0100 | [diff] [blame] | 33 | BOOST_ASSERT(biases.is_initialized()); |
| 34 | |
Francis Murtagh | 351d13d | 2018-09-24 15:01:18 +0100 | [diff] [blame] | 35 | aclBiasesInfo = BuildArmComputeTensorInfo(biases.get(), descriptor.m_DataLayout); |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 36 | optionalAclBiasesInfo = &aclBiasesInfo; |
| 37 | } |
| 38 | |
| 39 | arm_compute::PadStrideInfo layerInfo = BuildArmComputePadStrideInfo(descriptor); |
| 40 | |
| 41 | return arm_compute::CLConvolutionLayer::validate(&aclInputInfo, |
| 42 | &aclWeightsInfo, |
| 43 | optionalAclBiasesInfo, |
| 44 | &aclOutputInfo, |
| 45 | layerInfo); |
| 46 | } |
| 47 | |
| 48 | } |