aboutsummaryrefslogtreecommitdiff
path: root/src/armnn/layers
diff options
context:
space:
mode:
Diffstat (limited to 'src/armnn/layers')
-rw-r--r--src/armnn/layers/RsqrtLayer.cpp48
-rw-r--r--src/armnn/layers/RsqrtLayer.hpp40
2 files changed, 88 insertions, 0 deletions
diff --git a/src/armnn/layers/RsqrtLayer.cpp b/src/armnn/layers/RsqrtLayer.cpp
new file mode 100644
index 0000000000..d516810c68
--- /dev/null
+++ b/src/armnn/layers/RsqrtLayer.cpp
@@ -0,0 +1,48 @@
+//
+// Copyright © 2017 Arm Ltd. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
+
+#include "RsqrtLayer.hpp"
+
+#include "LayerCloneBase.hpp"
+
+#include <armnn/TypesUtils.hpp>
+#include <backendsCommon/WorkloadData.hpp>
+#include <backendsCommon/WorkloadFactory.hpp>
+
+namespace armnn
+{
+
+RsqrtLayer::RsqrtLayer(const char* name)
+ : Layer(1, 1, LayerType::Rsqrt, name)
+{
+}
+
+std::unique_ptr<IWorkload> RsqrtLayer::CreateWorkload(const Graph& graph,
+ const IWorkloadFactory& factory) const
+{
+ RsqrtQueueDescriptor descriptor;
+ return factory.CreateRsqrt(descriptor, PrepInfoAndDesc(descriptor, graph));
+}
+
+RsqrtLayer* RsqrtLayer::Clone(Graph& graph) const
+{
+ return CloneBase<RsqrtLayer>(graph, GetName());
+}
+
+void RsqrtLayer::ValidateTensorShapesFromInputs()
+{
+ VerifyLayerConnections(1, CHECK_LOCATION());
+
+ auto inferredShapes = InferOutputShapes({ GetInputSlot(0).GetConnection()->GetTensorInfo().GetShape() });
+
+ BOOST_ASSERT(inferredShapes.size() == 1);
+
+ ConditionalThrowIfNotEqual<LayerValidationException>(
+ "RsqrtLayer: TensorShape set on OutputSlot[0] does not match the inferred shape.",
+ GetOutputSlot(0).GetTensorInfo().GetShape(),
+ inferredShapes[0]);
+}
+
+} // namespace armnn \ No newline at end of file
diff --git a/src/armnn/layers/RsqrtLayer.hpp b/src/armnn/layers/RsqrtLayer.hpp
new file mode 100644
index 0000000000..47a4ccedd6
--- /dev/null
+++ b/src/armnn/layers/RsqrtLayer.hpp
@@ -0,0 +1,40 @@
+//
+// Copyright © 2017 Arm Ltd. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
+
+#pragma once
+
+#include <Layer.hpp>
+
+namespace armnn
+{
+
+class RsqrtLayer : public Layer
+{
+public:
+ /// Makes a workload for the Rsqrt 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 Graph& graph,
+ 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.
+ RsqrtLayer* Clone(Graph& graph) const override;
+
+ /// Check if the input tensor shape(s)
+ /// will lead to a valid configuration of @ref RsqrtLayer.
+ void ValidateTensorShapesFromInputs() override;
+
+protected:
+ /// Constructor to create an RsqrtLayer.
+ /// @param [in] name Optional name for the layer.
+ RsqrtLayer(const char* name);
+
+ /// Default destructor
+ ~RsqrtLayer() = default;
+};
+
+} // namespace \ No newline at end of file