ArmNN
 24.08
RefShapeWorkload.hpp
Go to the documentation of this file.
1 //
2 // Copyright © 2021-2023 Arm Ltd and Contributors. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
6 #pragma once
7 
8 #include "RefBaseWorkload.hpp"
10 
11 #include "RefWorkloadUtils.hpp"
12 
13 namespace armnn
14 {
15 
16 struct RefShapeWorkload : public RefBaseWorkload<ShapeQueueDescriptor>
17 {
18 public:
20  virtual void Execute() const override
21  {
23  }
24  void ExecuteAsync(ExecutionData& executionData) override
25  {
26  WorkingMemDescriptor* workingMemDescriptor = static_cast<WorkingMemDescriptor*>(executionData.m_Data);
27  Execute(workingMemDescriptor->m_Inputs, workingMemDescriptor->m_Outputs);
28  }
29 
30 private:
31  void Execute(std::vector<ITensorHandle*> inputs, std::vector<ITensorHandle*> outputs) const
32  {
33  ARMNN_SCOPED_PROFILING_EVENT_REF_NAME_GUID("RefShapeWorkload_Execute");
34 
35  const TensorShape Shape = GetTensorInfo(inputs[0]).GetShape();
36 
37  const TensorInfo& outputInfo = GetTensorInfo(outputs[0]);
38 
39  unsigned int numBytes =
40  GetTensorInfo(inputs[0]).GetNumDimensions() * GetDataTypeSize(outputInfo.GetDataType());
41 
42  std::memcpy(outputs[0]->Map(), &Shape, numBytes);
43  outputs[0]->Unmap();
44  }
45 };
46 
47 } //namespace armnn
48 
49 
50 
51 
WorkloadData.hpp
armnn::experimental::ExecutionData::m_Data
void * m_Data
Definition: ExecutionData.hpp:16
armnn::RefShapeWorkload
Definition: RefShapeWorkload.hpp:16
armnn::TensorInfo
Definition: Tensor.hpp:152
armnn::TensorInfo::GetNumDimensions
unsigned int GetNumDimensions() const
Definition: Tensor.hpp:197
ARMNN_SCOPED_PROFILING_EVENT_REF_NAME_GUID
#define ARMNN_SCOPED_PROFILING_EVENT_REF_NAME_GUID(label)
Creates a profiling event that uses GetGuid() and GetName() from the calling class.
Definition: RefWorkloadUtils.hpp:22
armnn::RefShapeWorkload::Execute
virtual void Execute() const override
Definition: RefShapeWorkload.hpp:20
armnn::TensorShape
Definition: Tensor.hpp:20
armnn::GetTensorInfo
const TensorInfo & GetTensorInfo(const ITensorHandle *tensorHandle)
float32 helpers
Definition: RefWorkloadUtils.hpp:33
armnn::GetDataTypeSize
constexpr unsigned int GetDataTypeSize(DataType dataType)
Definition: TypesUtils.hpp:182
armnn::RefShapeWorkload::ExecuteAsync
void ExecuteAsync(ExecutionData &executionData) override
Definition: RefShapeWorkload.hpp:24
armnn::TensorInfo::GetDataType
DataType GetDataType() const
Definition: Tensor.hpp:200
armnn::QueueDescriptor::m_Outputs
std::vector< ITensorHandle * > m_Outputs
Definition: WorkloadData.hpp:27
armnn::LayerType::Shape
@ Shape
RefWorkloadUtils.hpp
armnn::BaseWorkload< ShapeQueueDescriptor >::m_Data
ShapeQueueDescriptor m_Data
Definition: Workload.hpp:89
armnn::TensorInfo::GetShape
const TensorShape & GetShape() const
Definition: Tensor.hpp:193
armnn::LayerType::Map
@ Map
armnn::experimental::WorkingMemDescriptor::m_Inputs
std::vector< ITensorHandle * > m_Inputs
Definition: WorkingMemDescriptor.hpp:20
armnn
Copyright (c) 2021 ARM Limited and Contributors.
Definition: 01_00_quick_start.dox:6
armnn::experimental::WorkingMemDescriptor
Definition: WorkingMemDescriptor.hpp:18
RefBaseWorkload.hpp
armnn::RefBaseWorkload
Definition: RefBaseWorkload.hpp:13
armnn::experimental::WorkingMemDescriptor::m_Outputs
std::vector< ITensorHandle * > m_Outputs
Definition: WorkingMemDescriptor.hpp:21
armnn::QueueDescriptor::m_Inputs
std::vector< ITensorHandle * > m_Inputs
Definition: WorkloadData.hpp:26
armnn::experimental::ExecutionData
Definition: ExecutionData.hpp:14