telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [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. |
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 | |
arovir01 | 9e53a35 | 2018-08-31 15:26:35 +0100 | [diff] [blame] | 6 | #include "ClFloorFloatWorkload.hpp" |
Aron Virginas-Tar | c9cc804 | 2018-11-01 16:15:57 +0000 | [diff] [blame] | 7 | #include <cl/ClTensorHandle.hpp> |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8 | |
Matthew Bentham | 14e4669 | 2018-09-20 15:35:30 +0100 | [diff] [blame] | 9 | #include "ClWorkloadUtils.hpp" |
| 10 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 11 | namespace armnn |
| 12 | { |
| 13 | |
Sadik Armagan | 9be4916 | 2019-10-30 16:15:26 +0000 | [diff] [blame] | 14 | arm_compute::Status ClFloorWorkloadValidate(const TensorInfo& input, |
| 15 | const TensorInfo& output) |
| 16 | { |
| 17 | const arm_compute::TensorInfo aclInput = armcomputetensorutils::BuildArmComputeTensorInfo(input); |
| 18 | const arm_compute::TensorInfo aclOutput = armcomputetensorutils::BuildArmComputeTensorInfo(output); |
| 19 | |
| 20 | return arm_compute::CLFloor::validate(&aclInput, &aclOutput); |
| 21 | } |
| 22 | |
Sadik Armagan | e944475 | 2020-12-02 11:28:58 +0000 | [diff] [blame] | 23 | ClFloorFloatWorkload::ClFloorFloatWorkload(const FloorQueueDescriptor& descriptor, |
| 24 | const WorkloadInfo& info, |
| 25 | const arm_compute::CLCompileContext& clCompileContext) |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 26 | : FloatWorkload<FloorQueueDescriptor>(descriptor, info) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 27 | { |
arovir01 | 9e53a35 | 2018-08-31 15:26:35 +0100 | [diff] [blame] | 28 | m_Data.ValidateInputsOutputs("ClFloorFloatWorkload", 1, 1); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 29 | |
| 30 | arm_compute::ICLTensor& input = static_cast<IClTensorHandle*>(m_Data.m_Inputs[0])->GetTensor(); |
| 31 | arm_compute::ICLTensor& output = static_cast<IClTensorHandle*>(m_Data.m_Outputs[0])->GetTensor(); |
Kevin May | 9f6862d | 2021-10-22 15:42:28 +0100 | [diff] [blame] | 32 | { |
| 33 | ARMNN_SCOPED_PROFILING_EVENT(Compute::Undefined, "ClFloorFloatWorkload_configure"); |
| 34 | m_Layer.configure(clCompileContext, &input, &output); |
| 35 | } |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 36 | } |
| 37 | |
arovir01 | 9e53a35 | 2018-08-31 15:26:35 +0100 | [diff] [blame] | 38 | void ClFloorFloatWorkload::Execute() const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 39 | { |
Keith Davis | bcd860a | 2021-08-05 14:20:33 +0100 | [diff] [blame] | 40 | ARMNN_SCOPED_PROFILING_EVENT_CL_GUID("ClFloorFloatWorkload_Execute", this->GetGuid()); |
Aron Virginas-Tar | a8e06ed | 2018-10-19 16:46:15 +0100 | [diff] [blame] | 41 | RunClFunction(m_Layer, CHECK_LOCATION()); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 42 | } |
| 43 | |
David Monahan | ec81999 | 2022-02-10 14:47:13 +0000 | [diff] [blame] | 44 | void ClFloorFloatWorkload::ReplaceInputTensorHandle(ITensorHandle* tensorHandle, unsigned int slot) |
| 45 | { |
| 46 | ITensorHandle* backupHandle = this->m_Data.m_Inputs[slot]; |
| 47 | this->m_Data.m_Inputs[slot] = tensorHandle; |
| 48 | try |
| 49 | { |
| 50 | Reconfigure(); |
| 51 | } |
| 52 | catch(armnn::UnimplementedException& e) |
| 53 | { |
| 54 | // Cannot reconfigure, revert the slot back and throw the exception. |
| 55 | this->m_Data.m_Inputs[slot] = backupHandle; |
| 56 | throw e; |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | // Replace output tensor handle with the given TensorHandle |
| 61 | void ClFloorFloatWorkload::ReplaceOutputTensorHandle(ITensorHandle* tensorHandle, unsigned int slot) |
| 62 | { |
| 63 | ITensorHandle* backupHandle = this->m_Data.m_Inputs[slot]; |
| 64 | this->m_Data.m_Inputs[slot] = tensorHandle; |
| 65 | try |
| 66 | { |
| 67 | Reconfigure(); |
| 68 | } |
| 69 | catch(armnn::UnimplementedException& e) |
| 70 | { |
| 71 | // Cannot reconfigure, revert the slot back and throw the exception. |
| 72 | this->m_Data.m_Inputs[slot] = backupHandle; |
| 73 | throw e; |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | void ClFloorFloatWorkload::Reconfigure() |
| 78 | { |
| 79 | throw armnn::UnimplementedException("Reconfigure not implemented for this workload"); |
| 80 | } |
| 81 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 82 | } //namespace armnn |