IVGCVSW-8037 Add BROADCAST_TO to tflite classic and opaque delegate.

Signed-off-by: Idriss Chaouch <idriss.chaouch@arm.com>
Change-Id: Ibc145d0ea1ac9414b6a68b5b547bf2ea2852fd36
diff --git a/delegate/CMakeLists.txt b/delegate/CMakeLists.txt
index c1bf73a..d92611f 100644
--- a/delegate/CMakeLists.txt
+++ b/delegate/CMakeLists.txt
@@ -134,6 +134,8 @@
         test/BatchMatMulTestHelper.hpp
         test/BatchSpaceTest.cpp
         test/BatchSpaceTestHelper.hpp
+        test/BroadcastToTest.cpp
+        test/BroadcastToTestHelper.hpp
         test/CastTest.cpp
         test/CastTestHelper.hpp
         test/ComparisonTest.cpp
diff --git a/delegate/classic/CMakeLists.txt b/delegate/classic/CMakeLists.txt
index 7807153..dfd0cf9 100644
--- a/delegate/classic/CMakeLists.txt
+++ b/delegate/classic/CMakeLists.txt
@@ -13,6 +13,7 @@
         src/ArgMinMax.hpp
         src/BatchMatMul.hpp
         src/BatchSpace.hpp
+        src/BroadcastTo.hpp
         src/ClassicDelegateUtils.hpp
         src/Comparison.hpp
         src/Convolution.hpp
