ArmNN
 24.02
TosaMappings.cpp File Reference
#include "TosaMappings.hpp"
Include dependency graph for TosaMappings.cpp:

Go to the source code of this file.

Functions

TosaSerializationBasicBlock * CreateEmptyTosaSerializationBasicBlock ()
 
TosaSerializationBasicBlock * GetTosaMapping (const Layer *layer, const LayerType type, const std::vector< const TensorInfo * > &inputs, const std::vector< const TensorInfo * > &outputs, const BaseDescriptor &descriptor)
 
TosaSerializationBasicBlock * GetTosaMappingFromLayer (Layer *layer)
 

Function Documentation

◆ CreateEmptyTosaSerializationBasicBlock()

TosaSerializationBasicBlock* CreateEmptyTosaSerializationBasicBlock ( )

Definition at line 11 of file TosaMappings.cpp.

12 {
13  // Empty basic block when no TOSA mapping implemented/exists
14  auto* op = new TosaSerializationOperator(Op_UNKNOWN, Attribute_NONE, nullptr, {}, {});
15  return new TosaSerializationBasicBlock("", "", {op}, {}, {}, {});
16 }

Referenced by GetTosaMapping().

◆ GetTosaMapping()

TosaSerializationBasicBlock* GetTosaMapping ( const Layer layer,
const LayerType  type,
const std::vector< const TensorInfo * > &  inputs,
const std::vector< const TensorInfo * > &  outputs,
const BaseDescriptor descriptor 
)

Definition at line 18 of file TosaMappings.cpp.

23 {
24  switch (type)
25  {
27  {
28  auto activationDesc = PolymorphicDowncast<const ActivationDescriptor*>(&descriptor);
29  if (activationDesc->m_Function == ActivationFunction::LeakyReLu)
30  {
31  return ConvertActivationToTosaOperator(layer, inputs, outputs, activationDesc);
32  }
33  else
34  {
36  }
37  }
38  case LayerType::Addition:
39  case LayerType::Multiplication:
40  case LayerType::Subtraction:
41  {
42  return ConvertElementwiseBinaryToTosaOperator(layer, type, inputs, outputs);
43  }
44  case LayerType::ElementwiseBinary:
45  {
46  auto binaryDesc = PolymorphicDowncast<const ElementwiseBinaryDescriptor*>(&descriptor);
47  return ConvertElementwiseBinaryToTosaOperator(layer, type, inputs, outputs, binaryDesc);
48  }
49  case LayerType::ElementwiseUnary:
50  {
51  auto unaryDesc = PolymorphicDowncast<const ElementwiseUnaryDescriptor*>(&descriptor);
52  return ConvertElementwiseUnaryOperator(layer, inputs, outputs, unaryDesc);
53  }
54  case LayerType::Concat:
55  {
56  auto concatDesc = PolymorphicDowncast<const OriginsDescriptor*>(&descriptor);
57  return ConvertConcatToTosaOperator(layer, inputs, outputs, concatDesc);
58  }
59  case LayerType::Constant:
60  {
61  return ConvertConstantToTosaOperator(layer, outputs);
62  }
63  case LayerType::Convolution2d:
64  {
65  auto conv2dDesc = PolymorphicDowncast<const Convolution2dDescriptor*>(&descriptor);
66  return ConvertConv2dToTosaOperator(layer, inputs, outputs, conv2dDesc);
67  }
69  {
70  auto poolDesc = PolymorphicDowncast<const Pooling2dDescriptor*>(&descriptor);
71 
72  bool avgPoolIgnoreValue =
73  (poolDesc->m_PoolType == PoolingAlgorithm::Average) &&
74  (poolDesc->m_PaddingMethod == PaddingMethod::IgnoreValue);
75 
76  if (poolDesc->m_PoolType == PoolingAlgorithm::L2)
77  {
79  }
80  else if (avgPoolIgnoreValue)
81  {
82  return ConvertAvgPool2DIgnoreValueToTosaOperator(layer, inputs, outputs, poolDesc);
83  }
84  else
85  {
86  return ConvertPooling2DToTosaOperator(layer, inputs, outputs, poolDesc);
87  }
88  }
90  {
91  return ConvertQuantizeToTosaOperator(layer, inputs, outputs);
92  }
93  case LayerType::Reshape:
94  {
95  auto reshapeDesc = PolymorphicDowncast<const ReshapeDescriptor*>(&descriptor);
96  return ConvertReshapeToTosaOperator(layer, inputs, outputs, reshapeDesc);
97  }
98  case LayerType::Resize:
99  {
100  auto resizeDesc = PolymorphicDowncast<const ResizeDescriptor*>(&descriptor);
101  return ConvertResizeToTosaOperator(layer, inputs, outputs, resizeDesc);
102  }
103  case LayerType::Slice:
104  {
105  auto sliceDesc = PolymorphicDowncast<const SliceDescriptor*>(&descriptor);
106  return ConvertSliceToTosaOperator(layer, inputs, outputs, sliceDesc);
107  }
108  case LayerType::Splitter:
109  {
110  auto splitDesc = PolymorphicDowncast<const SplitterDescriptor*>(&descriptor);
111  return ConvertSplitToTosaOperator(layer, inputs, outputs, splitDesc);
112  }
113  case LayerType::TransposeConvolution2d:
114  {
115  auto transposeConv2dDesc = PolymorphicDowncast<const TransposeConvolution2dDescriptor*>(&descriptor);
116  return ConvertTransposeConv2dToTosaOperator(layer, inputs, outputs, transposeConv2dDesc);
117  }
119  {
120  auto transposeDesc = PolymorphicDowncast<const TransposeDescriptor*>(&descriptor);
121  return ConvertTransposeToTosaOperator(layer, inputs, outputs, transposeDesc);
122  }
123  default:
124  {
126  }
127  }
128 }

