ArmNN
 24.08
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  arm_compute::CLTensor& output = static_cast<GpuFsaTensorHandle*>(data.m_Outputs[0])->GetTensor();
61  arm_compute::DataType computeDataType = static_cast<GpuFsaTensorHandle*>(data.m_Outputs[0])->GetDataType();
62 
63  switch (computeDataType)
64  {
65  case arm_compute::DataType::F16:
66  {
68  break;
69  }
70  case arm_compute::DataType::F32:
71  {
73  break;
74  }
75  case arm_compute::DataType::QASYMM8:
76  {
78  break;
79  }
80  case arm_compute::DataType::QASYMM8_SIGNED:
81  {
83  break;
84  }
85  case arm_compute::DataType::QSYMM16:
86  {
88  break;
89  }
90  case arm_compute::DataType::QSYMM8:
91  case arm_compute::DataType::QSYMM8_PER_CHANNEL:
92  {
94  break;
95  }
96  case arm_compute::DataType::S32:
97  {
99  break;
100  }
101  default:
102  {
103  throw InvalidArgumentException("Unknown data type passed to GpuFsaConstantWorkload::Execute()");
104  break;
105  }
106  }
107 
108  m_RanOnce = true;
109  }
110 }
111 
112 } //namespace armnn
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
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::InvalidArgumentException
Definition: Exceptions.hpp:80
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