MLCE-335 'DEPTH_TO_SPACE and GATHER operator support in TfLiteParser'
authorSadik Armagan <sadik.armagan@arm.com>
Fri, 22 Jan 2021 14:25:31 +0000 (14:25 +0000)
committerSadik Armagan <sadik.armagan@arm.com>
Fri, 22 Jan 2021 14:25:31 +0000 (14:25 +0000)
* Added GATHER operator support to TfLiteParser
* Added DEPTH_TO_SPACE operator support to TfLiteParser

Signed-off-by: Sadik Armagan <sadik.armagan@arm.com>
Change-Id: Id5d3b54e2d850eb9f19417029efbeb73a3029e69

CMakeLists.txt
src/armnnTfLiteParser/TensorFlowLiteSupport.md
src/armnnTfLiteParser/TfLiteParser.cpp
src/armnnTfLiteParser/TfLiteParser.hpp
src/armnnTfLiteParser/test/DepthToSpace.cpp [new file with mode: 0644]
src/armnnTfLiteParser/test/Gather.cpp [new file with mode: 0644]
src/armnnTfLiteParser/test/ParserFlatbuffersFixture.hpp

index 2eb0263..b071bf0 100644 (file)
@@ -753,6 +753,7 @@ if(BUILD_UNIT_TESTS)
             src/armnnTfParser/test/Convolution2d.cpp
             src/armnnTfParser/test/Concat.cpp
             src/armnnTfParser/test/ConcatOfConcats.cpp
+            src/armnnTfLiteParser/test/DepthToSpace.cpp
             src/armnnTfParser/test/DepthwiseConvolution2d.cpp
             src/armnnTfParser/test/Equal.cpp
             src/armnnTfParser/test/ExpandDims.cpp
@@ -805,6 +806,7 @@ if(BUILD_UNIT_TESTS)
              src/armnnTfLiteParser/test/Div.cpp
              src/armnnTfLiteParser/test/Exp.cpp
              src/armnnTfLiteParser/test/FullyConnected.cpp
+             src/armnnTfLiteParser/test/Gather.cpp
              src/armnnTfLiteParser/test/L2Normalization.cpp
              src/armnnTfLiteParser/test/LeakyRelu.cpp
              src/armnnTfLiteParser/test/LoadScopeDynamicTensor.cpp
index 118fed7..16663c9 100644 (file)
@@ -16,6 +16,8 @@ The Arm NN SDK TensorFlow Lite parser currently supports the following operators
 
 * CONV_2D, Supported Fused Activation: RELU , RELU6 , TANH, NONE
 
+* DEPTH_TO_SPACE
+
 * DEPTHWISE_CONV_2D, Supported Fused Activation: RELU , RELU6 , TANH, NONE
 
 * DEQUANTIZE
@@ -28,6 +30,8 @@ The Arm NN SDK TensorFlow Lite parser currently supports the following operators
 
 * FULLY_CONNECTED, Supported Fused Activation: RELU , RELU6 , TANH, NONE
 
+* GATHER
+
 * HARD_SWISH
 
 * LEAKY_RELU
