24.11
|
Go to the documentation of this file.
15 namespace optimizations
29 ReplaceConstDequantisationLayer(graph, PolymorphicDowncast<ConstantLayer*>(&base),
30 PolymorphicDowncast<DequantizeLayer*>(&child));
38 static void ReplaceConstDequantisationLayer(
Graph&,
42 ARMNN_LOG(info) <<
"TurboConvertConstDequantisationLayersToConstLayersImpl::ReplaceConstDequantisationLayer()";
52 bool requiresPermute =
false;
65 ARMNN_LOG(info) <<
"ConvertConstDequantisationLayersToConstLayersImpl:: Connected to "
67 auto conv2dLayer = PolymorphicDowncast<Convolution2dLayer*>(&connection->GetOwningLayer());
70 ARMNN_LOG(info) <<
"ConvertConstDequantisationLayersToConstLayersImpl:: Connected to "
71 "Convolution layer and requires permute on weights. ";
72 requiresPermute =
true;
83 TensorInfo newInfo = inputDequantizeInfo;
87 ARMNN_LOG(info) <<
"TurboConvertConstDequantisationLayersToConstLayersImpl:: Permuting the constant data.";
88 const PermutationVector OHWIToOIHW = {0, 2, 3, 1};
90 std::vector<Half> permutedValues(outputDequantizeInfo.
GetNumElements());
92 constantLayer->
m_LayerOutput->Map(
true), permutedValues.data(),
94 ConstTensor newInput(newInfo, permutedValues);
95 constantLayer->
m_LayerOutput.reset(
new ScopedTensorHandle(newInput));
99 ConstTensor newInput(newInfo, constantLayer->
m_LayerOutput->Map(
true));
100 constantLayer->
m_LayerOutput.reset(
new ScopedTensorHandle(newInput));
112 for (
unsigned int i = numConnections; i < constantLayer->
GetOutputSlot(0).GetNumConnections(); ++i)
125 OptimizeForConnection<ConstantLayer,
#define ARMNN_ASSERT(COND)
unsigned int GetNumElements() const
const TensorInfo & GetTensorInfo() const override
void SetTensorInfo(const TensorInfo &tensorInfo) override
constexpr const char * GetDataTypeName(DataType dataType)
const OutputSlot & GetOutputSlot(unsigned int index=0) const override
Get the const output slot handle by slot index.
void Permute(const armnn::TensorShape &dstShape, const armnn::PermutationVector &mappings, const void *src, void *dst, size_t dataTypeSize)
const InputSlot & GetInputSlot(unsigned int index) const override
Get a const input slot handle by slot index.
OptimizeForConnection< ConstantLayer, DequantizeLayer, TurboConvertConstDequantisationLayersToConstLayersImpl > TurboConvertConstDequantisationLayersToConstLayers
#define ARMNN_LOG(severity)
void Run(Graph &graph, InputSlot &connection) const
Layer & GetOwningLayer() const
unsigned int GetNumConnections() const override
This layer dequantizes the input tensor.
constexpr unsigned int GetDataTypeSize(DataType dataType)
DataType GetDataType() const
void MoveAllConnections(OutputSlot &destination)
Moves all connections to another OutputSlot.
LayerType GetType() const override
Returns the armnn::LayerType of this layer.
const TensorShape & GetShape() const
std::shared_ptr< ConstTensorHandle > m_LayerOutput
~TurboConvertConstDequantisationLayersToConstLayersImpl()=default
A layer that the constant data can be bound to.
Copyright (c) 2021 ARM Limited and Contributors.
void SetConstant(const bool IsConstant=true)
Marks the data corresponding to this tensor info as constant.
const InputSlot * GetConnection(unsigned int index) const override
TurboConvertConstDequantisationLayersToConstLayersImpl()=default