diff --git a/delegate/classic/src/BroadcastTo.hpp b/delegate/classic/src/BroadcastTo.hpp
new file mode 100644
index 0000000..92aed79
--- /dev/null
+++ b/delegate/classic/src/BroadcastTo.hpp
@@ -0,0 +1,122 @@
+//
+// Copyright © 2023 Arm Ltd and Contributors. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
+
+#pragma once
+
+#include <armnn/utility/IgnoreUnused.hpp>
+
+#include <tensorflow/lite/builtin_ops.h>
+#include <tensorflow/lite/c/builtin_op_data.h>
+#include <tensorflow/lite/c/common.h>
+#include <tensorflow/lite/minimal_logging.h>
+#include <tensorflow/lite/kernels/internal/tensor_ctypes.h>
+#include <tensorflow/lite/schema/schema_generated.h>
+#include <armnn_delegate.hpp>
+
+namespace armnnDelegate
+{
+    TfLiteStatus ValidateBroadcastToOperator(DelegateData& delegateData,
+                                             TfLiteContext* tfLiteContext,
+                                             const armnn::TensorInfo& inputInfo,
+                                             const armnn::TensorInfo& outputInfo,
+                                             const armnn::BroadcastToDescriptor& descriptor)
+    {
+        bool isSupported = false;
+        FORWARD_LAYER_SUPPORT_FUNC("BROADCAST_TO",
+                                   tfLiteContext,
+                                   IsBroadcastToSupported,
+                                   delegateData.m_Backends,
+                                   isSupported,
+                                   armnn::BackendId(),
+                                   inputInfo,
+                                   outputInfo,
+                                   descriptor);
+        return isSupported ? kTfLiteOk : kTfLiteError;
+    }
+
+    TfLiteStatus VisitBroadcastToOperator(DelegateData& delegateData,
+                                          TfLiteContext* tfLiteContext,
+                                          TfLiteNode* tfLiteNode,
+                                          int nodeIndex,
+                                          int32_t broadcastToOperatorCode)
+    {
+        TF_LITE_ENSURE_STATUS(ValidateNumInputs(tfLiteContext, tfLiteNode, 2, nodeIndex));
+        TF_LITE_ENSURE_STATUS(ValidateNumOutputs(tfLiteContext, tfLiteNode, 1, nodeIndex));
+
+        const TfLiteTensor* tfLiteTensors = tfLiteContext->tensors;
+
+        // The input contains the data that should be broadcasted
+        const TfLiteTensor& tfLiteInputTensor = tfLiteTensors[tfLiteNode->inputs->data[0]];
+        if (IsDynamicTensor(tfLiteInputTensor))
+        {
+            TF_LITE_MAYBE_KERNEL_LOG(
+                tfLiteContext,
+                "TfLiteArmnnDelegate: Dynamic input tensors are not supported in operator #%d node #%d: ",
+                broadcastToOperatorCode, nodeIndex);
+            return kTfLiteError;
+        }
+
+        // The shape tensor contains the new shape to be applied on the input
+        const TfLiteTensor& tfLiteShapeTensor = tfLiteTensors[tfLiteNode->inputs->data[1]];
+        if (IsDynamicTensor(tfLiteShapeTensor))
+        {
+            TF_LITE_MAYBE_KERNEL_LOG(
+                tfLiteContext,
+                "TfLiteArmnnDelegate: Dynamic input tensors are not supported in operator #%d node #%d: ",
+                broadcastToOperatorCode, nodeIndex);
+            return kTfLiteError;
+        }
+
+        // The output tensor
+        const TfLiteTensor& tfLiteOutputTensor = tfLiteTensors[tfLiteNode->outputs->data[0]];
+        if (IsDynamicTensor(tfLiteOutputTensor))
+        {
+            TF_LITE_MAYBE_KERNEL_LOG(
+                tfLiteContext,
+                "TfLiteArmnnDelegate: Dynamic output tensors are not supported in operator #%d node #%d: ",
+                broadcastToOperatorCode, nodeIndex);
+            return kTfLiteError;
+        }
+
+        const armnn::TensorInfo& inputTensorInfo = GetTensorInfoForTfLiteTensor(tfLiteInputTensor);
+        const armnn::TensorInfo& outputTensorInfo = GetTensorInfoForTfLiteTensor(tfLiteOutputTensor);
+
+        auto* shapeData = tflite::GetTensorData<int32_t>(&tfLiteShapeTensor);
+        auto shapeTensorNum = tfLiteShapeTensor.dims->data[0];
+
+        armnn::BroadcastToDescriptor broadcastToDescriptor;
+        broadcastToDescriptor.m_BroadcastToShape = armnn::TensorShape(shapeTensorNum,
+                                                                      shapeData);
+
+        // No network pointer indicates that only support for this operator should be checked
+        if (!delegateData.m_Network)
+        {
+            return ValidateBroadcastToOperator(delegateData,
+                                               tfLiteContext,
+                                               inputTensorInfo,
+                                               outputTensorInfo,
+                                               broadcastToDescriptor);
+        }
+
+        auto layerName = GetLayerName(armnn::LayerType::BroadcastTo, nodeIndex);
+        armnn::IConnectableLayer* layer = delegateData.m_Network->AddBroadcastToLayer(broadcastToDescriptor,
+                                                                                      layerName.c_str());
+
+        if (layer == nullptr)
+        {
+            return kTfLiteError;
+        }
+
+        layer->GetOutputSlot(0).SetTensorInfo(outputTensorInfo);
+
+        if (ProcessInputs(layer, delegateData, tfLiteContext, tfLiteNode, nodeIndex) != kTfLiteOk)
+        {
+            return kTfLiteError;
+        }
+
+        return Connect(layer, tfLiteNode, delegateData);
+    }
+
+} // namespace armnnDelegate
\ No newline at end of file
diff --git a/delegate/classic/src/armnn_delegate.cpp b/delegate/classic/src/armnn_delegate.cpp
index de2aa0c..c428d46 100644
--- a/delegate/classic/src/armnn_delegate.cpp
+++ b/delegate/classic/src/armnn_delegate.cpp
@@ -11,6 +11,7 @@
 #include "ArgMinMax.hpp"
 #include "BatchMatMul.hpp"
 #include "BatchSpace.hpp"
+#include "BroadcastTo.hpp"
 #include "Comparison.hpp"
 #include "Convolution.hpp"
 #include "Control.hpp"
@@ -603,6 +604,12 @@
                                                tfLiteNode,
                                                nodeIndex,
                                                kTfLiteBuiltinBatchToSpaceNd);
