telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [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 |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4 | // |
| 5 | |
Matthew Bentham | e2ec330 | 2018-10-01 11:32:48 +0100 | [diff] [blame] | 6 | #include "ClMultiplicationWorkload.hpp" |
Aron Virginas-Tar | c9cc804 | 2018-11-01 16:15:57 +0000 | [diff] [blame] | 7 | #include <cl/ClTensorHandle.hpp> |
| 8 | #include <backendsCommon/CpuTensorHandle.hpp> |
Matthew Bentham | 14e4669 | 2018-09-20 15:35:30 +0100 | [diff] [blame] | 9 | #include "ClWorkloadUtils.hpp" |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 10 | |
| 11 | namespace armnn |
| 12 | { |
| 13 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 14 | arm_compute::Status ClMultiplicationWorkloadValidate(const TensorInfo& input0, |
| 15 | const TensorInfo& input1, |
| 16 | const TensorInfo& output) |
| 17 | { |
| 18 | const arm_compute::TensorInfo aclInput1 = armcomputetensorutils::BuildArmComputeTensorInfo(input0); |
| 19 | const arm_compute::TensorInfo aclInput2 = armcomputetensorutils::BuildArmComputeTensorInfo(input1); |
| 20 | const arm_compute::TensorInfo aclOutput = armcomputetensorutils::BuildArmComputeTensorInfo(output); |
| 21 | |
| 22 | // At the time of writing, configure() will fail if a rounding policy other than TO_ZERO is supplied to it, |
| 23 | // when providing a scale of 1.0 for F32 tensors, even though the provided rounding policy appears to be |
| 24 | // ignored for F32 tensors. |
| 25 | return arm_compute::CLPixelWiseMultiplication::validate(&aclInput1, |
| 26 | &aclInput2, |
| 27 | &aclOutput, |
| 28 | 1.0f, |
| 29 | arm_compute::ConvertPolicy::SATURATE, |
| 30 | arm_compute::RoundingPolicy::TO_ZERO); |
| 31 | } |
| 32 | |
| 33 | |
Matthew Bentham | e2ec330 | 2018-10-01 11:32:48 +0100 | [diff] [blame] | 34 | ClMultiplicationWorkload::ClMultiplicationWorkload(const MultiplicationQueueDescriptor& descriptor, |
| 35 | const WorkloadInfo& info) |
| 36 | : BaseWorkload<MultiplicationQueueDescriptor>(descriptor, info) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 37 | { |
Matthew Bentham | e2ec330 | 2018-10-01 11:32:48 +0100 | [diff] [blame] | 38 | m_Data.ValidateInputsOutputs("ClMultiplicationWorkload", 2, 1); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 39 | |
| 40 | arm_compute::ICLTensor& input0 = static_cast<IClTensorHandle*>(m_Data.m_Inputs[0])->GetTensor(); |
| 41 | arm_compute::ICLTensor& input1 = static_cast<IClTensorHandle*>(m_Data.m_Inputs[1])->GetTensor(); |
| 42 | arm_compute::ICLTensor& output = static_cast<IClTensorHandle*>(m_Data.m_Outputs[0])->GetTensor(); |
| 43 | // Construct |
| 44 | m_PixelWiseMultiplication.configure(&input0, |
| 45 | &input1, |
| 46 | &output, |
| 47 | 1.0f, |
| 48 | arm_compute::ConvertPolicy::SATURATE, |
| 49 | arm_compute::RoundingPolicy::TO_NEAREST_EVEN); |
| 50 | } |
| 51 | |
Matthew Bentham | e2ec330 | 2018-10-01 11:32:48 +0100 | [diff] [blame] | 52 | void ClMultiplicationWorkload::Execute() const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 53 | { |
Matthew Bentham | e2ec330 | 2018-10-01 11:32:48 +0100 | [diff] [blame] | 54 | ARMNN_SCOPED_PROFILING_EVENT_CL("ClMultiplicationWorkload_Execute"); |
Aron Virginas-Tar | a8e06ed | 2018-10-19 16:46:15 +0100 | [diff] [blame] | 55 | RunClFunction(m_PixelWiseMultiplication, CHECK_LOCATION()); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 56 | } |
| 57 | |
| 58 | } //namespace armnn |