ArmNN
 22.05
RankLayer.cpp
Go to the documentation of this file.
1 //
2 // Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
6 #include "RankLayer.hpp"
7 
8 #include "LayerCloneBase.hpp"
9 
12 
13 namespace armnn
14 {
15 
16 RankLayer::RankLayer(const char* name)
17  : Layer(1, 1, LayerType::Rank, name)
18 {}
19 
20 std::unique_ptr<IWorkload> RankLayer::CreateWorkload(const IWorkloadFactory& factory) const
21 {
22  RankQueueDescriptor descriptor;
23  SetAdditionalInfo(descriptor);
24 
25  return factory.CreateWorkload(LayerType::Rank, descriptor, PrepInfoAndDesc(descriptor));
26 }
27 
29 {
30  RankLayer* clone = CloneBase<RankLayer>(graph, GetName());
31  return clone;
32 }
33 
35 {
37 
38  const TensorShape& outputShape = GetOutputSlot(0).GetTensorInfo().GetShape();
39  const TensorShape inferredShape = TensorShape(Dimensionality::Scalar);
40 
42  ValidateAndCopyShape(outputShape, inferredShape, m_ShapeInferenceMethod, "RankLayer");
43 }
44 
46 void RankLayer::Accept(ILayerVisitor& visitor) const
47 {
48  visitor.VisitRankLayer(this, GetName());
49 }
51 
53 {
54  strategy.ExecuteStrategy(this, BaseDescriptor(), {}, GetName());
55 }
56 
57 } //namespace armnn
const TensorShape & GetShape() const
Definition: Tensor.hpp:191
#define ARMNN_NO_DEPRECATE_WARN_BEGIN
Definition: Deprecated.hpp:33
virtual void ExecuteStrategy(const armnn::IConnectableLayer *layer, const armnn::BaseDescriptor &descriptor, const std::vector< armnn::ConstTensor > &constants, const char *name, const armnn::LayerBindingId id=0)=0
virtual std::unique_ptr< IWorkload > CreateWorkload(const IWorkloadFactory &factory) const override
Makes a workload for the Rank type.
Definition: RankLayer.cpp:20
void ValidateTensorShapesFromInputs() override
Definition: RankLayer.cpp:34
void VerifyShapeInferenceType(const TensorShape &outputShape, ShapeInferenceMethod shapeInferenceMethod)
Definition: Layer.cpp:491
Copyright (c) 2021 ARM Limited and Contributors.
RankLayer(const char *name)
Definition: RankLayer.cpp:16
Layer * Clone(Graph &graph) const override
Creates a dynamically-allocated copy of this layer.
Definition: RankLayer.cpp:28
void ValidateAndCopyShape(const TensorShape &outputShape, const TensorShape &inferredShape, const ShapeInferenceMethod shapeInferenceMethod, const std::string &layerName, const unsigned int outputSlotIndex=0)
Definition: Layer.cpp:422
Base class for all descriptors.
Definition: Descriptors.hpp:22
void VerifyLayerConnections(unsigned int expectedConnections, const CheckLocation &location) const
Definition: Layer.cpp:378
#define ARMNN_NO_DEPRECATE_WARN_END
Definition: Deprecated.hpp:34
WorkloadInfo PrepInfoAndDesc(QueueDescriptor &descriptor) const
Helper function to reduce duplication in *LayerCreateWorkload.
Definition: Layer.hpp:394
ARMNN_NO_DEPRECATE_WARN_BEGIN void Accept(ILayerVisitor &visitor) const override
Definition: RankLayer.cpp:46
#define CHECK_LOCATION()
Definition: Exceptions.hpp:203
ARMNN_NO_DEPRECATE_WARN_END void ExecuteStrategy(IStrategy &strategy) const override
Apply a visitor to this layer.
Definition: RankLayer.cpp:52
void SetAdditionalInfo(QueueDescriptor &descriptor) const
Definition: Layer.cpp:274
const OutputSlot & GetOutputSlot(unsigned int index=0) const override
Get the const output slot handle by slot index.
Definition: Layer.hpp:324
const char * GetName() const override
Returns the name of the layer.
Definition: Layer.hpp:317
virtual std::unique_ptr< IWorkload > CreateWorkload(LayerType type, const QueueDescriptor &descriptor, const WorkloadInfo &info) const
const TensorInfo & GetTensorInfo() const override
Definition: Layer.cpp:92
ShapeInferenceMethod m_ShapeInferenceMethod
Definition: Layer.hpp:421
LayerType
When adding a new layer, adapt also the LastLayer enum value in the enum class LayerType below...
Definition: Types.hpp:467