ArmNN  NotReleased
ReshapeLayer Class Reference

This layer represents a reshape operation. More...

#include <ReshapeLayer.hpp>

Inheritance diagram for ReshapeLayer:
LayerWithParameters< ReshapeDescriptor > Layer IConnectableLayer

Public Member Functions

virtual std::unique_ptr< IWorkloadCreateWorkload (const IWorkloadFactory &factory) const override
 
ReshapeLayerClone (Graph &graph) const override
 
void ValidateTensorShapesFromInputs () override
 
std::vector< TensorShapeInferOutputShapes (const std::vector< TensorShape > &inputShapes) const override
 
bool IsEqual (const Layer &other) const
 
void Accept (ILayerVisitor &visitor) const override
 
- Public Member Functions inherited from LayerWithParameters< ReshapeDescriptor >
const ReshapeDescriptorGetParameters () 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

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

Definition at line 13 of file ReshapeLayer.hpp.

Constructor & Destructor Documentation

◆ ReshapeLayer()

ReshapeLayer ( const ReshapeDescriptor desc,
const char *  name 
)
protected

Constructor to create a ReshapeLayer.

Parameters
[in]paramReshapeDescriptor to configure the reshape operation.
[in]nameOptional name for the layer.

Definition at line 16 of file ReshapeLayer.cpp.

References armnn::Reshape.

Referenced by ReshapeLayer::IsEqual().

17  : LayerWithParameters(1, 1, LayerType::Reshape, param, name)
18 {
19 }
LayerWithParameters(unsigned int numInputSlots, unsigned int numOutputSlots, LayerType type, const ReshapeDescriptor &param, const char *name)

◆ ~ReshapeLayer()

~ReshapeLayer ( )
protecteddefault

Default destructor.

Referenced by ReshapeLayer::IsEqual().

Member Function Documentation

◆ Accept()

void Accept ( ILayerVisitor visitor) const
overridevirtual

Implements IConnectableLayer.

Definition at line 52 of file ReshapeLayer.cpp.

References Layer::GetName(), LayerWithParameters< ReshapeDescriptor >::GetParameters(), and ILayerVisitor::VisitReshapeLayer().

Referenced by ReshapeLayer::IsEqual().

53 {
54  visitor.VisitReshapeLayer(this, GetParameters(), GetName());
55 }
const char * GetName() const override
Definition: Layer.hpp:305
const ReshapeDescriptor & GetParameters() const

◆ Clone()

ReshapeLayer * 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 27 of file ReshapeLayer.cpp.

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

28 {
29  return CloneBase<ReshapeLayer>(graph, m_Param, GetName());
30 }
const char * GetName() const override
Definition: Layer.hpp:305
ReshapeDescriptor 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 Reshape 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 ReshapeLayer.cpp.

References IWorkloadFactory::CreateReshape(), and LayerWithParameters< ReshapeDescriptor >::PrepInfoAndDesc().

22 {
23  ReshapeQueueDescriptor descriptor;
24  return factory.CreateReshape(descriptor, PrepInfoAndDesc(descriptor));
25 }
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 32 of file ReshapeLayer.cpp.

References LayerWithParameters< ReshapeDescriptor >::m_Param, and ReshapeDescriptor::m_TargetShape.

Referenced by ReshapeLayer::ValidateTensorShapesFromInputs().

33 {
34  boost::ignore_unused(inputShapes);
35  return std::vector<TensorShape>({ m_Param.m_TargetShape });
36 }
TensorShape m_TargetShape
Target shape value.
ReshapeDescriptor m_Param
The parameters for the layer (not including tensor-valued weights etc.).

◆ IsEqual()

bool IsEqual ( const Layer other) const
inline

Indicates if the other layer received is equal to this one.

Parameters
otherThe other layer to be compared with.
Returns
true if other layer is equal to this false otherwise.

Definition at line 39 of file ReshapeLayer.hpp.

References ReshapeLayer::Accept(), Layer::GetType(), LayerWithParameters< ReshapeDescriptor >::m_Param, ReshapeDescriptor::m_TargetShape, armnn::Reshape, ReshapeLayer::ReshapeLayer(), and ReshapeLayer::~ReshapeLayer().

40  {
41  return (other.GetType() == LayerType::Reshape) &&
42  m_Param.m_TargetShape == boost::polymorphic_downcast<const ReshapeLayer*>(&other)->m_Param.m_TargetShape;
43  }
TensorShape m_TargetShape
Target shape value.
ReshapeDescriptor 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 ReshapeLayer.

Implements Layer.

Definition at line 38 of file ReshapeLayer.cpp.

References CHECK_LOCATION, Layer::GetOutputSlot(), TensorInfo::GetShape(), OutputSlot::GetTensorInfo(), ReshapeLayer::InferOutputShapes(), and Layer::VerifyLayerConnections().

39 {
41 
42  auto inferredShapes = InferOutputShapes({ });
43 
44  BOOST_ASSERT(inferredShapes.size() == 1);
45 
46  ConditionalThrowIfNotEqual<LayerValidationException>(
47  "ReshapeLayer: TensorShape set on OutputSlot[0] does not match the inferred shape.",
49  inferredShapes[0]);
50 }
#define CHECK_LOCATION()
Definition: Exceptions.hpp:169
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

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