ArmNN
 24.02
GpuFsaConstantWorkload.cpp
Go to the documentation of this file.
1 //
2 // Copyright © 2024 Arm Ltd and Contributors. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
8 
9 #include <Half.hpp>
13 
14 namespace armnn
15 {
16 
18 {
19  const arm_compute::TensorInfo neonOutputInfo = armcomputetensorutils::BuildArmComputeTensorInfo(output);
20 
21  std::array<arm_compute::DataType,8> supportedTypes = {
22  arm_compute::DataType::F16,
23  arm_compute::DataType::F32,
24  arm_compute::DataType::QASYMM8,
25  arm_compute::DataType::QASYMM8_SIGNED,
26  arm_compute::DataType::QSYMM16,
27  arm_compute::DataType::QSYMM8,
28  arm_compute::DataType::QSYMM8_PER_CHANNEL,
29  arm_compute::DataType::S32
30  };
31  auto it = std::find(begin(supportedTypes), end(supportedTypes), neonOutputInfo.data_type());
32 
33  if (it != end(supportedTypes))
34  {
35  return arm_compute::Status{};
36  }
37  else
38  {
39  return arm_compute::Status{arm_compute::ErrorCode::RUNTIME_ERROR, "Unsupported DataType"};
40  }
41 }
42 
44  const WorkloadInfo& info,
45  const arm_compute::CLCompileContext&)
47  , m_RanOnce(false)
48 {
49 }
50 
52 {
53  // The intermediate tensor held by the corresponding layer output handler can be initialised with the given data
54  // on the first inference, then reused for subsequent inferences.
55  // The initialisation cannot happen at workload construction time since the ACL kernel for the next layer may not
56  // have been configured at the time.
57  if (!m_RanOnce)
58  {
59  const ConstantQueueDescriptor& data = this->m_Data;
60 
61  ARMNN_ASSERT(data.m_LayerOutput != nullptr);
62  arm_compute::CLTensor& output = static_cast<GpuFsaTensorHandle*>(data.m_Outputs[0])->GetTensor();
63  arm_compute::DataType computeDataType = static_cast<GpuFsaTensorHandle*>(data.m_Outputs[0])->GetDataType();
64 
65  switch (computeDataType)
66  {
67  case arm_compute::DataType::F16:
68  {
70  break;
71  }
72  case arm_compute::DataType::F32:
73  {
75  break;
76  }
77  case arm_compute::DataType::QASYMM8:
78  {
80  break;
81  }
82  case arm_compute::DataType::QASYMM8_SIGNED:
83  {
85  break;
86  }
87  case arm_compute::DataType::QSYMM16:
88  {
90  break;
91  }
92  case arm_compute::DataType::QSYMM8:
93  case arm_compute::DataType::QSYMM8_PER_CHANNEL:
94  {
96  break;
97  }
98  case arm_compute::DataType::S32:
99  {
100  CopyArmComputeClTensorData(output, data.m_LayerOutput->GetConstTensor<int32_t>());
101  break;
102  }
103  default:
104  {
105  ARMNN_ASSERT_MSG(false, "Unknown data type");
106  break;
107  }
108  }
109 
110  m_RanOnce = true;
111  }
112 }
113 
114 } //namespace armnn
ARMNN_ASSERT
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14
armnn::TensorInfo
Definition: Tensor.hpp:152
armnn::Half
half_float::half Half
Definition: Half.hpp:22
armnn::CopyArmComputeClTensorData
void CopyArmComputeClTensorData(arm_compute::CLTensor &dstTensor, const T *srcData)
Definition: ClWorkloadUtils.hpp:64
ARMNN_ASSERT_MSG
#define ARMNN_ASSERT_MSG(COND, MSG)
Definition: Assert.hpp:15
GpuFsaTensorHandle.hpp
GpuFsaConstantWorkload.hpp
armnn::ConstantQueueDescriptor
Definition: WorkloadData.hpp:368
armnn::ConstTensorHandle::GetConstTensor
const T * GetConstTensor() const
Definition: TensorHandle.hpp:28
armnn::GpuFsaConstantWorkload::Execute
void Execute() const override
Definition: GpuFsaConstantWorkload.cpp:51
armnn::WorkloadInfo
Contains information about TensorInfos of a layer.
Definition: WorkloadInfo.hpp:16
armnn::DataType
DataType
Definition: Types.hpp:48
armnn::GpuFsaBaseWorkload
Definition: GpuFsaBaseWorkload.hpp:14
armnn::BoostLogSeverityMapping::info
@ info
armnn::GpuFsaConstantWorkload::GpuFsaConstantWorkload
GpuFsaConstantWorkload(const ConstantQueueDescriptor &descriptor, const WorkloadInfo &info, const arm_compute::CLCompileContext &clCompileContext)
Definition: GpuFsaConstantWorkload.cpp:43
armnn::GpuFsaTensorHandle
Definition: GpuFsaTensorHandle.hpp:25
armnn::QueueDescriptor::m_Outputs
std::vector< ITensorHandle * > m_Outputs
Definition: WorkloadData.hpp:27
GpuFsaWorkloadUtils.hpp
armnn::ConstantQueueDescriptor::m_LayerOutput
const ConstTensorHandle * m_LayerOutput
Definition: WorkloadData.hpp:375
Half.hpp
TensorHandle.hpp
armnn::Status
Status
Definition: Types.hpp:42
armnn::BaseWorkload< ConstantQueueDescriptor >::m_Data
ConstantQueueDescriptor m_Data
Definition: Workload.hpp:89
armnn
Copyright (c) 2021 ARM Limited and Contributors.
Definition: 01_00_quick_start.dox:6
ArmComputeTensorUtils.hpp
armnn::GpuFsaConstantWorkloadValidate
arm_compute::Status GpuFsaConstantWorkloadValidate(const TensorInfo &output)
Definition: GpuFsaConstantWorkload.cpp:17