ArmNN  NotReleased
SpaceToBatchNdLayer Class Reference

This layer represents a SpaceToBatchNd operation. More...

#include <SpaceToBatchNdLayer.hpp>

Inheritance diagram for SpaceToBatchNdLayer:
LayerWithParameters< SpaceToBatchNdDescriptor > Layer IConnectableLayer

Public Member Functions

virtual std::unique_ptr< IWorkloadCreateWorkload (const IWorkloadFactory &factory) const override
 
SpaceToBatchNdLayerClone (Graph &graph) const override
 
std::vector< TensorShapeInferOutputShapes (const std::vector< TensorShape > &inputShapes) const override
 
void ValidateTensorShapesFromInputs () override
 
void Accept (ILayerVisitor &visitor) const override
 
- Public Member Functions inherited from LayerWithParameters< SpaceToBatchNdDescriptor >
const SpaceToBatchNdDescriptorGetParameters () const
 
void SerializeLayerParameters (ParameterStringifyFunction &fn) const override
 
- Public Member Functions inherited from Layer
 Layer (unsigned int numInputSlots, unsigned int numOutputSlots, LayerType type, const char *name)
 
 Layer (unsigned int numInputSlots, unsigned int numOutputSlots, LayerType type, DataLayout layout, const char *name)
 
const std::string & GetNameStr () const
 
const OutputHandlerGetOutputHandler (unsigned int i=0) const
 
OutputHandlerGetOutputHandler (unsigned int i=0)
 
const std::vector< InputSlot > & GetInputSlots () const
 
const std::vector< OutputSlot > & GetOutputSlots () const
 
std::vector< InputSlot >::iterator BeginInputSlots ()
 
std::vector< InputSlot >::iterator EndInputSlots ()
 
std::vector< OutputSlot >::iterator BeginOutputSlots ()
 
std::vector< OutputSlot >::iterator EndOutputSlots ()
 
bool IsOutputUnconnected ()
 
void ResetPriority () const
 
LayerPriority GetPriority () const
 
LayerType GetType () const
 
DataType GetDataType () const
 
const BackendIdGetBackendId () const
 
void SetBackendId (const BackendId &id)
 
virtual void CreateTensorHandles (const TensorHandleFactoryRegistry &registry, const IWorkloadFactory &factory, const bool IsMemoryManaged=true)
 
void VerifyLayerConnections (unsigned int expectedConnections, const CheckLocation &location) const
 
virtual void ReleaseConstantData ()
 
template<typename Op >
void OperateOnConstantTensors (Op op)
 
const char * GetName () const override
 
unsigned int GetNumInputSlots () const override
 
unsigned int GetNumOutputSlots () const override
 
const InputSlotGetInputSlot (unsigned int index) const override
 
InputSlotGetInputSlot (unsigned int index) override
 
const OutputSlotGetOutputSlot (unsigned int index=0) const override
 
OutputSlotGetOutputSlot (unsigned int index=0) override
 
void SetGuid (LayerGuid guid)
 
LayerGuid GetGuid () const final
 
void AddRelatedLayerName (const std::string layerName)
 
const std::list< std::string > & GetRelatedLayerNames ()
 
virtual void Reparent (Graph &dest, std::list< Layer *>::const_iterator iterator)=0
 

Protected Member Functions

 SpaceToBatchNdLayer (const SpaceToBatchNdDescriptor param, const char *name)
 
 ~SpaceToBatchNdLayer ()=default
 Default destructor. More...
 
- Protected Member Functions inherited from LayerWithParameters< SpaceToBatchNdDescriptor >
 LayerWithParameters (unsigned int numInputSlots, unsigned int numOutputSlots, LayerType type, const SpaceToBatchNdDescriptor &param, const char *name)
 
 ~LayerWithParameters ()=default
 
WorkloadInfo PrepInfoAndDesc (QueueDescriptor &descriptor) const
 Helper function to reduce duplication in *LayerCreateWorkload. More...
 
- Protected Member Functions inherited from Layer
virtual ~Layer ()=default
 
template<typename QueueDescriptor >
void CollectQueueDescriptorInputs (QueueDescriptor &descriptor, WorkloadInfo &info) const
 
template<typename QueueDescriptor >
void CollectQueueDescriptorOutputs (QueueDescriptor &descriptor, WorkloadInfo &info) const
 
template<typename QueueDescriptor >
WorkloadInfo PrepInfoAndDesc (QueueDescriptor &descriptor) const
 Helper function to reduce duplication in *LayerCreateWorkload. More...
 
template<typename LayerType , typename ... Params>
LayerTypeCloneBase (Graph &graph, Params &&... params) const
 
virtual ConstantTensors GetConstantTensorsByRef ()
 