+        case kTfLiteBuiltinBroadcastTo:
+            return VisitBroadcastToOperator(delegateData,
+                                            tfLiteContext,
+                                            tfLiteNode,
+                                            nodeIndex,
+                                            kTfLiteBuiltinBroadcastTo);
         case kTfLiteBuiltinCast:
             return VisitCastOperator(delegateData,
                                      tfLiteContext,
diff --git a/delegate/opaque/CMakeLists.txt b/delegate/opaque/CMakeLists.txt
index c05bccf..365e016 100644
--- a/delegate/opaque/CMakeLists.txt
+++ b/delegate/opaque/CMakeLists.txt
@@ -13,6 +13,7 @@
         src/armnn_external_delegate.cpp
         src/BatchMatMul.hpp
         src/BatchSpace.hpp
+        src/BroadcastTo.hpp
         src/Comparison.hpp
         src/Control.hpp
         src/Convolution.hpp
diff --git a/delegate/opaque/src/BroadcastTo.hpp b/delegate/opaque/src/BroadcastTo.hpp
new file mode 100644
index 0000000..3795875
--- /dev/null
+++ b/delegate/opaque/src/BroadcastTo.hpp
@@ -0,0 +1,141 @@
+//
+// Copyright © 2023 Arm Ltd and Contributors. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
+
+#pragma once
+
+#include <OpaqueDelegateUtils.hpp>
+
+namespace armnnOpaqueDelegate
+{
+    TfLiteStatus ValidateBroadcastToOperator(DelegateData& delegateData,
+                                             TfLiteOpaqueContext *tfLiteContext,
+                                             const armnn::TensorInfo& inputInfo,
+                                             const armnn::TensorInfo& outputInfo,
+                                             const armnn::BroadcastToDescriptor& descriptor)
+    {
+        bool isSupported = false;
+        FORWARD_LAYER_OPAQUE_SUPPORT_FUNC("BROADCAST_TO",
+                                          tfLiteContext,
+                                          IsBroadcastToSupported,
+                                          delegateData.m_Backends,
+                                          isSupported,
+                                          armnn::BackendId(),
+                                          inputInfo,
+                                          outputInfo,
+                                          descriptor);
+        return isSupported ? kTfLiteOk : kTfLiteError;
+    }
+
+    TfLiteStatus VisitBroadcastToOperator(DelegateData& delegateData,
+                                          TfLiteOpaqueContext* tfLiteContext,
+                                          TfLiteOpaqueNode* tfLiteNode,
+                                          int nodeIndex,
+                                          int32_t broadcastToOperatorCode)
+    {
+        TF_LITE_ENSURE_STATUS(ValidateNumInputs(tfLiteContext, tfLiteNode, 2, nodeIndex));
+        TF_LITE_ENSURE_STATUS(ValidateNumOutputs(tfLiteContext, tfLiteNode, 1, nodeIndex));
+
+        // Gather input tensors
+        auto numInputs = TfLiteOpaqueNodeNumberOfInputs(tfLiteNode);
+        const int* inputTensors;
+        if (TfLiteOpaqueNodeInputs(tfLiteNode, &inputTensors, &numInputs) != kTfLiteOk)
+        {
+            TF_LITE_OPAQUE_MAYBE_KERNEL_LOG(
+                tfLiteContext,
+                "TfLiteArmnnOpaqueDelegate: Unable to gather input tensor indices from node #%d: ",
+                nodeIndex);
+            return kTfLiteError;
+        }
+
+        // Gather output tensors
+        int numOutputs = 0;
+        const int* outputTensors;
+        if (TfLiteOpaqueNodeOutputs(tfLiteNode, &outputTensors,
+                                    &numOutputs) != kTfLiteOk)
+        {
+            TF_LITE_OPAQUE_MAYBE_KERNEL_LOG(
+                tfLiteContext,
+                "TfLiteArmnnOpaqueDelegate: Unable to gather output tensor indices from node #%d: ",
+                nodeIndex);
+            return kTfLiteError;
+        }
+
+        // The input contains the data
+        const TfLiteOpaqueTensor* tfLiteInputTensor =
+                TfLiteOpaqueContextGetOpaqueTensor(tfLiteContext, inputTensors[0]);
+        if (IsDynamicTensor(tfLiteInputTensor))
+        {
+            TF_LITE_OPAQUE_MAYBE_KERNEL_LOG(
+                tfLiteContext,
+                "TfLiteArmnnOpaqueDelegate: Dynamic input tensors are not supported in operator #%d node #%d: ",
+                broadcastToOperatorCode, nodeIndex);
+            return kTfLiteError;
+        }
+
+        // The shape tensor
+        const TfLiteOpaqueTensor* tfLiteShapeTensor =
+                TfLiteOpaqueContextGetOpaqueTensor(tfLiteContext, inputTensors[1]);;
+        if (IsDynamicTensor(tfLiteShapeTensor))
+        {
+            TF_LITE_OPAQUE_MAYBE_KERNEL_LOG(
+                tfLiteContext,
+                "TfLiteArmnnOpaqueDelegate: Dynamic input tensors are not supported in operator #%d node #%d: ",
+                broadcastToOperatorCode, nodeIndex);
+            return kTfLiteError;
+        }
+
+        // The output tensor
+        const TfLiteOpaqueTensor* tfLiteOutputTensor =
+                TfLiteOpaqueContextGetOpaqueTensor(tfLiteContext, outputTensors[0]);
+        if (IsDynamicTensor(tfLiteOutputTensor))
+        {
+            TF_LITE_OPAQUE_MAYBE_KERNEL_LOG(
+                tfLiteContext,
+                "TfLiteArmnnOpaqueDelegate: Dynamic output tensors are not supported in operator #%d node #%d: ",
+                broadcastToOperatorCode, nodeIndex);
+            return kTfLiteError;
+        }
+
+        const armnn::TensorInfo& inputTensorInfo = GetTensorInfoForTfLiteOpaqueTensor(tfLiteInputTensor);
+        const armnn::TensorInfo& outputTensorInfo = GetTensorInfoForTfLiteOpaqueTensor(tfLiteOutputTensor,
+                                                                                       true);
+
+        auto* shapeData = static_cast<int32_t*>(TfLiteOpaqueTensorData(tfLiteShapeTensor));
+        int32_t shapeTensorNum = TfLiteOpaqueTensorDim(tfLiteShapeTensor, 0);
+
+        armnn::BroadcastToDescriptor broadcastToDescriptor;
+        broadcastToDescriptor.m_BroadcastToShape = armnn::TensorShape(shapeTensorNum,
+                                                                      shapeData);
+
+        // No network pointer indicates that only support for this operator should be checked
+        if (!delegateData.m_Network)
+        {
+            return ValidateBroadcastToOperator(delegateData,
+                                               tfLiteContext,
+                                               inputTensorInfo,
+                                               outputTensorInfo,
+                                               broadcastToDescriptor);
+        }
+
+        std::string layerName("BroadcastTo");
+        armnn::IConnectableLayer* layer = delegateData.m_Network->AddBroadcastToLayer(broadcastToDescriptor,
+                                                                                      layerName.c_str());
+
+        if (layer == nullptr)
+        {
+            return kTfLiteError;
+        }
+
+        layer->GetOutputSlot(0).SetTensorInfo(outputTensorInfo);
+
+        if (ProcessInputs(layer, delegateData, tfLiteContext, tfLiteNode, nodeIndex) != kTfLiteOk)
+        {
+            return kTfLiteError;
+        }
+
+        return Connect(layer, tfLiteContext, tfLiteNode, delegateData);
+    }
+
+} // namespace armnnOpaqueDelegate
\ No newline at end of file
diff --git a/delegate/opaque/src/armnn_delegate.cpp b/delegate/opaque/src/armnn_delegate.cpp
index bad1aba..08b1504 100644
--- a/delegate/opaque/src/armnn_delegate.cpp
+++ b/delegate/opaque/src/armnn_delegate.cpp
@@ -10,6 +10,7 @@
 #include "ArgMinMax.hpp"
 #include "BatchMatMul.hpp"
 #include "BatchSpace.hpp"
+#include "BroadcastTo.hpp"
 #include "Comparison.hpp"
 #include "Convolution.hpp"
 #include "Control.hpp"
@@ -654,6 +655,12 @@
                                             tfLiteNode,
                                             nodeIndex,
                                             kTfLiteBuiltinBatchMatmul);