index a18471a..1a1e854 100644 (file)
@@ -547,11 +547,13 @@ TfLiteParser::TfLiteParser(const Optional<ITfLiteParser::TfLiteParserOptions>& o
     m_ParserFunctions[tflite::BuiltinOperator_CONCATENATION]           = &TfLiteParser::ParseConcatenation;
     m_ParserFunctions[tflite::BuiltinOperator_CONV_2D]                 = &TfLiteParser::ParseConv2D;
     m_ParserFunctions[tflite::BuiltinOperator_CUSTOM]                  = &TfLiteParser::ParseCustomOperator;
+    m_ParserFunctions[tflite::BuiltinOperator_DEPTH_TO_SPACE]          = &TfLiteParser::ParseDepthToSpace;
     m_ParserFunctions[tflite::BuiltinOperator_DEPTHWISE_CONV_2D]       = &TfLiteParser::ParseDepthwiseConv2D;
     m_ParserFunctions[tflite::BuiltinOperator_DEQUANTIZE]              = &TfLiteParser::ParseDequantize;
     m_ParserFunctions[tflite::BuiltinOperator_ELU]                     = &TfLiteParser::ParseElu;
     m_ParserFunctions[tflite::BuiltinOperator_EXP]                     = &TfLiteParser::ParseExp;
     m_ParserFunctions[tflite::BuiltinOperator_FULLY_CONNECTED]         = &TfLiteParser::ParseFullyConnected;
+    m_ParserFunctions[tflite::BuiltinOperator_GATHER]                  = &TfLiteParser::ParseGather;
     m_ParserFunctions[tflite::BuiltinOperator_HARD_SWISH]              = &TfLiteParser::ParseHardSwish;
     m_ParserFunctions[tflite::BuiltinOperator_LEAKY_RELU]              = &TfLiteParser::ParseLeakyRelu;
     m_ParserFunctions[tflite::BuiltinOperator_LOGISTIC]                = &TfLiteParser::ParseLogistic;
@@ -2903,6 +2905,95 @@ void TfLiteParser::ParseArgMax(size_t subgraphIndex, size_t operatorIndex)
     RegisterOutputSlots(subgraphIndex, operatorIndex, layer, outputTensorIndexes);
 }
 
