ArmNN
 21.08
NeonConvertFp32ToFp16Workload.cpp
Go to the documentation of this file.
1 //
2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
7 
8 #include <Half.hpp>
9 #include <Profiling.hpp>
10 
12 
14 
15 namespace armnn
16 {
17 
19  const WorkloadInfo& info)
21 {
22  this->m_Data.ValidateInputsOutputs("NeonConvertFp32ToFp16Workload", 1, 1);
23  GatherTensorHandlePairs(descriptor, m_TensorHandlePairs);
24 }
25 
27 {
28  ARMNN_SCOPED_PROFILING_EVENT_NEON_GUID("NeonConvertFp32ToFp16Workload_Execute", this->GetGuid());
29 
30  auto convertFunc = [](uint8_t* dst, const uint8_t* src, size_t size)
31  {
32  auto input = reinterpret_cast<const float*>(src);
33  auto output = reinterpret_cast<Half*>(dst);
34  size_t numElements = size/2; // 2 bytes per fp16
36  };
37 
38  for (const auto& pair : m_TensorHandlePairs)
39  {
40  CopyTensorContentsGeneric(pair.first, pair.second, convertFunc);
41  }
42 }
43 
44 } //namespace armnn
void ValidateInputsOutputs(const std::string &descName, unsigned int numExpectedIn, unsigned int numExpectedOut) const
Copyright (c) 2021 ARM Limited and Contributors.
QueueDescriptor m_Data
Definition: Workload.hpp:58
static void ConvertFloat32To16(const float *srcFloat32Buffer, size_t numElements, void *dstFloat16Buffer)
Converts a buffer of FP32 values to FP16, and stores in the given dstFloat16Buffer.
profiling::ProfilingGuid GetGuid() const final
Definition: Workload.hpp:55
NeonConvertFp32ToFp16Workload(const ConvertFp32ToFp16QueueDescriptor &descriptor, const WorkloadInfo &info)
Contains information about TensorInfos of a layer.
void CopyTensorContentsGeneric(const ITensorHandle *srcTensor, ITensorHandle *dstTensor, CopyFunc copy)
void GatherTensorHandlePairs(const DescriptorType &descriptor, std::vector< std::pair< SrcTensorHandleType *, DstTensorHandleType *>> &tensorHandlePairs)
half_float::half Half
Definition: Half.hpp:16
#define ARMNN_SCOPED_PROFILING_EVENT_NEON_GUID(name, guid)