2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
6 #include "NeonConstantWorkload.hpp"
8 #include <arm_compute/core/Types.h>
10 #include <aclCommon/ArmComputeTensorUtils.hpp>
11 #include <neon/NeonTensorHandle.hpp>
12 #include <backendsCommon/CpuTensorHandle.hpp>
13 #include <backendsCommon/Workload.hpp>
15 #include <boost/cast.hpp>
20 NeonConstantWorkload::NeonConstantWorkload(const ConstantQueueDescriptor& descriptor,
21 const WorkloadInfo& info)
22 : BaseWorkload<ConstantQueueDescriptor>(descriptor, info)
27 void NeonConstantWorkload::Execute() const
29 ARMNN_SCOPED_PROFILING_EVENT_NEON("NeonConstantWorkload_Execute");
31 using namespace armcomputetensorutils;
33 // The intermediate tensor held by the corresponding layer output handler can be initialised with the
34 // given data on the first inference, then reused for subsequent inferences.
35 // The initialisation cannot happen at workload construction time since the ACL kernel for the next layer
36 // may not have been configured at the time.
39 const ConstantQueueDescriptor& data = this->m_Data;
41 BOOST_ASSERT(data.m_LayerOutput != nullptr);
42 arm_compute::ITensor& output =
43 boost::polymorphic_downcast<NeonTensorHandle*>(data.m_Outputs[0])->GetTensor();
44 arm_compute::DataType computeDataType =
45 boost::polymorphic_downcast<NeonTensorHandle*>(data.m_Outputs[0])->GetDataType();
47 switch (computeDataType)
49 case arm_compute::DataType::F16:
51 CopyArmComputeITensorData(data.m_LayerOutput->GetConstTensor<Half>(), output);
54 case arm_compute::DataType::F32:
56 CopyArmComputeITensorData(data.m_LayerOutput->GetConstTensor<float>(), output);
59 case arm_compute::DataType::QASYMM8:
61 CopyArmComputeITensorData(data.m_LayerOutput->GetConstTensor<uint8_t>(), output);
66 BOOST_ASSERT_MSG(false, "Unknown data type");