+void TfLiteParser::ParseGather(size_t subgraphIndex, size_t operatorIndex)
+{
+    CHECK_MODEL(m_Model, subgraphIndex, operatorIndex);
+
+    TfLiteParser::TensorRawPtrVector inputs = GetInputs(m_Model, subgraphIndex, operatorIndex);
+    CHECK_VALID_SIZE(inputs.size(), 2);
+    TfLiteParser::TensorRawPtrVector outputs = GetOutputs(m_Model, subgraphIndex, operatorIndex);
+    CHECK_VALID_SIZE(outputs.size(), 1);
+
+    armnn::TensorInfo inputTensorInfo = ToTensorInfo(inputs[0]);
+    armnn::TensorInfo indicesTensorInfo = ToTensorInfo(inputs[1]);
+    TensorInfo outputTensorInfo = ToTensorInfo(outputs[0], true);
+
+    armnn::GatherDescriptor gatherDescriptor;
+
+    const auto & operatorPtr = m_Model->subgraphs[subgraphIndex]->operators[operatorIndex];
+    const auto * options = operatorPtr->builtin_options.AsGatherOptions();
+    auto axis = options->axis;
+
+    auto inputDimensions = static_cast<int32_t>(inputTensorInfo.GetNumDimensions());
+    auto indicesDimensions = indicesTensorInfo.GetNumDimensions();
+    auto outputDimensions = outputTensorInfo.GetNumDimensions();
+    if (((axis < -inputDimensions) && (axis < 0)) || ((axis >= inputDimensions) && (axis > 0)))
+    {
+        throw ParseException(
+            fmt::format("Operation has invalid axis: {} It is out of bounds [ -{}, {} ) {}",
+                        axis,
+                        inputDimensions, inputDimensions,
+                        CHECK_LOCATION().AsString()));
+    }
+    if (outputDimensions != static_cast<unsigned int>(inputDimensions) + indicesDimensions - 1)
+    {
+        throw ParseException(
+            fmt::format("Operation has invalid output dimensions: {} Output must be an ({} + {} - 1) -D tensor {}",
+                        outputDimensions,
+                        inputDimensions, indicesDimensions,
+                        CHECK_LOCATION().AsString()));
+    }
+
+    gatherDescriptor.m_Axis = axis;
+
+    auto layerName = fmt::format("Gather:{}:{}", subgraphIndex, operatorIndex);
+    IConnectableLayer* layer = m_Network->AddGatherLayer(gatherDescriptor, layerName.c_str());
+    ARMNN_ASSERT(layer != nullptr);
+    layer->GetOutputSlot(0).SetTensorInfo(outputTensorInfo);
+
+    auto inputTensorIndexes = AsUnsignedVector(GetInputTensorIds(m_Model, subgraphIndex, operatorIndex));
+    RegisterInputSlots(subgraphIndex, operatorIndex, layer, {inputTensorIndexes[0], inputTensorIndexes[1]});
+
+    auto outputTensorIndexes = AsUnsignedVector(GetOutputTensorIds(m_Model, subgraphIndex, operatorIndex));
+    RegisterOutputSlots(subgraphIndex, operatorIndex, layer, {outputTensorIndexes[0]});
+}
+
+void TfLiteParser::ParseDepthToSpace(size_t subgraphIndex, size_t operatorIndex)
+{
+    CHECK_MODEL(m_Model, subgraphIndex, operatorIndex);
+
+    TfLiteParser::TensorRawPtrVector inputs = GetInputs(m_Model, subgraphIndex, operatorIndex);
+    CHECK_VALID_SIZE(inputs.size(), 1);
+    TfLiteParser::TensorRawPtrVector outputs = GetOutputs(m_Model, subgraphIndex, operatorIndex);
+    CHECK_VALID_SIZE(outputs.size(), 1);
+
+    armnn::DepthToSpaceDescriptor descriptor;
+
+    const auto & operatorPtr = m_Model->subgraphs[subgraphIndex]->operators[operatorIndex];
+    const auto * options = operatorPtr->builtin_options.AsDepthToSpaceOptions();
+    auto blockSize = options->block_size;
+    if (blockSize < 2)
+    {
+        throw ParseException(
+            fmt::format("Operation has invalid block size: {} Block size should be >= 2 {}",
+                        blockSize,
+                        CHECK_LOCATION().AsString()));
+    }
+    descriptor.m_BlockSize = armnn::numeric_cast<uint32_t>(blockSize);
+
+    auto layerName = fmt::format("DepthToSpace:{}:{}", subgraphIndex, operatorIndex);
+    IConnectableLayer* layer = m_Network->AddDepthToSpaceLayer(descriptor, layerName.c_str());
+    ARMNN_ASSERT(layer != nullptr);
+    TensorInfo outputTensorInfo = ToTensorInfo(outputs[0], true);
+    layer->GetOutputSlot(0).SetTensorInfo(outputTensorInfo);
+
+    auto inputTensorIndexes = AsUnsignedVector(GetInputTensorIds(m_Model, subgraphIndex, operatorIndex));
+    RegisterInputSlots(subgraphIndex, operatorIndex, layer, {inputTensorIndexes[0]});
+
+    auto outputTensorIndexes = AsUnsignedVector(GetOutputTensorIds(m_Model, subgraphIndex, operatorIndex));
+    RegisterOutputSlots(subgraphIndex, operatorIndex, layer, {outputTensorIndexes[0]});
+}
+
 armnn::IConnectableLayer* TfLiteParser::AddFusedActivationLayer(armnn::IConnectableLayer* prevLayer,
                                                                 unsigned int outputSlot,
                                                                 tflite::ActivationFunctionType activationType)
index a8ddc69..418180f 100644 (file)
@@ -99,12 +99,14 @@ private:
     void ParseBatchToSpaceND(size_t subgraphIndex, size_t operatorIndex);
     void ParseConcatenation(size_t subgraphIndex, size_t operatorIndex);
     void ParseConv2D(size_t subgraphIndex, size_t operatorIndex);
+    void ParseDepthToSpace(size_t subgraphIndex, size_t operatorIndex);
     void ParseDepthwiseConv2D(size_t subgraphIndex, size_t operatorIndex);
     void ParseDequantize(size_t subgraphIndex, size_t operatorIndex);
     void ParseDetectionPostProcess(size_t subgraphIndex, size_t operatorIndex);
     void ParseElu(size_t subgraphIndex, size_t operatorIndex);
     void ParseExp(size_t subgraphIndex, size_t operatorIndex);
     void ParseFullyConnected(size_t subgraphIndex, size_t operatorIndex);
+    void ParseGather(size_t subgraphIndex, size_t operatorIndex);
     void ParseHardSwish(size_t subgraphIndex, size_t operatorIndex);
     void ParseLeakyRelu(size_t subgraphIndex, size_t operatorIndex);
     void ParseLogistic(size_t subgraphIndex, size_t operatorIndex);
