aboutsummaryrefslogtreecommitdiff
path: root/delegate/classic/src/ElementwiseBinary.hpp
diff options
context:
space:
mode:
authorJohn Mcloughlin <john.mcloughlin@arm.com>2023-05-15 17:03:49 +0100
committerJohn Mcloughlin <john.mcloughlin@arm.com>2023-05-17 12:29:54 +0100
commit0ec008761ab26110dcb108d544be4040a14fd403 (patch)
tree87bbc145ff2a4ea3221440b0fbd7c91a5b8a7c91 /delegate/classic/src/ElementwiseBinary.hpp
parent499ebd917d8399f0a9d4d7e6e40a0ec321a4bab4 (diff)
downloadarmnn-0ec008761ab26110dcb108d544be4040a14fd403.tar.gz
IVGCVSW-7400 POW IVGCVSW-7278 SQUARED_DIFFERENCE.
* Added 2 new operators as ElementWiseBinary ops * Ref End to End and unit tests * Serialize and Deserialize tests * Delegate and Opaque Delegate tests * TfLite Parser tests Signed-off-by: John Mcloughlin <john.mcloughlin@arm.com> Change-Id: I537158127f602f0c41ca0402aa31655cd3bd4281
Diffstat (limited to 'delegate/classic/src/ElementwiseBinary.hpp')
-rw-r--r--delegate/classic/src/ElementwiseBinary.hpp70
1 files changed, 70 insertions, 0 deletions
diff --git a/delegate/classic/src/ElementwiseBinary.hpp b/delegate/classic/src/ElementwiseBinary.hpp
index dbbf47941a..8055a6958c 100644
--- a/delegate/classic/src/ElementwiseBinary.hpp
+++ b/delegate/classic/src/ElementwiseBinary.hpp
@@ -174,6 +174,56 @@ TfLiteStatus ValidateMulOperator(DelegateData& delegateData,
return isSupported ? kTfLiteOk : kTfLiteError;
}
+TfLiteStatus ValidatePowerOperator(DelegateData& delegateData,
+ TfLiteContext* tfLiteContext,
+ const armnn::TensorInfo& inputInfo1,
+ const armnn::TensorInfo& inputInfo2,
+ const armnn::TensorInfo& outputInfo)
+{
+ bool isSupported = false;
+ auto validateFunc = [&](const armnn::TensorInfo& outputTensorInfo, bool& isSupported)
+ {
+ FORWARD_LAYER_SUPPORT_FUNC("POWER",
+ tfLiteContext,
+ IsElementwiseBinarySupported,
+ delegateData.m_Backends,
+ isSupported,
+ armnn::BackendId(),
+ inputInfo1,
+ inputInfo2,
+ outputTensorInfo,
+ armnn::BinaryOperation::Power);
+ };
+
+ validateFunc(outputInfo, isSupported);
+ return isSupported ? kTfLiteOk : kTfLiteError;
+}
+
+TfLiteStatus ValidateSquaredDifferenceOperator(DelegateData& delegateData,
+ TfLiteContext* tfLiteContext,
+ const armnn::TensorInfo& inputInfo1,
+ const armnn::TensorInfo& inputInfo2,
+ const armnn::TensorInfo& outputInfo)
+{
+ bool isSupported = false;
+ auto validateFunc = [&](const armnn::TensorInfo& outputTensorInfo, bool& isSupported)
+ {
+ FORWARD_LAYER_SUPPORT_FUNC("SQUAREDDIFFERENCE",
+ tfLiteContext,
+ IsElementwiseBinarySupported,
+ delegateData.m_Backends,
+ isSupported,
+ armnn::BackendId(),
+ inputInfo1,
+ inputInfo2,
+ outputTensorInfo,
+ armnn::BinaryOperation::SqDiff);
+ };
+
+ validateFunc(outputInfo, isSupported);
+ return isSupported ? kTfLiteOk : kTfLiteError;
+}
+
TfLiteStatus ValidateSubOperator(DelegateData& delegateData,
TfLiteContext* tfLiteContext,
const armnn::TensorInfo& inputInfo1,
@@ -322,6 +372,18 @@ TfLiteStatus VisitElementwiseBinaryOperator(DelegateData& delegateData,
inputTensorInfo0,
inputTensorInfo1,
outputTensorInfo);
+ case kTfLiteBuiltinPow:
+ return ValidatePowerOperator(delegateData,
+ tfLiteContext,
+ inputTensorInfo0,
+ inputTensorInfo1,
+ outputTensorInfo);
+ case kTfLiteBuiltinSquaredDifference:
+ return ValidateSquaredDifferenceOperator(delegateData,
+ tfLiteContext,
+ inputTensorInfo0,
+ inputTensorInfo1,
+ outputTensorInfo);
case kTfLiteBuiltinSub:
return ValidateSubOperator(delegateData,
tfLiteContext,
@@ -364,6 +426,14 @@ TfLiteStatus VisitElementwiseBinaryOperator(DelegateData& delegateData,
elementwiseBinaryLayer = delegateData.m_Network->AddElementwiseBinaryLayer(
armnn::BinaryOperation::Mul);
break;
+ case kTfLiteBuiltinPow:
+ elementwiseBinaryLayer = delegateData.m_Network->AddElementwiseBinaryLayer(
+ armnn::BinaryOperation::Power);
+ break;
+ case kTfLiteBuiltinSquaredDifference:
+ elementwiseBinaryLayer = delegateData.m_Network->AddElementwiseBinaryLayer(
+ armnn::BinaryOperation::SqDiff);
+ break;
case kTfLiteBuiltinSub:
elementwiseBinaryLayer = delegateData.m_Network->AddElementwiseBinaryLayer(
armnn::BinaryOperation::Sub);