References armnn::Activation, armnn::Addition, armnn::Average, armnn::Concat, armnn::Constant, ConvertActivationToTosaOperator(), ConvertAvgPool2DIgnoreValueToTosaOperator(), ConvertConcatToTosaOperator(), ConvertConstantToTosaOperator(), ConvertConv2dToTosaOperator(), ConvertElementwiseBinaryToTosaOperator(), ConvertElementwiseUnaryOperator(), ConvertPooling2DToTosaOperator(), ConvertQuantizeToTosaOperator(), ConvertReshapeToTosaOperator(), ConvertResizeToTosaOperator(), ConvertSliceToTosaOperator(), ConvertSplitToTosaOperator(), ConvertTransposeConv2dToTosaOperator(), ConvertTransposeToTosaOperator(), armnn::Convolution2d, CreateEmptyTosaSerializationBasicBlock(), armnn::ElementwiseBinary, armnn::ElementwiseUnary, armnn::IgnoreValue, armnn::L2, armnn::LeakyReLu, armnn::Multiplication, armnn::Pooling2d, armnn::Quantize, armnn::Reshape, armnn::Resize, armnn::Slice, armnn::Splitter, armnn::Subtraction, armnn::Transpose, and armnn::TransposeConvolution2d.

Referenced by GetTosaMappingFromLayer(), and TosaRefLayerSupport::IsLayerSupported().

◆ GetTosaMappingFromLayer()

TosaSerializationBasicBlock* GetTosaMappingFromLayer ( Layer layer)

Definition at line 130 of file TosaMappings.cpp.

131 {
132  std::vector<const TensorInfo*> inputs;
133  for (auto inputSlot : layer->GetInputSlots())
134  {
135  inputs.push_back(&inputSlot.GetTensorInfo());
136  }
137 
138  std::vector<const TensorInfo*> outputs;
139  for (auto& outputSlot : layer->GetOutputSlots())
140  {
141  outputs.push_back(&outputSlot.GetTensorInfo());
142  }
143 
144  TosaSerializationBasicBlock* basicBlock = GetTosaMapping(layer,
145  layer->GetType(),
146  inputs,
147  outputs,
148  layer->GetParameters());
149  return basicBlock;
150 }

