diff options
author | David Beck <david.beck@arm.com> | 2018-09-26 17:41:13 +0100 |
---|---|---|
committer | Matthew Bentham <matthew.bentham@arm.com> | 2018-10-10 16:16:57 +0100 |
commit | ac42efd972b7d03da17f057b2ceaaac5d6e96b1a (patch) | |
tree | 1ebc1320fa3ea7f494d3716ea79a2bda0f4ffd1e /src/backends/cl/workloads/ClBaseConstantWorkload.cpp | |
parent | bcd3c85b5a7657b38f503676b88a80ae74165acd (diff) | |
download | armnn-ac42efd972b7d03da17f057b2ceaaac5d6e96b1a.tar.gz |
IVGCVSW-1900 : CL backend folder structure
* moving backends/ClWorkloads to backends/cl
* and moving pure Cl workload related code to
backends/cl/workloads
Change-Id: I019a3c6b4da5e7a23074bf03fb057e63199ad129
Diffstat (limited to 'src/backends/cl/workloads/ClBaseConstantWorkload.cpp')
-rw-r--r-- | src/backends/cl/workloads/ClBaseConstantWorkload.cpp | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/src/backends/cl/workloads/ClBaseConstantWorkload.cpp b/src/backends/cl/workloads/ClBaseConstantWorkload.cpp new file mode 100644 index 0000000000..2557020b59 --- /dev/null +++ b/src/backends/cl/workloads/ClBaseConstantWorkload.cpp @@ -0,0 +1,64 @@ +// +// Copyright © 2017 Arm Ltd. All rights reserved. +// SPDX-License-Identifier: MIT +// + +#include "ClBaseConstantWorkload.hpp" +#include <backends/aclCommon/ArmComputeTensorUtils.hpp> +#include <backends/cl/ClTensorHandle.hpp> +#include <backends/CpuTensorHandle.hpp> +#include <Half.hpp> + +#include "ClWorkloadUtils.hpp" + +namespace armnn +{ + +template class ClBaseConstantWorkload<DataType::Float16, DataType::Float32>; +template class ClBaseConstantWorkload<DataType::QuantisedAsymm8>; + +template<armnn::DataType... dataTypes> +void ClBaseConstantWorkload<dataTypes...>::Execute() const +{ + // The intermediate tensor held by the corresponding layer output handler can be initialised with the given data + // on the first inference, then reused for subsequent inferences. + // The initialisation cannot happen at workload construction time since the ACL kernel for the next layer may not + // have been configured at the time. + if (!m_RanOnce) + { + const ConstantQueueDescriptor& data = this->m_Data; + + BOOST_ASSERT(data.m_LayerOutput != nullptr); + arm_compute::CLTensor& output = static_cast<ClTensorHandle*>(data.m_Outputs[0])->GetTensor(); + arm_compute::DataType computeDataType = static_cast<ClTensorHandle*>(data.m_Outputs[0])->GetDataType(); + + switch (computeDataType) + { + case arm_compute::DataType::F16: + { + CopyArmComputeClTensorData(output, data.m_LayerOutput->GetConstTensor<Half>()); + break; + } + case arm_compute::DataType::F32: + { + CopyArmComputeClTensorData(output, data.m_LayerOutput->GetConstTensor<float>()); + break; + } + case arm_compute::DataType::QASYMM8: + { + CopyArmComputeClTensorData(output, data.m_LayerOutput->GetConstTensor<uint8_t>()); + break; + } + default: + { + BOOST_ASSERT_MSG(false, "Unknown data type"); + break; + } + } + + m_RanOnce = true; + } +} + + +} //namespace armnn |