blob: 0aae1a30e39f5f8f90ab01a1087532b625029948 [file] [log] [blame]
telsoa014fcda012018-03-09 14:13:49 +00001//
Teresa Charlin588cbdf2022-01-19 15:55:37 +00002// Copyright © 2017 Arm Ltd and Contributors. All rights reserved.
David Beckecb56cd2018-09-05 12:52:57 +01003// SPDX-License-Identifier: MIT
telsoa014fcda012018-03-09 14:13:49 +00004//
5
arovir019e53a352018-08-31 15:26:35 +01006#include "ClFloorFloatWorkload.hpp"
Aron Virginas-Tarc9cc8042018-11-01 16:15:57 +00007#include <cl/ClTensorHandle.hpp>
telsoa014fcda012018-03-09 14:13:49 +00008
Matthew Bentham14e46692018-09-20 15:35:30 +01009#include "ClWorkloadUtils.hpp"
10
telsoa014fcda012018-03-09 14:13:49 +000011namespace armnn
12{
13
Sadik Armagan9be49162019-10-30 16:15:26 +000014arm_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 Armagane9444752020-12-02 11:28:58 +000023ClFloorFloatWorkload::ClFloorFloatWorkload(const FloorQueueDescriptor& descriptor,
24 const WorkloadInfo& info,
25 const arm_compute::CLCompileContext& clCompileContext)
telsoa01c577f2c2018-08-31 09:22:23 +010026 : FloatWorkload<FloorQueueDescriptor>(descriptor, info)
telsoa014fcda012018-03-09 14:13:49 +000027{
arovir019e53a352018-08-31 15:26:35 +010028 m_Data.ValidateInputsOutputs("ClFloorFloatWorkload", 1, 1);
telsoa014fcda012018-03-09 14:13:49 +000029
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 May9f6862d2021-10-22 15:42:28 +010032 {
33 ARMNN_SCOPED_PROFILING_EVENT(Compute::Undefined, "ClFloorFloatWorkload_configure");
34 m_Layer.configure(clCompileContext, &input, &output);
35 }
telsoa014fcda012018-03-09 14:13:49 +000036}
37
arovir019e53a352018-08-31 15:26:35 +010038void ClFloorFloatWorkload::Execute() const
telsoa014fcda012018-03-09 14:13:49 +000039{
Keith Davisbcd860a2021-08-05 14:20:33 +010040 ARMNN_SCOPED_PROFILING_EVENT_CL_GUID("ClFloorFloatWorkload_Execute", this->GetGuid());
Aron Virginas-Tara8e06ed2018-10-19 16:46:15 +010041 RunClFunction(m_Layer, CHECK_LOCATION());
telsoa014fcda012018-03-09 14:13:49 +000042}
43
David Monahanec819992022-02-10 14:47:13 +000044void 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
61void 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
77void ClFloorFloatWorkload::Reconfigure()
78{
79 throw armnn::UnimplementedException("Reconfigure not implemented for this workload");
80}
81
telsoa014fcda012018-03-09 14:13:49 +000082} //namespace armnn