aboutsummaryrefslogtreecommitdiff
path: root/src/armnn
diff options
context:
space:
mode:
Diffstat (limited to 'src/armnn')
-rw-r--r--src/armnn/BackendHelper.cpp17
-rw-r--r--src/armnn/LayersFwd.hpp2
-rw-r--r--src/armnn/Network.cpp11
-rw-r--r--src/armnn/Network.hpp3
-rw-r--r--src/armnn/layers/ReverseV2Layer.cpp50
-rw-r--r--src/armnn/layers/ReverseV2Layer.hpp49
6 files changed, 131 insertions, 1 deletions
diff --git a/src/armnn/BackendHelper.cpp b/src/armnn/BackendHelper.cpp
index 580c52c568..404d278efc 100644
--- a/src/armnn/BackendHelper.cpp
+++ b/src/armnn/BackendHelper.cpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2017,2022 Arm Ltd and Contributors. All rights reserved.
+// Copyright © 2017,2022-2023 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
@@ -1211,6 +1211,21 @@ bool LayerSupportHandle::IsResizeSupported(const TensorInfo& input,
reasonIfUnsupported);
}
+bool LayerSupportHandle::IsReverseV2Supported(const armnn::TensorInfo &input,
+ const armnn::TensorInfo &output,
+ const armnn::ReverseV2Descriptor &descriptor,
+ Optional<std::string &> reasonIfUnsupported)
+{
+ TensorInfos infos{input, output};
+
+ return m_LayerSupport->IsLayerSupported(LayerType::ReverseV2,
+ infos,
+ descriptor,
+ EmptyOptional(),
+ EmptyOptional(),
+ reasonIfUnsupported);
+}
+
bool LayerSupportHandle::IsShapeSupported(const TensorInfo& input,
const TensorInfo& output,
Optional<std::string&> reasonIfUnsupported)
diff --git a/src/armnn/LayersFwd.hpp b/src/armnn/LayersFwd.hpp
index f634272316..d3ce6f2a67 100644
--- a/src/armnn/LayersFwd.hpp
+++ b/src/armnn/LayersFwd.hpp
@@ -64,6 +64,7 @@
#include "layers/ReduceLayer.hpp"
#include "layers/ReshapeLayer.hpp"
#include "layers/ResizeLayer.hpp"
+#include "layers/ReverseV2Layer.hpp"
#include "layers/ShapeLayer.hpp"
#include "layers/SliceLayer.hpp"
#include "layers/SoftmaxLayer.hpp"
@@ -165,6 +166,7 @@ DECLARE_LAYER(Rank)
DECLARE_LAYER(Reduce)
DECLARE_LAYER(Reshape)
DECLARE_LAYER(Resize)
+DECLARE_LAYER(ReverseV2)
DECLARE_LAYER(Shape)
DECLARE_LAYER(Slice)
DECLARE_LAYER(Softmax)
diff --git a/src/armnn/Network.cpp b/src/armnn/Network.cpp
index b768ea888f..2abaf44587 100644
--- a/src/armnn/Network.cpp
+++ b/src/armnn/Network.cpp
@@ -639,6 +639,12 @@ IConnectableLayer* INetwork::AddBatchMatMulLayer(const BatchMatMulDescriptor &de
return pNetworkImpl->AddBatchMatMulLayer(descriptor, name);
}
+IConnectableLayer* INetwork::AddReverseV2Layer(const ReverseV2Descriptor &descriptor,
+ const char *name)
+{
+ return pNetworkImpl->AddReverseV2Layer(descriptor, name);
+}
+
void INetwork::ExecuteStrategy(IStrategy& strategy) const
{
return pNetworkImpl->ExecuteStrategy(strategy);
@@ -2902,6 +2908,11 @@ IConnectableLayer* NetworkImpl::AddBatchMatMulLayer(const BatchMatMulDescriptor&
return m_Graph->AddLayer<BatchMatMulLayer>(desc, name);
}
+IConnectableLayer* NetworkImpl::AddReverseV2Layer(const ReverseV2Descriptor &desc, const char *name)
+{
+ return m_Graph->AddLayer<ReverseV2Layer>(desc, name);
+}
+
IConnectableLayer* NetworkImpl::AddPrecompiledLayer(const PreCompiledDescriptor& preCompiledDescriptor,
CompiledBlobPtr compiledBlobPtr,
const Optional<BackendId>& backend,
diff --git a/src/armnn/Network.hpp b/src/armnn/Network.hpp
index eced4587b9..fc3ae42aa9 100644
--- a/src/armnn/Network.hpp
+++ b/src/armnn/Network.hpp
@@ -188,6 +188,9 @@ public:
IConnectableLayer* AddReshapeLayer(const ReshapeDescriptor& reshapeDescriptor,
const char* name = nullptr);
+ IConnectableLayer* AddReverseV2Layer(const ReverseV2Descriptor& ReverseV2Descriptor,
+ const char* name = nullptr);
+
IConnectableLayer* AddShapeLayer(const char* name = nullptr);
IConnectableLayer* AddSliceLayer(const SliceDescriptor& sliceDescriptor, const char* name = nullptr);
diff --git a/src/armnn/layers/ReverseV2Layer.cpp b/src/armnn/layers/ReverseV2Layer.cpp
new file mode 100644
index 0000000000..29f8b1b781
--- /dev/null
+++ b/src/armnn/layers/ReverseV2Layer.cpp
@@ -0,0 +1,50 @@
+//
+// Copyright © 2023 Arm Ltd and Contributors. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
+
+#include "ReverseV2Layer.hpp"
+
+#include <armnn/backends/WorkloadFactory.hpp>
+#include "layers/LayerCloneBase.hpp"
+
+namespace armnn
+{
+ReverseV2Layer::ReverseV2Layer(const armnn::ReverseV2Descriptor &param, const char *name)
+ : LayerWithParameters(1, 1, LayerType::ReverseV2, param, name)
+{}
+
+std::unique_ptr<IWorkload> ReverseV2Layer::CreateWorkload(const armnn::IWorkloadFactory &factory) const
+{
+ ReverseV2QueueDescriptor descriptor;
+ SetAdditionalInfo(descriptor);
+
+ return factory.CreateWorkload(LayerType::ReverseV2, descriptor, PrepInfoAndDesc(descriptor));
+}
+
+ReverseV2Layer* ReverseV2Layer::Clone(armnn::Graph &graph) const
+{
+ auto layer = CloneBase<ReverseV2Layer>(graph, m_Param, GetName());
+
+ return std::move(layer);
+}
+
+/// Use the default Layer::InferOutputShape method
+
+void ReverseV2Layer::ValidateTensorShapesFromInputs()
+{
+ VerifyLayerConnections(1, CHECK_LOCATION());
+
+ const TensorShape& outputShape = GetOutputSlot(0).GetTensorInfo().GetShape();
+
+ VerifyShapeInferenceType(outputShape, m_ShapeInferenceMethod);
+
+ auto inferredShapes = InferOutputShapes({
+ GetInputSlot(0).GetConnection()->GetTensorInfo().GetShape() });
+
+ ARMNN_ASSERT(inferredShapes.size() == 1);
+
+ ValidateAndCopyShape(outputShape, inferredShapes[0], m_ShapeInferenceMethod, "ReverseV2Layer");
+}
+
+} \ No newline at end of file
diff --git a/src/armnn/layers/ReverseV2Layer.hpp b/src/armnn/layers/ReverseV2Layer.hpp
new file mode 100644
index 0000000000..046670e9de
--- /dev/null
+++ b/src/armnn/layers/ReverseV2Layer.hpp
@@ -0,0 +1,49 @@
+//
+// Copyright © 2023 Arm Ltd and Contributors. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
+
+#pragma once
+
+#include "LayerWithParameters.hpp"
+
+namespace armnn
+{
+
+ /// This layer represents a ReverseV2 operation.
+ class ReverseV2Layer : public LayerWithParameters<ReverseV2Descriptor>
+ {
+ public:
+ /// Makes a workload for the ReverseV2 type.
+ /// @param [in] graph The graph where this layer can be found.
+ /// @param [in] factory The workload factory which will create the workload.
+ /// @return A pointer to the created workload, or nullptr if not created.
+ virtual std::unique_ptr<IWorkload>CreateWorkload(const IWorkloadFactory& factory) const override;
+
+ /// Creates a dynamically-allocated copy of this layer.
+ /// @param [in] graph The graph into which this layer is being cloned.
+ ReverseV2Layer* Clone(Graph& graph) const override;
+
+ /// 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.
+ /// @param [in] inputShapes The vector of input shapes for ReverseV2.
+ /// @return A vector to the inferred output shape.
+
+ /// Use the default Layer::InferOutputShape method
+ // std::vector<TensorShape> InferOutputShapes(const std::vector<TensorShape>& inputShapes) const override;
+
+ /// Check if the input tensor shape(s)
+ /// will lead to a valid configuration of @ref ReverseV2Layer.
+ void ValidateTensorShapesFromInputs() override;
+
+ protected:
+ /// Constructor to create a ReverseV2Layer.
+ /// @param [in] param ReverseV2Descriptor to configure the ReverseV2 operation.
+ /// @param [in] name Optional name for the layer.
+ ReverseV2Layer(const ReverseV2Descriptor& param, const char* name);
+
+ /// Default destructor
+ ~ReverseV2Layer() = default;
+ };
+
+} // namespace armnn