24.08
|
Go to the source code of this file.
◆ CreateEmptyTosaSerializationBasicBlock()
TosaSerializationBasicBlock* CreateEmptyTosaSerializationBasicBlock |
( |
| ) |
|
Definition at line 11 of file TosaMappings.cpp.
14 auto* op =
new TosaSerializationOperator(Op_UNKNOWN, Attribute_NONE,
nullptr, {}, {});
15 return new TosaSerializationBasicBlock(
"",
"", {op}, {}, {}, {});
Referenced by GetTosaMapping().
◆ GetTosaMapping()
Definition at line 18 of file TosaMappings.cpp.
28 auto activationDesc = PolymorphicDowncast<const ActivationDescriptor*>(&descriptor);
29 switch (activationDesc->m_Function)
31 case ActivationFunction::LeakyReLu:
35 case ActivationFunction::ReLu:
36 case ActivationFunction::BoundedReLu:
40 case ActivationFunction::Gelu:
50 case LayerType::Addition:
51 case LayerType::Multiplication:
52 case LayerType::Subtraction:
56 case LayerType::ElementwiseBinary:
58 auto binaryDesc = PolymorphicDowncast<const ElementwiseBinaryDescriptor*>(&descriptor);
61 case LayerType::ElementwiseUnary:
63 auto unaryDesc = PolymorphicDowncast<const ElementwiseUnaryDescriptor*>(&descriptor);
64 switch(unaryDesc->m_Operation)
66 case UnaryOperation::Rsqrt:
70 case UnaryOperation::Exp:
74 case UnaryOperation::Log:
84 case LayerType::BatchMatMul:
86 auto batchMatMulDesc = PolymorphicDowncast<const BatchMatMulDescriptor*>(&descriptor);
89 case LayerType::Concat:
91 auto concatDesc = PolymorphicDowncast<const OriginsDescriptor*>(&descriptor);
94 case LayerType::Constant:
96 bool isDepthwiseConv2dWeights =
false;
103 if(type == LayerType::DepthwiseConvolution2d && slotIdx == 1)
105 isDepthwiseConv2dWeights =
true;
110 case LayerType::Convolution2d:
112 auto conv2dDesc = PolymorphicDowncast<const Convolution2dDescriptor*>(&descriptor);
115 case LayerType::DepthwiseConvolution2d:
117 auto conv2dDesc = PolymorphicDowncast<const DepthwiseConvolution2dDescriptor*>(&descriptor);
122 auto fullyConnectedDesc = PolymorphicDowncast<const FullyConnectedDescriptor*>(&descriptor);
127 auto padDesc = PolymorphicDowncast<const PadDescriptor*>(&descriptor);
132 auto poolDesc = PolymorphicDowncast<const Pooling2dDescriptor*>(&descriptor);
134 bool avgPoolIgnoreValue =
135 (poolDesc->m_PoolType == PoolingAlgorithm::Average) &&
136 (poolDesc->m_PaddingMethod == PaddingMethod::IgnoreValue);
138 if (poolDesc->m_PoolType == PoolingAlgorithm::L2)
142 else if (avgPoolIgnoreValue)
151 case LayerType::Mean:
153 auto meanDesc = PolymorphicDowncast<const MeanDescriptor*>(&descriptor);
157 reduceDesc.
m_vAxis = meanDesc->m_Axis;
168 auto reduceDesc = PolymorphicDowncast<const ReduceDescriptor*>(&descriptor);
171 case LayerType::Reshape:
173 auto reshapeDesc = PolymorphicDowncast<const ReshapeDescriptor*>(&descriptor);
178 auto resizeDesc = PolymorphicDowncast<const ResizeDescriptor*>(&descriptor);
183 auto sliceDesc = PolymorphicDowncast<const SliceDescriptor*>(&descriptor);
188 auto softmaxDesc = PolymorphicDowncast<const SoftmaxDescriptor*>(&descriptor);
193 auto splitDesc = PolymorphicDowncast<const SplitterDescriptor*>(&descriptor);
196 case LayerType::TransposeConvolution2d:
198 auto transposeConv2dDesc = PolymorphicDowncast<const TransposeConvolution2dDescriptor*>(&descriptor);
203 auto transposeDesc = PolymorphicDowncast<const TransposeDescriptor*>(&descriptor);
References armnn::Activation, armnn::Addition, armnn::Average, armnn::BatchMatMul, armnn::BoundedReLu, armnn::Concat, armnn::Constant, ConvertAvgPool2DIgnoreValueToTosaOperator(), ConvertBatchMatMulToTosaOperator(), ConvertConcatToTosaOperator(), ConvertConstantToTosaOperator(), ConvertConv2dToTosaOperator(), ConvertDepthwiseConv2dToTosaOperator(), ConvertElementwiseBinaryToTosaOperator(), ConvertExpOperator(), ConvertFullyConnectedToTosaOperator(), ConvertGeluToTosaOperator(), ConvertLeakyReluToTosaOperator(), ConvertLogOperator(), ConvertPadToTosaOperator(), ConvertPooling2DToTosaOperator(), ConvertQuantizeToTosaOperator(), ConvertReduceToTosaOperator(), ConvertReluToTosaOperator(), ConvertReshapeToTosaOperator(), ConvertResizeToTosaOperator(), ConvertRsqrtOperator(), ConvertSliceToTosaOperator(), ConvertSoftmaxToTosaOperator(), ConvertSplitToTosaOperator(), ConvertTransposeConv2dToTosaOperator(), ConvertTransposeToTosaOperator(), armnn::Convolution2d, CreateEmptyTosaSerializationBasicBlock(), armnn::DepthwiseConvolution2d, armnn::ElementwiseBinary, armnn::ElementwiseUnary, armnn::Exp, armnn::FullyConnected, armnn::Gelu, OutputSlot::GetConnection(), Layer::GetOutputSlot(), InputSlot::GetOwningLayer(), InputSlot::GetSlotIndex(), Layer::GetType(), armnn::IgnoreValue, armnn::L2, armnn::LeakyReLu, armnn::Log, ReduceDescriptor::m_KeepDims, ReduceDescriptor::m_ReduceOperation, ReduceDescriptor::m_vAxis, armnn::Mean, armnn::Multiplication, armnn::Pad, armnn::Pooling2d, armnn::Quantize, armnn::Reduce, armnn::ReLu, armnn::Reshape, armnn::Resize, armnn::Rsqrt, armnn::Slice, armnn::Softmax, armnn::Splitter, armnn::Subtraction, armnn::Transpose, and armnn::TransposeConvolution2d.
Referenced by GetTosaMappingFromLayer(), and TosaRefLayerSupport::IsLayerSupported().
◆ GetTosaMappingFromLayer()
TosaSerializationBasicBlock* GetTosaMappingFromLayer |
( |
const Layer * |
layer | ) |
|
void Transpose(const armnn::TensorShape &dstShape, const armnn::PermutationVector &mappings, const void *src, void *dst, size_t dataTypeSize)
TosaSerializationBasicBlock * ConvertGeluToTosaOperator(const Layer *layer, const std::vector< const TensorInfo * > &inputs, const std::vector< const TensorInfo * > &outputs, const ActivationDescriptor *desc)
TosaSerializationBasicBlock * CreateEmptyTosaSerializationBasicBlock()
TosaSerializationBasicBlock * ConvertReshapeToTosaOperator(const Layer *layer, const std::vector< const TensorInfo * > &inputs, const std::vector< const TensorInfo * > &outputs, const ReshapeDescriptor *reshapeDescriptor)
TosaSerializationBasicBlock * ConvertRsqrtOperator(const Layer *layer, const std::vector< const TensorInfo * > &inputs, const std::vector< const TensorInfo * > &outputs, const ElementwiseUnaryDescriptor *unaryDescriptor)
void Splitter(const SplitterQueueDescriptor &data, std::vector< ITensorHandle * > inputs, std::vector< ITensorHandle * > outputs)
TosaSerializationBasicBlock * ConvertElementwiseBinaryToTosaOperator(const Layer *layer, const LayerType type, const std::vector< const TensorInfo * > &inputs, const std::vector< const TensorInfo * > &outputs, const ElementwiseBinaryDescriptor *descriptor)
void Pooling2d(Decoder< float > &rInputDecoder, Encoder< float > &rOutputEncoder, const TensorInfo &inputInfo, const TensorInfo &outputInfo, const Pooling2dDescriptor ¶ms)
Computes the Pooling2d operation.
TosaSerializationBasicBlock * ConvertAvgPool2DIgnoreValueToTosaOperator(const Layer *layer, const std::vector< const TensorInfo * > &inputs, const std::vector< const TensorInfo * > &outputs, const Pooling2dDescriptor *poolDescriptor)
TosaSerializationBasicBlock * ConvertConv2dToTosaOperator(const Layer *layer, const std::vector< const TensorInfo * > &inputs, const std::vector< const TensorInfo * > &outputs, const Convolution2dDescriptor *conv2dDescriptor)
void Reduce(const TensorInfo &inputInfo, const TensorInfo &outputInfo, Decoder< float > &input, Encoder< float > &output, const std::vector< uint32_t > axis, const ReduceOperation reduceOperation)
TosaSerializationBasicBlock * ConvertPooling2DToTosaOperator(const Layer *layer, const std::vector< const TensorInfo * > &inputs, const std::vector< const TensorInfo * > &outputs, const Pooling2dDescriptor *poolDescriptor)
const OutputSlot & GetOutputSlot(unsigned int index=0) const override
Get the const output slot handle by slot index.
TosaSerializationBasicBlock * ConvertConcatToTosaOperator(const Layer *layer, const std::vector< const TensorInfo * > &inputs, const std::vector< const TensorInfo * > &outputs, const OriginsDescriptor *concatDescriptor)
const std::vector< InputSlot > & GetInputSlots() const
void FullyConnected(const TensorShape &rInputShape, Decoder< float > &rInputDecoder, const TensorShape &rOutputShape, Encoder< float > &rOutputEncoder, const TensorShape &rWeightsShape, Decoder< float > &rWeightDecoder, Decoder< float > *pBiasDecoder, const bool biasEnabled, const unsigned int K, const bool transposeWeights)
Performs a matrix multiplication and optionally adds a bias.
ReduceOperation m_ReduceOperation
Specifies the reduction operation to execute.
TosaSerializationBasicBlock * ConvertSplitToTosaOperator(const Layer *layer, const std::vector< const TensorInfo * > &inputs, const std::vector< const TensorInfo * > &outputs, const SplitterDescriptor *splitDescriptor)
TosaSerializationBasicBlock * ConvertPadToTosaOperator(const Layer *layer, const std::vector< const TensorInfo * > &inputs, const std::vector< const TensorInfo * > &outputs, const PadDescriptor *padDescriptor)
void Slice(const TensorInfo &inputInfo, const SliceDescriptor &descriptor, const void *inputData, void *outputData, unsigned int dataTypeSize)
TosaSerializationBasicBlock * ConvertSliceToTosaOperator(const Layer *layer, const std::vector< const TensorInfo * > &inputs, const std::vector< const TensorInfo * > &outputs, const SliceDescriptor *sliceDescriptor)
TosaSerializationBasicBlock * ConvertReluToTosaOperator(const Layer *layer, const std::vector< const TensorInfo * > &inputs, const std::vector< const TensorInfo * > &outputs, const ActivationDescriptor *desc)
void Softmax(Decoder< float > &in, Encoder< float > &out, const TensorInfo &inputTensorInfo, float beta, int axis)
Computes the softmax function on some inputs, into outputs, with a shape given by tensorInfo.
TosaSerializationBasicBlock * ConvertLeakyReluToTosaOperator(const Layer *layer, const std::vector< const TensorInfo * > &inputs, const std::vector< const TensorInfo * > &outputs, const ActivationDescriptor *activationDescriptor)
const std::vector< OutputSlot > & GetOutputSlots() const
QuantizedType Quantize(float value, float scale, int32_t offset)
Quantize a floating point data type into an 8-bit data type.
TosaSerializationBasicBlock * GetTosaMapping(const Layer *layer, const LayerType type, const std::vector< const TensorInfo * > &inputs, const std::vector< const TensorInfo * > &outputs, const BaseDescriptor &descriptor)
TosaSerializationBasicBlock * ConvertTransposeConv2dToTosaOperator(const Layer *layer, const std::vector< const TensorInfo * > &inputs, const std::vector< const TensorInfo * > &outputs, const TransposeConvolution2dDescriptor *descriptor)
bool m_KeepDims
if true then output shape has no change.
virtual const BaseDescriptor & GetParameters() const override
If the layer has a descriptor return it.
void Pad(const TensorInfo &inputInfo, const TensorInfo &outputInfo, const ITensorHandle *inputHandle, ITensorHandle *outputHandle, const PadQueueDescriptor &data)
TosaSerializationBasicBlock * ConvertQuantizeToTosaOperator(const Layer *layer, const std::vector< const TensorInfo * > &inputs, const std::vector< const TensorInfo * > &outputs)
TosaSerializationBasicBlock * ConvertReduceToTosaOperator(const Layer *layer, const std::vector< const TensorInfo * > &inputs, const std::vector< const TensorInfo * > &outputs, const ReduceDescriptor *reduceDescriptor)
LayerType GetType() const override
Returns the armnn::LayerType of this layer.
void Resize(Decoder< float > &in, const TensorInfo &inputInfo, Encoder< float > &out, const TensorInfo &outputInfo, DataLayoutIndexed dataLayout, ResizeMethod resizeMethod, bool alignCorners, bool halfPixelCenters)
TosaSerializationBasicBlock * ConvertConstantToTosaOperator(const Layer *layer, const std::vector< const TensorInfo * > &outputs, bool isDepthwiseConv2dWeights=false)
std::vector< uint32_t > m_vAxis
The indices of the dimensions to reduce.
TosaSerializationBasicBlock * ConvertDepthwiseConv2dToTosaOperator(const Layer *layer, const std::vector< const TensorInfo * > &inputs, const std::vector< const TensorInfo * > &outputs, const DepthwiseConvolution2dDescriptor *conv2dDescriptor)
TosaSerializationBasicBlock * ConvertFullyConnectedToTosaOperator(const Layer *layer, const std::vector< const TensorInfo * > &inputs, const std::vector< const TensorInfo * > &outputs, const FullyConnectedDescriptor *fcDescriptor)
TosaSerializationBasicBlock * ConvertResizeToTosaOperator(const Layer *layer, const std::vector< const TensorInfo * > &inputs, const std::vector< const TensorInfo * > &outputs, const ResizeDescriptor *resizeDescriptor)
TosaSerializationBasicBlock * ConvertSoftmaxToTosaOperator(const Layer *layer, const std::vector< const TensorInfo * > &inputs, const std::vector< const TensorInfo * > &outputs, const SoftmaxDescriptor *softmaxDescriptor)
TosaSerializationBasicBlock * ConvertTransposeToTosaOperator(const Layer *layer, const std::vector< const TensorInfo * > &inputs, const std::vector< const TensorInfo * > &outputs, const TransposeDescriptor *transposeDescriptor)
TosaSerializationBasicBlock * ConvertLogOperator(const Layer *layer, const std::vector< const TensorInfo * > &inputs, const std::vector< const TensorInfo * > &outputs, const ElementwiseUnaryDescriptor *unaryDescriptor)
float Activation(float in, ActivationFunction function, float a, float b)
A ReduceDescriptor for the REDUCE operators.
LayerType
When adding a new layer, adapt also the LastLayer enum value in the enum class LayerType below.
const InputSlot * GetConnection(unsigned int index) const override
TosaSerializationBasicBlock * ConvertExpOperator(const Layer *layer, const std::vector< const TensorInfo * > &inputs, const std::vector< const TensorInfo * > &outputs, const ElementwiseUnaryDescriptor *unaryDescriptor)
TosaSerializationBasicBlock * ConvertBatchMatMulToTosaOperator(const Layer *layer, const std::vector< const TensorInfo * > &inputs, const std::vector< const TensorInfo * > &outputs, const BatchMatMulDescriptor *descriptor)