23.08
|
Go to the documentation of this file.
19 class CheckForNCHW :
public StrategyBase<NoThrowStrategy>
27 const std::vector<armnn::ConstTensor>& constants,
121 template<
typename Descriptor>
122 void CheckDescForNCHW(
const Descriptor& descriptor)
127 bool m_Result =
false;
137 for (
auto&& layer : layers)
154 for (
auto &&layer: layers)
170 return check.Result();
175 std::vector<Layer*> untouchedVector;
176 for (
const auto& pair : untouched)
178 Layer* layer = pair.second;
180 CreateIInputsFrom({layer}),
181 CreateIOutputsFrom({layer}));
186 template<
typename LayerType>
192 SubgraphView substitutionSubgraph({padLayer, baseLayer},
193 CreateIInputsFrom({padLayer}),
194 CreateIOutputsFrom({baseLayer}));
197 optimizationViews.
AddSubstitution({substitutionSubgraph, replacementSubgraph});
199 return replacementLayer;
211 for (
unsigned int i = 0; i < baseLayer->
GetOutputSlot(0).GetNumConnections(); ++i)
233 for (
unsigned int i = 0; i < baseLayer->
GetOutputSlot(0).GetNumConnections(); ++i)
247 std::map<LayerGuid, Layer*>& untouched,
250 if (baseLayer ==
nullptr)
264 for (
unsigned int i = 0; i < baseLayer->
GetOutputSlot(0).GetNumConnections(); ++i)
273 auto it = untouched.find(baseLayer->
GetGuid());
274 if (it == untouched.end())
282 for (
unsigned int i = 0; i < baseLayer->
GetOutputSlot(0).GetNumConnections(); ++i)
293 template<
typename LayerType>
301 LayerType* replacementLayer = PolymorphicDowncast<LayerType*>(replacement);
308 return replacementLayer;
A BatchNormalizationDescriptor for the BatchNormalizationLayer.
void AddUntouchedSubgraph(SubgraphView &&subgraph)
std::vector< IOutputSlot * > IOutputSlots
virtual unsigned int GetNumInputSlots() const =0
Returns the number of connectable input slots.
const TensorInfo & GetTensorInfo() const override
A Pooling3dDescriptor for the Pooling3dLayer.
An InstanceNormalizationDescriptor for InstanceNormalizationLayer.
bool ConnectedToLayerType(Layer *baseLayer, LayerType layerType, unsigned int dimSize=0)
Checks the Layer's Connections to see if it's connected to a Layer with the provided layerType.
A L2NormalizationDescriptor for the L2NormalizationLayer.
A NormalizationDescriptor for the NormalizationLayer.
unsigned int GetNumDimensions() const
const OutputSlot & GetOutputSlot(unsigned int index=0) const override
Get the const output slot handle by slot index.
LayerType * FoldPadLayer(OptimizationViews &optimizationViews, LayerType *baseLayer, LayerType *replacementLayer, PadLayer *padLayer)
bool IsNCHW(armnn::Layer &layer)
virtual unsigned int GetNumOutputSlots() const =0
Returns the number of connectable output slots.
const InputSlot & GetInputSlot(unsigned int index) const override
Get a const input slot handle by slot index.
const Parameters & GetParameters() const override
If the layer has a descriptor return it.
Layer & GetOwningLayer() const
This layer represents a reshape operation.
void RemoveReshapeLayer(ReshapeLayer *baseLayer, std::map< LayerGuid, Layer * > &untouched, OptimizationViews &optimizationViews)
LayerType * FoldPadIntoAveragePool2d(OptimizationViews &optimizationViews, Pooling2dLayer *baseLayer, Pooling2dDescriptor &poolDescriptor, PadLayer *padLayer)
A ReshapeDescriptor for the ReshapeLayer.
std::vector< IInputSlot * > IInputSlots
int LayerBindingId
Type of identifiers for bindable layers (inputs, outputs).
LayerGuid GetGuid() const final
Returns the unique id of the layer.
A BatchMatMulDescriptor for the BatchMatMul operator.
virtual LayerType GetType() const =0
Returns the armnn::LayerType of this layer.
The SubgraphView class represents a subgraph of a Graph.
A SpaceToBatchNdDescriptor for the SpaceToBatchNdLayer.
A Convolution3dDescriptor for the Convolution3dLayer.
TensorShape m_TargetShape
Target shape value.
This layer represents a pooling 2d operation.
Base class for all descriptors.
void AddSubstitution(SubstitutionPair &&substitution)
A BatchToSpaceNdDescriptor for the BatchToSpaceNdLayer.
A Convolution2dDescriptor for the Convolution2dLayer.
LayerType GetType() const override
Returns the armnn::LayerType of this layer.
A StridedSliceDescriptor for the StridedSliceLayer.
void ExecuteStrategy(IStrategy &strategy) const override
Apply a visitor to this layer.
IConnectableLayer * AddPooling2dLayer(const Pooling2dDescriptor &pooling2dDescriptor, const char *name=nullptr)
Adds a 2D pooling layer to the network.
void AddDeletedSubgraph(SubgraphView &&subgraph)
void IgnoreUnused(Ts &&...)
void SetShape(const TensorShape &newShape)
virtual const IOutputSlot & GetOutputSlot(unsigned int index) const =0
Get the const output slot handle by slot index.
Copyright (c) 2021 ARM Limited and Contributors.
virtual const IInputSlot & GetInputSlot(unsigned int index) const =0
Get a const input slot handle by slot index.
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
void ReportUntouchedLayers(OptimizationViews &optimizationViews, std::map< LayerGuid, Layer * > untouched)
bool ConnectedToLayerWithNCHW(Layer *baseLayer)
Checks if the Layer is connected to any Layer that has an NCHW layout.
A Pooling2dDescriptor for the Pooling2dLayer.
A DepthwiseConvolution2dDescriptor for the DepthwiseConvolution2dLayer.
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
This layer represents a pad operation.
A SpaceToDepthDescriptor for the SpaceToDepthLayer.