diff --git a/src/armnnTfLiteParser/test/DepthToSpace.cpp b/src/armnnTfLiteParser/test/DepthToSpace.cpp
new file mode 100644 (file)
index 0000000..efd1207
--- /dev/null
@@ -0,0 +1,98 @@
+//
+// Copyright © 2021 Arm Ltd and Contributors. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
+
+#include <boost/test/unit_test.hpp>
+#include "ParserFlatbuffersFixture.hpp"
+#include "../TfLiteParser.hpp"
+
+#include <string>
+#include <iostream>
+
+BOOST_AUTO_TEST_SUITE(TensorflowLiteParser)
+
+struct DepthToSpaceFixture : public ParserFlatbuffersFixture
+{
+    explicit DepthToSpaceFixture(const std::string& inputShape,
+                                 const std::string& outputShape,
+                                 const std::string& dataType = "FLOAT32",
+                                 const std::string& scale = "1.0",
+                                 const std::string& offset = "0")
+    {
+        m_JsonString = R"(
+            {
+                "version": 3,
+                "operator_codes": [ { "builtin_code": "DEPTH_TO_SPACE" } ],
+                "subgraphs": [ {
+                    "tensors": [
+                        {
+                            "shape": )" + inputShape + R"(,
+                            "type": )" + dataType + R"(,
+                            "buffer": 0,
+                            "name": "inputTensor",
+                            "quantization": {
+                                "min": [ 0.0 ],
+                                "max": [ 255.0 ],
+                                "scale": [ )" + scale + R"( ],
+                                "zero_point": [ )" + offset + R"( ],
+                            }
+                        },
+                        {
+                             "shape": )" + outputShape + R"(,
+                             "type": )" + dataType + R"(,
+                             "buffer": 1,
+                             "name": "outputTensor",
+                             "quantization": {
+                                "min": [ 0.0 ],
+                                "max": [ 255.0 ],
+                                "scale": [ )" + scale + R"( ],
+                                "zero_point": [ )" + offset + R"( ],
+                            }
+                        }
+                    ],
+                    "inputs": [ 0 ],
+                    "outputs": [ 1 ],
+                    "operators": [
+                        {
+                            "opcode_index": 0,
+                            "inputs": [ 0 ],
+                            "outputs": [ 1 ],
+                            "builtin_options_type": "DepthToSpaceOptions",
+                            "builtin_options": {
+                              "block_size": 2
+                            },
+                            "custom_options_format": "FLEXBUFFERS"
+                        }
+                    ],
+                } ],
+                "buffers" : [
+                    { },
+                    { },
+                ]
+            }
+        )";
+      SetupSingleInputSingleOutput("inputTensor", "outputTensor");
+    }
+};
+
+struct SimpleDepthToSpaceFixture : public DepthToSpaceFixture
+{
+    SimpleDepthToSpaceFixture() : DepthToSpaceFixture("[ 1, 2, 2, 4 ]", "[ 1, 4, 4, 1 ]") {}
+};
+
+BOOST_FIXTURE_TEST_CASE(ParseDepthToSpace, SimpleDepthToSpaceFixture)
+{
+    RunTest<4, armnn::DataType::Float32>
+        (0,
+         {{ "inputTensor",  { 1.f,  2.f,  3.f,  4.f,
+                              5.f,  6.f,  7.f,  8.f,
+                              9.f, 10.f, 11.f, 12.f,
+                              13.f, 14.f, 15.f, 16.f }}},
+         {{ "outputTensor", { 1.f,   2.f,   5.f,   6.f,
+                              3.f,   4.f,   7.f,   8.f,
+                              9.f,  10.f,  13.f,  14.f,
+                              11.f,  12.f,  15.f,  16.f }}});
+}
+
+BOOST_AUTO_TEST_SUITE_END()
diff --git a/src/armnnTfLiteParser/test/Gather.cpp b/src/armnnTfLiteParser/test/Gather.cpp
new file mode 100644 (file)
index 0000000..498d56d
--- /dev/null
@@ -0,0 +1,121 @@
+//
+// Copyright © 2021 Arm Ltd and Contributors. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
+
+#include <boost/test/unit_test.hpp>
+#include "ParserFlatbuffersFixture.hpp"
+#include "../TfLiteParser.hpp"
+
+#include <string>
+#include <iostream>
+
+BOOST_AUTO_TEST_SUITE(TensorflowLiteParser)
+
+struct GatherFixture : public ParserFlatbuffersFixture
+{
+    explicit GatherFixture(const std::string& paramsShape,
+                           const std::string& outputShape,
+                           const std::string& indicesShape,
+                           const std::string& dataType = "FLOAT32",
+                           const std::string& scale = "1.0",
+                           const std::string& offset = "0")
+    {
+        m_JsonString = R"(
+            {
+                "version": 3,
+                "operator_codes": [ { "builtin_code": "GATHER" } ],
+                "subgraphs": [ {
+                    "tensors": [
+                        {
+                            "shape": )" + paramsShape + R"(,
+                            "type": )" + dataType + R"(,
+                            "buffer": 0,
+                            "name": "inputTensor",
+                            "quantization": {
+                                "min": [ 0.0 ],
+                                "max": [ 255.0 ],
+                                "scale": [ )" + scale + R"( ],
+                                "zero_point": [ )" + offset + R"( ],
+                            }
+                        },
+                        {
+                             "shape": )" + indicesShape + R"( ,
+                             "type": "INT32",
+                             "buffer": 1,
+                             "name": "indices",
+                             "quantization": {
+                                "min": [ 0.0 ],
+                                "max": [ 255.0 ],
+                                "scale": [ 1.0 ],
+                                "zero_point": [ 0 ],
+                             }
+                        },
+                        {
+                             "shape": )" + outputShape + R"(,
+                             "type": )" + dataType + R"(,
+                             "buffer": 2,
+                             "name": "outputTensor",
+                             "quantization": {
+                                "min": [ 0.0 ],
+                                "max": [ 255.0 ],
+                                "scale": [ )" + scale + R"( ],
+                                "zero_point": [ )" + offset + R"( ],
+                            }
+                        }
+                    ],
+                    "inputs": [ 0, 1 ],
+                    "outputs": [ 2 ],
+                    "operators": [
+                        {
+                            "opcode_index": 0,
+                            "inputs": [ 0, 1 ],
+                            "outputs": [ 2 ],
+                            "builtin_options_type": "GatherOptions",
+                            "builtin_options": {
+                              "axis": 0
+                            },
+                            "custom_options_format": "FLEXBUFFERS"
+                        }
+                    ],
+                } ],
+                "buffers" : [
+                    { },
+                    { },
+                    { },
+                ]
+            }
+        )";
+        Setup();
+    }
+};
+
+struct SimpleGatherFixture : public GatherFixture
+{
+    SimpleGatherFixture() : GatherFixture("[ 5, 2 ]", "[ 3, 2 ]", "[ 3 ]") {}
+};
+
+BOOST_FIXTURE_TEST_CASE(ParseGather, SimpleGatherFixture)
+{
+    RunTest<2, armnn::DataType::Float32, armnn::DataType::Signed32, armnn::DataType::Float32>
+        (0,
+         {{ "inputTensor",  { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }}},
+         {{ "indices", { 1, 3, 4 }}},
+         {{ "outputTensor", { 3, 4, 7, 8, 9, 10 }}});
+}
+
+struct GatherUint8Fixture : public GatherFixture
+{
+    GatherUint8Fixture() : GatherFixture("[ 8 ]", "[ 3 ]", "[ 3 ]", "UINT8") {}
+};
+
+BOOST_FIXTURE_TEST_CASE(ParseGatherUint8, GatherUint8Fixture)
+{
+    RunTest<1, armnn::DataType::QAsymmU8, armnn::DataType::Signed32, armnn::DataType::QAsymmU8>
+        (0,
+         {{ "inputTensor",  { 1, 2, 3, 4, 5, 6, 7, 8 }}},
+         {{ "indices", { 7, 6, 5 }}},
+         {{ "outputTensor", { 8, 7, 6 }}});
+}
+
+BOOST_AUTO_TEST_SUITE_END()
index 50a312f..fc1d94e 100644 (file)
@@ -152,6 +152,18 @@ struct ParserFlatbuffersFixture
                  const std::map<std::string, std::vector<armnn::ResolveType<ArmnnType2>>>& expectedOutputData,
                  bool isDynamic = false);
 
