From 3ec3077b4eaedcc0c20ab5774bdbe365da541445 Mon Sep 17 00:00:00 2001 From: Mike Kelly Date: Wed, 8 Mar 2023 13:47:17 +0000 Subject: 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 Signed-off-by: Mike Kelly Change-Id: I7cbb96b60eb01f0e2b57b0541016d48a08b86c75 --- src/armnnTfLiteParser/TfLiteParser.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/armnnTfLiteParser') diff --git a/src/armnnTfLiteParser/TfLiteParser.cpp b/src/armnnTfLiteParser/TfLiteParser.cpp index b7e2762ade..dc5afca30e 100644 --- a/src/armnnTfLiteParser/TfLiteParser.cpp +++ b/src/armnnTfLiteParser/TfLiteParser.cpp @@ -1838,7 +1838,7 @@ void TfLiteParserImpl::ParseMaximum(size_t subgraphIndex, size_t operatorIndex) TensorInfo input1TensorInfo = InputTensorInfo(subgraphIndex, operatorIndex, 1); CheckMatchingQuantization(inputTensorInfo, input1TensorInfo, layerName, "Input 0", "Input 1"); - IConnectableLayer* layer = m_Network->AddMaximumLayer(layerName.c_str()); + IConnectableLayer* layer = m_Network->AddElementwiseBinaryLayer(BinaryOperation::Maximum, layerName.c_str()); ARMNN_ASSERT(layer != nullptr); TensorInfo outputTensorInfo = OutputTensorInfoFromInputs(subgraphIndex, operatorIndex, layer, 0, {0, 1}); @@ -1868,7 +1868,7 @@ void TfLiteParserImpl::ParseMinimum(size_t subgraphIndex, size_t operatorIndex) TensorInfo input1TensorInfo = InputTensorInfo(subgraphIndex, operatorIndex, 1); CheckMatchingQuantization(inputTensorInfo, input1TensorInfo, layerName, "Input 0", "Input 1"); - IConnectableLayer* layer = m_Network->AddMinimumLayer(layerName.c_str()); + IConnectableLayer* layer = m_Network->AddElementwiseBinaryLayer(BinaryOperation::Minimum, layerName.c_str()); ARMNN_ASSERT(layer != nullptr); TensorInfo outputTensorInfo = OutputTensorInfoFromInputs(subgraphIndex, operatorIndex, layer, 0, {0, 1}); @@ -2384,7 +2384,7 @@ void TfLiteParserImpl::ParseSub(size_t subgraphIndex, size_t operatorIndex) armnn::TensorInfo input1TensorInfo = InputTensorInfo(subgraphIndex, operatorIndex, 1); auto layerName = fmt::format("Sub:{}:{}", subgraphIndex, operatorIndex); - IConnectableLayer* layer = m_Network->AddSubtractionLayer(layerName.c_str()); + IConnectableLayer* layer = m_Network->AddElementwiseBinaryLayer(BinaryOperation::Sub, layerName.c_str()); ARMNN_ASSERT(layer != nullptr); TensorInfo outputTensorInfo = OutputTensorInfoFromInputs(subgraphIndex, operatorIndex, layer, 0, {0, 1}); @@ -2416,7 +2416,7 @@ void TfLiteParserImpl::ParseDiv(size_t subgraphIndex, size_t operatorIndex) armnn::TensorInfo input1TensorInfo = InputTensorInfo(subgraphIndex, operatorIndex, 1); auto layerName = fmt::format("Div:{}:{}", subgraphIndex, operatorIndex); - IConnectableLayer* layer = m_Network->AddDivisionLayer(layerName.c_str()); + IConnectableLayer* layer = m_Network->AddElementwiseBinaryLayer(BinaryOperation::Div, layerName.c_str()); ARMNN_ASSERT(layer != nullptr); TensorInfo outputTensorInfo = OutputTensorInfoFromInputs(subgraphIndex, operatorIndex, layer, 0, {0, 1}); @@ -2444,7 +2444,7 @@ void TfLiteParserImpl::ParseFloorDiv(size_t subgraphIndex, size_t operatorIndex) armnn::TensorInfo input1TensorInfo = InputTensorInfo(subgraphIndex, operatorIndex, 1); auto layerName = fmt::format("Div:{}:{}", subgraphIndex, operatorIndex); - IConnectableLayer* layer = m_Network->AddDivisionLayer(layerName.c_str()); + IConnectableLayer* layer = m_Network->AddElementwiseBinaryLayer(BinaryOperation::Div, layerName.c_str()); ARMNN_ASSERT(layer != nullptr); TensorInfo outputTensorInfo = OutputTensorInfoFromInputs(subgraphIndex, operatorIndex, layer, 0, {0, 1}); @@ -2475,7 +2475,7 @@ void TfLiteParserImpl::ParseAdd(size_t subgraphIndex, size_t operatorIndex) armnn::TensorInfo input1TensorInfo = InputTensorInfo(subgraphIndex, operatorIndex, 1); auto layerName = fmt::format("Add:{}:{}", subgraphIndex, operatorIndex); - IConnectableLayer* layer = m_Network->AddAdditionLayer(layerName.c_str()); + IConnectableLayer* layer = m_Network->AddElementwiseBinaryLayer(BinaryOperation::Add, layerName.c_str()); ARMNN_ASSERT(layer != nullptr); TensorInfo outputTensorInfo = OutputTensorInfoFromInputs(subgraphIndex, operatorIndex, layer, 0, {0, 1}); @@ -2506,7 +2506,7 @@ void TfLiteParserImpl::ParseMul(size_t subgraphIndex, size_t operatorIndex) armnn::TensorInfo input1TensorInfo = InputTensorInfo(subgraphIndex, operatorIndex, 1); auto layerName = fmt::format("Mul:{}:{}", subgraphIndex, operatorIndex); - IConnectableLayer* layer = m_Network->AddMultiplicationLayer(layerName.c_str()); + IConnectableLayer* layer = m_Network->AddElementwiseBinaryLayer(BinaryOperation::Mul, layerName.c_str()); ARMNN_ASSERT(layer != nullptr); TensorInfo outputTensorInfo = OutputTensorInfoFromInputs(subgraphIndex, operatorIndex, layer, 0, {0, 1}); -- cgit v1.2.1