MLCE-545 INT8 TFLite model execution abnormal

 * Bug fix where files were being overwritten at each debug layer

Signed-off-by: Keith Davis <keith.davis@arm.com>
Change-Id: I609fdc82afcee925824efb02183c7dbc942fced0
diff --git a/src/backends/backendsCommon/test/layerTests/DebugTestImpl.cpp b/src/backends/backendsCommon/test/layerTests/DebugTestImpl.cpp
index fa9a825..e2fa8db 100644
--- a/src/backends/backendsCommon/test/layerTests/DebugTestImpl.cpp
+++ b/src/backends/backendsCommon/test/layerTests/DebugTestImpl.cpp
@@ -70,7 +70,10 @@
 
     if (toFile)
     {
+        // Given that this is dependent on an ExNet switch, we need to explicitly set the directory that the
+        //  files are stored in as this happens within the ExNet flow
         fs::path tmpDir = fs::temp_directory_path();
+        armnnUtils::Filesystem::CreateDirectory("/ArmNNIntermediateLayerOutputs");
         std::string full_path = tmpDir.generic_string() + "/ArmNNIntermediateLayerOutputs/" + layerName + ".numpy";
 
         ExecuteWorkload(*workload, memoryManager);
diff --git a/src/backends/reference/workloads/Debug.cpp b/src/backends/reference/workloads/Debug.cpp
index fdadfef..f4f9792 100644
--- a/src/backends/reference/workloads/Debug.cpp
+++ b/src/backends/reference/workloads/Debug.cpp
@@ -103,9 +103,10 @@
 {
     if (outputsToFile)
     {
-        auto rootPathToFile = armnnUtils::Filesystem::CreateDirectory("/ArmNNIntermediateLayerOutputs");
-        std::ofstream out(rootPathToFile + layerName + ".numpy");
+        fs::path tmpDir = fs::temp_directory_path();
+        std::ofstream out(tmpDir.generic_string() + "/ArmNNIntermediateLayerOutputs/" + layerName + ".numpy");
         PrintOutput<T>(inputInfo, inputData, guid, layerName, slotIndex, out);
+        out.close();
     }
     else
     {