+    /// Multiple Inputs with different DataTypes, Multiple Outputs w/ Variable DataTypes
+    /// Executes the network with the given input tensors and checks the results against the given output tensors.
+    /// This overload supports multiple inputs and multiple outputs, identified by name along with the allowance for
+    /// the input datatype to be different to the output
+    template <std::size_t NumOutputDimensions,
+        armnn::DataType inputType1,
+        armnn::DataType inputType2,
+        armnn::DataType outputType>
+    void RunTest(size_t subgraphId,
+                 const std::map<std::string, std::vector<armnn::ResolveType<inputType1>>>& input1Data,
+                 const std::map<std::string, std::vector<armnn::ResolveType<inputType2>>>& input2Data,
+                 const std::map<std::string, std::vector<armnn::ResolveType<outputType>>>& expectedOutputData);
 
     /// Multiple Inputs, Multiple Outputs w/ Variable Datatypes and different dimension sizes.
     /// Executes the network with the given input tensors and checks the results against the given output tensors.
@@ -212,8 +224,30 @@ struct ParserFlatbuffersFixture
                                       tensors->quantization.get()->zero_point.begin(),
                                       tensors->quantization.get()->zero_point.end());
     }
+
+private:
+    /// Fills the InputTensors with given input data
+    template <armnn::DataType dataType>
+    void FillInputTensors(armnn::InputTensors& inputTensors,
+                          const std::map<std::string, std::vector<armnn::ResolveType<dataType>>>& inputData,
+                          size_t subgraphId);
 };
 
