ArmNN
 20.02
ClConstantWorkload.cpp
Go to the documentation of this file.
1 //
2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
6 #include "ClConstantWorkload.hpp"
7 
8 #include <Half.hpp>
10 #include <cl/ClTensorHandle.hpp>
12 
13 #include "ClWorkloadUtils.hpp"
14 
15 namespace armnn
16 {
17 
19  : BaseWorkload<ConstantQueueDescriptor>(descriptor, info)
20  , m_RanOnce(false)
21 {
22 }
23 
25 {
26  ARMNN_SCOPED_PROFILING_EVENT_CL("ClConstantWorkload_Execute");
27 
28  // The intermediate tensor held by the corresponding layer output handler can be initialised with the given data
29  // on the first inference, then reused for subsequent inferences.
30  // The initialisation cannot happen at workload construction time since the ACL kernel for the next layer may not
31  // have been configured at the time.
32  if (!m_RanOnce)
33  {
34  const ConstantQueueDescriptor& data = this->m_Data;
35 
36  BOOST_ASSERT(data.m_LayerOutput != nullptr);
37  arm_compute::CLTensor& output = static_cast<ClTensorHandle*>(data.m_Outputs[0])->GetTensor();
38  arm_compute::DataType computeDataType = static_cast<ClTensorHandle*>(data.m_Outputs[0])->GetDataType();
39 
40  switch (computeDataType)
41  {
42  case arm_compute::DataType::F16:
43  {
45  break;
46  }
47  case arm_compute::DataType::F32:
48  {
50  break;
51  }
52  case arm_compute::DataType::QASYMM8:
53  {
55  break;
56  }
57  default:
58  {
59  BOOST_ASSERT_MSG(false, "Unknown data type");
60  break;
61  }
62  }
63 
64  m_RanOnce = true;
65  }
66 }
67 
68 } //namespace armnn
void Execute() const override
#define ARMNN_SCOPED_PROFILING_EVENT_CL(name)
const ConstantQueueDescriptor m_Data
Definition: Workload.hpp:46
const ConstCpuTensorHandle * m_LayerOutput
const T * GetConstTensor() const
Copyright (c) 2020 ARM Limited.
DataLayout::NHWC false
DataType
Definition: Types.hpp:32
ClConstantWorkload(const ConstantQueueDescriptor &descriptor, const WorkloadInfo &info)
void CopyArmComputeClTensorData(arm_compute::CLTensor &dstTensor, const T *srcData)
std::vector< ITensorHandle * > m_Outputs
Contains information about inputs and outputs to a layer.
half_float::half Half
Definition: Half.hpp:16