ArmNN
 23.05
RefShapeWorkload.hpp
Go to the documentation of this file.
1 //
2 // Copyright © 2022 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  const TensorShape Shape = GetTensorInfo(inputs[0]).GetShape();
34 
35  const TensorInfo& outputInfo = GetTensorInfo(outputs[0]);
36 
37  unsigned int numBytes =
38  GetTensorInfo(inputs[0]).GetNumDimensions() * GetDataTypeSize(outputInfo.GetDataType());
39 
40  std::memcpy(outputs[0]->Map(), &Shape, numBytes);
41  outputs[0]->Unmap();
42  }
43 };
44 
45 } //namespace armnn
46 
47 
48 
49 
armnn::GetTensorInfo
const TensorInfo & GetTensorInfo(const ITensorHandle *tensorHandle)
float32 helpers
Definition: RefWorkloadUtils.hpp:27
armnn::RefBaseWorkload
Definition: RefBaseWorkload.hpp:13
armnn::LayerType::Map
@ Map
armnn::experimental::WorkingMemDescriptor::m_Inputs
std::vector< ITensorHandle * > m_Inputs
Definition: WorkingMemDescriptor.hpp:20
armnn::experimental::ExecutionData
Definition: ExecutionData.hpp:14
armnn::LayerType::Shape
@ Shape
armnn::experimental::ExecutionData::m_Data
void * m_Data
Definition: ExecutionData.hpp:16
armnn::experimental::WorkingMemDescriptor
Definition: WorkingMemDescriptor.hpp:18
armnn::BaseWorkload< ShapeQueueDescriptor >::m_Data
ShapeQueueDescriptor m_Data
Definition: Workload.hpp:83
armnn::RefShapeWorkload::Execute
virtual void Execute() const override
Definition: RefShapeWorkload.hpp:20
RefBaseWorkload.hpp
armnn::GetDataTypeSize
constexpr unsigned int GetDataTypeSize(DataType dataType)
Definition: TypesUtils.hpp:169
armnn
Copyright (c) 2021 ARM Limited and Contributors.
Definition: 01_00_quick_start.dox:6
armnn::TensorShape
Definition: Tensor.hpp:20
armnn::TensorInfo::GetNumDimensions
unsigned int GetNumDimensions() const
Definition: Tensor.hpp:195
RefWorkloadUtils.hpp
armnn::TensorInfo
Definition: Tensor.hpp:152
armnn::RefShapeWorkload
Definition: RefShapeWorkload.hpp:16
armnn::RefShapeWorkload::ExecuteAsync
void ExecuteAsync(ExecutionData &executionData) override
Definition: RefShapeWorkload.hpp:24
armnn::TensorInfo::GetShape
const TensorShape & GetShape() const
Definition: Tensor.hpp:191
armnn::experimental::WorkingMemDescriptor::m_Outputs
std::vector< ITensorHandle * > m_Outputs
Definition: WorkingMemDescriptor.hpp:21
armnn::QueueDescriptor::m_Outputs
std::vector< ITensorHandle * > m_Outputs
Definition: WorkloadData.hpp:27
WorkloadData.hpp
armnn::TensorInfo::GetDataType
DataType GetDataType() const
Definition: Tensor.hpp:198
armnn::QueueDescriptor::m_Inputs
std::vector< ITensorHandle * > m_Inputs
Definition: WorkloadData.hpp:26