+/// Fills the InputTensors with given input data
+template <armnn::DataType dataType>
+void ParserFlatbuffersFixture::FillInputTensors(
+                  armnn::InputTensors& inputTensors,
+                  const std::map<std::string, std::vector<armnn::ResolveType<dataType>>>& inputData,
+                  size_t subgraphId)
+{
+    for (auto&& it : inputData)
+    {
+        armnn::BindingPointInfo bindingInfo = m_Parser->GetNetworkInputBindingInfo(subgraphId, it.first);
+        armnn::VerifyTensorInfoDataType(bindingInfo.second, dataType);
+        inputTensors.push_back({ bindingInfo.first, armnn::ConstTensor(bindingInfo.second, it.second.data()) });
+    }
+}
+
 /// Single Input, Single Output
 /// Executes the network with the given input tensor and checks the result against the given output tensor.
 /// This overload assumes the network has a single input and a single output.
@@ -256,12 +290,7 @@ void ParserFlatbuffersFixture::RunTest(size_t subgraphId,
 
     // Setup the armnn input tensors from the given vectors.
     armnn::InputTensors inputTensors;
-    for (auto&& it : inputData)
-    {
-        armnn::BindingPointInfo bindingInfo = m_Parser->GetNetworkInputBindingInfo(subgraphId, it.first);
-        armnn::VerifyTensorInfoDataType(bindingInfo.second, armnnType1);
-        inputTensors.push_back({ bindingInfo.first, armnn::ConstTensor(bindingInfo.second, it.second.data()) });
-    }
+    FillInputTensors<armnnType1>(inputTensors, inputData, subgraphId);
 
     // Allocate storage for the output tensors to be written to and setup the armnn output tensors.
     std::map<std::string, boost::multi_array<DataType2, NumOutputDimensions>> outputStorage;
@@ -310,13 +339,7 @@ void ParserFlatbuffersFixture::RunTest(std::size_t subgraphId,
 
     // Setup the armnn input tensors from the given vectors.
     armnn::InputTensors inputTensors;
-    for (auto&& it : inputData)
-    {
-        armnn::BindingPointInfo bindingInfo = m_Parser->GetNetworkInputBindingInfo(subgraphId, it.first);
-        armnn::VerifyTensorInfoDataType(bindingInfo.second, armnnType1);
-
-        inputTensors.push_back({ bindingInfo.first, armnn::ConstTensor(bindingInfo.second, it.second.data()) });
-    }
+    FillInputTensors<armnnType1>(inputTensors, inputData, subgraphId);
 
     armnn::OutputTensors outputTensors;
     outputTensors.reserve(expectedOutputData.size());
@@ -347,3 +370,56 @@ void ParserFlatbuffersFixture::RunTest(std::size_t subgraphId,
         }
     }
 }
