IVGCVSW-7168 Add Conv2d and Constant support to TOSA Reference Backend

 * Added TOSA Conv2d and Constant mappings.
 * Added unique naming to mappings based on previous and following
   layers, so they are connected correctly.
 * Updated existing mappings with new naming convention.
 * Added all mappings to one main block in OptimizeSubgraphView.
 * Removed isMain from mapping functions.
 * Added Conv2d EndToEnd test.

Signed-off-by: Matthew Sloyan <matthew.sloyan@arm.com>
Change-Id: I27c3e238407c32379ce25a1f01dad11523ef5d2b
diff --git a/src/backends/tosaCommon/operatorMappings/ConstantOperator.cpp b/src/backends/tosaCommon/operatorMappings/ConstantOperator.cpp
new file mode 100644
index 0000000..5e3973f
--- /dev/null
+++ b/src/backends/tosaCommon/operatorMappings/ConstantOperator.cpp
@@ -0,0 +1,44 @@
+//
+// Copyright © 2022 Arm Ltd and Contributors. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
+
+#include "ConstantOperator.hpp"
+
+#include <layers/ConstantLayer.hpp>
+
+TosaSerializationBasicBlock* ConvertConstantToTosaOperator(const Layer* layer,
+                                                           const std::vector<const TensorInfo*>& outputs)
+{
+    std::string outputName = std::string("constant_");
+    std::string blockName  = std::string("Op_CONST_block_") + GetUniqueTosaMappingID();
+
+    std::vector<uint8_t> uint8Data;
+
+    // If a layer is present then the block will be used for execution, so names need to be unique.
+    // Also, set constant tensor data.
+    if(layer != nullptr)
+    {
+        outputName.append(std::to_string(layer->GetGuid()));
+        blockName.append(std::to_string(layer->GetGuid()));
+
+        auto constantLayer = PolymorphicDowncast<const armnn::ConstantLayer*>(layer);
+        auto tensorInfo = constantLayer->GetOutputSlot().GetTensorInfo();
+
+        uint8Data = ConvertConstantTensorDataToBuffer(constantLayer->m_LayerOutput);
+    }
+
+    auto* op = new TosaSerializationOperator(Op_CONST, Attribute_NONE, nullptr, {}, {outputName});
+
+    std::vector<int32_t> outputShape0 = GetTosaTensorShape(outputs[0]->GetShape());
+    DType outputDType0 = ArmNNToDType(outputs[0]->GetDataType());
+
+    // Setup output tensor with constant tensor data if available.
+    auto* outputTensor0 = new TosaSerializationTensor(outputName, outputShape0, outputDType0, uint8Data);
+
+    return new TosaSerializationBasicBlock(blockName,       // name
+                                           {op},            // operators
+                                           {outputTensor0}, // tensors
+                                           {},              // inputs
+                                           {outputName});   // outputs
+}
\ No newline at end of file