+        case kTfLiteBuiltinBroadcastTo:
+            return VisitBroadcastToOperator(delegateData,
+                                            tfLiteContext,
+                                            tfLiteNode,
+                                            nodeIndex,
+                                            kTfLiteBuiltinBroadcastTo);
         case kTfLiteBuiltinBatchToSpaceNd:
             return VisitBatchToSpaceNdOperator(delegateData,
                                                tfLiteContext,
diff --git a/delegate/test/BroadcastToTest.cpp b/delegate/test/BroadcastToTest.cpp
new file mode 100644
index 0000000..f4692cf
--- /dev/null
+++ b/delegate/test/BroadcastToTest.cpp
@@ -0,0 +1,80 @@
+//
+// Copyright © 2023 Arm Ltd and Contributors. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
+
+#include "BroadcastToTestHelper.hpp"
+
+#include <armnn_delegate.hpp>
+#include <flatbuffers/flatbuffers.h>
+#include <tensorflow/lite/interpreter.h>
+#include <tensorflow/lite/kernels/register.h>
+#include <tensorflow/lite/model.h>
+#include <schema_generated.h>
+#include <tensorflow/lite/version.h>
+#include <doctest/doctest.h>
+
+namespace armnnDelegate
+{
+template<typename T>
+void BroadcastToTest(std::vector<armnn::BackendId> &backends, tflite::TensorType inputTensorType)
+{
+    // Set input data
+    std::vector<T> inputValues = {
+                                      0, 1, 2, 3
+                                  };
+    // Set output data
+    std::vector<T> expectedOutputValues = {
+                                               0, 1, 2, 3,
+                                               0, 1, 2, 3,
+                                               0, 1, 2, 3
+                                           };
+
+    // The shape data
+    const std::vector<int32_t> shapeData = {3, 4};
+
+    // Set shapes
+    const std::vector<int32_t> inputShape = {1, 4};
+    const std::vector<int32_t> shapeShape = {2};
+    const std::vector<int32_t> expectedOutputShape = {3, 4};
+
+    BroadcastToTestImpl<T>(inputTensorType,
+                           tflite::BuiltinOperator_BROADCAST_TO,
+                           backends,
+                           inputValues,
+                           inputShape,
+                           shapeShape,
+                           shapeData,
+                           expectedOutputValues,
+                           expectedOutputShape);
+}
+
+TEST_SUITE("BroadcastToTests_CpuRefTests")
+{
+
+    TEST_CASE ("BroadcastTo_int_CpuRef_Test")
+    {
+        std::vector<armnn::BackendId> backends = {armnn::Compute::CpuRef};
+        BroadcastToTest<int32_t>(backends, ::tflite::TensorType::TensorType_INT32);
+    }
+
+    TEST_CASE ("BroadcastTo_Float32_CpuRef_Test")
+    {
+        std::vector<armnn::BackendId> backends = {armnn::Compute::CpuRef};
+        BroadcastToTest<float>(backends, ::tflite::TensorType::TensorType_FLOAT32);
+    }
+
+    TEST_CASE ("BroadcastTo_Uint8_t_CpuRef_Test")
+    {
+        std::vector<armnn::BackendId> backends = {armnn::Compute::CpuRef};
+        BroadcastToTest<uint8_t>(backends, ::tflite::TensorType::TensorType_UINT8);
+    }
+
+    TEST_CASE ("BroadcastTo_Int8_t_CpuRef_Test")
+    {
+        std::vector<armnn::BackendId> backends = {armnn::Compute::CpuRef};
+        BroadcastToTest<int8_t>(backends, ::tflite::TensorType::TensorType_INT8);
+    }
+
+} // TEST_SUITE("BroadcastToTests_CpuRefTests")
+}
\ No newline at end of file
diff --git a/delegate/test/BroadcastToTestHelper.hpp b/delegate/test/BroadcastToTestHelper.hpp
new file mode 100644
index 0000000..630fe3a
--- /dev/null
+++ b/delegate/test/BroadcastToTestHelper.hpp
@@ -0,0 +1,167 @@
+//
+// Copyright © 2023 Arm Ltd and Contributors. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
+
+#pragma once
+
+#include "TestUtils.hpp"
+
+#include <armnn_delegate.hpp>
+#include <DelegateTestInterpreter.hpp>
+
+#include <flatbuffers/flatbuffers.h>
+#include <tensorflow/lite/kernels/register.h>
+#include <tensorflow/lite/version.h>
+
+#include <schema_generated.h>
+
+#include <doctest/doctest.h>
+
+namespace
+{
+    std::vector<char> CreateBroadcastToTfLiteModel(tflite::BuiltinOperator operatorCode,
+                                                   tflite::TensorType inputTensorType,
+                                                   const std::vector<int32_t>& inputTensorShape,
+                                                   const std::vector<int32_t>& shapeTensorShape,
+                                                   const std::vector<int32_t>& shapeTensorData,
+                                                   const std::vector<int32_t>& outputTensorShape)
+    {
+        using namespace tflite;
+        flatbuffers::FlatBufferBuilder flatBufferBuilder;
+
+        std::vector<flatbuffers::Offset<tflite::Buffer>> buffers;
+        buffers.push_back(CreateBuffer(flatBufferBuilder));
+        buffers.push_back(CreateBuffer(flatBufferBuilder));
+        buffers.push_back(CreateBuffer(flatBufferBuilder,
+                                       flatBufferBuilder.CreateVector(
+                                       reinterpret_cast<const uint8_t*>(shapeTensorData.data()),
+                                       sizeof(int32_t) * shapeTensorData.size())));
+        buffers.push_back(CreateBuffer(flatBufferBuilder));
+
+        float   qScale  = 1.0f;
+        int32_t qOffset = 0;
+
+        auto quantizationParameters =
+                CreateQuantizationParameters(flatBufferBuilder,
+                                             0,
+                                             0,
+                                             flatBufferBuilder.CreateVector<float>({ qScale }),
+                                             flatBufferBuilder.CreateVector<int64_t>({ qOffset }));
+
+        std::array<flatbuffers::Offset<Tensor>, 3> tensors;
+        tensors[0] = CreateTensor(flatBufferBuilder,
+                                  flatBufferBuilder.CreateVector<int32_t>(inputTensorShape.data(),
+                                                                          inputTensorShape.size()),
+                                  inputTensorType,
+                                  1,
+                                  flatBufferBuilder.CreateString("input_tensor"),
+                                  quantizationParameters);
+
+        tensors[1] = CreateTensor(flatBufferBuilder,
+                                  flatBufferBuilder.CreateVector<int32_t>(shapeTensorShape.data(),
+                                                                          shapeTensorShape.size()),
+                                  TensorType_INT32,
+                                  2,
+                                  flatBufferBuilder.CreateString("shape_input_tensor"),
+                                  quantizationParameters);
+
+        tensors[2] = CreateTensor(flatBufferBuilder,
+                                  flatBufferBuilder.CreateVector<int32_t>(outputTensorShape.data(),
+                                                                          outputTensorShape.size()),
+                                  inputTensorType,
+                                  3,
+                                  flatBufferBuilder.CreateString("output_tensor"),
+                                  quantizationParameters);
+
+        // Create Operator
+        tflite::BuiltinOptions operatorBuiltinOptionsType = tflite::BuiltinOptions_BroadcastToOptions;
+        flatbuffers::Offset<void> operatorBuiltinOption = 0;
+
+        const std::vector<int> operatorInputs {0, 1};
+        const std::vector<int> operatorOutputs {2};
+
+        flatbuffers::Offset<Operator> broadcastOperator =
+                CreateOperator(flatBufferBuilder,
+                               0,
+                               flatBufferBuilder.CreateVector<int32_t>(operatorInputs.data(), operatorInputs.size()),
+                               flatBufferBuilder.CreateVector<int32_t>(operatorOutputs.data(), operatorOutputs.size()),
+                               operatorBuiltinOptionsType,
+                               operatorBuiltinOption);
+
+        const std::vector<int> subgraphInputs{0, 1};
+        const std::vector<int> subgraphOutputs{2};
+        flatbuffers::Offset <SubGraph> subgraph =
+                CreateSubGraph(flatBufferBuilder,
+                               flatBufferBuilder.CreateVector(tensors.data(), tensors.size()),
+                               flatBufferBuilder.CreateVector<int32_t>(subgraphInputs.data(), subgraphInputs.size()),
+                               flatBufferBuilder.CreateVector<int32_t>(subgraphOutputs.data(), subgraphOutputs.size()),
+                               flatBufferBuilder.CreateVector(&broadcastOperator, 1));
+
+        flatbuffers::Offset <flatbuffers::String> modelDescription =
+                flatBufferBuilder.CreateString("ArmnnDelegate: BrodacastTo Operator Model");
+        flatbuffers::Offset <OperatorCode> opCode = CreateOperatorCode(flatBufferBuilder,0,
+                                                                       0, 2,
+                                                                       tflite::BuiltinOperator_BROADCAST_TO);
+
+        flatbuffers::Offset <Model> flatbufferModel =
+                CreateModel(flatBufferBuilder,
+                            TFLITE_SCHEMA_VERSION,
+                            flatBufferBuilder.CreateVector(&opCode, 1),
+                            flatBufferBuilder.CreateVector(&subgraph, 1),
+                            modelDescription,
+                            flatBufferBuilder.CreateVector(buffers.data(), buffers.size()));
+
+        flatBufferBuilder.Finish(flatbufferModel, armnnDelegate::FILE_IDENTIFIER);
+
+        return std::vector<char>(flatBufferBuilder.GetBufferPointer(),
+                                 flatBufferBuilder.GetBufferPointer() + flatBufferBuilder.GetSize());
+    }
+
+    template<typename T>
+    void BroadcastToTestImpl(tflite::TensorType inputTensorType,
+                             tflite::BuiltinOperator operatorCode,
+                             std::vector<armnn::BackendId>& backends,
+                             std::vector<T>& inputValues,
+                             std::vector<int32_t> inputShape,
+                             std::vector<int32_t> shapeShapes,
+                             std::vector<int32_t> shapeData,
+                             std::vector<T>& expectedOutputValues,
+                             std::vector<int32_t> expectedOutputShape)
+    {
+        using namespace delegateTestInterpreter;
+
+        std::vector<char> modelBuffer = CreateBroadcastToTfLiteModel(operatorCode,
+                                                                     inputTensorType,
+                                                                     inputShape,
+                                                                     shapeShapes,
+                                                                     shapeData,
+                                                                     expectedOutputShape);
+
+
+        // Setup interpreter with just TFLite Runtime.
+        auto tfLiteInterpreter = DelegateTestInterpreter(modelBuffer);
+        CHECK(tfLiteInterpreter.AllocateTensors() == kTfLiteOk);
+        CHECK(tfLiteInterpreter.FillInputTensor<T>(inputValues, 0) == kTfLiteOk);
+        CHECK(tfLiteInterpreter.FillInputTensor<int32_t>(shapeData, 1) == kTfLiteOk);
+        CHECK(tfLiteInterpreter.Invoke() == kTfLiteOk);
+        std::vector<T>   tfLiteOutputValues = tfLiteInterpreter.GetOutputResult<T>(0);
+        std::vector<int32_t> tfLiteOutputShape  = tfLiteInterpreter.GetOutputShape(0);
+
+        // Setup interpreter with Arm NN Delegate applied.
+        auto armnnInterpreter = DelegateTestInterpreter(modelBuffer, backends);
+        CHECK(armnnInterpreter.AllocateTensors() == kTfLiteOk);
+        CHECK(armnnInterpreter.FillInputTensor<T>(inputValues, 0) == kTfLiteOk);
+        CHECK(armnnInterpreter.FillInputTensor<int32_t>(shapeData, 1) == kTfLiteOk);
+        CHECK(armnnInterpreter.Invoke() == kTfLiteOk);
+        std::vector<T>   armnnOutputValues = armnnInterpreter.GetOutputResult<T>(0);
+        std::vector<int32_t> armnnOutputShape  = armnnInterpreter.GetOutputShape(0);
+
+        armnnDelegate::CompareOutputData<T>(tfLiteOutputValues, armnnOutputValues, expectedOutputValues);
+        armnnDelegate::CompareOutputShape(tfLiteOutputShape, armnnOutputShape, expectedOutputShape);
+
+        tfLiteInterpreter.Cleanup();
+        armnnInterpreter.Cleanup();
+    }
+
+} // anonymous namespace
\ No newline at end of file
diff --git a/docs/05_03_delegate.dox b/docs/05_03_delegate.dox
index 624f06f..9a40a8a 100644
--- a/docs/05_03_delegate.dox
+++ b/docs/05_03_delegate.dox
@@ -46,6 +46,8 @@
 
 - BATCH_TO_SPACE_ND
 
+- BROADCAST_TO
+
 - CAST
 
 - CEIL