diff options
author | Mike Kelly <mike.kelly@arm.com> | 2023-03-08 13:47:17 +0000 |
---|---|---|
committer | Francis Murtagh <francis.murtagh@arm.com> | 2023-03-14 16:40:09 +0000 |
commit | 3ec3077b4eaedcc0c20ab5774bdbe365da541445 (patch) | |
tree | d601d2000897dec8691bf64cbddc9036f26b8034 /src/armnnSerializer/SerializerUtils.cpp | |
parent | a088cd00b3cce672d26cdcb4965fc2a86b48f339 (diff) | |
download | armnn-3ec3077b4eaedcc0c20ab5774bdbe365da541445.tar.gz |
IVGCVSW-3808 Add ElementwiseBinaryLayer
!android-nn-driver:9329
* Added ElementwiseBinaryLayer that can represent all ElementwiseBinary
operations including Add, Div, Sub, Maximum, Mul and Minimum.
* Updated Delegate to use ElementwiseBinaryLayer instead of the Add,
Div, Sub, Maximum, Mul and Minimum layers.
* Updated Deserializer to use ElementwiseBinaryLayer instead of the Add,
Div, Sub, Maximum, Mul and Minimum layers.
* Updated OnnxParser to use ElementwiseBinaryLayer instead of the Add
layer.
* Updated TfLiteParser to use ElementwiseBinaryLayer instead of the Add,
Div, Sub, Maximum, Mul and Minimum layers.
* Updated CL and Neon tests to use ElementwiseBinaryLayer.
* Updated CL and Neon Backend Specific Optimizations to accept
ElementBinaryLayers as well as Add, Div, Mul, Sub, Maximum and Minimum
layers.
Signed-off-by: Teresa Charlin <teresa.charlinreyes@arm.com>
Signed-off-by: Mike Kelly <mike.kelly@arm.com>
Change-Id: I7cbb96b60eb01f0e2b57b0541016d48a08b86c75
Diffstat (limited to 'src/armnnSerializer/SerializerUtils.cpp')
-rw-r--r-- | src/armnnSerializer/SerializerUtils.cpp | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/src/armnnSerializer/SerializerUtils.cpp b/src/armnnSerializer/SerializerUtils.cpp index 49ce7217dc..703f56ff5c 100644 --- a/src/armnnSerializer/SerializerUtils.cpp +++ b/src/armnnSerializer/SerializerUtils.cpp @@ -1,5 +1,5 @@ // -// Copyright © 2017 Arm Ltd and Contributors. All rights reserved. +// Copyright © 2017,2019-2021,2023 Arm Ltd and Contributors. All rights reserved. // SPDX-License-Identifier: MIT // @@ -107,9 +107,30 @@ armnnSerializer::DataLayout GetFlatBufferDataLayout(armnn::DataLayout dataLayout } } -armnnSerializer::UnaryOperation GetFlatBufferUnaryOperation(armnn::UnaryOperation comparisonOperation) +armnnSerializer::BinaryOperation GetFlatBufferBinaryOperation(armnn::BinaryOperation binaryOperation) { - switch (comparisonOperation) + switch (binaryOperation) + { + case armnn::BinaryOperation::Add: + return armnnSerializer::BinaryOperation::BinaryOperation_Add; + case armnn::BinaryOperation::Div: + return armnnSerializer::BinaryOperation::BinaryOperation_Div; + case armnn::BinaryOperation::Maximum: + return armnnSerializer::BinaryOperation::BinaryOperation_Maximum; + case armnn::BinaryOperation::Minimum: + return armnnSerializer::BinaryOperation::BinaryOperation_Minimum; + case armnn::BinaryOperation::Mul: + return armnnSerializer::BinaryOperation::BinaryOperation_Mul; + case armnn::BinaryOperation::Sub: + return armnnSerializer::BinaryOperation::BinaryOperation_Sub; + default: + throw armnn::InvalidArgumentException("Elementwise Binary operation unknown"); + } +} + +armnnSerializer::UnaryOperation GetFlatBufferUnaryOperation(armnn::UnaryOperation unaryOperation) +{ + switch (unaryOperation) { case armnn::UnaryOperation::Abs: return armnnSerializer::UnaryOperation::UnaryOperation_Abs; @@ -128,7 +149,7 @@ armnnSerializer::UnaryOperation GetFlatBufferUnaryOperation(armnn::UnaryOperatio case armnn::UnaryOperation::Sin: return armnnSerializer::UnaryOperation::UnaryOperation_Sin; default: - throw armnn::InvalidArgumentException("Unary operation unknown"); + throw armnn::InvalidArgumentException("Elementwise Unary operation unknown"); } } |