ArmNN
 21.11
RefShapeWorkload.hpp
Go to the documentation of this file.
1 //
2 // Copyright © 2021 Arm Ltd and Contributors. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
6 #pragma once
7 
10 
11 #include "RefWorkloadUtils.hpp"
12 
13 namespace armnn
14 {
15 
16 struct RefShapeWorkload : public BaseWorkload<ShapeQueueDescriptor>
17 {
18 public:
20  virtual void Execute() const override
21  {
23  }
24  void ExecuteAsync(WorkingMemDescriptor& workingMemDescriptor) override
25  {
26  Execute(workingMemDescriptor.m_Inputs, workingMemDescriptor.m_Outputs);
27  }
28 
29 private:
30  void Execute(std::vector<ITensorHandle*> inputs, std::vector<ITensorHandle*> outputs) const
31  {
32  const TensorShape Shape = GetTensorInfo(inputs[0]).GetShape();
33 
34  const TensorInfo& outputInfo = GetTensorInfo(outputs[0]);
35 
36  unsigned int numBytes =
37  GetTensorInfo(inputs[0]).GetNumDimensions() * GetDataTypeSize(outputInfo.GetDataType());
38 
39  std::memcpy(outputs[0]->Map(), &Shape, numBytes);
40  outputs[0]->Unmap();
41  }
42 };
43 
44 } //namespace armnn
45 
46 
47 
48 
const TensorShape & GetShape() const
Definition: Tensor.hpp:191
Copyright (c) 2021 ARM Limited and Contributors.
void ExecuteAsync(WorkingMemDescriptor &workingMemDescriptor) override
DataType GetDataType() const
Definition: Tensor.hpp:198
virtual void Execute() const override
std::vector< ITensorHandle * > m_Outputs
std::vector< ITensorHandle * > m_Inputs
const TensorInfo & GetTensorInfo(const ITensorHandle *tensorHandle)
float32 helpers
unsigned int GetNumDimensions() const
Definition: Tensor.hpp:195
constexpr unsigned int GetDataTypeSize(DataType dataType)
Definition: TypesUtils.hpp:151