+
+/// Multiple Inputs with different DataTypes, Multiple Outputs w/ Variable DataTypes
+/// Executes the network with the given input tensors and checks the results against the given output tensors.
+/// This overload supports multiple inputs and multiple outputs, identified by name along with the allowance for
+/// the input datatype to be different to the output
+template <std::size_t NumOutputDimensions,
+          armnn::DataType inputType1,
+          armnn::DataType inputType2,
+          armnn::DataType outputType>
+void ParserFlatbuffersFixture::RunTest(size_t subgraphId,
+    const std::map<std::string, std::vector<armnn::ResolveType<inputType1>>>& input1Data,
+    const std::map<std::string, std::vector<armnn::ResolveType<inputType2>>>& input2Data,
+    const std::map<std::string, std::vector<armnn::ResolveType<outputType>>>& expectedOutputData)
+{
+    using DataType2 = armnn::ResolveType<outputType>;
+
+    // Setup the armnn input tensors from the given vectors.
+    armnn::InputTensors inputTensors;
+    FillInputTensors<inputType1>(inputTensors, input1Data, subgraphId);
+    FillInputTensors<inputType2>(inputTensors, input2Data, subgraphId);
+
+    // Allocate storage for the output tensors to be written to and setup the armnn output tensors.
+    std::map<std::string, boost::multi_array<DataType2, NumOutputDimensions>> outputStorage;
+    armnn::OutputTensors outputTensors;
+    for (auto&& it : expectedOutputData)
+    {
+        armnn::LayerBindingId outputBindingId = m_Parser->GetNetworkOutputBindingInfo(subgraphId, it.first).first;
+        armnn::TensorInfo outputTensorInfo = m_Runtime->GetOutputTensorInfo(m_NetworkIdentifier, outputBindingId);
+
+        // Check that output tensors have correct number of dimensions (NumOutputDimensions specified in test)
+        auto outputNumDimensions = outputTensorInfo.GetNumDimensions();
+        BOOST_CHECK_MESSAGE((outputNumDimensions == NumOutputDimensions),
+            fmt::format("Number of dimensions expected {}, but got {} for output layer {}",
+                        NumOutputDimensions,
+                        outputNumDimensions,
+                        it.first));
+
+        armnn::VerifyTensorInfoDataType(outputTensorInfo, outputType);
+        outputStorage.emplace(it.first, MakeTensor<DataType2, NumOutputDimensions>(outputTensorInfo));
+        outputTensors.push_back(
+                { outputBindingId, armnn::Tensor(outputTensorInfo, outputStorage.at(it.first).data()) });
+    }
+
+    m_Runtime->EnqueueWorkload(m_NetworkIdentifier, inputTensors, outputTensors);
+
+    // Compare each output tensor to the expected values
+    for (auto&& it : expectedOutputData)
+    {
+        armnn::BindingPointInfo bindingInfo = m_Parser->GetNetworkOutputBindingInfo(subgraphId, it.first);
+        auto outputExpected = MakeTensor<DataType2, NumOutputDimensions>(bindingInfo.second, it.second);
+        BOOST_TEST(CompareTensors(outputExpected, outputStorage[it.first], false));
+    }
+}
\ No newline at end of file