ArmNN  NotReleased
SplitterLayer Class Reference

This layer represents a split operation. More...

#include <SplitterLayer.hpp>

Inheritance diagram for SplitterLayer:
LayerWithParameters< ViewsDescriptor > Layer IConnectableLayer

Public Member Functions

virtual std::unique_ptr< IWorkloadCreateWorkload (const IWorkloadFactory &factory) const override
 
virtual void CreateTensorHandles (const TensorHandleFactoryRegistry &registry, const IWorkloadFactory &factory, const bool IsMemoryManaged=true) override
 
SplitterLayerClone (Graph &graph) const override
 
void ValidateTensorShapesFromInputs () override
 
std::vector< TensorShapeInferOutputShapes (const std::vector< TensorShape > &inputShapes) const override
 
void Accept (ILayerVisitor &visitor) const override
 
- Public Member Functions inherited from LayerWithParameters< ViewsDescriptor >
const ViewsDescriptorGetParameters () 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)
 
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

 SplitterLayer (const ViewsDescriptor &param, const char *name)
 
 ~SplitterLayer ()=default
 Default destructor. More...
 
- Protected Member Functions inherited from LayerWithParameters< ViewsDescriptor >
 LayerWithParameters (unsigned int numInputSlots, unsigned int numOutputSlots, LayerType type, const ViewsDescriptor &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< ViewsDescriptor >
using DescriptorType = ViewsDescriptor
 
- Protected Types inherited from Layer
using ConstantTensors = std::vector< std::reference_wrapper< std::unique_ptr< ScopedCpuTensorHandle > >>
 
- Protected Attributes inherited from LayerWithParameters< ViewsDescriptor >
ViewsDescriptor 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 split operation.

Definition at line 13 of file SplitterLayer.hpp.

Constructor & Destructor Documentation

◆ SplitterLayer()

SplitterLayer ( const ViewsDescriptor param,
const char *  name 
)
protected

Constructor to create a SplitterLayer.

Parameters
[in]paramViewsDescriptor to configure the splitter operation.
[in]nameOptional name for the layer.

Definition at line 16 of file SplitterLayer.cpp.

17  : LayerWithParameters(1, param.GetNumViews(), LayerType::Splitter, param, name)
18 {
19 }
LayerWithParameters(unsigned int numInputSlots, unsigned int numOutputSlots, LayerType type, const ViewsDescriptor &param, const char *name)

◆ ~SplitterLayer()

~SplitterLayer ( )
protecteddefault

Default destructor.

Member Function Documentation

◆ Accept()

void Accept ( ILayerVisitor visitor) const
overridevirtual

Implements IConnectableLayer.

Definition at line 164 of file SplitterLayer.cpp.

References Layer::GetName(), LayerWithParameters< ViewsDescriptor >::GetParameters(), and ILayerVisitor::VisitSplitterLayer().

165 {
166  visitor.VisitSplitterLayer(this, GetParameters(), GetName());
167 }
const char * GetName() const override
Definition: Layer.hpp:305

◆ Clone()

SplitterLayer * 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 123 of file SplitterLayer.cpp.

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

124 {
125  return CloneBase<SplitterLayer>(graph, m_Param, GetName());
126 }
const char * GetName() const override
Definition: Layer.hpp:305
ViewsDescriptor m_Param
The parameters for the layer (not including tensor-valued weights etc.).

◆ CreateTensorHandles()

void CreateTensorHandles ( const TensorHandleFactoryRegistry registry,
const IWorkloadFactory factory,
const bool  IsMemoryManaged = true 
)
overridevirtual

Set the outputs to be appropriate sub tensors of the input if sub tensors are supported otherwise creates tensor handlers.

Parameters
[in]registryContains all the registered tensor handle factories available for use.
[in]factoryThe workload factory which will create the workload.
[in]IsMemoryManagedDetermine whether or not to assign a memory manager during creation

Reimplemented from Layer.

Definition at line 103 of file SplitterLayer.cpp.

References TensorHandleFactoryRegistry::GetFactory(), Layer::GetOutputSlot(), OutputSlot::GetTensorHandleFactoryId(), and ITensorHandleFactory::LegacyFactoryId.

106 {
107  boost::ignore_unused(IsMemoryManaged);
108  OutputSlot& slot = GetOutputSlot(0);
109  ITensorHandleFactory::FactoryId factoryId = slot.GetTensorHandleFactoryId();
110 
111  if (factoryId == ITensorHandleFactory::LegacyFactoryId)
112  {
113  CreateTensors(workloadFactory);
114  }
115  else
116  {
117  ITensorHandleFactory* handleFactory = registry.GetFactory(factoryId);
118  BOOST_ASSERT(handleFactory);
119  CreateTensors(*handleFactory);
120  }
121 }
static const FactoryId LegacyFactoryId
const OutputSlot & GetOutputSlot(unsigned int index=0) const override
Definition: Layer.hpp:312

◆ CreateWorkload()

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

Makes a workload for the Splitter 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 21 of file SplitterLayer.cpp.

References IWorkloadFactory::CreateSplitter(), OutputHandler::GetData(), Layer::GetInputSlots(), ViewsDescriptor::GetNumDimensions(), ViewsDescriptor::GetNumViews(), Layer::GetOutputSlot(), TensorInfo::GetShape(), OutputSlot::GetTensorHandleFactoryId(), OutputHandler::GetTensorInfo(), ViewsDescriptor::GetViewOrigin(), armnn::info, TensorInfo::IsTypeSpaceMatch(), Layer::m_OutputHandlers, LayerWithParameters< ViewsDescriptor >::m_Param, SplitterQueueDescriptor::m_ViewOrigins, and LayerWithParameters< ViewsDescriptor >::PrepInfoAndDesc().

22 {
23  SplitterQueueDescriptor descriptor;
24 
25  // Copies the window origins to the descriptor.
26  for (unsigned int i = 0; i < m_Param.GetNumViews(); ++i)
27  {
28  descriptor.m_ViewOrigins.emplace_back(
29  std::vector<unsigned int>(m_Param.GetViewOrigin(i), m_Param.GetViewOrigin(i) + m_Param.GetNumDimensions()));
30  }
31 
32  return factory.CreateSplitter(descriptor, PrepInfoAndDesc(descriptor));
33 }
uint32_t GetNumDimensions() const
Get the number of dimensions.
ViewsDescriptor 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.
const uint32_t * GetViewOrigin(uint32_t idx) const
Get the view origin at the int value idx.
uint32_t GetNumViews() const
Get the number of views.

◆ 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 128 of file SplitterLayer.cpp.

References ViewsDescriptor::GetNumDimensions(), ViewsDescriptor::GetNumViews(), ViewsDescriptor::GetViewSizes(), and LayerWithParameters< ViewsDescriptor >::m_Param.

Referenced by SplitterLayer::ValidateTensorShapesFromInputs().

129 {
130  boost::ignore_unused(inputShapes);
131  BOOST_ASSERT(inputShapes.size() == m_Param.GetNumViews());
132  std::vector<TensorShape> outShapes;
133  //Output shapes must match View shapes.
134  for (unsigned int viewIdx = 0; viewIdx < m_Param.GetNumViews(); viewIdx++)
135  {
136  const uint32_t* sizes = m_Param.GetViewSizes(viewIdx);
137  outShapes.push_back(TensorShape(m_Param.GetNumDimensions(), sizes));
138  }
139  return outShapes;
140 }
uint32_t GetNumDimensions() const
Get the number of dimensions.
ViewsDescriptor m_Param
The parameters for the layer (not including tensor-valued weights etc.).
const uint32_t * GetViewSizes(uint32_t idx) const
Get the view sizes at the int value idx.
uint32_t GetNumViews() const
Get the number of views.

◆ ValidateTensorShapesFromInputs()

void ValidateTensorShapesFromInputs ( )
overridevirtual

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

Implements Layer.

Definition at line 142 of file SplitterLayer.cpp.

References ViewsDescriptor::GetNumDimensions(), ViewsDescriptor::GetNumViews(), Layer::GetOutputSlot(), TensorInfo::GetShape(), OutputSlot::GetTensorInfo(), ViewsDescriptor::GetViewSizes(), SplitterLayer::InferOutputShapes(), and LayerWithParameters< ViewsDescriptor >::m_Param.

143 {
144  std::vector<TensorShape> views;
145  for (unsigned int viewIdx = 0; viewIdx < m_Param.GetNumViews(); viewIdx++)
146  {
147  const uint32_t* sizes = m_Param.GetViewSizes(viewIdx);
148  views.push_back(TensorShape(m_Param.GetNumDimensions(), sizes));
149  }
150 
151  auto inferredShapes = InferOutputShapes(views);
152 
153  BOOST_ASSERT(inferredShapes.size() == m_Param.GetNumViews());
154 
155  for (unsigned int viewIdx = 0; viewIdx < m_Param.GetNumViews(); viewIdx++)
156  {
157  ConditionalThrowIfNotEqual<LayerValidationException>(
158  "SplitterLayer: View sizes must match output tensor shapes.",
159  GetOutputSlot(viewIdx).GetTensorInfo().GetShape(),
160  inferredShapes[viewIdx]);
161  }
162 }
std::vector< TensorShape > InferOutputShapes(const std::vector< TensorShape > &inputShapes) const override
uint32_t GetNumDimensions() const
Get the number of dimensions.
ViewsDescriptor m_Param
The parameters for the layer (not including tensor-valued weights etc.).
const uint32_t * GetViewSizes(uint32_t idx) const
Get the view sizes at the int value idx.
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
uint32_t GetNumViews() const
Get the number of views.

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