aboutsummaryrefslogtreecommitdiff
path: root/src/armnn/layers
diff options
context:
space:
mode:
authorTianle Cheng <tianle.cheng@arm.com>2023-06-28 13:20:47 +0100
committerTianle Cheng <tianle.cheng@arm.com>2023-07-04 10:36:43 +0000
commit988354de127528bdebb98fd25661fbf2f39f17dd (patch)
treec06f5250bdd0182055ac9e84e20d6e338518ad08 /src/armnn/layers
parent9414936e62ed8cd18cc33c0390bb605a782556c6 (diff)
downloadarmnn-988354de127528bdebb98fd25661fbf2f39f17dd.tar.gz
IVGCVSW-7831: Front end and Reference Implementation for REVERSE_V2
* Descriptors added for ReverseV2 * Layer definition added * Input validation added * Reference workload implementation for ReverseV2 added * Reference layer unit tests made for ReverseV2 * CompareTensors method updated to support comparison between empty tensors * CMake and other build files updated Signed-off-by: Tianle Cheng <tianle.cheng@arm.com> Change-Id: I805738454421309fda77c44218a8df171d68dc18
Diffstat (limited to 'src/armnn/layers')
-rw-r--r--src/armnn/layers/ReverseV2Layer.cpp50
-rw-r--r--src/armnn/layers/ReverseV2Layer.hpp49
2 files changed, 99 insertions, 0 deletions
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