diff options
author | josh minor <josh.minor@arm.com> | 2020-01-06 16:40:46 -0600 |
---|---|---|
committer | Derek Lamberti <derek.lamberti@arm.com> | 2020-01-23 14:29:14 +0000 |
commit | 4a3c61091037e7e86e8b03bb060d8c1ab82731a9 (patch) | |
tree | 928644023400ad5ac0c26b33dfff2f975567d6e8 /src/backends/reference/workloads/ElementwiseFunction.cpp | |
parent | 190a39a4a9598e42b636ae4ab843761884148160 (diff) | |
download | armnn-4a3c61091037e7e86e8b03bb060d8c1ab82731a9.tar.gz |
IVGCVSW-4259 Add frontend and reference workload for UnaryOperationLayer
* Added new layer named ElementwiseUnary
* Deprecated existing Abs/Rsqrt layer functions
* Updated existing Abs/Rsqrt test infrastructure to use new layer
* Added boilerplate for new Exp,Neg,Sqrt elemwise op layers
* AbsQuantize test removed pending future commit
* Serialization support added
!android-nn-driver:2550
Change-Id: Ic595c645925e17b45db568187fd05646daf2e87f
Signed-off-by: josh minor <josh.minor@arm.com>
Diffstat (limited to 'src/backends/reference/workloads/ElementwiseFunction.cpp')
-rw-r--r-- | src/backends/reference/workloads/ElementwiseFunction.cpp | 58 |
1 files changed, 39 insertions, 19 deletions
diff --git a/src/backends/reference/workloads/ElementwiseFunction.cpp b/src/backends/reference/workloads/ElementwiseFunction.cpp index 888037f9a6..5687cf5861 100644 --- a/src/backends/reference/workloads/ElementwiseFunction.cpp +++ b/src/backends/reference/workloads/ElementwiseFunction.cpp @@ -7,36 +7,56 @@ #include "Broadcast.hpp" #include <functional> #include "Minimum.hpp" - #include "Maximum.hpp" +#include "Abs.hpp" +#include "Exp.hpp" +#include "Rsqrt.hpp" +#include "Sqrt.hpp" + namespace armnn { template <typename Functor> -ElementwiseFunction<Functor>::ElementwiseFunction(const TensorShape& inShape0, - const TensorShape& inShape1, - const TensorShape& outShape, - armnn::Decoder<InType>& inData0, - armnn::Decoder<InType>& inData1, - armnn::Encoder<OutType>& outData) +ElementwiseBinaryFunction<Functor>::ElementwiseBinaryFunction(const TensorShape& inShape0, + const TensorShape& inShape1, + const TensorShape& outShape, + Decoder<InType>& inData0, + Decoder<InType>& inData1, + Encoder<OutType>& outData) { BroadcastLoop(inShape0, inShape1, outShape).Unroll(Functor(), 0, inData0, inData1, outData); } +template <typename Functor> +ElementwiseUnaryFunction<Functor>::ElementwiseUnaryFunction(const TensorShape& inShape, + const TensorShape& outShape, + Decoder<InType>& inData, + Encoder<OutType>& outData) +{ + BroadcastLoop(inShape, outShape).Unroll(Functor(), 0, inData, outData); +} + } //namespace armnn -template struct armnn::ElementwiseFunction<std::plus<float>>; -template struct armnn::ElementwiseFunction<std::minus<float>>; -template struct armnn::ElementwiseFunction<std::multiplies<float>>; -template struct armnn::ElementwiseFunction<std::divides<float>>; -template struct armnn::ElementwiseFunction<armnn::maximum<float>>; -template struct armnn::ElementwiseFunction<armnn::minimum<float>>; +template struct armnn::ElementwiseBinaryFunction<std::plus<float>>; +template struct armnn::ElementwiseBinaryFunction<std::minus<float>>; +template struct armnn::ElementwiseBinaryFunction<std::multiplies<float>>; +template struct armnn::ElementwiseBinaryFunction<std::divides<float>>; +template struct armnn::ElementwiseBinaryFunction<armnn::maximum<float>>; +template struct armnn::ElementwiseBinaryFunction<armnn::minimum<float>>; // Comparison -template struct armnn::ElementwiseFunction<std::equal_to<float>>; -template struct armnn::ElementwiseFunction<std::greater<float>>; -template struct armnn::ElementwiseFunction<std::greater_equal<float>>; -template struct armnn::ElementwiseFunction<std::less<float>>; -template struct armnn::ElementwiseFunction<std::less_equal<float>>; -template struct armnn::ElementwiseFunction<std::not_equal_to<float>>; +template struct armnn::ElementwiseBinaryFunction<std::equal_to<float>>; +template struct armnn::ElementwiseBinaryFunction<std::greater<float>>; +template struct armnn::ElementwiseBinaryFunction<std::greater_equal<float>>; +template struct armnn::ElementwiseBinaryFunction<std::less<float>>; +template struct armnn::ElementwiseBinaryFunction<std::less_equal<float>>; +template struct armnn::ElementwiseBinaryFunction<std::not_equal_to<float>>; + +// Unary +template struct armnn::ElementwiseUnaryFunction<armnn::abs<float>>; +template struct armnn::ElementwiseUnaryFunction<armnn::exp<float>>; +template struct armnn::ElementwiseUnaryFunction<std::negate<float>>; +template struct armnn::ElementwiseUnaryFunction<armnn::rsqrt<float>>; +template struct armnn::ElementwiseUnaryFunction<armnn::sqrt<float>>; |