- Protected Member Functions inherited from IConnectableLayer
 ~IConnectableLayer ()
 Objects are not deletable via the handle. More...
 

Additional Inherited Members

- Public Types inherited from LayerWithParameters< SpaceToBatchNdDescriptor >
using DescriptorType = SpaceToBatchNdDescriptor
 
- Protected Types inherited from Layer
using ConstantTensors = std::vector< std::reference_wrapper< std::unique_ptr< ScopedCpuTensorHandle > >>
 
- Protected Attributes inherited from LayerWithParameters< SpaceToBatchNdDescriptor >
SpaceToBatchNdDescriptor m_Param
 The parameters for the layer (not including tensor-valued weights etc.). More...
 
- Protected Attributes inherited from Layer
std::vector< OutputHandlerm_OutputHandlers
 

Detailed Description

This layer represents a SpaceToBatchNd operation.

Definition at line 14 of file SpaceToBatchNdLayer.hpp.

Constructor & Destructor Documentation

◆ SpaceToBatchNdLayer()

SpaceToBatchNdLayer ( const SpaceToBatchNdDescriptor  param,
const char *  name 
)
protected

Constructor to create a SpaceToBatchNdLayer.

Parameters
[in]paramSpaceToBatchNdDescriptor to configure the SpaceToBatchNdLayer operation.
[in]nameOptional name for the layer.

Definition at line 23 of file SpaceToBatchNdLayer.cpp.

References armnn::SpaceToBatchNd().

25 {}
LayerWithParameters(unsigned int numInputSlots, unsigned int numOutputSlots, LayerType type, const SpaceToBatchNdDescriptor &param, const char *name)

◆ ~SpaceToBatchNdLayer()

~SpaceToBatchNdLayer ( )
protecteddefault

Default destructor.

Member Function Documentation

◆ Accept()

void Accept ( ILayerVisitor visitor) const
overridevirtual

Implements IConnectableLayer.

Definition at line 84 of file SpaceToBatchNdLayer.cpp.

References Layer::GetName(), LayerWithParameters< SpaceToBatchNdDescriptor >::GetParameters(), and ILayerVisitor::VisitSpaceToBatchNdLayer().

85 {
87 }
const char * GetName() const override
Definition: Layer.hpp:305
const SpaceToBatchNdDescriptor & GetParameters() const
virtual void VisitSpaceToBatchNdLayer(const IConnectableLayer *layer, const SpaceToBatchNdDescriptor &spaceToBatchNdDescriptor, const char *name=nullptr)=0

◆ Clone()

SpaceToBatchNdLayer * Clone ( Graph graph) const
overridevirtual

Creates a dynamically-allocated copy of this layer.

Parameters
[in]graphThe graph into which this layer is being cloned.

Implements Layer.

Definition at line 36 of file SpaceToBatchNdLayer.cpp.

References Layer::GetName(), and LayerWithParameters< SpaceToBatchNdDescriptor >::m_Param.

37 {
38  boost::ignore_unused(graph);
39  return CloneBase<SpaceToBatchNdLayer>(graph, m_Param, GetName());
40 }
const char * GetName() const override
Definition: Layer.hpp:305
SpaceToBatchNdDescriptor m_Param
The parameters for the layer (not including tensor-valued weights etc.).

◆ CreateWorkload()

std::unique_ptr< IWorkload > CreateWorkload ( const IWorkloadFactory factory) const
overridevirtual

Makes a workload for the SpaceToBatchNd type.

Parameters
[in]graphThe graph where this layer can be found.
[in]factoryThe workload factory which will create the workload.
Returns
A pointer to the created workload, or nullptr if not created.

Implements Layer.

Definition at line 27 of file SpaceToBatchNdLayer.cpp.

References IWorkloadFactory::CreateSpaceToBatchNd(), SpaceToBatchNdDescriptor::m_BlockShape, SpaceToBatchNdDescriptor::m_PadList, LayerWithParameters< SpaceToBatchNdDescriptor >::m_Param, QueueDescriptorWithParameters< LayerDescriptor >::m_Parameters, and LayerWithParameters< SpaceToBatchNdDescriptor >::PrepInfoAndDesc().

28 {
32 
33  return factory.CreateSpaceToBatchNd(descriptor, PrepInfoAndDesc(descriptor));
34 }
virtual std::unique_ptr< IWorkload > CreateSpaceToBatchNd(const SpaceToBatchNdQueueDescriptor &descriptor, const WorkloadInfo &info) const
std::vector< std::pair< unsigned int, unsigned int > > m_PadList
Specifies the padding values for the input dimension: heightPad{top, bottom} widthPad{left, right}.
std::vector< unsigned int > m_BlockShape
Block shape value.
SpaceToBatchNdDescriptor m_Param
The parameters for the layer (not including tensor-valued weights etc.).
WorkloadInfo PrepInfoAndDesc(QueueDescriptor &descriptor) const
Helper function to reduce duplication in *LayerCreateWorkload.

