1 //
2 // Copyright © 2017 Arm Ltd and Contributors. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5
6 #include "NeonFloorFloatWorkload.hpp"
7
8 #include "NeonWorkloadUtils.hpp"
9
10 #include <armnn/utility/PolymorphicDowncast.hpp>
11
12 #include <arm_compute/runtime/NEON/functions/NEFloor.h>
13
14 namespace armnn
15 {
NeonFloorFloatWorkload(const FloorQueueDescriptor & descriptor,const WorkloadInfo & info)16 NeonFloorFloatWorkload::NeonFloorFloatWorkload(const FloorQueueDescriptor& descriptor,
17 const WorkloadInfo& info)
18 : FloatWorkload<FloorQueueDescriptor>(descriptor, info)
19 {
20 m_Data.ValidateInputsOutputs("NeonFloorFloatWorkload", 1, 1);
21
22 arm_compute::ITensor& input = PolymorphicDowncast<IAclTensorHandle*>(m_Data.m_Inputs[0])->GetTensor();
23 arm_compute::ITensor& output = PolymorphicDowncast<IAclTensorHandle*>(m_Data.m_Outputs[0])->GetTensor();
24
25 auto layer = std::make_unique<arm_compute::NEFloor>();
26 layer->configure(&input, &output);
27 m_Layer.reset(layer.release());
28 }
29
Execute() const30 void NeonFloorFloatWorkload::Execute() const
31 {
32 ARMNN_SCOPED_PROFILING_EVENT_NEON_GUID("NeonFloorFloatWorkload_Execute", this->GetGuid());
33 m_Layer->run();
34 }
35
ReplaceInputTensorHandle(ITensorHandle * tensorHandle,unsigned int slot)36 void NeonFloorFloatWorkload::ReplaceInputTensorHandle(ITensorHandle* tensorHandle, unsigned int slot)
37 {
38 ITensorHandle* backupHandle = this->m_Data.m_Inputs[slot];
39 this->m_Data.m_Inputs[slot] = tensorHandle;
40 try
41 {
42 Reconfigure();
43 }
44 catch(armnn::UnimplementedException& e)
45 {
46 // Cannot reconfigure, revert the slot back and throw the exception.
47 this->m_Data.m_Inputs[slot] = backupHandle;
48 throw e;
49 }
50 }
51
52 // Replace output tensor handle with the given TensorHandle
ReplaceOutputTensorHandle(ITensorHandle * tensorHandle,unsigned int slot)53 void NeonFloorFloatWorkload::ReplaceOutputTensorHandle(ITensorHandle* tensorHandle, unsigned int slot)
54 {
55 ITensorHandle* backupHandle = this->m_Data.m_Inputs[slot];
56 this->m_Data.m_Inputs[slot] = tensorHandle;
57 try
58 {
59 Reconfigure();
60 }
61 catch(armnn::UnimplementedException& e)
62 {
63 // Cannot reconfigure, revert the slot back and throw the exception.
64 this->m_Data.m_Inputs[slot] = backupHandle;
65 throw e;
66 }
67 }
68
Reconfigure()69 void NeonFloorFloatWorkload::Reconfigure()
70 {
71 throw armnn::UnimplementedException("Reconfigure not implemented for this workload");
72 }
73
74 } //namespace armnn
75
76
77
78