diff options
author | Mohamed Nour Abouelseoud <mohamednour.abouelseoud@arm.com> | 2018-12-27 12:39:16 +0000 |
---|---|---|
committer | Mohamed Nour Abouelseoud <mohamednour.abouelseoud@arm.com> | 2019-01-07 11:51:21 +0000 |
commit | a1d3c6a49f35d7d3f11cc7e1b588d1d5401bdbf1 (patch) | |
tree | b5aca3b07f2935adc3abe25a14e7bd66ff5201fc /src/armnn/layers | |
parent | d5b9e6497b03d58c671c15b9ebe8e35500171f06 (diff) | |
download | armnn-a1d3c6a49f35d7d3f11cc7e1b588d1d5401bdbf1.tar.gz |
IVGCVSW-2371 Add Rsqrt Ref implementation
*Added Unit Tests
Change-Id: I6cceb8e6dcda35ce08415f8e5ca86019a64d26e3
Diffstat (limited to 'src/armnn/layers')
-rw-r--r-- | src/armnn/layers/RsqrtLayer.cpp | 48 | ||||
-rw-r--r-- | src/armnn/layers/RsqrtLayer.hpp | 40 |
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 |