References Layer::GetInputSlots(), Layer::GetOutputSlots(), Layer::GetParameters(), GetTosaMapping(), and Layer::GetType().

Referenced by TosaRefBackend::OptimizeSubgraphView().

armnnUtils::Transpose
void Transpose(const armnn::TensorShape &dstShape, const armnn::PermutationVector &mappings, const void *src, void *dst, size_t dataTypeSize)
Definition: Transpose.cpp:153
CreateEmptyTosaSerializationBasicBlock
TosaSerializationBasicBlock * CreateEmptyTosaSerializationBasicBlock()
Definition: TosaMappings.cpp:11
ConvertReshapeToTosaOperator
TosaSerializationBasicBlock * ConvertReshapeToTosaOperator(const Layer *layer, const std::vector< const TensorInfo * > &inputs, const std::vector< const TensorInfo * > &outputs, const ReshapeDescriptor *reshapeDescriptor)
Definition: ReshapeOperator.cpp:8
armnn::Splitter
void Splitter(const SplitterQueueDescriptor &data, std::vector< ITensorHandle * > inputs, std::vector< ITensorHandle * > outputs)
Definition: Splitter.hpp:17
ConvertElementwiseBinaryToTosaOperator
TosaSerializationBasicBlock * ConvertElementwiseBinaryToTosaOperator(const Layer *layer, const LayerType type, const std::vector< const TensorInfo * > &inputs, const std::vector< const TensorInfo * > &outputs, const ElementwiseBinaryDescriptor *descriptor)
Definition: ElementwiseBinaryOperator.cpp:8
armnn::Pooling2d
void Pooling2d(Decoder< float > &rInputDecoder, Encoder< float > &rOutputEncoder, const TensorInfo &inputInfo, const TensorInfo &outputInfo, const Pooling2dDescriptor &params)
Computes the Pooling2d operation.
Definition: Pooling2d.cpp:142
ConvertAvgPool2DIgnoreValueToTosaOperator
TosaSerializationBasicBlock * ConvertAvgPool2DIgnoreValueToTosaOperator(const Layer *layer, const std::vector< const TensorInfo * > &inputs, const std::vector< const TensorInfo * > &outputs, const Pooling2dDescriptor *poolDescriptor)
Definition: AvgPool2DIgnoreValueOperator.cpp:8
ConvertConv2dToTosaOperator
TosaSerializationBasicBlock * ConvertConv2dToTosaOperator(const Layer *layer, const std::vector< const TensorInfo * > &inputs, const std::vector< const TensorInfo * > &outputs, const Convolution2dDescriptor *conv2dDescriptor)
Definition: Conv2dOperator.cpp:8
ConvertPooling2DToTosaOperator
TosaSerializationBasicBlock * ConvertPooling2DToTosaOperator(const Layer *layer, const std::vector< const TensorInfo * > &inputs, const std::vector< const TensorInfo * > &outputs, const Pooling2dDescriptor *poolDescriptor)
Definition: Pooling2DOperator.cpp:8
ConvertConcatToTosaOperator
TosaSerializationBasicBlock * ConvertConcatToTosaOperator(const Layer *layer, const std::vector< const TensorInfo * > &inputs, const std::vector< const TensorInfo * > &outputs, const OriginsDescriptor *concatDescriptor)
Definition: ConcatOperator.cpp:8
armnn::Layer::GetInputSlots
const std::vector< InputSlot > & GetInputSlots() const
Definition: Layer.hpp:258
ConvertElementwiseUnaryOperator
TosaSerializationBasicBlock * ConvertElementwiseUnaryOperator(const Layer *layer, const std::vector< const TensorInfo * > &inputs, const std::vector< const TensorInfo * > &outputs, const ElementwiseUnaryDescriptor *unaryDescriptor)
Definition: ElementwiseUnaryOperator.cpp:8
ConvertConstantToTosaOperator
TosaSerializationBasicBlock * ConvertConstantToTosaOperator(const Layer *layer, const std::vector< const TensorInfo * > &outputs)
Definition: ConstantOperator.cpp:10
ConvertSplitToTosaOperator
TosaSerializationBasicBlock * ConvertSplitToTosaOperator(const Layer *layer, const std::vector< const TensorInfo * > &inputs, const std::vector< const TensorInfo * > &outputs, const SplitterDescriptor *splitDescriptor)
Definition: SplitOperator.cpp:13
armnn::Slice
void Slice(const TensorInfo &inputInfo, const SliceDescriptor &descriptor, const void *inputData, void *outputData, unsigned int dataTypeSize)
Definition: Slice.cpp:14
ConvertSliceToTosaOperator
TosaSerializationBasicBlock * ConvertSliceToTosaOperator(const Layer *layer, const std::vector< const TensorInfo * > &inputs, const std::vector< const TensorInfo * > &outputs, const SliceDescriptor *sliceDescriptor)
Definition: SliceOperator.cpp:8
armnn::Layer::GetOutputSlots
const std::vector< OutputSlot > & GetOutputSlots() const
Definition: Layer.hpp:259
armnn::Quantize
QuantizedType Quantize(float value, float scale, int32_t offset)
Quantize a floating point data type into an 8-bit data type.
Definition: TypesUtils.cpp:30
GetTosaMapping
TosaSerializationBasicBlock * GetTosaMapping(const Layer *layer, const LayerType type, const std::vector< const TensorInfo * > &inputs, const std::vector< const TensorInfo * > &outputs, const BaseDescriptor &descriptor)
Definition: TosaMappings.cpp:18
ConvertTransposeConv2dToTosaOperator
TosaSerializationBasicBlock * ConvertTransposeConv2dToTosaOperator(const Layer *layer, const std::vector< const TensorInfo * > &inputs, const std::vector< const TensorInfo * > &outputs, const TransposeConvolution2dDescriptor *descriptor)
Definition: TransposeConv2dOperator.cpp:10
armnn::Layer::GetParameters
virtual const BaseDescriptor & GetParameters() const override
If the layer has a descriptor return it.
Definition: Layer.hpp:378
ConvertQuantizeToTosaOperator
TosaSerializationBasicBlock * ConvertQuantizeToTosaOperator(const Layer *layer, const std::vector< const TensorInfo * > &inputs, const std::vector< const TensorInfo * > &outputs)
Definition: QuantizeOperator.cpp:13
armnn::Layer::GetType
LayerType GetType() const override
Returns the armnn::LayerType of this layer.
Definition: Layer.hpp:286
armnn::Resize
void Resize(Decoder< float > &in, const TensorInfo &inputInfo, Encoder< float > &out, const TensorInfo &outputInfo, DataLayoutIndexed dataLayout, ResizeMethod resizeMethod, bool alignCorners, bool halfPixelCenters)
Definition: Resize.cpp:65
ConvertActivationToTosaOperator
TosaSerializationBasicBlock * ConvertActivationToTosaOperator(const Layer *layer, const std::vector< const TensorInfo * > &inputs, const std::vector< const TensorInfo * > &outputs, const ActivationDescriptor *activationDescriptor)
Definition: ActivationOperator.cpp:17
ConvertResizeToTosaOperator
TosaSerializationBasicBlock * ConvertResizeToTosaOperator(const Layer *layer, const std::vector< const TensorInfo * > &inputs, const std::vector< const TensorInfo * > &outputs, const ResizeDescriptor *resizeDescriptor)
Definition: ResizeOperator.cpp:15
ConvertTransposeToTosaOperator
TosaSerializationBasicBlock * ConvertTransposeToTosaOperator(const Layer *layer, const std::vector< const TensorInfo * > &inputs, const std::vector< const TensorInfo * > &outputs, const TransposeDescriptor *transposeDescriptor)
Definition: TransposeOperator.cpp:8
armnn::Activation
float Activation(float in, ActivationFunction function, float a, float b)
Definition: Activation.cpp:13