ArmNN
 22.08
ClFloorFloatWorkload.cpp
Go to the documentation of this file.
1 //
2 // Copyright © 2017 Arm Ltd and Contributors. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
7 #include <cl/ClTensorHandle.hpp>
8 
9 #include "ClWorkloadUtils.hpp"
10 
11 namespace armnn
12 {
13 
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 
24  const WorkloadInfo& info,
25  const arm_compute::CLCompileContext& clCompileContext)
26  : FloatWorkload<FloorQueueDescriptor>(descriptor, info)
27 {
28  m_Data.ValidateInputsOutputs("ClFloorFloatWorkload", 1, 1);
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();
32  {
33  ARMNN_SCOPED_PROFILING_EVENT(Compute::Undefined, "ClFloorFloatWorkload_configure");
34  m_Layer.configure(clCompileContext, &input, &output);
35  }
36 }
37 
39 {
40  ARMNN_SCOPED_PROFILING_EVENT_CL_GUID("ClFloorFloatWorkload_Execute", this->GetGuid());
41  RunClFunction(m_Layer, CHECK_LOCATION());
42 }
43 
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  }
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  }
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 
82 } //namespace armnn
#define ARMNN_SCOPED_PROFILING_EVENT_CL_GUID(name, guid)
void RunClFunction(arm_compute::IFunction &function, const CheckLocation &location)
arm::pipe::ProfilingGuid GetGuid() const final
Definition: Workload.hpp:61
void ValidateInputsOutputs(const std::string &descName, unsigned int numExpectedIn, unsigned int numExpectedOut) const
Copyright (c) 2021 ARM Limited and Contributors.
#define ARMNN_SCOPED_PROFILING_EVENT(backendId, name)
Definition: Profiling.hpp:220
QueueDescriptor m_Data
Definition: Workload.hpp:83
Status
enumeration
Definition: Types.hpp:42
#define CHECK_LOCATION()
Definition: Exceptions.hpp:203
void ReplaceOutputTensorHandle(ITensorHandle *tensorHandle, unsigned int slot) override
void ReplaceInputTensorHandle(ITensorHandle *tensorHandle, unsigned int slot) override
std::vector< ITensorHandle * > m_Outputs
Contains information about TensorInfos of a layer.
std::vector< ITensorHandle * > m_Inputs
ClFloorFloatWorkload(const FloorQueueDescriptor &descriptor, const WorkloadInfo &info, const arm_compute::CLCompileContext &clCompileContext)
arm_compute::Status ClFloorWorkloadValidate(const TensorInfo &input, const TensorInfo &output)