◆ InferOutputShapes()

std::vector< TensorShape > InferOutputShapes ( const std::vector< TensorShape > &  inputShapes) const
overridevirtual

By default returns inputShapes if the number of inputs are equal to number of outputs, otherwise infers the output shapes from given input shapes and layer properties.

Parameters
[in]inputShapesThe input shapes layer has.
Returns
A vector to the inferred output shape.

Reimplemented from Layer.

Definition at line 42 of file SpaceToBatchNdLayer.cpp.

References DataLayoutIndexed::GetHeightIndex(), DataLayoutIndexed::GetWidthIndex(), SpaceToBatchNdDescriptor::m_BlockShape, SpaceToBatchNdDescriptor::m_DataLayout, SpaceToBatchNdDescriptor::m_PadList, and LayerWithParameters< SpaceToBatchNdDescriptor >::m_Param.

Referenced by SpaceToBatchNdLayer::ValidateTensorShapesFromInputs().

43 {
44  BOOST_ASSERT(inputShapes.size() == 1);
45 
46  TensorShape inputShape = inputShapes[0];
47  TensorShape outputShape(inputShape);
48 
49  outputShape[0] = inputShape[0] * std::accumulate(m_Param.m_BlockShape.begin(),
50  m_Param.m_BlockShape.end(),
51  1U,
52  std::multiplies<>());
53 
54  DataLayoutIndexed dimensionIndices = m_Param.m_DataLayout;
55  unsigned int heightIndex = dimensionIndices.GetHeightIndex();
56  unsigned int widthIndex = dimensionIndices.GetWidthIndex();
57 
58  std::pair<unsigned int, unsigned int> heightPad = m_Param.m_PadList[0];
59  std::pair<unsigned int, unsigned int> widthPad = m_Param.m_PadList[1];
60 
61  outputShape[heightIndex] =
62  (inputShape[heightIndex] + heightPad.first + heightPad.second) / m_Param.m_BlockShape[0];
63  outputShape[widthIndex] =
64  (inputShape[widthIndex] + widthPad.first + widthPad.second) / m_Param.m_BlockShape[1];
65 
66  return std::vector<TensorShape>({ outputShape });
67 }
std::vector< std::pair< unsigned int, unsigned int > > m_PadList
Specifies the padding values for the input dimension: heightPad{top, bottom} widthPad{left, right}.
unsigned int GetHeightIndex() const
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
std::vector< unsigned int > m_BlockShape
Block shape value.
unsigned int GetWidthIndex() const
SpaceToBatchNdDescriptor m_Param
The parameters for the layer (not including tensor-valued weights etc.).

◆ ValidateTensorShapesFromInputs()

void ValidateTensorShapesFromInputs ( )
overridevirtual

Check if the input tensor shape(s) will lead to a valid configuration of SpaceToBatchNdLayer.

Implements Layer.

Definition at line 69 of file SpaceToBatchNdLayer.cpp.

References CHECK_LOCATION, InputSlot::GetConnection(), Layer::GetInputSlot(), Layer::GetOutputSlot(), TensorInfo::GetShape(), IOutputSlot::GetTensorInfo(), OutputSlot::GetTensorInfo(), SpaceToBatchNdLayer::InferOutputShapes(), and Layer::VerifyLayerConnections().

70 {
72 
73  std::vector<TensorShape> inferredShapes = InferOutputShapes({
75 
76  BOOST_ASSERT(inferredShapes.size() == 1);
77 
78  ConditionalThrowIfNotEqual<LayerValidationException>(
79  "SpaceToBatchNdLayer: TensorShape set on OutputSlot[0] does not match the inferred shape.",
81  inferredShapes[0]);
82 }
virtual const TensorInfo & GetTensorInfo() const =0
#define CHECK_LOCATION()
Definition: Exceptions.hpp:169
const IOutputSlot * GetConnection() const override
Definition: Layer.hpp:199
std::vector< TensorShape > InferOutputShapes(const std::vector< TensorShape > &inputShapes) const override
void VerifyLayerConnections(unsigned int expectedConnections, const CheckLocation &location) const
Definition: Layer.cpp:337
const TensorShape & GetShape() const
Definition: Tensor.hpp:88
const TensorInfo & GetTensorInfo() const override
Definition: Layer.cpp:63
const OutputSlot & GetOutputSlot(unsigned int index=0) const override
Definition: Layer.hpp:312
const InputSlot & GetInputSlot(unsigned int index) const override
Definition: Layer.hpp:310

The documentation for this class was generated from the following files: